CMS 3D CMS Logo

AlCaIsoTracksProducer.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //#define DebugLog
4 
5 // system include files
6 #include <atomic>
7 #include <memory>
8 #include <string>
9 #include <cmath>
10 #include <iostream>
11 #include <sstream>
12 #include <fstream>
13 #include <vector>
14 #include <boost/regex.hpp>
15 
16 // user include files
27 
54 
56 
61 
75 
76 
77 //
78 // class declaration
79 //
80 
81 namespace AlCaIsoTracks {
82  struct Counters {
83  Counters() : nAll_(0), nGood_(0), nRange_(0) {}
84  mutable std::atomic<unsigned int> nAll_, nGood_, nRange_;
85  };
86 }
87 
88 class AlCaIsoTracksProducer : public edm::stream::EDProducer<edm::GlobalCache<AlCaIsoTracks::Counters> > {
89 public:
91  ~AlCaIsoTracksProducer() override;
92 
93  static std::unique_ptr<AlCaIsoTracks::Counters> initializeGlobalCache(edm::ParameterSet const& ) {
94  return std::make_unique<AlCaIsoTracks::Counters>();
95  }
96 
97  void produce(edm::Event &, edm::EventSetup const&) override;
98  void endStream() override;
99  static void globalEndJob(const AlCaIsoTracks::Counters* counters);
100  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
101 
102 private:
103 
104  void beginRun(edm::Run const&, edm::EventSetup const&) override;
105  void endRun(edm::Run const&, edm::EventSetup const&) override;
106  reco::HcalIsolatedTrackCandidateCollection* select(edm::Handle<edm::TriggerResults>& triggerResults, const std::vector<std::string> & triggerNames_, edm::Handle<reco::TrackCollection>& trkCollection, math::XYZPoint& leadPV,edm::Handle<EcalRecHitCollection>& barrelRecHitsHandle, edm::Handle<EcalRecHitCollection>& endcapRecHitsHandle, edm::Handle<HBHERecHitCollection>& hbhe, double ptL1, double etaL1, double phiL1);
107  void setPtEtaPhi(std::vector< edm::Ref<l1extra::L1JetParticleCollection> >& objref, double &ptL1, double &etaL1, double &phiL1);
108 
109  // ----------member data ---------------------------
111  unsigned int nRun_, nAll_, nGood_, nRange_;
113  const std::vector<std::string> trigNames_;
114  const std::string theTrackQuality_, processName_;
115  const double a_coneR_, a_mipR_;
116  const double maxRestrictionP_, slopeRestrictionP_;
117  const double pTrackMin_, eEcalMax_, eIsolate_;
118  const double pTrackLow_, pTrackHigh_;
119  const int preScale_;
120  const edm::InputTag labelGenTrack_, labelRecVtx_, labelBS_;
121  const edm::InputTag labelEB_, labelEE_, labelHBHE_, labelHltGT_;
122  const edm::InputTag labelTriggerEvent_, labelTriggerResults_;
124  double a_charIsoR_;
127 
137 };
138 
139 
141  nRun_(0), nAll_(0), nGood_(0), nRange_(0),
142  trigNames_(iConfig.getParameter<std::vector<std::string> >("triggers")),
143  theTrackQuality_(iConfig.getParameter<std::string>("trackQuality")),
144  processName_(iConfig.getParameter<std::string>("processName")),
145  a_coneR_(iConfig.getParameter<double>("coneRadius")),
146  a_mipR_(iConfig.getParameter<double>("coneRadiusMIP")),
147  maxRestrictionP_(iConfig.getParameter<double>("maxTrackP")),
148  slopeRestrictionP_(iConfig.getParameter<double>("slopeTrackP")),
149  pTrackMin_(iConfig.getParameter<double>("minimumTrackP")),
150  eEcalMax_(iConfig.getParameter<double>("maximumEcalEnergy")),
151  eIsolate_(iConfig.getParameter<double>("isolationEnergy")),
152  pTrackLow_(iConfig.getParameter<double>("momentumRangeLow")),
153  pTrackHigh_(iConfig.getParameter<double>("momentumRangeHigh")),
154  preScale_(iConfig.getParameter<int>("preScaleFactor")),
155  labelGenTrack_(iConfig.getParameter<edm::InputTag>("TrackLabel")),
156  labelRecVtx_(iConfig.getParameter<edm::InputTag>("VertexLabel")),
157  labelBS_(iConfig.getParameter<edm::InputTag>("BeamSpotLabel")),
158  labelEB_(iConfig.getParameter<edm::InputTag>("EBRecHitLabel")),
159  labelEE_(iConfig.getParameter<edm::InputTag>("EERecHitLabel")),
160  labelHBHE_(iConfig.getParameter<edm::InputTag>("HBHERecHitLabel")),
161  labelHltGT_(iConfig.getParameter<edm::InputTag>("L1GTSeedLabel")),
162  labelTriggerEvent_(iConfig.getParameter<edm::InputTag>("TriggerEventLabel")),
163  labelTriggerResults_(iConfig.getParameter<edm::InputTag>("TriggerResultLabel")),
164  labelIsoTk_(iConfig.getParameter<std::string>("IsoTrackLabel")) {
165  // Get the run parameters
166  // Different isolation cuts are described in DN-2016/029
167  // Tight cut uses 2 GeV; Loose cut uses 10 GeV
168  // Eta dependent cut uses (maxRestrictionP_ * exp(|ieta|*log(2.5)/18))
169  // with the factor for exponential slopeRestrictionP_ = log(2.5)/18
170  // maxRestrictionP_ = 8 GeV as came from a study
171  const double isolationRadius(28.9);
172  selectionParameter_.minPt = iConfig.getParameter<double>("minTrackPt");;
174  selectionParameter_.maxDxyPV = iConfig.getParameter<double>("maxDxyPV");
175  selectionParameter_.maxDzPV = iConfig.getParameter<double>("maxDzPV");
176  selectionParameter_.maxChi2 = iConfig.getParameter<double>("maxChi2");
177  selectionParameter_.maxDpOverP = iConfig.getParameter<double>("maxDpOverP");
178  selectionParameter_.minOuterHit = iConfig.getParameter<int>("minOuterHit");
179  selectionParameter_.minLayerCrossed = iConfig.getParameter<int>("minLayerCrossed");
180  selectionParameter_.maxInMiss = iConfig.getParameter<int>("maxInMiss");
181  selectionParameter_.maxOutMiss = iConfig.getParameter<int>("maxOutMiss");
182  a_charIsoR_ = a_coneR_ + isolationRadius;
183 
184  // define tokens for access
185  tok_hltGT_ = consumes<trigger::TriggerFilterObjectWithRefs>(labelHltGT_);
186  tok_trigEvt_ = consumes<trigger::TriggerEvent>(labelTriggerEvent_);
187  tok_trigRes_ = consumes<edm::TriggerResults>(labelTriggerResults_);
188  tok_genTrack_ = consumes<reco::TrackCollection>(labelGenTrack_);
189  tok_recVtx_ = consumes<reco::VertexCollection>(labelRecVtx_);
190  tok_bs_ = consumes<reco::BeamSpot>(labelBS_);
191  tok_EB_ = consumes<EcalRecHitCollection>(labelEB_);
192  tok_EE_ = consumes<EcalRecHitCollection>(labelEE_);
193  tok_hbhe_ = consumes<HBHERecHitCollection>(labelHBHE_);
194 
195  edm::LogInfo("HcalIsoTrack") <<"Parameters read from config file \n"
196  <<"\t minPt " << selectionParameter_.minPt
197  <<"\t theTrackQuality " << theTrackQuality_
198  <<"\t minQuality " << selectionParameter_.minQuality
199  <<"\t maxDxyPV " << selectionParameter_.maxDxyPV
200  <<"\t maxDzPV " << selectionParameter_.maxDzPV
201  <<"\t maxChi2 " << selectionParameter_.maxChi2
202  <<"\t maxDpOverP " << selectionParameter_.maxDpOverP
203  <<"\t minOuterHit " << selectionParameter_.minOuterHit
204  <<"\t minLayerCrossed " << selectionParameter_.minLayerCrossed
205  <<"\t maxInMiss " << selectionParameter_.maxInMiss
206  <<"\t maxOutMiss " << selectionParameter_.maxOutMiss << "\n"
207  <<"\t a_coneR " << a_coneR_
208  <<"\t a_charIsoR " << a_charIsoR_
209  <<"\t a_mipR " << a_mipR_
210  <<"\t pTrackMin " << pTrackMin_
211  <<"\t eEcalMax " << eEcalMax_
212  <<"\t maxRestrictionP_ "<< maxRestrictionP_
213  <<"\t slopeRestrictionP_ " << slopeRestrictionP_
214  <<"\t eIsolate_ " << eIsolate_
215  <<"\t Process " << processName_ << "\n"
216  <<"\t Precale factor " << preScale_
217  <<"\t in momentum range " << pTrackLow_
218  <<":" << pTrackHigh_;
219  for (unsigned int k=0; k<trigNames_.size(); ++k)
220  edm::LogInfo("HcalIsoTrack") << "Trigger[" << k << "] " << trigNames_[k];
221 
222  //create also IsolatedPixelTrackCandidateCollection which contains isolation info and reference to primary track
223  produces<reco::HcalIsolatedTrackCandidateCollection>(labelIsoTk_);
224  produces<reco::VertexCollection>(labelRecVtx_.label());
225  produces<EcalRecHitCollection>(labelEB_.instance());
226  produces<EcalRecHitCollection>(labelEE_.instance());
227  produces<HBHERecHitCollection>(labelHBHE_.label());
228 
229  edm::LogInfo("HcalIsoTrack") << " Expected to produce the collections:\n"
230  << "reco::HcalIsolatedTrackCandidateCollection "
231  << " with label HcalIsolatedTrackCollection\n"
232  << "reco::VertexCollection with label " << labelRecVtx_.label() << "\n"
233  << "EcalRecHitCollection with label EcalRecHitsEB\n"
234  << "EcalRecHitCollection with label EcalRecHitsEE\n"
235  << "HBHERecHitCollection with label " << labelHBHE_.label();
236 }
237 
238 
240 
243  // producer for (HCAL isolated tracks)
244  desc.add<edm::InputTag>("TrackLabel", edm::InputTag("generalTracks"));
245  desc.add<edm::InputTag>("VertexLabel", edm::InputTag("offlinePrimaryVertices"));
246  desc.add<edm::InputTag>("BeamSpotLabel",edm::InputTag("offlineBeamSpot"));
247  desc.add<edm::InputTag>("EBRecHitLabel",edm::InputTag("ecalRecHit","EcalRecHitsEB"));
248  desc.add<edm::InputTag>("EERecHitLabel",edm::InputTag("ecalRecHit","EcalRecHitsEE"));
249  desc.add<edm::InputTag>("HBHERecHitLabel",edm::InputTag("hbhereco"));
250  desc.add<edm::InputTag>("L1GTSeedLabel",edm::InputTag("hltL1sV0SingleJet60"));
251  desc.add<edm::InputTag>("TriggerEventLabel",edm::InputTag("hltTriggerSummaryAOD","","HLT"));
252  desc.add<edm::InputTag>("TriggerResultLabel",edm::InputTag("TriggerResults","","HLT"));
253  desc.add<std::string>("IsoTrackLabel","HcalIsolatedTrackCollection");
254  std::vector<std::string> triggers = {"HLT_IsoTrackHB","HLT_IsoTrackHE"};
255  desc.add<std::vector<std::string> >("triggers", triggers);
256  desc.add<std::string>("processName", "HLT");
257  // following 10 parameters are parameters to select good tracks
258  desc.add<std::string>("trackQuality","highPurity");
259  desc.add<double>("minTrackPt", 1.0);
260  desc.add<double>("maxDxyPV", 10.0);
261  desc.add<double>("maxDzPV", 100.0);
262  desc.add<double>("maxChi2", 5.0);
263  desc.add<double>("maxDpOverP", 0.1);
264  desc.add<int>("minOuterHit", 4);
265  desc.add<int>("minLayerCrossed", 8);
266  desc.add<int>("maxInMiss", 2);
267  desc.add<int>("maxOutMiss", 2);
268  // Minimum momentum of selected isolated track and signal zone
269  desc.add<double>("coneRadius", 34.98);
270  desc.add<double>("minimumTrackP", 20.0);
271  // signal zone in ECAL and MIP energy cutoff
272  desc.add<double>("coneRadiusMIP", 14.0);
273  desc.add<double>("maximumEcalEnergy",2.0);
274  // following 3 parameters are for isolation cuts and described in the code
275  desc.add<double>("maxTrackP", 8.0);
276  desc.add<double>("slopeTrackP", 0.05090504066);
277  desc.add<double>("isolationEnergy", 10.0);
278  // Prescale events only containing isolated tracks in the range
279  desc.add<double>("momentumRangeLow", 20.0);
280  desc.add<double>("momentumRangeHigh",40.0);
281  desc.add<int>("preScaleFactor", 10);
282  descriptions.add("alcaisotrk",desc);
283 }
284 
286 
287  nAll_++;
288 #ifdef DebugLog
289  edm::LogInfo("HcalIsoTrack") << "Run " << iEvent.id().run() << " Event "
290  << iEvent.id().event() << " Luminosity "
291  << iEvent.luminosityBlock() << " Bunch "
292  << iEvent.bunchCrossing();
293 #endif
294  bool valid(true);
295  //Step1: Get all the relevant containers
296  trigger::TriggerEvent triggerEvent;
297  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
298  iEvent.getByToken(tok_trigEvt_, triggerEventHandle);
299  if (!triggerEventHandle.isValid()) {
300  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelTriggerEvent_;
301  valid = false;
302  }
304  iEvent.getByToken(tok_trigRes_, triggerResults);
305  if (!triggerResults.isValid()) {
306  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelTriggerResults_;
307  valid = false;
308  }
309 
311  iEvent.getByToken(tok_genTrack_, trkCollection);
312  if (!trkCollection.isValid()) {
313  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_;
314  valid = false;
315  }
316 
318  iEvent.getByToken(tok_recVtx_, recVtxs);
319  if (!recVtxs.isValid()) {
320  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_;
321  valid = false;
322  }
323 
324  edm::Handle<reco::BeamSpot> beamSpotH;
325  iEvent.getByToken(tok_bs_, beamSpotH);
326  math::XYZPoint leadPV(0,0,0);
327  if (valid) {
328  if (!recVtxs->empty() && !((*recVtxs)[0].isFake())) {
329  leadPV = math::XYZPoint((*recVtxs)[0].x(),(*recVtxs)[0].y(),
330  (*recVtxs)[0].z());
331  } else if (beamSpotH.isValid()) {
332  leadPV = beamSpotH->position();
333  }
334  }
335 #ifdef DebugLog
336  edm::LogInfo("HcalIsoTrack") << "Primary Vertex " << leadPV;
337 #endif
338 
339  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
340  iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
341  if (!barrelRecHitsHandle.isValid()) {
342  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEB_;
343  valid = false;
344  }
345  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
346  iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
347  if (!endcapRecHitsHandle.isValid()) {
348  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEE_;
349  valid = false;
350  }
352  iEvent.getByToken(tok_hbhe_, hbhe);
353  if (!hbhe.isValid()) {
354  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelHBHE_;
355  valid = false;
356  }
357 
358  //Get L1 trigger object
359  double ptL1(0), etaL1(0), phiL1(0);
361  iEvent.getByToken(tok_hltGT_, l1trigobj);
362 
363  if (l1trigobj.isValid()) {
364  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1tauobjref;
365  l1trigobj->getObjects(trigger::TriggerL1TauJet, l1tauobjref);
366  setPtEtaPhi(l1tauobjref,ptL1,etaL1,phiL1);
367 
368  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1jetobjref;
369  l1trigobj->getObjects(trigger::TriggerL1CenJet, l1jetobjref);
370  setPtEtaPhi(l1jetobjref,ptL1,etaL1,phiL1);
371 
372  std::vector< edm::Ref<l1extra::L1JetParticleCollection> > l1forjetobjref;
373  l1trigobj->getObjects(trigger::TriggerL1ForJet, l1forjetobjref);
374  setPtEtaPhi(l1forjetobjref,ptL1,etaL1,phiL1);
375  } else {
376  valid = false;
377  }
378 
379  auto outputHcalIsoTrackColl = std::make_unique<reco::HcalIsolatedTrackCandidateCollection>();
380  auto outputVColl = std::make_unique<reco::VertexCollection>();
381  auto outputEBColl = std::make_unique<EBRecHitCollection>();
382  auto outputEEColl = std::make_unique<EERecHitCollection>();
383  auto outputHBHEColl = std::make_unique<HBHERecHitCollection>();
384 
385  //For valid HLT record
386  if (!valid) {
387  edm::LogWarning("HcalIsoTrack") << "Error! Can't get some of the products";
388  } else {
389  trigger::TriggerEvent triggerEvent = *(triggerEventHandle.product());
390  if (triggerResults.isValid()) {
391  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
392  const std::vector<std::string> & triggerNames_ = triggerNames.triggerNames();
393  reco::HcalIsolatedTrackCandidateCollection* isotk = select(triggerResults, triggerNames_, trkCollection, leadPV, barrelRecHitsHandle, endcapRecHitsHandle, hbhe, ptL1, etaL1, phiL1);
394 #ifdef DebugLog
395  edm::LogInfo("HcalIsoTrack") << "AlCaIsoTracksProducer::select returns "
396  << isotk->size() << " isolated tracks";
397 #endif
398 
399  if (!isotk->empty()) {
400  int ntrin(0), ntrout(0);
401  for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr=isotk->begin(); itr!=isotk->end(); ++itr) {
402  if (itr->p() > pTrackLow_ && itr->p() < pTrackHigh_) ntrin++;
403  else ntrout++;
404  }
405  bool selectEvent = ntrout > 0;
406  if (!selectEvent && ntrin > 0) {
407  ++nRange_;
408  if (preScale_ <= 1) selectEvent = true;
409  else if (nRange_%preScale_ == 1) selectEvent = true;
410  }
411  if (selectEvent) {
412  for (reco::HcalIsolatedTrackCandidateCollection::const_iterator itr=isotk->begin(); itr!=isotk->end(); ++itr)
413  outputHcalIsoTrackColl->push_back(*itr);
414 
415  for (reco::VertexCollection::const_iterator vtx=recVtxs->begin(); vtx!=recVtxs->end(); ++vtx)
416  outputVColl->push_back(*vtx);
417 
418  for (edm::SortedCollection<EcalRecHit>::const_iterator ehit=barrelRecHitsHandle->begin(); ehit!=barrelRecHitsHandle->end(); ++ehit)
419  outputEBColl->push_back(*ehit);
420 
421  for (edm::SortedCollection<EcalRecHit>::const_iterator ehit=endcapRecHitsHandle->begin(); ehit!=endcapRecHitsHandle->end(); ++ehit)
422  outputEEColl->push_back(*ehit);
423 
424  for (std::vector<HBHERecHit>::const_iterator hhit=hbhe->begin(); hhit!=hbhe->end(); ++hhit)
425  outputHBHEColl->push_back(*hhit);
426  ++nGood_;
427  }
428  }
429  }
430  }
431  iEvent.put(std::move(outputHcalIsoTrackColl), labelIsoTk_);
432  iEvent.put(std::move(outputVColl), labelRecVtx_.label());
433  iEvent.put(std::move(outputEBColl), labelEB_.instance());
434  iEvent.put(std::move(outputEEColl), labelEE_.instance());
435  iEvent.put(std::move(outputHBHEColl), labelHBHE_.label());
436 }
437 
439  globalCache()->nAll_ += nAll_;
440  globalCache()->nGood_ += nGood_;
441  globalCache()->nRange_ += nRange_;
442 }
443 
445  edm::LogInfo("HcalIsoTrack") << "Finds " << count->nGood_ <<" good tracks in "
446  << count->nAll_ << " events and " << count->nRange_
447  << " events in the momentum raange";
448 }
449 
450 void AlCaIsoTracksProducer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
451  bool changed(false);
452  edm::LogInfo("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run()
453  << " hltconfig.init " << hltConfig_.init(iRun,iSetup,processName_,changed);
454 
456  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
457  bField = bFieldH.product();
459  iSetup.get<CaloGeometryRecord>().get(pG);
460  geo = pG.product();
461 }
462 
464  edm::LogInfo("HcalIsoTrack") << "endRun [" << nRun_ << "] " << iRun.run();
465  ++nRun_;
466 }
467 
470  const std::vector<std::string> & triggerNames_,
471  edm::Handle<reco::TrackCollection>& trkCollection,
472  math::XYZPoint& leadPV,edm::Handle<EcalRecHitCollection>& barrelRecHitsHandle,
473  edm::Handle<EcalRecHitCollection>& endcapRecHitsHandle,
475  double ptL1, double etaL1, double phiL1) {
476 
478  bool ok(false);
479 
480  // Find a good HLT trigger
481  for (unsigned int iHLT=0; iHLT<triggerResults->size(); iHLT++) {
482  int hlt = triggerResults->accept(iHLT);
483  for (unsigned int i=0; i<trigNames_.size(); ++i) {
484  if (triggerNames_[iHLT].find(trigNames_[i])!=std::string::npos) {
485  if (hlt > 0) {
486  ok = true;
487  }
488  edm::LogInfo("HcalIsoTrack") << "The trigger we are looking for "
489  << triggerNames_[iHLT] << " Flag "
490  << hlt << ":" << ok;
491  }
492  }
493  }
494 
495  //Propagate tracks to calorimeter surface)
496  std::vector<spr::propagatedTrackDirection> trkCaloDirections;
498  trkCaloDirections, false);
499 
500  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
501  unsigned int nTracks(0), nselTracks(0);
502  for (trkDetItr = trkCaloDirections.begin(),nTracks=0;
503  trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++) {
504  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
505  math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(),
506  pTrack->pz(), pTrack->p());
507 #ifdef DebugLog
508  edm::LogInfo("HcalIsoTrack") << "This track : " << nTracks
509  << " (pt|eta|phi|p) :" << pTrack->pt()
510  << "|" << pTrack->eta() << "|"
511  << pTrack->phi() << "|" << pTrack->p();
512 #endif
513  //Selection of good track
514  bool qltyFlag = spr::goodTrack(pTrack,leadPV,selectionParameter_,false);
515 #ifdef DebugLog
516  edm::LogInfo("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag
517  << "|" << trkDetItr->okECAL << "|"
518  << trkDetItr->okHCAL;
519 #endif
520  if (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL) {
521  double t_p = pTrack->p();
522  nselTracks++;
523  int nRH_eMipDR(0), nNearTRKs(0);
524  double eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle,
525  endcapRecHitsHandle,
526  trkDetItr->pointHCAL,
527  trkDetItr->pointECAL, a_mipR_,
528  trkDetItr->directionECAL,
529  nRH_eMipDR);
530  double hmaxNearP = spr::chargeIsolationCone(nTracks,
531  trkCaloDirections,
532  a_charIsoR_,
533  nNearTRKs, false);
534  HcalDetId detId = (HcalDetId)(trkDetItr->detIdHCAL);
535  int ieta = detId.ietaAbs();
536  double eIsolation = (maxRestrictionP_*exp(slopeRestrictionP_*((double)(ieta))));
537  if (eIsolation < eIsolate_) eIsolation = eIsolate_;
538 #ifdef DebugLog
539  edm::LogInfo("HcalIsoTrack") << "This track : " << nTracks
540  << " (pt|eta|phi|p) :" << pTrack->pt()
541  << "|" << pTrack->eta() << "|"
542  << pTrack->phi() << "|" << t_p
543  << " e_MIP " << eMipDR
544  << " Chg Isolation " << hmaxNearP
545  << ":" << eIsolation;
546 #endif
547  if (t_p>pTrackMin_ && eMipDR<eEcalMax_ && hmaxNearP<eIsolation) {
548  reco::HcalIsolatedTrackCandidate newCandidate(v4);
549  newCandidate.SetMaxP(hmaxNearP);
550  newCandidate.SetEnergyEcal(eMipDR);
551  newCandidate.setL1(ptL1,etaL1,phiL1);
552  newCandidate.SetEtaPhiEcal((trkDetItr->pointECAL).eta(),
553  (trkDetItr->pointECAL).phi());
554  HcalDetId detId = HcalDetId(trkDetItr->detIdHCAL);
555  newCandidate.SetEtaPhiHcal((trkDetItr->pointHCAL).eta(),
556  (trkDetItr->pointHCAL).phi(),
557  detId.ieta(), detId.iphi());
558  int indx(0);
559  for (reco::TrackCollection::const_iterator trkItr1=trkCollection->begin();
560  trkItr1 != trkCollection->end(); ++trkItr1,++indx) {
561  const reco::Track* pTrack1 = &(*trkItr1);
562  if (pTrack1 == pTrack) {
563  reco::TrackRef tRef = reco::TrackRef(trkCollection,indx);
564  newCandidate.setTrack(tRef);
565  break;
566  }
567  }
568  trackCollection->push_back(newCandidate);
569  }
570  }
571  }
572  return trackCollection;
573 }
574 
575 void AlCaIsoTracksProducer::setPtEtaPhi(std::vector< edm::Ref<l1extra::L1JetParticleCollection> >& objref, double &ptL1, double &etaL1, double &phiL1) {
576 
577  for (unsigned int p=0; p<objref.size(); p++) {
578  if (objref[p]->pt()>ptL1) {
579  ptL1 = objref[p]->pt();
580  phiL1 = objref[p]->phi();
581  etaL1 = objref[p]->eta();
582  }
583  }
584 }
585 
587 
RunNumber_t run() const
Definition: EventID.h:39
double p() const
momentum vector magnitude
Definition: TrackBase.h:648
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, const std::string &theTrackQuality, bool debug=false)
const unsigned int nTracks(const reco::Vertex &sv)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
const edm::InputTag labelEE_
RunNumber_t run() const
Definition: RunBase.h:40
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
AlCaIsoTracksProducer(edm::ParameterSet const &, const AlCaIsoTracks::Counters *count)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
void beginRun(edm::Run const &, edm::EventSetup const &) override
bool accept() const
Has at least one path accepted the event?
const edm::InputTag labelHBHE_
const CaloGeometry * geo
std::vector< T >::const_iterator const_iterator
int bunchCrossing() const
Definition: EventBase.h:66
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
void produce(edm::Event &, edm::EventSetup const &) override
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:678
const edm::InputTag labelHltGT_
const edm::InputTag labelBS_
const edm::InputTag labelTriggerEvent_
static void globalEndJob(const AlCaIsoTracks::Counters *counters)
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:660
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hltGT_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
const std::string processName_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
const std::string theTrackQuality_
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:684
std::vector< HcalIsolatedTrackCandidate > HcalIsolatedTrackCandidateCollection
collectin of HcalIsolatedTrackCandidate objects
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
void SetEtaPhiEcal(double eta, double phi)
eta, phi at ECAL surface
unsigned int size() const
Get number of paths stored.
double pt() const
track transverse momentum
Definition: TrackBase.h:654
void setPtEtaPhi(std::vector< edm::Ref< l1extra::L1JetParticleCollection > > &objref, double &ptL1, double &etaL1, double &phiL1)
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
int ieta() const
get the cell ieta
Definition: HcalDetId.h:159
void SetEtaPhiHcal(double eta, double phi, int ieta, int iphi)
eta, phi at HCAL surface
double eCone_ecal(const CaloGeometry *geo, edm::Handle< T > &barrelhits, edm::Handle< T > &endcaphits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)
const MagneticField * bField
static std::string const triggerResults
Definition: EdmProvDump.cc:42
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt_
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:672
int k[5][pyjets_maxn]
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:154
std::atomic< unsigned int > nGood_
const_iterator end() const
void endRun(edm::Run const &, edm::EventSetup const &) override
void setPtEtaPhi(const reco::Candidate &p, float &pt, float &eta, float &phi)
int iphi() const
get the cell iphi
Definition: HcalDetId.h:161
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:134
static std::unique_ptr< AlCaIsoTracks::Counters > initializeGlobalCache(edm::ParameterSet const &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
Definition: Handle.h:81
void setL1(double pt, double eta, double phi)
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::atomic< unsigned int > nAll_
std::string const & label() const
Definition: InputTag.h:36
const std::vector< std::string > trigNames_
spr::trackSelectionParameters selectionParameter_
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
T get() const
Definition: EventSetup.h:68
reco::TrackBase::TrackQuality minQuality
const edm::InputTag labelRecVtx_
void setTrack(const reco::TrackRef &tr)
const Point & position() const
position
Definition: BeamSpot.h:62
reco::HcalIsolatedTrackCandidateCollection * select(edm::Handle< edm::TriggerResults > &triggerResults, const std::vector< std::string > &triggerNames_, edm::Handle< reco::TrackCollection > &trkCollection, math::XYZPoint &leadPV, edm::Handle< EcalRecHitCollection > &barrelRecHitsHandle, edm::Handle< EcalRecHitCollection > &endcapRecHitsHandle, edm::Handle< HBHERecHitCollection > &hbhe, double ptL1, double etaL1, double phiL1)
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
const edm::InputTag labelTriggerResults_
T const * product() const
Definition: ESHandle.h:84
std::string const & instance() const
Definition: InputTag.h:37
std::atomic< unsigned int > nRange_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:301
def move(src, dest)
Definition: eostools.py:511
const edm::InputTag labelEB_
const_iterator begin() const
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:666
Definition: Run.h:44
const edm::InputTag labelGenTrack_