-
Notifications
You must be signed in to change notification settings - Fork 4.6k
TICLv5 Adjust Linking step #48851
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
Merged
Merged
TICLv5 Adjust Linking step #48851
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a187a56
tighter cuts in CEE region
waredjeb 9a4e5cf
move linking energy regression to TICLCandidateLevel, remove Track on…
waredjeb c301faa
remove linking between CEE objects
waredjeb 3549178
fix wfs selection in ticl_v5 procModifiers
AuroraPerego 7ea385e
remove duplicate call to mergeTracksters
AuroraPerego 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
19 changes: 19 additions & 0 deletions
19
HLTrigger/Configuration/python/HLT_75e33/modules/hltTiclCandidate_cfi.py
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| // Author: Felice Pantaleo, Wahid Redjeb, Aurora Perego (CERN) - [email protected], [email protected], [email protected] | ||
| // Date: 12/2023 | ||
| // Author: Felice Pantaleo, Wahid Redjeb, Aurora Perego (CERN) - [email protected], [email protected], [email protected] Date: 12/2023 | ||
| #include <memory> // unique_ptr | ||
| #include "DataFormats/HGCalReco/interface/MultiVectorManager.h" | ||
| #include "FWCore/Framework/interface/stream/EDProducer.h" | ||
|
|
@@ -47,22 +46,28 @@ | |
| #include "MagneticField/Engine/interface/MagneticField.h" | ||
| #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" | ||
|
|
||
| #include "PhysicsTools/ONNXRuntime/interface/ONNXRuntime.h" | ||
|
|
||
| #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h" | ||
| #include "Geometry/Records/interface/IdealGeometryRecord.h" | ||
| #include "Geometry/CommonDetUnit/interface/GeomDet.h" | ||
| #include "RecoHGCal/TICL/interface/TracksterInferenceAlgoFactory.h" | ||
|
|
||
| #include "TrackstersPCA.h" | ||
|
|
||
| using namespace ticl; | ||
| using cms::Ort::ONNXRuntime; | ||
|
|
||
| class TICLCandidateProducer : public edm::stream::EDProducer<> { | ||
| class TICLCandidateProducer : public edm::stream::EDProducer<edm::GlobalCache<ONNXRuntime>> { | ||
| public: | ||
| explicit TICLCandidateProducer(const edm::ParameterSet &ps); | ||
| explicit TICLCandidateProducer(const edm::ParameterSet &ps, const ONNXRuntime *); | ||
| ~TICLCandidateProducer() override {} | ||
| void produce(edm::Event &, const edm::EventSetup &) override; | ||
| static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); | ||
|
|
||
| void beginRun(edm::Run const &iEvent, edm::EventSetup const &es) override; | ||
| static std::unique_ptr<ONNXRuntime> initializeGlobalCache(const edm::ParameterSet &iConfig); | ||
| static void globalEndJob(const ONNXRuntime *); | ||
|
|
||
| private: | ||
| void dumpCandidate(const TICLCandidate &) const; | ||
|
|
@@ -82,6 +87,8 @@ class TICLCandidateProducer : public edm::stream::EDProducer<> { | |
|
|
||
| const edm::EDGetTokenT<std::vector<reco::CaloCluster>> clusters_token_; | ||
| const edm::EDGetTokenT<edm::ValueMap<std::pair<float, float>>> clustersTime_token_; | ||
| const bool regressionAndPid_; | ||
| std::unique_ptr<TracksterInferenceAlgoBase> inferenceAlgo_; | ||
|
|
||
| std::vector<edm::EDGetTokenT<std::vector<float>>> original_masks_tokens_; | ||
|
|
||
|
|
@@ -113,10 +120,11 @@ class TICLCandidateProducer : public edm::stream::EDProducer<> { | |
| static constexpr float timeRes = 0.02f; | ||
| }; | ||
|
|
||
| TICLCandidateProducer::TICLCandidateProducer(const edm::ParameterSet &ps) | ||
| TICLCandidateProducer::TICLCandidateProducer(const edm::ParameterSet &ps, const ONNXRuntime *) | ||
| : clusters_token_(consumes<std::vector<reco::CaloCluster>>(ps.getParameter<edm::InputTag>("layer_clusters"))), | ||
| clustersTime_token_( | ||
| consumes<edm::ValueMap<std::pair<float, float>>>(ps.getParameter<edm::InputTag>("layer_clustersTime"))), | ||
| regressionAndPid_(ps.getParameter<bool>("regressionAndPid")), | ||
| tracks_token_(consumes<std::vector<reco::Track>>(ps.getParameter<edm::InputTag>("tracks"))), | ||
| muons_token_(consumes<std::vector<reco::Muon>>(ps.getParameter<edm::InputTag>("muons"))), | ||
| useMTDTiming_(ps.getParameter<bool>("useMTDTiming")), | ||
|
|
@@ -168,6 +176,11 @@ TICLCandidateProducer::TICLCandidateProducer(const edm::ParameterSet &ps) | |
| if (useMTDTiming_) { | ||
| inputTimingToken_ = consumes<MtdHostCollection>(ps.getParameter<edm::InputTag>("timingSoA")); | ||
| } | ||
| // Initialize inference algorithm using the factory | ||
| std::string inferencePlugin = ps.getParameter<std::string>("inferenceAlgo"); | ||
| edm::ParameterSet inferencePSet = ps.getParameter<edm::ParameterSet>("pluginInferenceAlgo" + inferencePlugin); | ||
| inferenceAlgo_ = std::unique_ptr<TracksterInferenceAlgoBase>( | ||
| TracksterInferenceAlgoFactory::get()->create(inferencePlugin, inferencePSet)); | ||
|
|
||
| produces<std::vector<TICLCandidate>>(); | ||
|
|
||
|
|
@@ -180,6 +193,12 @@ TICLCandidateProducer::TICLCandidateProducer(const edm::ParameterSet &ps) | |
| TICLGeneralInterpretationPluginFactory::get()->create(algoType, interpretationPSet, consumesCollector()); | ||
| } | ||
|
|
||
| std::unique_ptr<ONNXRuntime> TICLCandidateProducer::initializeGlobalCache(const edm::ParameterSet &iConfig) { | ||
| return std::unique_ptr<ONNXRuntime>(nullptr); | ||
| } | ||
|
|
||
| void TICLCandidateProducer::globalEndJob(const ONNXRuntime *) {} | ||
|
|
||
| void TICLCandidateProducer::beginRun(edm::Run const &iEvent, edm::EventSetup const &es) { | ||
| edm::ESHandle<HGCalDDDConstants> hdc = es.getHandle(hdc_token_); | ||
| hgcons_ = hdc.product(); | ||
|
|
@@ -311,6 +330,12 @@ void TICLCandidateProducer::produce(edm::Event &evt, const edm::EventSetup &es) | |
| rhtools_.getPositionLayer(rhtools_.lastLayerEE()).z(), | ||
| rhtools_, | ||
| true); | ||
| if (regressionAndPid_) { | ||
| // Run inference algorithm | ||
| inferenceAlgo_->inputData(layerClusters, *resultTracksters); | ||
| inferenceAlgo_->runInference( | ||
| *resultTracksters); //option to use "Linking" instead of "CLU3D"/"energyAndPid" instead of "PID" | ||
| } | ||
|
|
||
| std::vector<bool> maskTracksters(resultTracksters->size(), true); | ||
| edm::OrphanHandle<std::vector<Trackster>> resultTracksters_h = evt.put(std::move(resultTracksters)); | ||
|
|
@@ -326,16 +351,16 @@ void TICLCandidateProducer::produce(edm::Event &evt, const edm::EventSetup &es) | |
| maskTracksters[tracksterId] = false; | ||
| } else { | ||
| //charged candidates track only | ||
| edm::Ptr<Trackster> tracksterPtr; | ||
| TICLCandidate chargedCandidate(trackPtr, tracksterPtr); | ||
| auto trackRef = edm::Ref<reco::TrackCollection>(tracks_h, iTrack); | ||
| const int muId = PFMuonAlgo::muAssocToTrack(trackRef, *muons_h); | ||
| const reco::MuonRef muonRef = reco::MuonRef(muons_h, muId); | ||
| if (muonRef.isNonnull() and muonRef->isGlobalMuon()) { | ||
| // create muon candidate | ||
| edm::Ptr<Trackster> tracksterPtr; | ||
| TICLCandidate chargedCandidate(trackPtr, tracksterPtr); | ||
| chargedCandidate.setPdgId(13 * trackPtr.get()->charge()); | ||
| resultCandidates->push_back(chargedCandidate); | ||
| } | ||
| resultCandidates->push_back(chargedCandidate); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -478,6 +503,9 @@ void TICLCandidateProducer::fillDescriptions(edm::ConfigurationDescriptions &des | |
| edm::ParameterSetDescription desc; | ||
| edm::ParameterSetDescription interpretationDesc; | ||
| interpretationDesc.addNode(edm::PluginDescription<TICLGeneralInterpretationPluginFactory>("type", "General", true)); | ||
| edm::ParameterSetDescription inferenceDesc; | ||
| inferenceDesc.addNode(edm::PluginDescription<TracksterInferenceAlgoFactory>("type", "TracksterInferenceByPFN", true)); | ||
| desc.add<edm::ParameterSetDescription>("pluginInferenceAlgoTracksterInferenceByPFN", inferenceDesc); | ||
| desc.add<edm::ParameterSetDescription>("interpretationDescPSet", interpretationDesc); | ||
| desc.add<std::vector<edm::InputTag>>("egamma_tracksters_collections", {edm::InputTag("ticlTracksterLinks")}); | ||
| desc.add<std::vector<edm::InputTag>>("egamma_tracksterlinks_collections", {edm::InputTag("ticlTracksterLinks")}); | ||
|
|
@@ -498,6 +526,8 @@ void TICLCandidateProducer::fillDescriptions(edm::ConfigurationDescriptions &des | |
| desc.add<std::string>("cutTk", | ||
| "1.48 < abs(eta) < 3.0 && pt > 1. && quality(\"highPurity\") && " | ||
| "hitPattern().numberOfLostHits(\"MISSING_OUTER_HITS\") < 5"); | ||
| desc.add<bool>("regressionAndPid", true); | ||
| desc.add<std::string>("inferenceAlgo", "TracksterInferenceByPFN"); | ||
| descriptions.add("ticlCandidateProducer", desc); | ||
| } | ||
|
|
||
|
|
||
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.
So just to check, this is where you discarded the alone track, right?
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.
Yes, here we just produce muons, but the other tracks are discarded, at least for now