diff --git a/L1Trigger/Phase2L1ParticleFlow/interface/JetId.h b/L1Trigger/Phase2L1ParticleFlow/interface/JetId.h index 4c940d5d9ea90..219ad24aca33f 100644 --- a/L1Trigger/Phase2L1ParticleFlow/interface/JetId.h +++ b/L1Trigger/Phase2L1ParticleFlow/interface/JetId.h @@ -31,7 +31,7 @@ class JetId { void setNNVectorVar(); float EvaluateNN(); - ap_fixed<16, 6> EvaluateNNFixed(); + ap_fixed<14, 8, AP_TRN, AP_SAT, 0> EvaluateNNFixed(); float compute(const l1t::PFJet &iJet, float vz, bool useRawPt); ap_fixed<16, 6> computeFixed(const l1t::PFJet &iJet, float vz, bool useRawPt); diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/TOoLLiPProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/TOoLLiPProducer.cc index e33ff7040865a..73067668116b2 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/TOoLLiPProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/TOoLLiPProducer.cc @@ -30,7 +30,6 @@ class TOoLLiPProducer : public edm::stream::EDProducer<> { static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); private: - std::unique_ptr fJetId_; void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; edm::EDGetTokenT> const jets_; @@ -43,6 +42,7 @@ class TOoLLiPProducer : public edm::stream::EDProducer<> { hls4mlEmulator::ModelLoader loader; std::shared_ptr model; + std::unique_ptr fJetId_; }; TOoLLiPProducer::TOoLLiPProducer(const edm::ParameterSet& cfg) @@ -53,10 +53,10 @@ TOoLLiPProducer::TOoLLiPProducer(const edm::ParameterSet& cfg) fMaxJets_(cfg.getParameter("maxJets")), fNParticles_(cfg.getParameter("nParticles")), fVtxEmu_(consumes>(cfg.getParameter("vtx"))), - loader(hls4mlEmulator::ModelLoader(cfg.getParameter("TOoLLiPVersion"))) { - model = loader.load_model(); - fJetId_ = std::make_unique( - cfg.getParameter("NNInput"), cfg.getParameter("NNOutput"), model, fNParticles_); + loader(cfg.getParameter("TOoLLiPVersion")), + model(loader.load_model()), + fJetId_(std::make_unique( + cfg.getParameter("NNInput"), cfg.getParameter("NNOutput"), model, fNParticles_)) { produces>("L1PFLLPJets"); } @@ -78,10 +78,10 @@ void TOoLLiPProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) for (const auto& srcjet : *jets) { if (((fUseRawPt_ ? srcjet.rawPt() : srcjet.pt()) < fMinPt_) || std::abs(srcjet.eta()) > fMaxEta_ || LLPScores.size() >= fMaxJets_) { - LLPScores.push_back(-1.); + LLPScores.push_back(-999.); continue; } - ap_fixed<16, 6> LLPScore = fJetId_->computeFixed(srcjet, vz, fUseRawPt_); + ap_fixed<14, 8, AP_TRN, AP_SAT, 0> LLPScore = fJetId_->computeFixed(srcjet, vz, fUseRawPt_); LLPScores.push_back(LLPScore); } @@ -97,7 +97,8 @@ void TOoLLiPProducer::fillDescriptions(edm::ConfigurationDescriptions& descripti edm::ParameterSetDescription desc; desc.add("jets", edm::InputTag("scPFL1Puppi")); desc.add("useRawPt", true); - desc.add("TOoLLiPVersion", std::string("TOoLLiP_v1")); + desc.add("TOoLLiPVersion", std::string("TOoLLiP_v3")); + desc.add("NNInput", "input:0"); desc.add("NNOutput", "sequential/dense_2/Sigmoid"); desc.add("maxJets", 10); diff --git a/L1Trigger/Phase2L1ParticleFlow/src/JetId.cc b/L1Trigger/Phase2L1ParticleFlow/src/JetId.cc index 611949001b85c..fe09cb6e7e56e 100644 --- a/L1Trigger/Phase2L1ParticleFlow/src/JetId.cc +++ b/L1Trigger/Phase2L1ParticleFlow/src/JetId.cc @@ -57,7 +57,7 @@ void JetId::setNNVectorVar() { NNvectorVar_.push_back(fId_.get()[i0] == l1t::PFCandidate::ChargedHadron && fCharge_.get()[i0] < 0); // Pion NNvectorVar_.push_back(fId_.get()[i0] == l1t::PFCandidate::ChargedHadron && fCharge_.get()[i0] > 0); // Anti-Pion NNvectorVar_.push_back(fDZ_.get()[i0]); //dZ - NNvectorVar_.push_back(std::hypot(fDX_.get()[i0], fDY_.get()[i0])); //d0 + NNvectorVar_.push_back(std::hypot(fDX_.get()[i0], fDY_.get()[i0])); NNvectorVar_.push_back(fPt_.get()[i0]); //pT as a fraction of jet pT NNvectorVar_.push_back(fEta_.get()[i0]); //dEta from jet axis NNvectorVar_.push_back(fPhi_.get()[i0]); //dPhi from jet axis @@ -73,17 +73,17 @@ float JetId::EvaluateNN() { return outputs[0].matrix()(0, 0); } //end EvaluateNN -ap_fixed<16, 6> JetId::EvaluateNNFixed() { - ap_fixed<16, 6> modelInput[140] = {}; +ap_fixed<14, 8, AP_TRN, AP_SAT, 0> JetId::EvaluateNNFixed() { + ap_fixed<12, 6, AP_TRN, AP_SAT, 0> modelInput[130] = {}; for (unsigned int i = 0; i < NNvectorVar_.size(); i++) { modelInput[i] = NNvectorVar_[i]; } - ap_fixed<16, 6> modelResult[1] = {-1}; + ap_fixed<14, 8, AP_TRN, AP_SAT, 0> modelResult[1] = {-1}; modelRef_->prepare_input(modelInput); modelRef_->predict(); modelRef_->read_result(modelResult); - ap_fixed<16, 6> modelResult_ = modelResult[0]; + ap_fixed<14, 8, AP_TRN, AP_SAT, 0> modelResult_ = modelResult[0]; return modelResult_; } //end EvaluateNNFixed @@ -152,5 +152,6 @@ ap_fixed<16, 6> JetId::computeFixed(const l1t::PFJet &iJet, float vz, bool useRa } } setNNVectorVar(); + return EvaluateNNFixed(); }