CMS 3D CMS Logo

L1TkElectronTrackProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
10 //
11 // system include files
12 #include <memory>
13 
14 // user include files
17 
21 
26 
29 
31 
34 
35 // Matching Algorithm
39 
42 
43 #include <string>
44 
45 static constexpr float EB_MaxEta = 0.9;
46 
47 using namespace l1t;
48 
49 //
50 // class declaration
51 //
52 
54 public:
56  typedef std::vector<L1TTTrackType> L1TTTrackCollectionType;
57 
59  ~L1TkElectronTrackProducer() override;
60 
61  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
62 
63 private:
64  //void beginJob() override;
65  void produce(edm::Event&, const edm::EventSetup&) override;
66  //void endJob() override;
67 
68  float isolation(const edm::Handle<L1TTTrackCollectionType>& trkHandle, int match_index);
69  double getPtScaledCut(double pt, std::vector<double>& parameters);
70  bool selectMatchedTrack(double& d_r, double& d_phi, double& d_eta, double& tk_pt, float& eg_eta);
71 
72  // ----------member data ---------------------------
74 
75  const float etMin_; // min ET in GeV of L1EG objects
76  const float pTMinTra_;
77  const float dRMin_;
78  const float dRMax_;
79  float deltaZ_; // | z_track - z_ref_track | < deltaZ_ in cm.
80  // Used only when primaryVtxConstrain_ = True.
81  const float maxChi2IsoTracks_;
82  const unsigned int minNStubsIsoTracks_;
83  float isoCut_;
85  bool primaryVtxConstrain_; // use the primary vertex (default = false)
89  bool useClusterET_; // use cluster et to extrapolate tracks
90  std::vector<double> dPhiCutoff_;
91  std::vector<double> dRCutoff_;
92  std::vector<double> dEtaCutoff_;
94 
98 };
99 
100 //
101 // constructors and destructor
102 //
104  : label(iConfig.getParameter<std::string>("label")),
105  etMin_((float)iConfig.getParameter<double>("ETmin")),
106  pTMinTra_((float)iConfig.getParameter<double>("PTMINTRA")),
107  dRMin_((float)iConfig.getParameter<double>("DRmin")),
108  dRMax_((float)iConfig.getParameter<double>("DRmax")),
109  deltaZ_((float)iConfig.getParameter<double>("DeltaZ")),
110  maxChi2IsoTracks_(iConfig.getParameter<double>("maxChi2IsoTracks")),
111  minNStubsIsoTracks_(iConfig.getParameter<int>("minNStubsIsoTracks")),
112  isoCut_((float)iConfig.getParameter<double>("IsoCut")),
113  relativeIsolation_(iConfig.getParameter<bool>("RelativeIsolation")),
114  trkQualityChi2_((float)iConfig.getParameter<double>("TrackChi2")),
115  trkQualityPtMin_((float)iConfig.getParameter<double>("TrackMinPt")),
116  useTwoStubsPT_(iConfig.getParameter<bool>("useTwoStubsPT")),
117  useClusterET_(iConfig.getParameter<bool>("useClusterET")),
118  dPhiCutoff_(iConfig.getParameter<std::vector<double>>("TrackEGammaDeltaPhi")),
119  dRCutoff_(iConfig.getParameter<std::vector<double>>("TrackEGammaDeltaR")),
120  dEtaCutoff_(iConfig.getParameter<std::vector<double>>("TrackEGammaDeltaEta")),
121  matchType_(iConfig.getParameter<std::string>("TrackEGammaMatchType")),
122  egToken_(consumes<EGammaBxCollection>(iConfig.getParameter<edm::InputTag>("L1EGammaInputTag"))),
123  trackToken_(consumes<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>(
124  iConfig.getParameter<edm::InputTag>("L1TrackInputTag"))),
126  produces<TkElectronCollection>(label);
127 }
128 
130 
131 // ------------ method called to produce the data ------------
133  std::unique_ptr<TkElectronCollection> result(new TkElectronCollection);
134 
135  // geometry needed to call pTFrom2Stubs
136  const TrackerGeometry& tGeom = iSetup.getData(tGeomToken_);
137  const TrackerGeometry* tGeometry = &tGeom;
138 
139  // the L1EGamma objects
140  edm::Handle<EGammaBxCollection> eGammaHandle;
141  iEvent.getByToken(egToken_, eGammaHandle);
142  EGammaBxCollection eGammaCollection = (*eGammaHandle.product());
144 
145  // the L1Tracks
146  edm::Handle<L1TTTrackCollectionType> L1TTTrackHandle;
147  iEvent.getByToken(trackToken_, L1TTTrackHandle);
148  L1TTTrackCollectionType::const_iterator trackIter;
149 
150  if (!eGammaHandle.isValid()) {
151  throw cms::Exception("L1TkElectronTrackProducer")
152  << "\nWarning: L1EmCollection not found in the event. Exit" << std::endl;
153  return;
154  }
155  if (!L1TTTrackHandle.isValid()) {
156  throw cms::Exception("L1TkElectronTrackProducer")
157  << "\nWarning: L1TTTrackCollectionType not found in the event. Exit." << std::endl;
158  return;
159  }
160 
161  int ieg = 0;
162  for (egIter = eGammaCollection.begin(0); egIter != eGammaCollection.end(0); ++egIter) { // considering BX = only
163  edm::Ref<EGammaBxCollection> EGammaRef(eGammaHandle, ieg);
164  ieg++;
165 
166  float e_ele = egIter->energy();
167  float eta_ele = egIter->eta();
168  float et_ele = 0;
169  float cosh_eta_ele = cosh(eta_ele);
170  if (cosh_eta_ele > 0.0)
171  et_ele = e_ele / cosh_eta_ele;
172  else
173  et_ele = -1.0;
174  if (etMin_ > 0.0 && et_ele <= etMin_)
175  continue;
176  // match the L1EG object with a L1Track
177  float drmin = 999;
178  int itr = 0;
179  int itrack = -1;
180  for (trackIter = L1TTTrackHandle->begin(); trackIter != L1TTTrackHandle->end(); ++trackIter) {
181  edm::Ptr<L1TTTrackType> L1TrackPtr(L1TTTrackHandle, itr);
182  double trkPt_fit = trackIter->momentum().perp();
183  double trkPt_stubs = pTFrom2Stubs::pTFrom2(trackIter, tGeometry);
184  double trkPt = trkPt_fit;
185  if (useTwoStubsPT_)
186  trkPt = trkPt_stubs;
187 
188  if (trkPt > trkQualityPtMin_ && trackIter->chi2() < trkQualityChi2_) {
189  double dPhi = 99.;
190  double dR = 99.;
191  double dEta = 99.;
192  if (useClusterET_)
194  else
195  L1TkElectronTrackMatchAlgo::doMatch(egIter, L1TrackPtr, dPhi, dR, dEta);
196  if (dR < drmin && selectMatchedTrack(dR, dPhi, dEta, trkPt, eta_ele)) {
197  drmin = dR;
198  itrack = itr;
199  }
200  }
201  itr++;
202  }
203  if (itrack >= 0) {
204  edm::Ptr<L1TTTrackType> matchedL1TrackPtr(L1TTTrackHandle, itrack);
205 
206  const math::XYZTLorentzVector P4 = egIter->p4();
207  float trkisol = isolation(L1TTTrackHandle, itrack);
208  if (relativeIsolation_ && et_ele > 0.0) { // relative isolation
209  trkisol = trkisol / et_ele;
210  }
211 
212  TkElectron trkEm(P4, EGammaRef, matchedL1TrackPtr, trkisol);
213 
214  trkEm.setTrackCurvature(matchedL1TrackPtr->rInv()); // should this have npars? 4? 5?
215 
216  //std::cout<<matchedL1TrackPtr->rInv()<<" "<<matchedL1TrackPtr->rInv(4)<<" "<<matchedL1TrackPtr->rInv()<<std::endl;
217 
218  if (isoCut_ <= 0) {
219  // write the L1TkEm particle to the collection,
220  // irrespective of its relative isolation
221  result->push_back(trkEm);
222  } else {
223  // the object is written to the collection only
224  // if it passes the isolation cut
225  if (trkisol <= isoCut_)
226  result->push_back(trkEm);
227  }
228  }
229 
230  } // end loop over EGamma objects
231 
232  iEvent.put(std::move(result), label);
233 }
234 
235 // ------------ method called once each job just before starting event loop ------------
236 //void L1TkElectronTrackProducer::beginJob() {}
237 
238 // ------------ method called once each job just after ending the event loop ------------
239 //void L1TkElectronTrackProducer::endJob() {}
240 
241 // ------------ method called when starting to processes a run ------------
242 /*
243 void
244 L1TkElectronTrackProducer::beginRun(edm::Run& iRun, edm::EventSetup const& iSetup)
245 {
246 }
247 */
248 
249 // ------------ method called when ending the processing of a run ------------
250 /*
251 void
252 L1TkElectronTrackProducer::endRun(edm::Run&, edm::EventSetup const&)
253 {
254 }
255 */
256 
257 // ------------ method called when starting to processes a luminosity block ------------
258 /*
259 void
260 L1TkElectronTrackProducer::beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
261 {
262 }
263 */
264 
265 // ------------ method called when ending the processing of a luminosity block ------------
266 /*
267 void
268 L1TkElectronTrackProducer::endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
269 {
270 }
271 */
272 
273 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
275  {
276  // L1TkElectrons
278  desc.add<std::string>("label", "EG");
279  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("simCaloStage2Digis"));
280  desc.add<double>("ETmin", -1.0);
281  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
282  desc.add<double>("TrackChi2", 10000000000.0);
283  desc.add<double>("TrackMinPt", 10.0);
284  desc.add<bool>("useTwoStubsPT", false);
285  desc.add<bool>("useClusterET", false);
286  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
287  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
288  {
289  0.07,
290  0.0,
291  0.0,
292  });
293  desc.add<std::vector<double>>("TrackEGammaDeltaR",
294  {
295  0.08,
296  0.0,
297  0.0,
298  });
299  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
300  {
301  10000000000.0,
302  0.0,
303  0.0,
304  });
305  desc.add<bool>("RelativeIsolation", true);
306  desc.add<double>("IsoCut", -0.1);
307  desc.add<double>("PTMINTRA", 2.0);
308  desc.add<double>("DRmin", 0.03);
309  desc.add<double>("DRmax", 0.2);
310  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
311  desc.add<int>("minNStubsIsoTracks", 0);
312  desc.add<double>("DeltaZ", 0.6);
313  descriptions.add("L1TkElectrons", desc);
314  // or use the following to generate the label from the module's C++ type
315  //descriptions.addWithDefaultLabel(desc);
316  }
317  {
318  // L1TkIsoElectrons
320  desc.add<std::string>("label", "EG");
321  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("simCaloStage2Digis"));
322  desc.add<double>("ETmin", -1.0);
323  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
324  desc.add<double>("TrackChi2", 10000000000.0);
325  desc.add<double>("TrackMinPt", 10.0);
326  desc.add<bool>("useTwoStubsPT", false);
327  desc.add<bool>("useClusterET", false);
328  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
329  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
330  {
331  0.07,
332  0.0,
333  0.0,
334  });
335  desc.add<std::vector<double>>("TrackEGammaDeltaR",
336  {
337  0.08,
338  0.0,
339  0.0,
340  });
341  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
342  {
343  10000000000.0,
344  0.0,
345  0.0,
346  });
347  desc.add<bool>("RelativeIsolation", true);
348  desc.add<double>("IsoCut", 0.1);
349  desc.add<double>("PTMINTRA", 2.0);
350  desc.add<double>("DRmin", 0.03);
351  desc.add<double>("DRmax", 0.2);
352  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
353  desc.add<int>("minNStubsIsoTracks", 0);
354  desc.add<double>("DeltaZ", 0.6);
355  descriptions.add("L1TkIsoElectrons", desc);
356  // or use the following to generate the label from the module's C++ type
357  //descriptions.addWithDefaultLabel(desc);
358  }
359  {
360  // L1TkElectronsLoose
362  desc.add<std::string>("label", "EG");
363  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("simCaloStage2Digis"));
364  desc.add<double>("ETmin", -1.0);
365  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
366  desc.add<double>("TrackChi2", 10000000000.0);
367  desc.add<double>("TrackMinPt", 3.0);
368  desc.add<bool>("useTwoStubsPT", false);
369  desc.add<bool>("useClusterET", false);
370  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
371  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
372  {
373  0.07,
374  0.0,
375  0.0,
376  });
377  desc.add<std::vector<double>>("TrackEGammaDeltaR",
378  {
379  0.12,
380  0.0,
381  0.0,
382  });
383  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
384  {
385  10000000000.0,
386  0.0,
387  0.0,
388  });
389  desc.add<bool>("RelativeIsolation", true);
390  desc.add<double>("IsoCut", -0.1);
391  desc.add<double>("PTMINTRA", 2.0);
392  desc.add<double>("DRmin", 0.03);
393  desc.add<double>("DRmax", 0.2);
394  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
395  desc.add<int>("minNStubsIsoTracks", 0);
396  desc.add<double>("DeltaZ", 0.6);
397  descriptions.add("L1TkElectronsLoose", desc);
398  // or use the following to generate the label from the module's C++ type
399  //descriptions.addWithDefaultLabel(desc);
400  }
401  {
402  // L1TkElectronsCrystal
404  desc.add<std::string>("label", "EG");
405  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("L1EGammaClusterEmuProducer"));
406  desc.add<double>("ETmin", -1.0);
407  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
408  desc.add<double>("TrackChi2", 10000000000.0);
409  desc.add<double>("TrackMinPt", 10.0);
410  desc.add<bool>("useTwoStubsPT", false);
411  desc.add<bool>("useClusterET", false);
412  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
413  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
414  {
415  0.07,
416  0.0,
417  0.0,
418  });
419  desc.add<std::vector<double>>("TrackEGammaDeltaR",
420  {
421  0.08,
422  0.0,
423  0.0,
424  });
425  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
426  {
427  10000000000.0,
428  0.0,
429  0.0,
430  });
431  desc.add<bool>("RelativeIsolation", true);
432  desc.add<double>("IsoCut", -0.1);
433  desc.add<double>("PTMINTRA", 2.0);
434  desc.add<double>("DRmin", 0.03);
435  desc.add<double>("DRmax", 0.2);
436  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
437  desc.add<int>("minNStubsIsoTracks", 0);
438  desc.add<double>("DeltaZ", 0.6);
439  descriptions.add("L1TkElectronsCrystal", desc);
440  // or use the following to generate the label from the module's C++ type
441  //descriptions.addWithDefaultLabel(desc);
442  }
443  {
444  // L1TkIsoElectronsCrystal
446  desc.add<std::string>("label", "EG");
447  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("L1EGammaClusterEmuProducer"));
448  desc.add<double>("ETmin", -1.0);
449  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
450  desc.add<double>("TrackChi2", 10000000000.0);
451  desc.add<double>("TrackMinPt", 10.0);
452  desc.add<bool>("useTwoStubsPT", false);
453  desc.add<bool>("useClusterET", false);
454  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
455  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
456  {
457  0.07,
458  0.0,
459  0.0,
460  });
461  desc.add<std::vector<double>>("TrackEGammaDeltaR",
462  {
463  0.08,
464  0.0,
465  0.0,
466  });
467  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
468  {
469  10000000000.0,
470  0.0,
471  0.0,
472  });
473  desc.add<bool>("RelativeIsolation", true);
474  desc.add<double>("IsoCut", 0.1);
475  desc.add<double>("PTMINTRA", 2.0);
476  desc.add<double>("DRmin", 0.03);
477  desc.add<double>("DRmax", 0.2);
478  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
479  desc.add<int>("minNStubsIsoTracks", 0);
480  desc.add<double>("DeltaZ", 0.6);
481  descriptions.add("L1TkIsoElectronsCrystal", desc);
482  // or use the following to generate the label from the module's C++ type
483  //descriptions.addWithDefaultLabel(desc);
484  }
485  {
486  // L1TkElectronsLooseCrystal
488  desc.add<std::string>("label", "EG");
489  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("L1EGammaClusterEmuProducer"));
490  desc.add<double>("ETmin", -1.0);
491  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
492  desc.add<double>("TrackChi2", 10000000000.0);
493  desc.add<double>("TrackMinPt", 3.0);
494  desc.add<bool>("useTwoStubsPT", false);
495  desc.add<bool>("useClusterET", false);
496  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
497  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
498  {
499  0.07,
500  0.0,
501  0.0,
502  });
503  desc.add<std::vector<double>>("TrackEGammaDeltaR",
504  {
505  0.12,
506  0.0,
507  0.0,
508  });
509  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
510  {
511  10000000000.0,
512  0.0,
513  0.0,
514  });
515  desc.add<bool>("RelativeIsolation", true);
516  desc.add<double>("IsoCut", -0.1);
517  desc.add<double>("PTMINTRA", 2.0);
518  desc.add<double>("DRmin", 0.03);
519  desc.add<double>("DRmax", 0.2);
520  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
521  desc.add<int>("minNStubsIsoTracks", 0);
522  desc.add<double>("DeltaZ", 0.6);
523  descriptions.add("L1TkElectronsLooseCrystal", desc);
524  // or use the following to generate the label from the module's C++ type
525  //descriptions.addWithDefaultLabel(desc);
526  }
527  {
528  // L1TkElectronsEllipticMatchCrystal
530  desc.add<std::string>("label", "EG");
531  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("L1EGammaClusterEmuProducer"));
532  desc.add<double>("ETmin", -1.0);
533  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
534  desc.add<double>("TrackChi2", 10000000000.0);
535  desc.add<double>("TrackMinPt", 10.0);
536  desc.add<bool>("useTwoStubsPT", false);
537  desc.add<bool>("useClusterET", false);
538  desc.add<std::string>("TrackEGammaMatchType", "EllipticalCut");
539  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
540  {
541  0.07,
542  0.0,
543  0.0,
544  });
545  desc.add<std::vector<double>>("TrackEGammaDeltaR",
546  {
547  0.08,
548  0.0,
549  0.0,
550  });
551  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
552  {
553  0.015,
554  0.025,
555  10000000000.0,
556  });
557  desc.add<bool>("RelativeIsolation", true);
558  desc.add<double>("IsoCut", -0.1);
559  desc.add<double>("PTMINTRA", 2.0);
560  desc.add<double>("DRmin", 0.03);
561  desc.add<double>("DRmax", 0.2);
562  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
563  desc.add<int>("minNStubsIsoTracks", 0);
564  desc.add<double>("DeltaZ", 0.6);
565  descriptions.add("L1TkElectronsEllipticMatchCrystal", desc);
566  // or use the following to generate the label from the module's C++ type
567  //descriptions.addWithDefaultLabel(desc);
568  }
569  {
570  // L1TkElectronsHGC
572  desc.add<std::string>("label", "EG");
573  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("l1EGammaEEProducer", "L1EGammaCollectionBXVWithCuts"));
574  desc.add<double>("ETmin", -1.0);
575  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
576  desc.add<double>("TrackChi2", 10000000000.0);
577  desc.add<double>("TrackMinPt", 10.0);
578  desc.add<bool>("useTwoStubsPT", false);
579  desc.add<bool>("useClusterET", false);
580  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
581  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
582  {
583  0.07,
584  0.0,
585  0.0,
586  });
587  desc.add<std::vector<double>>("TrackEGammaDeltaR",
588  {
589  0.08,
590  0.0,
591  0.0,
592  });
593  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
594  {
595  10000000000.0,
596  0.0,
597  0.0,
598  });
599  desc.add<bool>("RelativeIsolation", true);
600  desc.add<double>("IsoCut", -0.1);
601  desc.add<double>("PTMINTRA", 2.0);
602  desc.add<double>("DRmin", 0.03);
603  desc.add<double>("DRmax", 0.2);
604  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
605  desc.add<int>("minNStubsIsoTracks", 0);
606  desc.add<double>("DeltaZ", 0.6);
607  descriptions.add("L1TkElectronsHGC", desc);
608  // or use the following to generate the label from the module's C++ type
609  //descriptions.addWithDefaultLabel(desc);
610  }
611  {
612  // L1TkElectronsEllipticMatchHGC
614  desc.add<std::string>("label", "EG");
615  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("l1EGammaEEProducer", "L1EGammaCollectionBXVWithCuts"));
616  desc.add<double>("ETmin", -1.0);
617  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
618  desc.add<double>("TrackChi2", 10000000000.0);
619  desc.add<double>("TrackMinPt", 10.0);
620  desc.add<bool>("useTwoStubsPT", false);
621  desc.add<bool>("useClusterET", false);
622  desc.add<std::string>("TrackEGammaMatchType", "EllipticalCut");
623  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
624  {
625  0.07,
626  0.0,
627  0.0,
628  });
629  desc.add<std::vector<double>>("TrackEGammaDeltaR",
630  {
631  0.08,
632  0.0,
633  0.0,
634  });
635  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
636  {
637  0.01,
638  0.01,
639  10000000000.0,
640  });
641  desc.add<bool>("RelativeIsolation", true);
642  desc.add<double>("IsoCut", -0.1);
643  desc.add<double>("PTMINTRA", 2.0);
644  desc.add<double>("DRmin", 0.03);
645  desc.add<double>("DRmax", 0.2);
646  desc.add<double>("maxChi2IsoTracks", 100);
647  desc.add<int>("minNStubsIsoTracks", 4);
648  desc.add<double>("DeltaZ", 0.6);
649  descriptions.add("L1TkElectronsEllipticMatchHGC", desc);
650  // or use the following to generate the label from the module's C++ type
651  //descriptions.addWithDefaultLabel(desc);
652  }
653  {
654  // L1TkIsoElectronsHGC
656  desc.add<std::string>("label", "EG");
657  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("l1EGammaEEProducer", "L1EGammaCollectionBXVWithCuts"));
658  desc.add<double>("ETmin", -1.0);
659  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
660  desc.add<double>("TrackChi2", 10000000000.0);
661  desc.add<double>("TrackMinPt", 10.0);
662  desc.add<bool>("useTwoStubsPT", false);
663  desc.add<bool>("useClusterET", false);
664  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
665  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
666  {
667  0.07,
668  0.0,
669  0.0,
670  });
671  desc.add<std::vector<double>>("TrackEGammaDeltaR",
672  {
673  0.08,
674  0.0,
675  0.0,
676  });
677  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
678  {
679  10000000000.0,
680  0.0,
681  0.0,
682  });
683  desc.add<bool>("RelativeIsolation", true);
684  desc.add<double>("IsoCut", 0.1);
685  desc.add<double>("PTMINTRA", 2.0);
686  desc.add<double>("DRmin", 0.03);
687  desc.add<double>("DRmax", 0.4);
688  desc.add<double>("maxChi2IsoTracks", 100);
689  desc.add<int>("minNStubsIsoTracks", 4);
690  desc.add<double>("DeltaZ", 1.0);
691  descriptions.add("L1TkIsoElectronsHGC", desc);
692  // or use the following to generate the label from the module's C++ type
693  //descriptions.addWithDefaultLabel(desc);
694  }
695  {
696  // L1TkElectronsLooseHGC
698  desc.add<std::string>("label", "EG");
699  desc.add<edm::InputTag>("L1EGammaInputTag", edm::InputTag("l1EGammaEEProducer", "L1EGammaCollectionBXVWithCuts"));
700  desc.add<double>("ETmin", -1.0);
701  desc.add<edm::InputTag>("L1TrackInputTag", edm::InputTag("TTTracksFromTrackletEmulation", "Level1TTTracks"));
702  desc.add<double>("TrackChi2", 10000000000.0);
703  desc.add<double>("TrackMinPt", 3.0);
704  desc.add<bool>("useTwoStubsPT", false);
705  desc.add<bool>("useClusterET", false);
706  desc.add<std::string>("TrackEGammaMatchType", "PtDependentCut");
707  desc.add<std::vector<double>>("TrackEGammaDeltaPhi",
708  {
709  0.07,
710  0.0,
711  0.0,
712  });
713  desc.add<std::vector<double>>("TrackEGammaDeltaR",
714  {
715  0.12,
716  0.0,
717  0.0,
718  });
719  desc.add<std::vector<double>>("TrackEGammaDeltaEta",
720  {
721  10000000000.0,
722  0.0,
723  0.0,
724  });
725  desc.add<bool>("RelativeIsolation", true);
726  desc.add<double>("IsoCut", -0.1);
727  desc.add<double>("PTMINTRA", 2.0);
728  desc.add<double>("DRmin", 0.03);
729  desc.add<double>("DRmax", 0.2);
730  desc.add<double>("maxChi2IsoTracks", 10000000000.0);
731  desc.add<int>("minNStubsIsoTracks", 0);
732  desc.add<double>("DeltaZ", 0.6);
733  descriptions.add("L1TkElectronsLooseHGC", desc);
734  // or use the following to generate the label from the module's C++ type
735  //descriptions.addWithDefaultLabel(desc);
736  }
737 }
738 
739 // method to calculate isolation
741  edm::Ptr<L1TTTrackType> matchedTrkPtr(trkHandle, match_index);
742  L1TTTrackCollectionType::const_iterator trackIter;
743 
744  float sumPt = 0.0;
745  int itr = 0;
746 
747  float dRMin2 = dRMin_ * dRMin_;
748  float dRMax2 = dRMax_ * dRMax_;
749 
750  for (trackIter = trkHandle->begin(); trackIter != trkHandle->end(); ++trackIter) {
751  if (itr++ != match_index) {
752  if (trackIter->chi2() > maxChi2IsoTracks_ || trackIter->momentum().perp() <= pTMinTra_ ||
753  trackIter->getStubRefs().size() < minNStubsIsoTracks_) {
754  continue;
755  }
756 
757  float dZ = std::abs(trackIter->POCA().z() - matchedTrkPtr->POCA().z());
758 
759  float phi1 = trackIter->momentum().phi();
760  float phi2 = matchedTrkPtr->momentum().phi();
761  float dPhi = reco::deltaPhi(phi1, phi2);
762  float dEta = (trackIter->momentum().eta() - matchedTrkPtr->momentum().eta());
763  float dR2 = (dPhi * dPhi + dEta * dEta);
764 
765  if (dR2 > dRMin2 && dR2 < dRMax2 && dZ < deltaZ_ && trackIter->momentum().perp() > pTMinTra_) {
766  sumPt += trackIter->momentum().perp();
767  }
768  }
769  }
770 
771  return sumPt;
772 }
773 double L1TkElectronTrackProducer::getPtScaledCut(double pt, std::vector<double>& parameters) {
774  return (parameters[0] + parameters[1] * exp(parameters[2] * pt));
775 }
777  double& d_r, double& d_phi, double& d_eta, double& tk_pt, float& eg_eta) {
778  if (matchType_ == "PtDependentCut") {
779  if (std::abs(d_phi) < getPtScaledCut(tk_pt, dPhiCutoff_) && d_r < getPtScaledCut(tk_pt, dRCutoff_))
780  return true;
781  } else {
782  double deta_max = dEtaCutoff_[0];
783  if (std::abs(eg_eta) < EB_MaxEta)
784  deta_max = dEtaCutoff_[1];
785  double dphi_max = dPhiCutoff_[0];
786  if ((d_eta / deta_max) * (d_eta / deta_max) + (d_phi / dphi_max) * (d_phi / dphi_max) < 1)
787  return true;
788  }
789  return false;
790 }
791 //define this as a plug-in
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
const edm::EDGetTokenT< EGammaBxCollection > egToken_
L1TkElectronTrackProducer(const edm::ParameterSet &)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< L1TTTrackType > L1TTTrackCollectionType
std::vector< TkElectron > TkElectronCollection
Definition: TkElectronFwd.h:15
edm::Ref< EGammaBxCollection > EGammaRef
Definition: TkEGTau.h:35
T z() const
Definition: PV3DBase.h:61
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T eta() const
Definition: PV3DBase.h:73
static constexpr float EB_MaxEta
T const * product() const
Definition: Handle.h:70
void doMatchClusterET(BXVector< l1t::EGamma >::const_iterator egIter, const edm::Ptr< L1TTTrackType > &pTrk, double &dph, double &dr, double &deta)
delete x;
Definition: CaloConfig.h:22
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tGeomToken_
GlobalVector momentum() const
Track momentum.
Definition: TTTrack.h:295
const_iterator begin(int bx) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
bool selectMatchedTrack(double &d_r, double &d_phi, double &d_eta, double &tk_pt, float &eg_eta)
char const * label
std::vector< T >::const_iterator const_iterator
Definition: BXVector.h:18
const edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > trackToken_
int iEvent
Definition: GenABIO.cc:224
void produce(edm::Event &, const edm::EventSetup &) override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double rInv() const
Track curvature.
Definition: TTTrack.h:300
void setTrackCurvature(double trackCurvature)
Definition: TkElectron.h:46
bool getData(T &iHolder) const
Definition: EventSetup.h:122
void doMatch(BXVector< l1t::EGamma >::const_iterator egIter, const edm::Ptr< L1TTTrackType > &pTrk, double &dph, double &dr, double &deta)
TTTrack< Ref_Phase2TrackerDigi_ > L1TTTrackType
float isolation(const edm::Handle< L1TTTrackCollectionType > &trkHandle, int match_index)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isValid() const
Definition: HandleBase.h:70
const_iterator end(int bx) const
HLT enums.
double getPtScaledCut(double pt, std::vector< double > &parameters)
float pTFrom2(std::vector< TTTrack< Ref_Phase2TrackerDigi_ > >::const_iterator trk, const TrackerGeometry *tkGeometry)
Definition: pTFrom2Stubs.cc:72
GlobalPoint POCA() const
POCA.
Definition: TTTrack.h:335
def move(src, dest)
Definition: eostools.py:511
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)