Repository navigation
Track Purity DNN for Phase-2 HLT #251
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
github-actions
merged 1 commit into
SegmentLinking:master
from
jchismar:track-purity-dnn
Jul 15, 2026
Merged
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions
4
Configuration/ProcessModifiers/python/trackCutClassifier_cff.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| # This modifier sets the use of cut based high purity track selection | ||
| trackCutClassifier = cms.Modifier() |
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
9 changes: 9 additions & 0 deletions
9
HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrackFeatureExtractor_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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| hltInitialStepTrackFeatureExtractor = cms.EDProducer("alpaka_serial_sync::TrackFeatureExtractor", | ||
| src = cms.InputTag("hltInitialStepTracks"), | ||
| beamSpot = cms.InputTag("hltOnlineBeamSpot"), | ||
| alpaka = cms.untracked.PSet( | ||
| backend = cms.untracked.string('') | ||
| ) | ||
| ) |
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
14 changes: 14 additions & 0 deletions
14
...er/Configuration/python/HLT_75e33/modules/hltInitialStepTrackTorchClassifierOutput_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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| hltInitialStepTrackTorchClassifierOutput = cms.EDProducer("TrackTorchClassifierFromSoA", | ||
| src = cms.InputTag("hltInitialStepTracks"), | ||
| scores = cms.InputTag("hltInitialStepTrackTorchClassifier"), | ||
| features = cms.InputTag("hltInitialStepTrackFeatureExtractor"), | ||
| copyTrajectories = cms.bool(False), | ||
| minScore = cms.double(0.377), | ||
| dxyThreshold = cms.double(0.5), | ||
| highDxyMinScore = cms.double(0.267) | ||
| ) | ||
|
|
||
| from Configuration.ProcessModifiers.mtd_at_hlt_cff import mtd_at_hlt | ||
| mtd_at_hlt.toModify(hltInitialStepTrackTorchClassifierOutput, copyTrajectories = True) |
9 changes: 9 additions & 0 deletions
9
HLTrigger/Configuration/python/HLT_75e33/modules/hltInitialStepTrackTorchClassifier_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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| hltInitialStepTrackTorchClassifier = cms.EDProducer("alpaka_serial_sync::TrackTorchClassifierAlpaka", | ||
| modelPath = cms.FileInPath('RecoTracker/FinalTrackSelectors/data/TrackTorchClassifier/model.pt'), | ||
| features = cms.InputTag("hltInitialStepTrackFeatureExtractor"), | ||
| alpaka = cms.untracked.PSet( | ||
| backend = cms.untracked.string('') | ||
| ) | ||
| ) |
9 changes: 9 additions & 0 deletions
9
...guration/python/HLT_75e33/sequences/HLTInitialStepCutClassifierHPSelectionSequence_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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| from ..modules.hltInitialStepTrackCutClassifier_cfi import * | ||
| from ..modules.hltInitialStepTrackSelectionHighPurity_cfi import * | ||
|
|
||
| HLTInitialStepCutClassifierHPSelectionSequence = cms.Sequence( | ||
| hltInitialStepTrackCutClassifier | ||
| +hltInitialStepTrackSelectionHighPurity | ||
| ) |
15 changes: 15 additions & 0 deletions
15
HLTrigger/Configuration/python/HLT_75e33/sequences/HLTInitialStepHPSelectionSequence_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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| from ..modules.hltInitialStepTrackCutClassifier_cfi import * | ||
| from ..modules.hltInitialStepTrackSelectionHighPurity_cfi import * | ||
| from ..modules.hltInitialStepTrackFeatureExtractor_cfi import * | ||
| from ..modules.hltInitialStepTrackTorchClassifier_cfi import * | ||
| from ..modules.hltInitialStepTrackTorchClassifierOutput_cfi import * | ||
|
|
||
| HLTInitialStepHPSelectionSequence = cms.Sequence( | ||
| hltInitialStepTrackFeatureExtractor | ||
| +hltInitialStepTrackTorchClassifier | ||
| +hltInitialStepTrackTorchClassifierOutput | ||
| +hltInitialStepTrackCutClassifier | ||
| +hltInitialStepTrackSelectionHighPurity | ||
| ) |
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
3 changes: 3 additions & 0 deletions
3
HLTrigger/Configuration/python/HLT_75e33/services/PyTorchService_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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| PyTorchService = cms.Service("PyTorchService") |
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,13 +1,20 @@ | ||
| <use name="ofast-flag"/> | ||
| <use name="alpaka"/> | ||
| <use name="DataFormats/Common"/> | ||
| <use name="DataFormats/Portable"/> | ||
| <use name="DataFormats/SoATemplate"/> | ||
| <use name="DataFormats/TrackReco"/> | ||
| <use name="DataFormats/VertexReco"/> | ||
| <use name="FWCore/Framework"/> | ||
| <use name="FWCore/MessageLogger"/> | ||
| <use name="FWCore/ParameterSet"/> | ||
| <use name="CondFormats/GBRForest"/> | ||
| <use name="TrackingTools/PatternTools"/> | ||
| <use name="HeterogeneousCore/AlpakaInterface"/> | ||
| <use name="roottmva"/> | ||
| <use name="lwtnn"/> | ||
| <!-- src/alpaka models the behavior of data formats --> | ||
| <flags ALPAKA_BACKENDS="!serial"/> | ||
| <export> | ||
| <lib name="1"/> | ||
| </export> |
30 changes: 30 additions & 0 deletions
30
RecoTracker/FinalTrackSelectors/interface/TrackTorchClassifierFeaturesSoA.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,30 @@ | ||
| #ifndef RecoTracker_FinalTrackSelectors_TrackTorchClassifierFeaturesSoA_h | ||
| #define RecoTracker_FinalTrackSelectors_TrackTorchClassifierFeaturesSoA_h | ||
|
|
||
| #include "DataFormats/SoATemplate/interface/SoALayout.h" | ||
|
|
||
| GENERATE_SOA_LAYOUT(TrackTorchClassifierFeaturesSoALayout, | ||
| SOA_COLUMN(float, dxyBeamSpot), | ||
| SOA_COLUMN(float, dzBeamSpot), | ||
| SOA_COLUMN(float, dxyError), | ||
| SOA_COLUMN(float, dzError), | ||
| SOA_COLUMN(float, normalizedChi2), | ||
| SOA_COLUMN(float, eta), | ||
| SOA_COLUMN(float, phi), | ||
| SOA_COLUMN(float, etaError), | ||
| SOA_COLUMN(float, phiError), | ||
| SOA_COLUMN(float, ndof), | ||
| SOA_COLUMN(float, lostInnerHits), | ||
| SOA_COLUMN(float, lostOuterHits), | ||
| SOA_COLUMN(float, layersWithoutMeas), | ||
| SOA_COLUMN(float, validPixelHits), | ||
| SOA_COLUMN(float, validStripHits)) | ||
|
|
||
| using TrackTorchClassifierFeaturesSoA = TrackTorchClassifierFeaturesSoALayout<>; | ||
|
|
||
| // Define the SoA layout for track scores (output) | ||
| GENERATE_SOA_LAYOUT(TrackTorchClassifierScoresSoALayout, SOA_COLUMN(float, score)) | ||
|
|
||
| using TrackTorchClassifierScoresSoA = TrackTorchClassifierScoresSoALayout<>; | ||
|
|
||
| #endif // RecoTracker_FinalTrackSelectors_TrackTorchClassifierFeaturesSoA_h |
12 changes: 12 additions & 0 deletions
12
RecoTracker/FinalTrackSelectors/interface/alpaka/TrackFeaturesDeviceCollection.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,12 @@ | ||
| #ifndef RecoTracker_FinalTrackSelectors_alpaka_TrackFeaturesDeviceCollection_h | ||
| #define RecoTracker_FinalTrackSelectors_alpaka_TrackFeaturesDeviceCollection_h | ||
|
|
||
| #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" | ||
| #include "RecoTracker/FinalTrackSelectors/interface/TrackTorchClassifierFeaturesSoA.h" | ||
| #include "HeterogeneousCore/AlpakaInterface/interface/config.h" | ||
|
|
||
| namespace ALPAKA_ACCELERATOR_NAMESPACE { | ||
| using TrackFeaturesDeviceCollection = PortableCollection<TrackTorchClassifierFeaturesSoA>; | ||
| } // namespace ALPAKA_ACCELERATOR_NAMESPACE | ||
|
|
||
| #endif // RecoTracker_FinalTrackSelectors_alpaka_TrackFeaturesDeviceCollection_h |
12 changes: 12 additions & 0 deletions
12
RecoTracker/FinalTrackSelectors/interface/alpaka/TrackScoresDeviceCollection.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,12 @@ | ||
| #ifndef RecoTracker_FinalTrackSelectors_alpaka_TrackScoresDeviceCollection_h | ||
| #define RecoTracker_FinalTrackSelectors_alpaka_TrackScoresDeviceCollection_h | ||
|
|
||
| #include "DataFormats/Portable/interface/alpaka/PortableCollection.h" | ||
| #include "RecoTracker/FinalTrackSelectors/interface/TrackTorchClassifierFeaturesSoA.h" | ||
| #include "HeterogeneousCore/AlpakaInterface/interface/config.h" | ||
|
|
||
| namespace ALPAKA_ACCELERATOR_NAMESPACE { | ||
| using TrackScoresDeviceCollection = PortableCollection<TrackTorchClassifierScoresSoA>; | ||
| } // namespace ALPAKA_ACCELERATOR_NAMESPACE | ||
|
|
||
| #endif // RecoTracker_FinalTrackSelectors_alpaka_TrackScoresDeviceCollection_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
127 changes: 127 additions & 0 deletions
127
RecoTracker/FinalTrackSelectors/plugins/TrackTorchClassifierFromSoA.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,127 @@ | ||
| #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/ParameterSet/interface/ConfigurationDescriptions.h" | ||
| #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
|
|
||
| #include "DataFormats/TrackReco/interface/Track.h" | ||
| #include "DataFormats/TrackReco/interface/TrackFwd.h" | ||
|
|
||
| #include "DataFormats/Portable/interface/PortableHostCollection.h" | ||
| #include "RecoTracker/FinalTrackSelectors/interface/TrackTorchClassifierFeaturesSoA.h" | ||
| #include "TrackingTools/PatternTools/interface/Trajectory.h" | ||
| #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" | ||
|
|
||
| // This module consumes the HOST copy of the Alpaka device scores | ||
| // The framework automatically creates host copies of device PortableCollections | ||
| class TrackTorchClassifierFromSoA : public edm::stream::EDProducer<> { | ||
| public: | ||
| explicit TrackTorchClassifierFromSoA(const edm::ParameterSet& iConfig); | ||
| ~TrackTorchClassifierFromSoA() override = default; | ||
|
|
||
| static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); | ||
|
|
||
| private: | ||
| void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; | ||
|
|
||
| const edm::EDGetTokenT<reco::TrackCollection> tracks_token_; | ||
| edm::EDGetTokenT<std::vector<Trajectory>> trajectories_token_; | ||
| const edm::EDGetTokenT<PortableHostCollection<TrackTorchClassifierScoresSoA>> scores_token_; | ||
| const edm::EDGetTokenT<PortableHostCollection<TrackTorchClassifierFeaturesSoA>> features_token_; | ||
| const bool copy_trajectories_; | ||
| const float min_score_; | ||
| const float dxy_threshold_; | ||
| const float high_dxy_min_score_; | ||
|
|
||
| const edm::EDPutTokenT<reco::TrackCollection> filtered_tracks_token_; | ||
| const edm::EDPutTokenT<std::vector<Trajectory>> filtered_trajectories_token_; | ||
| const edm::EDPutTokenT<TrajTrackAssociationCollection> traj_track_associations_token_; | ||
| const edm::EDPutTokenT<std::vector<float>> scores_output_token_; | ||
| }; | ||
|
|
||
| TrackTorchClassifierFromSoA::TrackTorchClassifierFromSoA(const edm::ParameterSet& iConfig) | ||
| : tracks_token_(consumes(iConfig.getParameter<edm::InputTag>("src"))), | ||
| trajectories_token_(), | ||
| scores_token_(consumes(iConfig.getParameter<edm::InputTag>("scores"))), | ||
| features_token_(consumes(iConfig.getParameter<edm::InputTag>("features"))), | ||
| copy_trajectories_(iConfig.getParameter<bool>("copyTrajectories")), | ||
| min_score_(iConfig.getParameter<double>("minScore")), | ||
| dxy_threshold_(iConfig.getParameter<double>("dxyThreshold")), | ||
| high_dxy_min_score_(iConfig.getParameter<double>("highDxyMinScore")), | ||
| filtered_tracks_token_(produces<reco::TrackCollection>()), | ||
| filtered_trajectories_token_(produces<std::vector<Trajectory>>()), | ||
| traj_track_associations_token_(produces<TrajTrackAssociationCollection>()), | ||
| scores_output_token_(produces<std::vector<float>>("MVAScores")) { | ||
| if (copy_trajectories_) { | ||
| trajectories_token_ = consumes(iConfig.getParameter<edm::InputTag>("src")); | ||
| } | ||
| } | ||
|
|
||
| void TrackTorchClassifierFromSoA::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
| edm::ParameterSetDescription desc; | ||
| desc.add<edm::InputTag>("src", edm::InputTag("hltInitialStepTracks")); | ||
| desc.add<edm::InputTag>("scores", edm::InputTag("hltInitialStepTrackTorchClassifier")); | ||
| desc.add<edm::InputTag>("features", edm::InputTag("hltInitialStepTrackTorchClassifier")); | ||
| desc.add<bool>("copyTrajectories", false) | ||
| ->setComment("Whether to produce the filtered trajectory collection and associations"); | ||
| desc.add<double>("minScore", 0.5)->setComment("Minimum DNN score to keep track (working point)"); | ||
| desc.add<double>("dxyThreshold", 0.5)->setComment("Tracks with |dxy| > this value bypass the score cut"); | ||
| desc.add<double>("highDxyMinScore", 0.5)->setComment("Minimum DNN score to keep high dxy track (working point)"); | ||
| descriptions.addWithDefaultLabel(desc); | ||
| } | ||
|
|
||
| void TrackTorchClassifierFromSoA::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { | ||
| const auto& tracks = iEvent.get(tracks_token_); | ||
| const auto& scores_host = iEvent.get(scores_token_); | ||
| const auto& features_host = iEvent.get(features_token_); | ||
|
|
||
| const std::vector<Trajectory>* trajectories = nullptr; | ||
| if (copy_trajectories_) { | ||
| trajectories = &iEvent.get(trajectories_token_); | ||
| } | ||
|
|
||
| const auto nTracks = tracks.size(); | ||
|
|
||
| // Create filtered track collection and optionally copy the corresponding trajectories | ||
| auto filtered_tracks = std::make_unique<reco::TrackCollection>(); | ||
| std::unique_ptr<std::vector<Trajectory>> filtered_trajectories; | ||
| std::unique_ptr<TrajTrackAssociationCollection> traj_track_associations; | ||
| if (copy_trajectories_) { | ||
| filtered_trajectories = std::make_unique<std::vector<Trajectory>>(); | ||
| traj_track_associations = std::make_unique<TrajTrackAssociationCollection>( | ||
| iEvent.getRefBeforePut<std::vector<Trajectory>>(), iEvent.getRefBeforePut<reco::TrackCollection>()); | ||
| } | ||
| auto all_scores = std::make_unique<std::vector<float>>(); | ||
| all_scores->reserve(nTracks); | ||
|
|
||
| // Access scores and features from the host collection | ||
| auto scores_view = scores_host.const_view(); | ||
| auto features_view = features_host.const_view(); | ||
|
|
||
| for (size_t i = 0; i < nTracks; ++i) { | ||
| float score = scores_view[i].score(); | ||
| float dxy = features_view[i].dxyBeamSpot(); | ||
| all_scores->push_back(score); | ||
|
|
||
| if (score >= min_score_ || ((std::abs(dxy) > dxy_threshold_) && (score >= high_dxy_min_score_))) { | ||
| filtered_tracks->push_back(tracks[i]); | ||
| if (copy_trajectories_) { | ||
| filtered_trajectories->push_back((*trajectories)[i]); | ||
| traj_track_associations->insert( | ||
| edm::Ref<std::vector<Trajectory>>(iEvent.getRefBeforePut<std::vector<Trajectory>>(), | ||
| filtered_trajectories->size() - 1), | ||
| reco::TrackRef(iEvent.getRefBeforePut<reco::TrackCollection>(), filtered_tracks->size() - 1)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| iEvent.put(filtered_tracks_token_, std::move(filtered_tracks)); | ||
| if (copy_trajectories_) { | ||
| iEvent.put(filtered_trajectories_token_, std::move(filtered_trajectories)); | ||
| iEvent.put(traj_track_associations_token_, std::move(traj_track_associations)); | ||
| } | ||
| iEvent.put(scores_output_token_, std::move(all_scores)); | ||
| } | ||
|
|
||
| DEFINE_FWK_MODULE(TrackTorchClassifierFromSoA); |
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.
why is this here? looks duplicate of 10 lines above