-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Phase2 L1T: Correlator development for AR2026 #51093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cerminar
wants to merge
2
commits into
cms-sw:master
Choose a base branch
from
cerminar:L1PF_17_0_X_dev
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
L1Trigger/Phase2L1ParticleFlow/interface/L1TSC82ProngJetID.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #ifndef L1TRIGGER_PHASE2L1PARTICLEFLOWS_L1TSC82ProngJetID_H | ||
| #define L1TRIGGER_PHASE2L1PARTICLEFLOWS_L1TSC82ProngJetID_H | ||
|
|
||
| #include "DataFormats/L1TParticleFlow/interface/PFJet.h" | ||
| #include <memory> | ||
| #include <vector> | ||
|
|
||
| //HLS4ML compiled emulator modeling | ||
| #include "ap_fixed.h" | ||
| #include "hls4ml/emulator.h" | ||
|
|
||
| class L1TSC82ProngJetID { | ||
| public: | ||
| L1TSC82ProngJetID(const std::shared_ptr<hls4mlEmulator::Model> model, int iNParticles); | ||
|
|
||
| typedef ap_fixed<24, 12, AP_RND, AP_SAT, 0> inputtype; | ||
| typedef ap_ufixed<20, 10, AP_RND, AP_SAT, 0> prong_score; | ||
|
|
||
| void setNNVectorVar(); | ||
| std::vector<float> EvaluateNNFixed(); | ||
|
Comment on lines
+19
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could these be const? |
||
| std::vector<float> computeFixed(const l1t::PFJet &iJet); | ||
|
|
||
| private: | ||
| std::vector<inputtype> NNvectorVar_; | ||
| int fNParticles_; | ||
| std::unique_ptr<float[]> fPt_; | ||
| std::unique_ptr<float[]> fPt_rel_; | ||
| std::unique_ptr<float[]> fDEta_; | ||
| std::unique_ptr<float[]> fDPhi_; | ||
| std::unique_ptr<float[]> fPt_log_; | ||
| std::unique_ptr<float[]> fMass_; | ||
| std::unique_ptr<float[]> fZ0_; | ||
| std::unique_ptr<float[]> fDxy_; | ||
| std::unique_ptr<int[]> fIs_filled_; | ||
| std::unique_ptr<float[]> fPuppi_weight_; | ||
| std::unique_ptr<int[]> fEmID_; | ||
| std::unique_ptr<float[]> fQuality_; | ||
|
|
||
| std::unique_ptr<int[]> fCharge_; | ||
| std::unique_ptr<int[]> fId_; | ||
| std::shared_ptr<hls4mlEmulator::Model> modelRef_; | ||
|
|
||
| //bool isDebugEnabled_; | ||
| }; | ||
| #endif | ||
108 changes: 108 additions & 0 deletions
108
L1Trigger/Phase2L1ParticleFlow/plugins/L1TSC82ProngJetModelProducer.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| #include "FWCore/Framework/interface/Frameworkfwd.h" | ||
| #include "FWCore/Framework/interface/stream/EDProducer.h" | ||
| #include "FWCore/Framework/interface/Event.h" | ||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
| #include "FWCore/Utilities/interface/InputTag.h" | ||
|
|
||
| #include "DataFormats/L1TParticleFlow/interface/PFJet.h" | ||
| #include "DataFormats/JetReco/interface/Jet.h" | ||
| #include "DataFormats/L1TParticleFlow/interface/PFCandidate.h" | ||
| #include "L1Trigger/Phase2L1ParticleFlow/interface/L1TSC82ProngJetID.h" | ||
| #include "DataFormats/Common/interface/ValueMap.h" | ||
|
|
||
| #include "DataFormats/L1Trigger/interface/VertexWord.h" | ||
|
|
||
| #include <cmath> | ||
| #include <vector> | ||
|
|
||
| #include <string> | ||
| #include "ap_fixed.h" | ||
| #include "hls4ml/emulator.h" | ||
|
|
||
| using namespace l1t; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you use l1t::name rather than using namespace l1t? |
||
|
|
||
| class L1TSC82ProngJetProducer : public edm::stream::EDProducer<> { | ||
| public: | ||
| explicit L1TSC82ProngJetProducer(const edm::ParameterSet&); | ||
| ~L1TSC82ProngJetProducer() override = default; | ||
|
|
||
| static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
|
||
| private: | ||
| std::unique_ptr<L1TSC82ProngJetID> fJetId_; | ||
| void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; | ||
|
|
||
| edm::EDGetTokenT<edm::View<l1t::PFJet>> const jets_; | ||
| double const fMinPt_; | ||
| double const fMaxEta_; | ||
| unsigned int const fMaxJets_; | ||
| int const fNParticles_; | ||
|
|
||
| hls4mlEmulator::ModelLoader loader; | ||
| std::shared_ptr<hls4mlEmulator::Model> model; | ||
| }; | ||
|
|
||
| L1TSC82ProngJetProducer::L1TSC82ProngJetProducer(const edm::ParameterSet& cfg) | ||
| : jets_(consumes<edm::View<l1t::PFJet>>(cfg.getParameter<edm::InputTag>("jets"))), | ||
| fMinPt_(cfg.getParameter<double>("minPt")), | ||
| fMaxEta_(cfg.getParameter<double>("maxEta")), | ||
| fMaxJets_(cfg.getParameter<int>("maxJets")), | ||
| fNParticles_(cfg.getParameter<int>("nParticles")), | ||
| loader(hls4mlEmulator::ModelLoader(cfg.getParameter<std::string>("l1tSC82ProngJetModelPath"))) { | ||
| model = loader.load_model(); | ||
| fJetId_ = std::make_unique<L1TSC82ProngJetID>(model, fNParticles_); | ||
| produces<l1t::PFJetCollection>("l1tSC82ProngJets"); | ||
| } | ||
|
|
||
| void L1TSC82ProngJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
| edm::Handle<edm::View<l1t::PFJet>> jets; | ||
| iEvent.getByToken(jets_, jets); | ||
| std::vector<l1t::PFJet> taggedJets; | ||
|
|
||
| for (const auto& srcjet : *jets) { | ||
| l1ct::Jet ctHWJet = l1ct::Jet::unpack(srcjet.encodedJet(l1t::PFJet::HWEncoding::CT)); | ||
|
|
||
| if (srcjet.pt() < fMinPt_ || std::abs(srcjet.eta()) > fMaxEta_ || taggedJets.size() >= fMaxJets_) { | ||
| ctHWJet.clear(); | ||
| continue; | ||
| } | ||
| std::vector<float> JetProngScore_float = fJetId_->computeFixed(srcjet); | ||
| l1gt::WideJet gtwHWJet = l1gt::WideJet::unpack(srcjet.getHWJetGTWide()); | ||
|
|
||
| l1t::PFJet edmJet( | ||
| srcjet.pt(), srcjet.eta(), srcjet.phi(), srcjet.mass(), gtwHWJet.v3.pt.V, gtwHWJet.v3.eta.V, gtwHWJet.v3.phi.V); | ||
|
|
||
| std::vector<l1ct::JetTagClass> classes{l1ct::JetTagClass(l1ct::JetTagClass::JetTagClassValue::nprong)}; | ||
|
|
||
| edmJet.addTagScores(JetProngScore_float, classes, 1.); | ||
| edmJet.setEncodedJet(l1t::PFJet::HWEncoding::CT, ctHWJet.pack()); | ||
| edmJet.setEncodedJet(l1t::PFJet::HWEncoding::GTWide, gtwHWJet.pack()); | ||
|
|
||
| std::vector<edm::Ptr<l1t::PFCandidate>> constituents; | ||
| std::for_each(srcjet.constituents().begin(), srcjet.constituents().end(), [&](auto constituent) { | ||
| edmJet.addConstituent(constituent); | ||
| }); | ||
|
|
||
| taggedJets.push_back(edmJet); | ||
| } | ||
| std::sort(taggedJets.begin(), taggedJets.end(), [](l1t::PFJet a, l1t::PFJet b) { return (a.pt() > b.pt()); }); | ||
|
|
||
| std::unique_ptr<l1t::PFJetCollection> taggedJetsCollection(new l1t::PFJetCollection); | ||
| taggedJetsCollection->swap(taggedJets); | ||
| iEvent.put(std::move(taggedJetsCollection), "l1tSC82ProngJets"); | ||
| } | ||
|
|
||
| void L1TSC82ProngJetProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
| edm::ParameterSetDescription desc; | ||
| desc.add<edm::InputTag>("jets", edm::InputTag("l1tSC8PFL1PuppiEmulator")); | ||
| desc.add<std::string>("l1tSC82ProngJetModelPath", std::string("L1TSC82ProngJetModel_v0")); | ||
| desc.add<double>("minPt", 0.); | ||
| desc.add<double>("maxEta", 5.); | ||
| desc.add<int>("maxJets", 16); | ||
| desc.add<int>("nParticles", 8); | ||
| descriptions.add("l1tSC82ProngJetProducer", desc); | ||
| } | ||
|
|
||
| #include "FWCore/Framework/interface/MakerMacros.h" | ||
| DEFINE_FWK_MODULE(L1TSC82ProngJetProducer); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should L1TSC82ProngJetID be uppercase?