-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Track Purity DNN for Phase-2 HLT #51084
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
jchismar
wants to merge
7
commits into
cms-sw:master
Choose a base branch
from
jchismar:track-purity-dnn
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 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4986d26
Add pytorch model for phase-2 hlt track classification
aashayarora 4026bba
Add missing newlines
jchismar 21877eb
Add modifier to Phase 2 modifier chain
jchismar 5503f34
Anti-selection on ngtScouting modifier
jchismar 8d3e6b2
Add PyTorch Service
jchismar c16c933
Remove unnecessary line
jchismar 93e8c78
Clean up files
jchismar 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/trackTorchClassifier_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 a deep neural network for high purity track selection | ||
| trackTorchClassifier = 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("TrackFeatureExtractor@alpaka", | ||
| 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
10 changes: 10 additions & 0 deletions
10
...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,10 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| hltInitialStepTrackTorchClassifierOutput = cms.EDProducer("TrackTorchClassifierFromSoA", | ||
| src = cms.InputTag("hltInitialStepTracks"), | ||
| scores = cms.InputTag("hltInitialStepTrackTorchClassifier"), | ||
| features = cms.InputTag("hltInitialStepTrackFeatureExtractor"), | ||
| minScore = cms.double(0.377), | ||
| dxyThreshold = cms.double(0.5), | ||
| highDxyMinScore = cms.double(0.267) | ||
| ) |
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("TrackTorchClassifierAlpaka@alpaka", | ||
| 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
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,9 @@ | ||
| import FWCore.ParameterSet.Config as cms | ||
|
|
||
| from ..modules.hltInitialStepTrackCutClassifier_cfi import * | ||
| from ..modules.hltInitialStepTrackSelectionHighPurity_cfi import * | ||
|
|
||
| HLTInitialStepHPSelectionSequence = cms.Sequence( | ||
| hltInitialStepTrackCutClassifier | ||
| +hltInitialStepTrackSelectionHighPurity | ||
| ) | ||
|
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. nit: missing newline. |
||
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
15 changes: 15 additions & 0 deletions
15
...ration/python/HLT_75e33/sequences/HLTInitialStepTorchClassifierHPSelectionSequence_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 * | ||
|
|
||
| HLTInitialStepTorchClassifierHPSelectionSequence = cms.Sequence( | ||
| hltInitialStepTrackFeatureExtractor | ||
| +hltInitialStepTrackTorchClassifier | ||
| +hltInitialStepTrackTorchClassifierOutput | ||
| +hltInitialStepTrackCutClassifier | ||
| +hltInitialStepTrackSelectionHighPurity | ||
| ) | ||
|
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. nit: missing newline. |
||
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"/> | ||
| <use name="clhep"/> | ||
|
jchismar marked this conversation as resolved.
Outdated
|
||
| <flags ALPAKA_BACKENDS="1"/> | ||
| <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
88 changes: 88 additions & 0 deletions
88
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,88 @@ | ||
| #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" | ||
|
|
||
| // 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_; | ||
| const edm::EDGetTokenT<PortableHostCollection<TrackTorchClassifierScoresSoA>> scores_token_; | ||
| const edm::EDGetTokenT<PortableHostCollection<TrackTorchClassifierFeaturesSoA>> features_token_; | ||
| 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<float>> scores_output_token_; | ||
| }; | ||
|
|
||
| TrackTorchClassifierFromSoA::TrackTorchClassifierFromSoA(const edm::ParameterSet& iConfig) | ||
| : tracks_token_(consumes(iConfig.getParameter<edm::InputTag>("src"))), | ||
| scores_token_(consumes(iConfig.getParameter<edm::InputTag>("scores"))), | ||
| features_token_(consumes(iConfig.getParameter<edm::InputTag>("features"))), | ||
| 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>()), | ||
| scores_output_token_(produces<std::vector<float>>("MVAScores")) {} | ||
|
|
||
| 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<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 auto nTracks = tracks.size(); | ||
|
|
||
| // Create filtered track collection | ||
| auto filtered_tracks = std::make_unique<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]); | ||
| } | ||
| } | ||
|
|
||
| iEvent.put(filtered_tracks_token_, std::move(filtered_tracks)); | ||
| 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.
for my understanding why is this proposed via a modifier and not directly in the "production" workflow?