@@ -141,8 +141,11 @@ class MkFitOutputConverter : public edm::global::EDProducer<> {
141141 const bool doErrorRescale_;
142142
143143 const int algo_;
144- const bool algoCandSelection_;
145- const float algoCandWorkingPoint_;
144+ const bool algoCandCutSelection_;
145+ const float algoCandMinPtCut_;
146+ const int algoCandMinNHitsCut_;
147+ const bool algoCandMVASelection_;
148+ const float algoCandMVAWorkingPoint_;
146149 const int bsize_;
147150 const edm::EDGetTokenT<reco::BeamSpot> bsToken_;
148151 const edm::EDGetTokenT<reco::VertexCollection> verticesToken_;
@@ -177,13 +180,16 @@ MkFitOutputConverter::MkFitOutputConverter(edm::ParameterSet const& iConfig)
177180 doErrorRescale_{iConfig.getParameter <bool >(" doErrorRescale" )},
178181 algo_{reco::TrackBase::algoByName (
179182 TString (iConfig.getParameter <edm::InputTag>(" seeds" ).label ()).ReplaceAll (" Seeds" , " " ).Data ())},
180- algoCandSelection_{bool (iConfig.getParameter <bool >(" candMVASel" ))},
181- algoCandWorkingPoint_{float (iConfig.getParameter <double >(" candWP" ))},
183+ algoCandCutSelection_{bool (iConfig.getParameter <bool >(" candCutSel" ))},
184+ algoCandMinPtCut_{float (iConfig.getParameter <double >(" candMinPtCut" ))},
185+ algoCandMinNHitsCut_{iConfig.getParameter <int >(" candMinNHitsCut" )},
186+ algoCandMVASelection_{bool (iConfig.getParameter <bool >(" candMVASel" ))},
187+ algoCandMVAWorkingPoint_{float (iConfig.getParameter <double >(" candWP" ))},
182188 bsize_{int (iConfig.getParameter <int >(" batchSize" ))},
183- bsToken_ (algoCandSelection_ ? consumes<reco::BeamSpot>(edm::InputTag(" offlineBeamSpot" ))
184- : edm::EDGetTokenT<reco::BeamSpot>()),
185- verticesToken_(algoCandSelection_ ? consumes<reco::VertexCollection>(edm::InputTag(" firstStepPrimaryVertices" ))
186- : edm::EDGetTokenT<reco::VertexCollection>()),
189+ bsToken_ (algoCandMVASelection_ ? consumes<reco::BeamSpot>(edm::InputTag(" offlineBeamSpot" ))
190+ : edm::EDGetTokenT<reco::BeamSpot>()),
191+ verticesToken_(algoCandMVASelection_ ? consumes<reco::VertexCollection>(edm::InputTag(" firstStepPrimaryVertices" ))
192+ : edm::EDGetTokenT<reco::VertexCollection>()),
187193 tfDnnLabel_(iConfig.getParameter<std::string>(" tfDnnLabel" )),
188194 tfDnnToken_(esConsumes(edm::ESInputTag(" " , tfDnnLabel_))) {}
189195
@@ -211,6 +217,10 @@ void MkFitOutputConverter::fillDescriptions(edm::ConfigurationDescriptions& desc
211217
212218 desc.add <std::string>(" tfDnnLabel" , " trackSelectionTf" );
213219
220+ desc.add <bool >(" candCutSel" , false )->setComment (" flag used to trigger cut-based selection at cand level" );
221+ desc.add <double >(" candMinPtCut" , 0 )->setComment (" min pt cut at cand level" );
222+ desc.add <int >(" candMinNHitsCut" , 0 )->setComment (" min cut on number of hits at cand level" );
223+
214224 desc.add <bool >(" candMVASel" , false )->setComment (" flag used to trigger MVA selection at cand level" );
215225 desc.add <double >(" candWP" , 0 )->setComment (" MVA selection at cand level working point" );
216226 desc.add <int >(" batchSize" , 16 )->setComment (" batch size for cand DNN evaluation" );
@@ -232,13 +242,13 @@ void MkFitOutputConverter::produce(edm::StreamID iID, edm::Event& iEvent, const
232242 // beamspot as well since the producer can be used in hlt
233243 const reco::VertexCollection* vertices = nullptr ;
234244 const reco::BeamSpot* beamspot = nullptr ;
235- if (algoCandSelection_ ) {
245+ if (algoCandMVASelection_ ) {
236246 vertices = &iEvent.get (verticesToken_);
237247 beamspot = &iEvent.get (bsToken_);
238248 }
239249
240250 const tensorflow::Session* session = nullptr ;
241- if (algoCandSelection_ )
251+ if (algoCandMVASelection_ )
242252 session = iSetup.getData (tfDnnToken_).getSession ();
243253
244254 // Convert mkfit presentation back to CMSSW
@@ -308,6 +318,9 @@ TrackCandidateCollection MkFitOutputConverter::convertCandidates(const MkFitOutp
308318 continue ;
309319 }
310320
321+ if (algoCandCutSelection_ && (cand.pT () < algoCandMinPtCut_ || cand.nTotalHits () < algoCandMinNHitsCut_))
322+ continue ;
323+
311324 auto state = cand.state (); // copy because have to modify
312325 state.convertFromCCSToGlbCurvilinear ();
313326 const auto & param = state.parameters ;
@@ -512,15 +525,15 @@ TrackCandidateCollection MkFitOutputConverter::convertCandidates(const MkFitOutp
512525 states.push_back (tsosDet.first );
513526 }
514527
515- if (algoCandSelection_ ) {
528+ if (algoCandMVASelection_ ) {
516529 const auto & dnnScores = computeDNNs (
517530 output, states, bs, vertices, session, chi2, mkFitOutput.propagatedToFirstLayer () && doErrorRescale_);
518531
519532 TrackCandidateCollection reducedOutput;
520533 reducedOutput.reserve (output.size ());
521534 int scoreIndex = 0 ;
522535 for (const auto & score : dnnScores) {
523- if (score > algoCandWorkingPoint_ )
536+ if (score > algoCandMVAWorkingPoint_ )
524537 reducedOutput.push_back (output[scoreIndex]);
525538 scoreIndex++;
526539 }
0 commit comments