CMS 3D CMS Logo

HcalIsoTrkAnalyzer.cc
Go to the documentation of this file.
1 // system include files
2 #include <atomic>
3 #include <cmath>
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 // Root objects
9 #include "TROOT.h"
10 #include "TSystem.h"
11 #include "TFile.h"
12 #include "TProfile.h"
13 #include "TDirectory.h"
14 #include "TTree.h"
15 #include "TLorentzVector.h"
16 #include "TInterpreter.h"
17 
20 
24 
25 //Tracks
30 // Vertices
34 //Muons
38 
39 //Triggers
46 
51 
55 
56 //Generator information
60 
63 
71 
78 
91 
92 //#define EDM_ML_DEBUG
93 
94 class HcalIsoTrkAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns, edm::one::SharedResources> {
95 public:
96  explicit HcalIsoTrkAnalyzer(edm::ParameterSet const&);
97  ~HcalIsoTrkAnalyzer() override {}
98 
99  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
100 
101 private:
102  void analyze(edm::Event const&, edm::EventSetup const&) override;
103  void beginJob() override;
104  void beginRun(edm::Run const&, edm::EventSetup const&) override;
105  void endRun(edm::Run const&, edm::EventSetup const&) override;
106 
107  std::array<int, 3> fillTree(std::vector<math::XYZTLorentzVector>& vecL1,
108  std::vector<math::XYZTLorentzVector>& vecL3,
109  math::XYZPoint& leadPV,
110  std::vector<spr::propagatedTrackDirection>& trkCaloDirections,
111  std::vector<spr::propagatedTrackID>& trkCaloDets,
112  const CaloGeometry* geo,
113  const CaloTopology* topo,
114  const HcalTopology* theHBHETopology,
115  const EcalChannelStatus* theEcalChStatus,
116  const EcalSeverityLevelAlgo* theEcalSevlv,
117  edm::Handle<EcalRecHitCollection>& barrelRecHitsHandle,
118  edm::Handle<EcalRecHitCollection>& endcapRecHitsHandle,
122  const HcalRespCorrs* respCorrs,
123  const edm::Handle<reco::MuonCollection>& muonh);
126  double rhoh(const edm::Handle<CaloTowerCollection>&);
127  double eThreshold(const DetId& id, const CaloGeometry* geo) const;
128  DetId newId(const DetId&);
129  void storeEnergy(int indx,
130  const HcalRespCorrs* respCorrs,
131  const std::vector<DetId>& ids,
132  std::vector<double>& edet,
133  double& eHcal,
134  std::vector<unsigned int>* detIds,
135  std::vector<double>* hitEnergies);
136  bool notaMuon(const reco::Track* pTrack0, const edm::Handle<reco::MuonCollection>& muonh);
137 
140  const std::vector<std::string> trigNames_;
149  const double pTrackLow_, pTrackHigh_;
151  const int useRaw_, dataType_, mode_;
155  const double hitEthrEE2_, hitEthrEE3_;
156  const double hitEthrEELo_, hitEthrEEHi_;
160  const std::vector<int> oldID_, newDepth_;
161  const bool hep17_;
162  const std::vector<int> debEvents_;
163  const bool usePFThresh_;
166 
180 
190 
191  unsigned int nRun_, nLow_, nHigh_;
195 
196  std::vector<double> etabins_, phibins_;
197  std::vector<int> oldDet_, oldEta_, oldDepth_;
199 
200  TTree *tree, *tree2;
201  unsigned int t_RunNo, t_EventNo;
214  std::vector<unsigned int>*t_DetIds, *t_DetIds1, *t_DetIds3;
215  std::vector<double>*t_HitEnergies, *t_HitEnergies1, *t_HitEnergies3;
216  std::vector<bool>*t_trgbits, *t_hltbits;
217  bool t_L1Bit;
220  std::vector<int>*t_ietaAll, *t_ietaGood, *t_trackType;
221 
222  bool debug_;
223 };
224 
226  : trigNames_(iConfig.getParameter<std::vector<std::string>>("triggers")),
227  theTrackQuality_(iConfig.getParameter<std::string>("trackQuality")),
228  processName_(iConfig.getParameter<std::string>("processName")),
229  l1Filter_(iConfig.getParameter<std::string>("l1Filter")),
230  l2Filter_(iConfig.getParameter<std::string>("l2Filter")),
231  l3Filter_(iConfig.getParameter<std::string>("l3Filter")),
232  a_coneR_(iConfig.getParameter<double>("coneRadius")),
233  a_mipR_(iConfig.getParameter<double>("coneRadiusMIP")),
234  a_mipR2_(iConfig.getParameter<double>("coneRadiusMIP2")),
235  a_mipR3_(iConfig.getParameter<double>("coneRadiusMIP3")),
236  a_mipR4_(iConfig.getParameter<double>("coneRadiusMIP4")),
237  a_mipR5_(iConfig.getParameter<double>("coneRadiusMIP5")),
238  pTrackMin_(iConfig.getParameter<double>("minimumTrackP")),
239  eEcalMax_(iConfig.getParameter<double>("maximumEcalEnergy")),
240  maxRestrictionP_(iConfig.getParameter<double>("maxTrackP")),
241  slopeRestrictionP_(iConfig.getParameter<double>("slopeTrackP")),
242  hcalScale_(iConfig.getUntrackedParameter<double>("hHcalScale", 1.0)),
243  eIsolate1_(iConfig.getParameter<double>("isolationEnergyTight")),
244  eIsolate2_(iConfig.getParameter<double>("isolationEnergyLoose")),
245  pTrackLow_(iConfig.getParameter<double>("momentumLow")),
246  pTrackHigh_(iConfig.getParameter<double>("momentumHigh")),
247  prescaleLow_(iConfig.getParameter<int>("prescaleLow")),
248  prescaleHigh_(iConfig.getParameter<int>("prescaleHigh")),
249  useRaw_(iConfig.getUntrackedParameter<int>("useRaw", 0)),
250  dataType_(iConfig.getUntrackedParameter<int>("dataType", 0)),
251  mode_(iConfig.getUntrackedParameter<int>("outMode", 11)),
252  ignoreTrigger_(iConfig.getUntrackedParameter<bool>("ignoreTriggers", false)),
253  useL1Trigger_(iConfig.getUntrackedParameter<bool>("useL1Trigger", false)),
254  unCorrect_(iConfig.getUntrackedParameter<bool>("unCorrect", false)),
255  collapseDepth_(iConfig.getUntrackedParameter<bool>("collapseDepth", false)),
256  hitEthrEB_(iConfig.getParameter<double>("EBHitEnergyThreshold")),
257  hitEthrEE0_(iConfig.getParameter<double>("EEHitEnergyThreshold0")),
258  hitEthrEE1_(iConfig.getParameter<double>("EEHitEnergyThreshold1")),
259  hitEthrEE2_(iConfig.getParameter<double>("EEHitEnergyThreshold2")),
260  hitEthrEE3_(iConfig.getParameter<double>("EEHitEnergyThreshold3")),
261  hitEthrEELo_(iConfig.getParameter<double>("EEHitEnergyThresholdLow")),
262  hitEthrEEHi_(iConfig.getParameter<double>("EEHitEnergyThresholdHigh")),
263  triggerEvent_(iConfig.getParameter<edm::InputTag>("labelTriggerEvent")),
264  theTriggerResultsLabel_(iConfig.getParameter<edm::InputTag>("labelTriggerResult")),
265  labelGenTrack_(iConfig.getParameter<std::string>("labelTrack")),
266  labelRecVtx_(iConfig.getParameter<std::string>("labelVertex")),
267  labelEB_(iConfig.getParameter<std::string>("labelEBRecHit")),
268  labelEE_(iConfig.getParameter<std::string>("labelEERecHit")),
269  labelHBHE_(iConfig.getParameter<std::string>("labelHBHERecHit")),
270  labelTower_(iConfig.getParameter<std::string>("labelCaloTower")),
271  l1TrigName_(iConfig.getUntrackedParameter<std::string>("l1TrigName", "L1_SingleJet60")),
272  oldID_(iConfig.getUntrackedParameter<std::vector<int>>("oldID")),
273  newDepth_(iConfig.getUntrackedParameter<std::vector<int>>("newDepth")),
274  hep17_(iConfig.getUntrackedParameter<bool>("hep17")),
275  debEvents_(iConfig.getParameter<std::vector<int>>("debugEvents")),
276  usePFThresh_(iConfig.getParameter<bool>("usePFThreshold")),
277  labelBS_(iConfig.getParameter<std::string>("labelBeamSpot")),
278  modnam_(iConfig.getUntrackedParameter<std::string>("moduleName", "")),
279  prdnam_(iConfig.getUntrackedParameter<std::string>("producerName", "")),
280  labelMuon_(iConfig.getParameter<std::string>("labelMuon")),
281  algTag_(iConfig.getParameter<edm::InputTag>("algInputTag")),
282  extTag_(iConfig.getParameter<edm::InputTag>("extInputTag")),
283  tok_trigEvt_(consumes<trigger::TriggerEvent>(triggerEvent_)),
284  tok_trigRes_(consumes<edm::TriggerResults>(theTriggerResultsLabel_)),
285  tok_parts_(consumes<reco::GenParticleCollection>(edm::InputTag("genParticles"))),
286  tok_genTrack_(consumes<reco::TrackCollection>(labelGenTrack_)),
287  tok_bs_(consumes<reco::BeamSpot>(labelBS_)),
288  tok_recVtx_((modnam_.empty()) ? consumes<reco::VertexCollection>(labelRecVtx_)
289  : consumes<reco::VertexCollection>(edm::InputTag(modnam_, labelRecVtx_, prdnam_))),
290  tok_EB_((modnam_.empty()) ? consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit", labelEB_))
291  : consumes<EcalRecHitCollection>(edm::InputTag(modnam_, labelEB_, prdnam_))),
292  tok_EE_((modnam_.empty()) ? consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit", labelEE_))
293  : consumes<EcalRecHitCollection>(edm::InputTag(modnam_, labelEE_, prdnam_))),
294  tok_hbhe_((modnam_.empty()) ? consumes<HBHERecHitCollection>(labelHBHE_)
295  : consumes<HBHERecHitCollection>(edm::InputTag(modnam_, labelHBHE_, prdnam_))),
296  tok_cala_(consumes<CaloTowerCollection>(labelTower_)),
297  tok_ew_(consumes<GenEventInfoProduct>(edm::InputTag("generator"))),
298  tok_alg_(consumes<BXVector<GlobalAlgBlk>>(algTag_)),
299  tok_Muon_(consumes<reco::MuonCollection>(labelMuon_)),
302  tok_ecalChStatus_(esConsumes<EcalChannelStatus, EcalChannelStatusRcd>()),
305  tok_caloTopology_(esConsumes<CaloTopology, CaloTopologyRecord>()),
308  tok_ecalPFRecHitThresholds_(esConsumes<EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd>()),
309  nRun_(0),
310  nLow_(0),
311  nHigh_(0),
312  hdc_(nullptr) {
313  usesResource(TFileService::kSharedResource);
314 
315  //now do whatever initialization is needed
316  const double isolationRadius(28.9), innerR(10.0), outerR(30.0);
318  selectionParameter_.minPt = iConfig.getParameter<double>("minTrackPt");
319  ;
320  selectionParameter_.minQuality = trackQuality_;
321  selectionParameter_.maxDxyPV = iConfig.getParameter<double>("maxDxyPV");
322  selectionParameter_.maxDzPV = iConfig.getParameter<double>("maxDzPV");
323  selectionParameter_.maxChi2 = iConfig.getParameter<double>("maxChi2");
324  selectionParameter_.maxDpOverP = iConfig.getParameter<double>("maxDpOverP");
325  selectionParameter_.minOuterHit = iConfig.getParameter<int>("minOuterHit");
326  selectionParameter_.minLayerCrossed = iConfig.getParameter<int>("minLayerCrossed");
327  selectionParameter_.maxInMiss = iConfig.getParameter<int>("maxInMiss");
328  selectionParameter_.maxOutMiss = iConfig.getParameter<int>("maxOutMiss");
329  a_charIsoR_ = a_coneR_ + isolationRadius;
330  a_coneR1_ = a_coneR_ + innerR;
331  a_coneR2_ = a_coneR_ + outerR;
332  // Different isolation cuts are described in DN-2016/029
333  // Tight cut uses 2 GeV; Loose cut uses 10 GeV
334  // Eta dependent cut uses (maxRestrictionP_ * exp(|ieta|*log(2.5)/18))
335  // with the factor for exponential slopeRestrictionP_ = log(2.5)/18
336  // maxRestrictionP_ = 8 GeV as came from a study
337 
338  for (unsigned int k = 0; k < oldID_.size(); ++k) {
339  oldDet_.emplace_back((oldID_[k] / 10000) % 10);
340  oldEta_.emplace_back((oldID_[k] / 100) % 100);
341  oldDepth_.emplace_back(oldID_[k] % 100);
342  }
343 
344  l1GtUtils_ =
346  // define tokens for access
347 
348  if (modnam_.empty()) {
349  edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " << theTriggerResultsLabel_ << " "
350  << labelBS_ << " " << labelRecVtx_ << " " << labelGenTrack_ << " "
351  << edm::InputTag("ecalRecHit", labelEB_) << " "
352  << edm::InputTag("ecalRecHit", labelEE_) << " " << labelHBHE_ << " " << labelTower_
353  << " " << labelMuon_;
354  } else {
355  edm::LogVerbatim("HcalIsoTrack") << "Labels used " << triggerEvent_ << " " << theTriggerResultsLabel_ << " "
356  << labelBS_ << " " << edm::InputTag(modnam_, labelRecVtx_, prdnam_) << " "
357  << labelGenTrack_ << " " << edm::InputTag(modnam_, labelEB_, prdnam_) << " "
359  << edm::InputTag(modnam_, labelHBHE_, prdnam_) << " " << labelTower_ << " "
360  << labelMuon_;
361  }
362 
363  edm::LogVerbatim("HcalIsoTrack")
364  << "Parameters read from config file \n"
365  << "\t minPt " << selectionParameter_.minPt << "\t theTrackQuality " << theTrackQuality_ << "\t minQuality "
366  << selectionParameter_.minQuality << "\t maxDxyPV " << selectionParameter_.maxDxyPV << "\t maxDzPV "
367  << selectionParameter_.maxDzPV << "\t maxChi2 " << selectionParameter_.maxChi2 << "\t maxDpOverP "
368  << selectionParameter_.maxDpOverP << "\t minOuterHit " << selectionParameter_.minOuterHit << "\t minLayerCrossed "
369  << selectionParameter_.minLayerCrossed << "\t maxInMiss " << selectionParameter_.maxInMiss << "\t maxOutMiss "
370  << selectionParameter_.maxOutMiss << "\t a_coneR " << a_coneR_ << ":" << a_coneR1_ << ":" << a_coneR2_
371  << "\t a_charIsoR " << a_charIsoR_ << "\t a_mipR " << a_mipR_ << "\t a_mipR2 " << a_mipR2_ << "\t a_mipR3 "
372  << a_mipR3_ << "\t a_mipR4 " << a_mipR4_ << "\t a_mipR5 " << a_mipR5_ << "\n pTrackMin_ " << pTrackMin_
373  << "\t eEcalMax_ " << eEcalMax_ << "\t maxRestrictionP_ " << maxRestrictionP_ << "\t slopeRestrictionP_ "
374  << slopeRestrictionP_ << "\t eIsolateStrong_ " << eIsolate1_ << "\t eIsolateSoft_ " << eIsolate2_
375  << "\t hcalScale_ " << hcalScale_ << "\n\t momentumLow_ " << pTrackLow_ << "\t prescaleLow_ " << prescaleLow_
376  << "\t momentumHigh_ " << pTrackHigh_ << "\t prescaleHigh_ " << prescaleHigh_ << "\n\t useRaw_ " << useRaw_
377  << "\t ignoreTrigger_ " << ignoreTrigger_ << "\n\t useL1Trigegr_ " << useL1Trigger_ << "\t dataType_ "
378  << dataType_ << "\t mode_ " << mode_ << "\t unCorrect_ " << unCorrect_ << "\t collapseDepth_ "
379  << collapseDepth_ << "\t L1TrigName_ " << l1TrigName_ << "\nThreshold flag used " << usePFThresh_
380  << " value for EB " << hitEthrEB_ << " EE " << hitEthrEE0_ << ":" << hitEthrEE1_ << ":" << hitEthrEE2_ << ":"
381  << hitEthrEE3_ << ":" << hitEthrEELo_ << ":" << hitEthrEEHi_ << " and " << debEvents_.size()
382  << " events to be debugged";
383  edm::LogVerbatim("HcalIsoTrack") << "Process " << processName_ << " L1Filter:" << l1Filter_
384  << " L2Filter:" << l2Filter_ << " L3Filter:" << l3Filter_;
385  for (unsigned int k = 0; k < trigNames_.size(); ++k) {
386  edm::LogVerbatim("HcalIsoTrack") << "Trigger[" << k << "] " << trigNames_[k];
387  }
388  edm::LogVerbatim("HcalIsoTrack") << oldID_.size() << " DetIDs to be corrected with HEP17 flag:" << hep17_;
389  for (unsigned int k = 0; k < oldID_.size(); ++k)
390  edm::LogVerbatim("HcalIsoTrack") << "[" << k << "] Det " << oldDet_[k] << " EtaAbs " << oldEta_[k] << " Depth "
391  << oldDepth_[k] << ":" << newDepth_[k];
392 
393  for (int i = 0; i < 10; i++)
394  phibins_.push_back(-M_PI + 0.1 * (2 * i + 1) * M_PI);
395  for (int i = 0; i < 8; ++i)
396  etabins_.push_back(-2.1 + 0.6 * i);
397  etadist_ = etabins_[1] - etabins_[0];
398  phidist_ = phibins_[1] - phibins_[0];
399  etahalfdist_ = 0.5 * etadist_;
400  phihalfdist_ = 0.5 * phidist_;
401  edm::LogVerbatim("HcalIsoTrack") << "EtaDist " << etadist_ << " " << etahalfdist_ << " PhiDist " << phidist_ << " "
402  << phihalfdist_;
403  unsigned int k1(0), k2(0);
404  for (auto phi : phibins_) {
405  edm::LogVerbatim("HcalIsoTrack") << "phibin_[" << k1 << "] " << phi;
406  ++k1;
407  }
408  for (auto eta : etabins_) {
409  edm::LogVerbatim("HcalIsoTrack") << "etabin_[" << k2 << "] " << eta;
410  ++k2;
411  }
412 }
413 
415  t_Run = iEvent.id().run();
416  t_Event = iEvent.id().event();
418  debug_ = (debEvents_.empty())
419  ? true
420  : (std::find(debEvents_.begin(), debEvents_.end(), iEvent.id().event()) != debEvents_.end());
421 #ifdef EDM_ML_DEBUG
422  if (debug_)
423  edm::LogVerbatim("HcalIsoTrack") << "Run " << t_Run << " Event " << t_Event << " type " << t_DataType
424  << " Luminosity " << iEvent.luminosityBlock() << " Bunch "
425  << iEvent.bunchCrossing();
426 #endif
427  //Get magnetic field and ECAL channel status
428  const MagneticField* bField = &iSetup.getData(tok_bFieldH_);
429  const EcalChannelStatus* theEcalChStatus = &iSetup.getData(tok_ecalChStatus_);
430  const EcalSeverityLevelAlgo* theEcalSevlv = &iSetup.getData(tok_sevlv_);
432 
433  // get calogeometry and calotopology
434  const CaloGeometry* geo = &iSetup.getData(tok_geom_);
435  const CaloTopology* caloTopology = &iSetup.getData(tok_caloTopology_);
436  const HcalTopology* theHBHETopology = &iSetup.getData(tok_htopo_);
437 
438  // get Hcal response corrections
439  const HcalRespCorrs* respCorrs = &iSetup.getData(tok_resp_);
440 
441  //=== genParticle information
443 
444  bool okC(true);
445  //Get track collection
446  edm::Handle<reco::TrackCollection> trkCollection = iEvent.getHandle(tok_genTrack_);
447  if (!trkCollection.isValid()) {
448  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelGenTrack_;
449  okC = false;
450  }
451 
452  //Get muon collection
453  const edm::Handle<reco::MuonCollection> muonh = iEvent.getHandle(tok_Muon_);
454 
455  //event weight for FLAT sample
456  t_EventWeight = 1.0;
458  if (genEventInfo.isValid())
459  t_EventWeight = genEventInfo->weight();
460 
461  //Define the best vertex and the beamspot
462  const edm::Handle<reco::VertexCollection> recVtxs = iEvent.getHandle(tok_recVtx_);
463  const edm::Handle<reco::BeamSpot> beamSpotH = iEvent.getHandle(tok_bs_);
464  math::XYZPoint leadPV(0, 0, 0);
465  t_goodPV = t_nVtx = 0;
466  if (recVtxs.isValid() && !(recVtxs->empty())) {
467  t_nVtx = recVtxs->size();
468  for (unsigned int k = 0; k < recVtxs->size(); ++k) {
469  if (!((*recVtxs)[k].isFake()) && ((*recVtxs)[k].ndof() > 4)) {
470  if (t_goodPV == 0)
471  leadPV = math::XYZPoint((*recVtxs)[k].x(), (*recVtxs)[k].y(), (*recVtxs)[k].z());
472  t_goodPV++;
473  }
474  }
475  }
476  if (t_goodPV == 0 && beamSpotH.isValid()) {
477  leadPV = beamSpotH->position();
478  }
480 #ifdef EDM_ML_DEBUG
481  if (debug_) {
482  edm::LogVerbatim("HcalIsoTrack") << "Primary Vertex " << leadPV << " out of " << t_goodPV << " vertex";
483  if (beamSpotH.isValid())
484  edm::LogVerbatim("HcalIsoTrack") << " Beam Spot " << beamSpotH->position();
485  }
486 #endif
487  // RecHits
488  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle = iEvent.getHandle(tok_EB_);
489  if (!barrelRecHitsHandle.isValid()) {
490  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEB_;
491  okC = false;
492  }
493  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle = iEvent.getHandle(tok_EE_);
494  if (!endcapRecHitsHandle.isValid()) {
495  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelEE_;
496  okC = false;
497  }
499  if (!hbhe.isValid()) {
500  edm::LogWarning("HcalIsoTrack") << "Cannot access the collection " << labelHBHE_;
501  okC = false;
502  }
503  edm::Handle<CaloTowerCollection> caloTower = iEvent.getHandle(tok_cala_);
504 
505  //Propagate tracks to calorimeter surface)
506  std::vector<spr::propagatedTrackDirection> trkCaloDirections;
507  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDirections, false);
508  std::vector<spr::propagatedTrackID> trkCaloDets;
509  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDets, false);
510  std::vector<math::XYZTLorentzVector> vecL1, vecL3;
511  t_RunNo = iEvent.id().run();
512  t_EventNo = iEvent.id().event();
513  t_Tracks = trkCollection->size();
514  t_TracksProp = trkCaloDirections.size();
515  t_ietaAll->clear();
516  t_ietaGood->clear();
517  t_trackType->clear();
518  t_trgbits->clear();
519  t_hltbits->clear();
520 #ifdef EDM_ML_DEBUG
521  if (debug_)
522  edm::LogVerbatim("HcalIsoTrack") << "# of propagated tracks " << t_TracksProp << " out of " << t_Tracks
523  << " with Trigger " << ignoreTrigger_;
524 #endif
525 
526  //Trigger
527  t_trgbits->assign(trigNames_.size(), false);
528  t_hltbits->assign(trigNames_.size(), false);
530  t_L1Bit = true;
531  t_TrigPass = false;
532 
533  if (!ignoreTrigger_) {
534  //L1
536  const std::vector<std::pair<std::string, bool>>& finalDecisions = l1GtUtils_->decisionsFinal();
537  for (const auto& decision : finalDecisions) {
538  if (decision.first.find(l1TrigName_) != std::string::npos) {
539  t_L1Bit = decision.second;
540  break;
541  }
542  }
543 #ifdef EDM_ML_DEBUG
544  if (debug_)
545  edm::LogVerbatim("HcalIsoTrack") << "Trigger Information for " << l1TrigName_ << " is " << t_L1Bit
546  << " from a list of " << finalDecisions.size() << " decisions";
547 #endif
548 
549  //HLT
551  if (triggerResults.isValid()) {
552  const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults);
553  const std::vector<std::string>& names = triggerNames.triggerNames();
554  if (!trigNames_.empty()) {
555  for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) {
556  int hlt = triggerResults->accept(iHLT);
557  for (unsigned int i = 0; i < trigNames_.size(); ++i) {
558  if (names[iHLT].find(trigNames_[i]) != std::string::npos) {
559  t_trgbits->at(i) = (hlt > 0);
560  t_hltbits->at(i) = (hlt > 0);
561  if (hlt > 0)
562  t_TrigPass = true;
563 #ifdef EDM_ML_DEBUG
564  if (debug_)
565  edm::LogVerbatim("HcalIsoTrack")
566  << "This trigger " << names[iHLT] << " Flag " << hlt << ":" << t_trgbits->at(i);
567 #endif
568  }
569  }
570  }
571  }
572  }
573 #ifdef EDM_ML_DEBUG
574  if (debug_)
575  edm::LogVerbatim("HcalIsoTrack") << "HLT Information shows " << t_TrigPass << ":" << trigNames_.empty() << ":"
576  << okC;
577 #endif
578  }
579 
580  std::array<int, 3> ntksave{{0, 0, 0}};
581  if (ignoreTrigger_ || useL1Trigger_) {
582  t_l1pt = t_l1eta = t_l1phi = 0;
583  t_l3pt = t_l3eta = t_l3phi = 0;
584  if (ignoreTrigger_ || t_L1Bit)
585  ntksave = fillTree(vecL1,
586  vecL3,
587  leadPV,
588  trkCaloDirections,
589  trkCaloDets,
590  geo,
591  caloTopology,
592  theHBHETopology,
593  theEcalChStatus,
594  theEcalSevlv,
595  barrelRecHitsHandle,
596  endcapRecHitsHandle,
597  hbhe,
598  caloTower,
599  genParticles,
600  respCorrs,
601  muonh);
602  t_TracksSaved = ntksave[0];
603  t_TracksLoose = ntksave[1];
604  t_TracksTight = ntksave[2];
605  } else {
607  const edm::Handle<trigger::TriggerEvent>& triggerEventHandle = iEvent.getHandle(tok_trigEvt_);
608  if (!triggerEventHandle.isValid()) {
609  edm::LogWarning("HcalIsoTrack") << "Error! Can't get the product " << triggerEvent_.label();
610  } else if (okC) {
612  triggerEvent = *(triggerEventHandle.product());
613  const trigger::TriggerObjectCollection& TOC(triggerEvent.getObjects());
614  bool done(false);
615  if (triggerResults.isValid()) {
616  std::vector<std::string> modules;
617  const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults);
618  const std::vector<std::string>& names = triggerNames.triggerNames();
619  for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) {
620  bool ok = (t_TrigPass) || (trigNames_.empty());
621  if (ok) {
622  unsigned int triggerindx = hltConfig_.triggerIndex(names[iHLT]);
623  const std::vector<std::string>& moduleLabels(hltConfig_.moduleLabels(triggerindx));
624  std::vector<math::XYZTLorentzVector> vecL2;
625  vecL1.clear();
626  vecL3.clear();
627  //loop over all trigger filters in event (i.e. filters passed)
628  for (unsigned int ifilter = 0; ifilter < triggerEvent.sizeFilters(); ++ifilter) {
629  std::vector<int> Keys;
630  std::string label = triggerEvent.filterTag(ifilter).label();
631  //loop over keys to objects passing this filter
632  for (unsigned int imodule = 0; imodule < moduleLabels.size(); imodule++) {
633  if (label.find(moduleLabels[imodule]) != std::string::npos) {
634 #ifdef EDM_ML_DEBUG
635  if (debug_)
636  edm::LogVerbatim("HcalIsoTrack") << "FilterName " << label;
637 #endif
638  for (unsigned int ifiltrKey = 0; ifiltrKey < triggerEvent.filterKeys(ifilter).size(); ++ifiltrKey) {
639  Keys.push_back(triggerEvent.filterKeys(ifilter)[ifiltrKey]);
640  const trigger::TriggerObject& TO(TOC[Keys[ifiltrKey]]);
641  math::XYZTLorentzVector v4(TO.px(), TO.py(), TO.pz(), TO.energy());
642  if (label.find(l2Filter_) != std::string::npos) {
643  vecL2.push_back(v4);
644  } else if (label.find(l3Filter_) != std::string::npos) {
645  vecL3.push_back(v4);
646  } else if ((label.find(l1Filter_) != std::string::npos) || (l1Filter_.empty())) {
647  vecL1.push_back(v4);
648  }
649 #ifdef EDM_ML_DEBUG
650  if (debug_)
651  edm::LogVerbatim("HcalIsoTrack")
652  << "key " << ifiltrKey << " : pt " << TO.pt() << " eta " << TO.eta() << " phi " << TO.phi()
653  << " mass " << TO.mass() << " Id " << TO.id();
654 #endif
655  }
656 #ifdef EDM_ML_DEBUG
657  if (debug_)
658  edm::LogVerbatim("HcalIsoTrack")
659  << "sizes " << vecL1.size() << ":" << vecL2.size() << ":" << vecL3.size();
660 #endif
661  }
662  }
663  }
665  math::XYZTLorentzVector mindRvec1;
666  double mindR1(999);
667  for (unsigned int i = 0; i < vecL2.size(); i++) {
668  double dr = dR(vecL1[0], vecL2[i]);
669 #ifdef EDM_ML_DEBUG
670  if (debug_)
671  edm::LogVerbatim("HcalIsoTrack") << "lvl2[" << i << "] dR " << dr;
672 #endif
673  if (dr < mindR1) {
674  mindR1 = dr;
675  mindRvec1 = vecL2[i];
676  }
677  }
678 #ifdef EDM_ML_DEBUG
679  if (debug_)
680  edm::LogVerbatim("HcalIsoTrack") << "L2 object closest to L1 " << mindRvec1 << " at Dr " << mindR1;
681 #endif
682 
683  if (!vecL1.empty()) {
684  t_l1pt = vecL1[0].pt();
685  t_l1eta = vecL1[0].eta();
686  t_l1phi = vecL1[0].phi();
687  } else {
688  t_l1pt = t_l1eta = t_l1phi = 0;
689  }
690  if (!vecL3.empty()) {
691  t_l3pt = vecL3[0].pt();
692  t_l3eta = vecL3[0].eta();
693  t_l3phi = vecL3[0].phi();
694  } else {
695  t_l3pt = t_l3eta = t_l3phi = 0;
696  }
697  // Now fill in the tree for each selected track
698  if (!done) {
699  ntksave = fillTree(vecL1,
700  vecL3,
701  leadPV,
702  trkCaloDirections,
703  trkCaloDets,
704  geo,
705  caloTopology,
706  theHBHETopology,
707  theEcalChStatus,
708  theEcalSevlv,
709  barrelRecHitsHandle,
710  endcapRecHitsHandle,
711  hbhe,
712  caloTower,
713  genParticles,
714  respCorrs,
715  muonh);
716  t_TracksSaved += ntksave[0];
717  t_TracksLoose += ntksave[1];
718  t_TracksTight += ntksave[2];
719  done = true;
720  }
721  }
722  }
723  }
724  }
725  }
726 #ifdef EDM_ML_DEBUG
727  if (debug_)
728  edm::LogVerbatim("HcalIsoTrack") << "Final results on selected tracks " << t_TracksSaved << ":" << t_TracksLoose
729  << ":" << t_TracksTight;
730 #endif
732  tree2->Fill();
733 }
734 
737  tree = fs->make<TTree>("CalibTree", "CalibTree");
738 
739  tree->Branch("t_Run", &t_Run, "t_Run/I");
740  tree->Branch("t_Event", &t_Event, "t_Event/I");
741  tree->Branch("t_DataType", &t_DataType, "t_DataType/I");
742  tree->Branch("t_ieta", &t_ieta, "t_ieta/I");
743  tree->Branch("t_iphi", &t_iphi, "t_iphi/I");
744  tree->Branch("t_EventWeight", &t_EventWeight, "t_EventWeight/D");
745  tree->Branch("t_nVtx", &t_nVtx, "t_nVtx/I");
746  tree->Branch("t_nTrk", &t_nTrk, "t_nTrk/I");
747  tree->Branch("t_goodPV", &t_goodPV, "t_goodPV/I");
748  tree->Branch("t_l1pt", &t_l1pt, "t_l1pt/D");
749  tree->Branch("t_l1eta", &t_l1eta, "t_l1eta/D");
750  tree->Branch("t_l1phi", &t_l1phi, "t_l1phi/D");
751  tree->Branch("t_l3pt", &t_l3pt, "t_l3pt/D");
752  tree->Branch("t_l3eta", &t_l3eta, "t_l3eta/D");
753  tree->Branch("t_l3phi", &t_l3phi, "t_l3phi/D");
754  tree->Branch("t_p", &t_p, "t_p/D");
755  tree->Branch("t_pt", &t_pt, "t_pt/D");
756  tree->Branch("t_phi", &t_phi, "t_phi/D");
757  tree->Branch("t_mindR1", &t_mindR1, "t_mindR1/D");
758  tree->Branch("t_mindR2", &t_mindR2, "t_mindR2/D");
759  tree->Branch("t_eMipDR", &t_eMipDR, "t_eMipDR/D");
760  tree->Branch("t_eMipDR2", &t_eMipDR2, "t_eMipDR2/D");
761  tree->Branch("t_eMipDR3", &t_eMipDR3, "t_eMipDR3/D");
762  tree->Branch("t_eMipDR4", &t_eMipDR4, "t_eMipDR4/D");
763  tree->Branch("t_eMipDR5", &t_eMipDR5, "t_eMipDR5/D");
764  tree->Branch("t_eHcal", &t_eHcal, "t_eHcal/D");
765  tree->Branch("t_eHcal10", &t_eHcal10, "t_eHcal10/D");
766  tree->Branch("t_eHcal30", &t_eHcal30, "t_eHcal30/D");
767  tree->Branch("t_hmaxNearP", &t_hmaxNearP, "t_hmaxNearP/D");
768  tree->Branch("t_emaxNearP", &t_emaxNearP, "t_emaxNearP/D");
769  tree->Branch("t_eAnnular", &t_eAnnular, "t_eAnnular/D");
770  tree->Branch("t_hAnnular", &t_hAnnular, "t_hAnnular/D");
771  tree->Branch("t_rhoh", &t_rhoh, "t_rhoh/D");
772  tree->Branch("t_selectTk", &t_selectTk, "t_selectTk/O");
773  tree->Branch("t_qltyFlag", &t_qltyFlag, "t_qltyFlag/O");
774  tree->Branch("t_qltyMissFlag", &t_qltyMissFlag, "t_qltyMissFlag/O");
775  tree->Branch("t_qltyPVFlag", &t_qltyPVFlag, "t_qltyPVFlag/O");
776  tree->Branch("t_gentrackP", &t_gentrackP, "t_gentrackP/D");
777 
778  t_DetIds = new std::vector<unsigned int>();
779  t_DetIds1 = new std::vector<unsigned int>();
780  t_DetIds3 = new std::vector<unsigned int>();
781  t_HitEnergies = new std::vector<double>();
782  t_HitEnergies1 = new std::vector<double>();
783  t_HitEnergies3 = new std::vector<double>();
784  t_trgbits = new std::vector<bool>();
785  tree->Branch("t_DetIds", "std::vector<unsigned int>", &t_DetIds);
786  tree->Branch("t_HitEnergies", "std::vector<double>", &t_HitEnergies);
787  tree->Branch("t_trgbits", "std::vector<bool>", &t_trgbits);
788  tree->Branch("t_DetIds1", "std::vector<unsigned int>", &t_DetIds1);
789  tree->Branch("t_DetIds3", "std::vector<unsigned int>", &t_DetIds3);
790  tree->Branch("t_HitEnergies1", "std::vector<double>", &t_HitEnergies1);
791  tree->Branch("t_HitEnergies3", "std::vector<double>", &t_HitEnergies3);
792 
793  tree2 = fs->make<TTree>("EventInfo", "Event Information");
794 
795  tree2->Branch("t_RunNo", &t_RunNo, "t_RunNo/i");
796  tree2->Branch("t_EventNo", &t_EventNo, "t_EventNo/i");
797  tree2->Branch("t_Tracks", &t_Tracks, "t_Tracks/I");
798  tree2->Branch("t_TracksProp", &t_TracksProp, "t_TracksProp/I");
799  tree2->Branch("t_TracksSaved", &t_TracksSaved, "t_TracksSaved/I");
800  tree2->Branch("t_TracksLoose", &t_TracksLoose, "t_TracksLoose/I");
801  tree2->Branch("t_TracksTight", &t_TracksTight, "t_TracksTight/I");
802  tree2->Branch("t_TrigPass", &t_TrigPass, "t_TrigPass/O");
803  tree2->Branch("t_TrigPassSel", &t_TrigPassSel, "t_TrigPassSel/O");
804  tree2->Branch("t_L1Bit", &t_L1Bit, "t_L1Bit/O");
805  tree2->Branch("t_allvertex", &t_allvertex, "t_allvertex/I");
806  t_hltbits = new std::vector<bool>();
807  t_ietaAll = new std::vector<int>();
808  t_ietaGood = new std::vector<int>();
809  t_trackType = new std::vector<int>();
810  tree2->Branch("t_ietaAll", "std::vector<int>", &t_ietaAll);
811  tree2->Branch("t_ietaGood", "std::vector<int>", &t_ietaGood);
812  tree2->Branch("t_trackType", "std::vector<int>", &t_trackType);
813  tree2->Branch("t_hltbits", "std::vector<bool>", &t_hltbits);
814 }
815 
816 // ------------ method called when starting to processes a run ------------
817 void HcalIsoTrkAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
818  hdc_ = &iSetup.getData(tok_ddrec_);
819 
820  if (!ignoreTrigger_) {
821  bool changed_(true);
822  bool flag = hltConfig_.init(iRun, iSetup, processName_, changed_);
823  edm::LogVerbatim("HcalIsoTrack") << "Run[" << nRun_ << "] " << iRun.run() << " process " << processName_
824  << " init flag " << flag << " change flag " << changed_;
825  // check if trigger names in (new) config
826  if (changed_) {
827 #ifdef EDM_ML_DEBUG
828  edm::LogVerbatim("HcalIsoTrack") << "New trigger menu found !!!";
829 #endif
830  const unsigned int n(hltConfig_.size());
831  for (unsigned itrig = 0; itrig < trigNames_.size(); itrig++) {
832  unsigned int triggerindx = hltConfig_.triggerIndex(trigNames_[itrig]);
833  if (triggerindx >= n) {
834  edm::LogWarning("HcalIsoTrack") << trigNames_[itrig] << " " << triggerindx << " does not exist in "
835  << "the current menu";
836 #ifdef EDM_ML_DEBUG
837  } else {
838  edm::LogVerbatim("HcalIsoTrack") << trigNames_[itrig] << " " << triggerindx << " exists";
839 #endif
840  }
841  }
842  }
843  }
844 }
845 
846 // ------------ method called when ending the processing of a run ------------
848  nRun_++;
849  edm::LogVerbatim("HcalIsoTrack") << "endRun[" << nRun_ << "] " << iRun.run();
850 }
851 
854  std::vector<std::string> trig = {"HLT_PFJet40",
855  "HLT_PFJet60",
856  "HLT_PFJet80",
857  "HLT_PFJet140",
858  "HLT_PFJet200",
859  "HLT_PFJet260",
860  "HLT_PFJet320",
861  "HLT_PFJet400",
862  "HLT_PFJet450",
863  "HLT_PFJet500"};
864  desc.add<std::vector<std::string>>("triggers", trig);
865  desc.add<std::string>("processName", "HLT");
866  desc.add<std::string>("l1Filter", "");
867  desc.add<std::string>("l2Filter", "L2Filter");
868  desc.add<std::string>("l3Filter", "Filter");
869  // following 10 parameters are parameters to select good tracks
870  desc.add<std::string>("trackQuality", "highPurity");
871  desc.add<double>("minTrackPt", 1.0);
872  desc.add<double>("maxDxyPV", 0.02);
873  desc.add<double>("maxDzPV", 0.02);
874  desc.add<double>("maxChi2", 5.0);
875  desc.add<double>("maxDpOverP", 0.1);
876  desc.add<int>("minOuterHit", 4);
877  desc.add<int>("minLayerCrossed", 8);
878  desc.add<int>("maxInMiss", 0);
879  desc.add<int>("maxOutMiss", 0);
880  // Minimum momentum of selected isolated track and signal zone
881  desc.add<double>("minimumTrackP", 10.0);
882  desc.add<double>("coneRadius", 34.98);
883  // signal zone in ECAL and MIP energy cutoff
884  desc.add<double>("coneRadiusMIP", 14.0);
885  desc.add<double>("coneRadiusMIP2", 18.0);
886  desc.add<double>("coneRadiusMIP3", 20.0);
887  desc.add<double>("coneRadiusMIP4", 22.0);
888  desc.add<double>("coneRadiusMIP5", 24.0);
889  desc.add<double>("maximumEcalEnergy", 2.0);
890  // following 4 parameters are for isolation cuts and described in the code
891  desc.add<double>("maxTrackP", 8.0);
892  desc.add<double>("slopeTrackP", 0.05090504066);
893  desc.add<double>("isolationEnergyTight", 2.0);
894  desc.add<double>("isolationEnergyLoose", 10.0);
895  // energy thershold for ECAL (from Egamma group)
896  desc.add<double>("EBHitEnergyThreshold", 0.08);
897  desc.add<double>("EEHitEnergyThreshold0", 0.30);
898  desc.add<double>("EEHitEnergyThreshold1", 0.00);
899  desc.add<double>("EEHitEnergyThreshold2", 0.00);
900  desc.add<double>("EEHitEnergyThreshold3", 0.00);
901  desc.add<double>("EEHitEnergyThresholdLow", 0.30);
902  desc.add<double>("EEHitEnergyThresholdHigh", 0.30);
903  // prescale factors
904  desc.add<double>("momentumLow", 40.0);
905  desc.add<double>("momentumHigh", 60.0);
906  desc.add<int>("prescaleLow", 1);
907  desc.add<int>("prescaleHigh", 1);
908  // various labels for collections used in the code
909  desc.add<edm::InputTag>("labelTriggerEvent", edm::InputTag("hltTriggerSummaryAOD", "", "HLT"));
910  desc.add<edm::InputTag>("labelTriggerResult", edm::InputTag("TriggerResults", "", "HLT"));
911  desc.add<std::string>("labelTrack", "generalTracks");
912  desc.add<std::string>("labelVertex", "offlinePrimaryVertices");
913  desc.add<std::string>("labelEBRecHit", "EcalRecHitsEB");
914  desc.add<std::string>("labelEERecHit", "EcalRecHitsEE");
915  desc.add<std::string>("labelHBHERecHit", "hbhereco");
916  desc.add<std::string>("labelBeamSpot", "offlineBeamSpot");
917  desc.add<std::string>("labelCaloTower", "towerMaker");
918  desc.add<std::string>("labelMuon", "muons");
919  desc.add<edm::InputTag>("algInputTag", edm::InputTag("gtStage2Digis"));
920  desc.add<edm::InputTag>("extInputTag", edm::InputTag("gtStage2Digis"));
921  desc.addUntracked<std::string>("moduleName", "");
922  desc.addUntracked<std::string>("producerName", "");
923  // Various flags used for selecting tracks, choice of energy Method2/0
924  // Data type 0/1 for single jet trigger or others
925  desc.addUntracked<int>("useRaw", 0);
926  desc.addUntracked<bool>("ignoreTriggers", false);
927  desc.addUntracked<bool>("useL1Trigger", false);
928  desc.addUntracked<double>("hcalScale", 1.0);
929  desc.addUntracked<int>("dataType", 0);
930  desc.addUntracked<bool>("unCorrect", false);
931  desc.addUntracked<bool>("collapseDepth", false);
932  desc.addUntracked<std::string>("l1TrigName", "L1_SingleJet60");
933  desc.addUntracked<int>("outMode", 11);
934  std::vector<int> dummy;
935  desc.addUntracked<std::vector<int>>("oldID", dummy);
936  desc.addUntracked<std::vector<int>>("newDepth", dummy);
937  desc.addUntracked<bool>("hep17", false);
938  std::vector<int> events;
939  desc.add<std::vector<int>>("debugEvents", events);
940  desc.add<bool>("usePFThreshold", true);
941  descriptions.add("hcalIsoTrkAnalyzer", desc);
942 }
943 
944 std::array<int, 3> HcalIsoTrkAnalyzer::fillTree(std::vector<math::XYZTLorentzVector>& vecL1,
945  std::vector<math::XYZTLorentzVector>& vecL3,
946  math::XYZPoint& leadPV,
947  std::vector<spr::propagatedTrackDirection>& trkCaloDirections,
948  std::vector<spr::propagatedTrackID>& trkCaloDets,
949  const CaloGeometry* geo,
950  const CaloTopology* caloTopology,
951  const HcalTopology* theHBHETopology,
952  const EcalChannelStatus* theEcalChStatus,
953  const EcalSeverityLevelAlgo* theEcalSevlv,
954  edm::Handle<EcalRecHitCollection>& barrelRecHitsHandle,
955  edm::Handle<EcalRecHitCollection>& endcapRecHitsHandle,
959  const HcalRespCorrs* respCorrs,
960  const edm::Handle<reco::MuonCollection>& muonh) {
961  int nSave(0), nLoose(0), nTight(0);
962  //Loop over tracks
963  unsigned int nTracks(0);
964  t_nTrk = trkCaloDirections.size();
965  t_rhoh = (tower.isValid()) ? rhoh(tower) : 0;
966  for (const auto& trkDetItr : trkCaloDirections) {
967  const reco::Track* pTrack = &(*(trkDetItr.trkItr));
968  math::XYZTLorentzVector v4(pTrack->px(), pTrack->py(), pTrack->pz(), pTrack->p());
969  t_p = pTrack->p();
970  t_pt = pTrack->pt();
971  t_phi = pTrack->phi();
972 
973 #ifdef EDM_ML_DEBUG
974  if (debug_)
975  edm::LogVerbatim("HcalIsoTrack") << "This track : " << nTracks << " (pt|eta|phi|p) : " << t_pt << "|"
976  << pTrack->eta() << "|" << t_phi << "|" << t_p;
977 #endif
978  t_mindR2 = 999;
979  for (unsigned int k = 0; k < vecL3.size(); ++k) {
980  double dr = dR(vecL3[k], v4);
981  if (dr < t_mindR2) {
982  t_mindR2 = dr;
983  }
984  }
985  t_mindR1 = (!vecL1.empty()) ? dR(vecL1[0], v4) : 999;
986 #ifdef EDM_ML_DEBUG
987  if (debug_)
988  edm::LogVerbatim("HcalIsoTrack") << "Closest L3 object at dr : " << t_mindR2 << " and from L1 " << t_mindR1;
989 #endif
990 
991  t_ieta = t_iphi = 0;
992  if (trkDetItr.okHCAL) {
993  HcalDetId detId = (HcalDetId)(trkDetItr.detIdHCAL);
994  t_ieta = detId.ieta();
995  t_iphi = detId.iphi();
996  if (t_p > 40.0 && t_p <= 60.0)
997  t_ietaAll->emplace_back(t_ieta);
998  }
999  //Selection of good track
1000  t_selectTk = spr::goodTrack(pTrack, leadPV, selectionParameter_, false);
1002  oneCutParameters.maxDxyPV = 10;
1003  oneCutParameters.maxDzPV = 100;
1004  oneCutParameters.maxInMiss = 2;
1005  oneCutParameters.maxOutMiss = 2;
1006  bool qltyFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false);
1007  oneCutParameters = selectionParameter_;
1008  oneCutParameters.maxDxyPV = 10;
1009  oneCutParameters.maxDzPV = 100;
1010  t_qltyMissFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false);
1011  oneCutParameters = selectionParameter_;
1012  oneCutParameters.maxInMiss = 2;
1013  oneCutParameters.maxOutMiss = 2;
1014  t_qltyPVFlag = spr::goodTrack(pTrack, leadPV, oneCutParameters, false);
1015  double eIsolation = maxRestrictionP_ * exp(slopeRestrictionP_ * std::abs((double)t_ieta));
1016  if (eIsolation < eIsolate1_)
1017  eIsolation = eIsolate1_;
1018  if (eIsolation < eIsolate2_)
1019  eIsolation = eIsolate2_;
1020 #ifdef EDM_ML_DEBUG
1021  if (debug_)
1022  edm::LogVerbatim("HcalIsoTrack") << "qltyFlag|okECAL|okHCAL : " << qltyFlag << "|" << trkDetItr.okECAL << "|"
1023  << trkDetItr.okHCAL << " eIsolation " << eIsolation;
1024 #endif
1025  t_qltyFlag = (qltyFlag && trkDetItr.okECAL && trkDetItr.okHCAL);
1026  bool notMuon = (muonh.isValid()) ? notaMuon(pTrack, muonh) : true;
1027  if (t_qltyFlag && notMuon) {
1028  int nNearTRKs(0);
1030  std::vector<DetId> eIds;
1031  std::vector<double> eHit;
1032  t_eMipDR = spr::eCone_ecal(geo,
1033  barrelRecHitsHandle,
1034  endcapRecHitsHandle,
1035  trkDetItr.pointHCAL,
1036  trkDetItr.pointECAL,
1037  a_mipR_,
1038  trkDetItr.directionECAL,
1039  eIds,
1040  eHit);
1041  double eEcal(0);
1042  for (unsigned int k = 0; k < eIds.size(); ++k) {
1043  if (eHit[k] > eThreshold(eIds[k], geo))
1044  eEcal += eHit[k];
1045  }
1046 #ifdef EDM_ML_DEBUG
1047  if (debug_)
1048  edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR << ":" << eEcal;
1049 #endif
1050  t_eMipDR = eEcal;
1053  std::vector<DetId> eIds2;
1054  std::vector<double> eHit2;
1055  t_eMipDR2 = spr::eCone_ecal(geo,
1056  barrelRecHitsHandle,
1057  endcapRecHitsHandle,
1058  trkDetItr.pointHCAL,
1059  trkDetItr.pointECAL,
1060  a_mipR2_,
1061  trkDetItr.directionECAL,
1062  eIds2,
1063  eHit2);
1064  double eEcal2(0);
1065  for (unsigned int k = 0; k < eIds2.size(); ++k) {
1066  if (eHit2[k] > eThreshold(eIds2[k], geo))
1067  eEcal2 += eHit2[k];
1068  }
1069 #ifdef EDM_ML_DEBUG
1070  if (debug_)
1071  edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR2 << ":" << eEcal2;
1072 #endif
1073  t_eMipDR2 = eEcal2;
1076  std::vector<DetId> eIds3;
1077  std::vector<double> eHit3;
1078  t_eMipDR3 = spr::eCone_ecal(geo,
1079  barrelRecHitsHandle,
1080  endcapRecHitsHandle,
1081  trkDetItr.pointHCAL,
1082  trkDetItr.pointECAL,
1083  a_mipR3_,
1084  trkDetItr.directionECAL,
1085  eIds3,
1086  eHit3);
1087  double eEcal3(0);
1088  for (unsigned int k = 0; k < eIds3.size(); ++k) {
1089  if (eHit3[k] > eThreshold(eIds3[k], geo))
1090  eEcal3 += eHit3[k];
1091  }
1092 #ifdef EDM_ML_DEBUG
1093  if (debug_)
1094  edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR3 << ":" << eEcal3;
1095 #endif
1096  t_eMipDR3 = eEcal3;
1099  std::vector<DetId> eIds4;
1100  std::vector<double> eHit4;
1101  t_eMipDR4 = spr::eCone_ecal(geo,
1102  barrelRecHitsHandle,
1103  endcapRecHitsHandle,
1104  trkDetItr.pointHCAL,
1105  trkDetItr.pointECAL,
1106  a_mipR4_,
1107  trkDetItr.directionECAL,
1108  eIds4,
1109  eHit4);
1110  double eEcal4(0);
1111  for (unsigned int k = 0; k < eIds4.size(); ++k) {
1112  if (eHit4[k] > eThreshold(eIds4[k], geo))
1113  eEcal4 += eHit4[k];
1114  }
1115 #ifdef EDM_ML_DEBUG
1116  if (debug_)
1117  edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR4 << ":" << eEcal4;
1118 #endif
1119  t_eMipDR4 = eEcal4;
1122  std::vector<DetId> eIds5;
1123  std::vector<double> eHit5;
1124  t_eMipDR5 = spr::eCone_ecal(geo,
1125  barrelRecHitsHandle,
1126  endcapRecHitsHandle,
1127  trkDetItr.pointHCAL,
1128  trkDetItr.pointECAL,
1129  a_mipR5_,
1130  trkDetItr.directionECAL,
1131  eIds5,
1132  eHit5);
1133  double eEcal5(0);
1134  for (unsigned int k = 0; k < eIds5.size(); ++k) {
1135  if (eHit5[k] > eThreshold(eIds5[k], geo))
1136  eEcal5 += eHit5[k];
1137  }
1138 #ifdef EDM_ML_DEBUG
1139  if (debug_)
1140  edm::LogVerbatim("HcalIsoTrack") << "eMIP before and after: " << t_eMipDR5 << ":" << eEcal5;
1141 #endif
1142  t_eMipDR5 = eEcal5;
1144 
1145  t_emaxNearP = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology, 15, 15);
1146  const DetId cellE(trkDetItr.detIdECAL);
1147  std::pair<double, bool> e11x11P = spr::eECALmatrix(cellE,
1148  barrelRecHitsHandle,
1149  endcapRecHitsHandle,
1150  *theEcalChStatus,
1151  geo,
1152  caloTopology,
1153  theEcalSevlv,
1154  5,
1155  5,
1156  -100.0,
1157  -100.0,
1158  -100.0,
1159  100.0);
1160  std::pair<double, bool> e15x15P = spr::eECALmatrix(cellE,
1161  barrelRecHitsHandle,
1162  endcapRecHitsHandle,
1163  *theEcalChStatus,
1164  geo,
1165  caloTopology,
1166  theEcalSevlv,
1167  7,
1168  7,
1169  -100.0,
1170  -100.0,
1171  -100.0,
1172  100.0);
1173  if (e11x11P.second && e15x15P.second) {
1174  t_eAnnular = (e15x15P.first - e11x11P.first);
1175  } else {
1176  t_eAnnular = -(e15x15P.first - e11x11P.first);
1177  }
1178  t_hmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, false);
1179  const DetId cellH(trkDetItr.detIdHCAL);
1180  double h5x5 = spr::eHCALmatrix(
1181  theHBHETopology, cellH, hbhe, 2, 2, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0);
1182  double h7x7 = spr::eHCALmatrix(
1183  theHBHETopology, cellH, hbhe, 3, 3, false, true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0);
1184  t_hAnnular = h7x7 - h5x5;
1185 #ifdef EDM_ML_DEBUG
1186  if (debug_)
1187  edm::LogVerbatim("HcalIsoTrack") << "max p Near (Ecal) " << t_emaxNearP << " (Hcal) " << t_hmaxNearP
1188  << " Annular E (Ecal) " << e11x11P.first << ":" << e15x15P.first << ":"
1189  << t_eAnnular << " (Hcal) " << h5x5 << ":" << h7x7 << ":" << t_hAnnular;
1190 #endif
1191  t_gentrackP = trackP(pTrack, genParticles);
1192  if (t_eMipDR < eEcalMax_ && t_hmaxNearP < eIsolation) {
1193  t_DetIds->clear();
1194  t_HitEnergies->clear();
1195  t_DetIds1->clear();
1196  t_HitEnergies1->clear();
1197  t_DetIds3->clear();
1198  t_HitEnergies3->clear();
1199  int nRecHits(-999), nRecHits1(-999), nRecHits3(-999);
1200  std::vector<DetId> ids, ids1, ids3;
1201  std::vector<double> edet0, edet1, edet3;
1202  t_eHcal = spr::eCone_hcal(geo,
1203  hbhe,
1204  trkDetItr.pointHCAL,
1205  trkDetItr.pointECAL,
1206  a_coneR_,
1207  trkDetItr.directionHCAL,
1208  nRecHits,
1209  ids,
1210  edet0,
1211  useRaw_);
1212  if (!oldID_.empty()) {
1213  for (unsigned k = 0; k < ids.size(); ++k)
1214  ids[k] = newId(ids[k]);
1215  }
1216  storeEnergy(0, respCorrs, ids, edet0, t_eHcal, t_DetIds, t_HitEnergies);
1217 
1218  //----- hcal energy in the extended cone 1 (a_coneR+10) --------------
1219  t_eHcal10 = spr::eCone_hcal(geo,
1220  hbhe,
1221  trkDetItr.pointHCAL,
1222  trkDetItr.pointECAL,
1223  a_coneR1_,
1224  trkDetItr.directionHCAL,
1225  nRecHits1,
1226  ids1,
1227  edet1,
1228  useRaw_);
1229  if (!oldID_.empty()) {
1230  for (unsigned k = 0; k < ids1.size(); ++k)
1231  ids1[k] = newId(ids1[k]);
1232  }
1233  storeEnergy(1, respCorrs, ids1, edet1, t_eHcal10, t_DetIds1, t_HitEnergies1);
1234 
1235  //----- hcal energy in the extended cone 3 (a_coneR+30) --------------
1236  t_eHcal30 = spr::eCone_hcal(geo,
1237  hbhe,
1238  trkDetItr.pointHCAL,
1239  trkDetItr.pointECAL,
1240  a_coneR2_,
1241  trkDetItr.directionHCAL,
1242  nRecHits3,
1243  ids3,
1244  edet3,
1245  useRaw_);
1246  if (!oldID_.empty()) {
1247  for (unsigned k = 0; k < ids3.size(); ++k)
1248  ids3[k] = newId(ids3[k]);
1249  }
1250  storeEnergy(3, respCorrs, ids3, edet3, t_eHcal30, t_DetIds3, t_HitEnergies3);
1251 
1252 #ifdef EDM_ML_DEBUG
1253  if (debug_) {
1254  edm::LogVerbatim("HcalIsoTrack")
1255  << "This track : " << nTracks << " (pt|eta|phi|p) : " << t_pt << "|" << pTrack->eta() << "|" << t_phi
1256  << "|" << t_p << " Generator Level p " << t_gentrackP;
1257  edm::LogVerbatim("HcalIsoTrack")
1258  << "e_MIP " << t_eMipDR << " Chg Isolation " << t_hmaxNearP << " eHcal" << t_eHcal << " ieta " << t_ieta
1259  << " Quality " << t_qltyMissFlag << ":" << t_qltyPVFlag << ":" << t_selectTk;
1260  for (unsigned int ll = 0; ll < t_DetIds->size(); ll++) {
1261  edm::LogVerbatim("HcalIsoTrack")
1262  << "det id is = " << HcalDetId(t_DetIds->at(ll)) << " hit enery is = " << t_HitEnergies->at(ll);
1263  }
1264  for (unsigned int ll = 0; ll < t_DetIds1->size(); ll++) {
1265  edm::LogVerbatim("HcalIsoTrack")
1266  << "det id is = " << HcalDetId(t_DetIds1->at(ll)) << " hit enery is = " << t_HitEnergies1->at(ll);
1267  }
1268  for (unsigned int ll = 0; ll < t_DetIds3->size(); ll++) {
1269  edm::LogVerbatim("HcalIsoTrack")
1270  << "det id is = " << HcalDetId(t_DetIds3->at(ll)) << " hit enery is = " << t_HitEnergies3->at(ll);
1271  }
1272  }
1273 #endif
1274  bool accept(false);
1275  if (t_p > pTrackMin_) {
1276  if (t_p < pTrackLow_) {
1277  ++nLow_;
1278  if (prescaleLow_ <= 1)
1279  accept = true;
1280  else if (nLow_ % prescaleLow_ == 1)
1281  accept = true;
1282  } else if (t_p > pTrackHigh_) {
1283  ++nHigh_;
1284  if (prescaleHigh_ <= 1)
1285  accept = true;
1286  else if (nHigh_ % prescaleHigh_ == 1)
1287  accept = true;
1288  } else {
1289  accept = true;
1290  }
1291  }
1292  if (accept) {
1293  tree->Fill();
1294  edm::LogVerbatim("HcalIsoTrackX")
1295  << "Run " << t_RunNo << " Event " << t_EventNo << " Track " << nTracks << " p " << t_p;
1296  nSave++;
1297  int type(0);
1298  if (t_eMipDR < 1.0) {
1299  if (t_hmaxNearP < eIsolate2_) {
1300  ++nLoose;
1301  type = 1;
1302  }
1303  if (t_hmaxNearP < eIsolate1_) {
1304  ++nTight;
1305  type = 2;
1306  }
1307  }
1308  if (t_p > 40.0 && t_p <= 60.0 && t_selectTk) {
1309  t_ietaGood->emplace_back(t_ieta);
1310  t_trackType->emplace_back(type);
1311  }
1312 #ifdef EDM_ML_DEBUG
1313  if (debug_) {
1314  for (unsigned int k = 0; k < t_trgbits->size(); k++) {
1315  edm::LogVerbatim("HcalIsoTrack") << "trigger bit is = " << t_trgbits->at(k);
1316  }
1317  }
1318 #endif
1319  }
1320  }
1321  }
1322  ++nTracks;
1323  }
1324  std::array<int, 3> i3{{nSave, nLoose, nTight}};
1325  return i3;
1326 }
1327 
1329  return reco::deltaR(vec1.eta(), vec1.phi(), vec2.eta(), vec2.phi());
1330 }
1331 
1334  double pmom = -1.0;
1335  if (genParticles.isValid()) {
1336  double mindR(999.9);
1337  for (const auto& p : (*genParticles)) {
1338  double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), p.momentum().Eta(), p.momentum().Phi());
1339  if (dR < mindR) {
1340  mindR = dR;
1341  pmom = p.momentum().R();
1342  }
1343  }
1344  }
1345  return pmom;
1346 }
1347 
1349  std::vector<double> sumPFNallSMDQH2;
1350  sumPFNallSMDQH2.reserve(phibins_.size() * etabins_.size());
1351 
1352  for (auto eta : etabins_) {
1353  for (auto phi : phibins_) {
1354  double hadder = 0;
1355  for (const auto& pf_it : (*tower)) {
1356  if (fabs(eta - pf_it.eta()) > etahalfdist_)
1357  continue;
1358  if (fabs(reco::deltaPhi(phi, pf_it.phi())) > phihalfdist_)
1359  continue;
1360  hadder += pf_it.hadEt();
1361  }
1362  sumPFNallSMDQH2.emplace_back(hadder);
1363  }
1364  }
1365 
1366  double evt_smdq(0);
1367  std::sort(sumPFNallSMDQH2.begin(), sumPFNallSMDQH2.end());
1368  if (sumPFNallSMDQH2.size() % 2)
1369  evt_smdq = sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 1) / 2];
1370  else
1371  evt_smdq = (sumPFNallSMDQH2[sumPFNallSMDQH2.size() / 2] + sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 2) / 2]) / 2.;
1372  double rhoh = evt_smdq / (etadist_ * phidist_);
1373 #ifdef EDM_ML_DEBUG
1374  if (debug_)
1375  edm::LogVerbatim("HcalIsoTrack") << "Rho " << evt_smdq << ":" << rhoh;
1376 #endif
1377  return rhoh;
1378 }
1379 
1380 double HcalIsoTrkAnalyzer::eThreshold(const DetId& id, const CaloGeometry* geo) const {
1381  double eThr(hitEthrEB_);
1382  if (usePFThresh_) {
1383  eThr = static_cast<double>((*eThresholds_)[id]);
1384  } else {
1385  const GlobalPoint& pos = geo->getPosition(id);
1386  double eta = std::abs(pos.eta());
1387  if (id.subdetId() != EcalBarrel) {
1388  eThr = (((eta * hitEthrEE3_ + hitEthrEE2_) * eta + hitEthrEE1_) * eta + hitEthrEE0_);
1389  if (eThr < hitEthrEELo_)
1390  eThr = hitEthrEELo_;
1391  else if (eThr > hitEthrEEHi_)
1392  eThr = hitEthrEEHi_;
1393  }
1394  }
1395  return eThr;
1396 }
1397 
1399  HcalDetId hid(id);
1400  if (hep17_ && ((hid.iphi() < 63) || (hid.iphi() > 66) || (hid.zside() < 0)))
1401  return id;
1402  for (unsigned int k = 0; k < oldID_.size(); ++k) {
1403  if ((hid.subdetId() == oldDet_[k]) && (hid.ietaAbs() == oldEta_[k]) && (hid.depth() == oldDepth_[k])) {
1404  return static_cast<DetId>(HcalDetId(hid.subdet(), hid.ieta(), hid.iphi(), newDepth_[k]));
1405  }
1406  }
1407  return id;
1408 }
1409 
1411  const HcalRespCorrs* respCorrs,
1412  const std::vector<DetId>& ids,
1413  std::vector<double>& edet,
1414  double& eHcal,
1415  std::vector<unsigned int>* detIds,
1416  std::vector<double>* hitEnergies) {
1417  double ehcal(0);
1418  if (unCorrect_) {
1419  for (unsigned int k = 0; k < ids.size(); ++k) {
1420  double corr = (respCorrs->getValues(ids[k]))->getValue();
1421  if (corr != 0)
1422  edet[k] /= corr;
1423  ehcal += edet[k];
1424  }
1425  } else {
1426  for (const auto& en : edet)
1427  ehcal += en;
1428  }
1429  if ((std::abs(ehcal - eHcal) > 0.001) && (!unCorrect_))
1430  edm::LogWarning("HcalIsoTrack") << "Check inconsistent energies: " << indx << " " << eHcal << ":" << ehcal
1431  << " from " << ids.size() << " cells";
1432  eHcal = hcalScale_ * ehcal;
1433 
1434  if (collapseDepth_) {
1435  std::map<HcalDetId, double> hitMap;
1436  for (unsigned int k = 0; k < ids.size(); ++k) {
1437  HcalDetId id = hdc_->mergedDepthDetId(HcalDetId(ids[k]));
1438  auto itr = hitMap.find(id);
1439  if (itr == hitMap.end()) {
1440  hitMap[id] = edet[k];
1441  } else {
1442  (itr->second) += edet[k];
1443  }
1444  }
1445  detIds->reserve(hitMap.size());
1446  hitEnergies->reserve(hitMap.size());
1447  for (const auto& hit : hitMap) {
1448  detIds->emplace_back(hit.first.rawId());
1449  hitEnergies->emplace_back(hit.second);
1450  }
1451  } else {
1452  detIds->reserve(ids.size());
1453  hitEnergies->reserve(ids.size());
1454  for (unsigned int k = 0; k < ids.size(); ++k) {
1455  detIds->emplace_back(ids[k].rawId());
1456  hitEnergies->emplace_back(edet[k]);
1457  }
1458  }
1459 #ifdef EDM_ML_DEBUG
1460  if (debug_) {
1461  edm::LogVerbatim("HcalIsoTrack") << "Input to storeEnergy with " << ids.size() << " cells";
1462  for (unsigned int k = 0; k < ids.size(); ++k)
1463  edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << HcalDetId(ids[k]) << " E " << edet[k];
1464  edm::LogVerbatim("HcalIsoTrack") << "Output of storeEnergy with " << detIds->size() << " cells and Etot " << eHcal;
1465  for (unsigned int k = 0; k < detIds->size(); ++k)
1466  edm::LogVerbatim("HcalIsoTrack") << "Hit [" << k << "] " << HcalDetId((*detIds)[k]) << " E " << (*hitEnergies)[k];
1467  }
1468 #endif
1469 }
1470 
1472  bool flag(true);
1473  for (reco::MuonCollection::const_iterator recMuon = muonh->begin(); recMuon != muonh->end(); ++recMuon) {
1474  if (recMuon->innerTrack().isNonnull()) {
1475  const reco::Track* pTrack = (recMuon->innerTrack()).get();
1476  bool mediumMuon = (((recMuon->isPFMuon()) && (recMuon->isGlobalMuon() || recMuon->isTrackerMuon())) &&
1477  (recMuon->innerTrack()->validFraction() > 0.49));
1478  if (mediumMuon) {
1479  double chiGlobal = ((recMuon->globalTrack().isNonnull()) ? recMuon->globalTrack()->normalizedChi2() : 999);
1480  bool goodGlob = (recMuon->isGlobalMuon() && chiGlobal < 3 &&
1481  recMuon->combinedQuality().chi2LocalPosition < 12 && recMuon->combinedQuality().trkKink < 20);
1482  mediumMuon = muon::segmentCompatibility(*recMuon) > (goodGlob ? 0.303 : 0.451);
1483  }
1484  if (mediumMuon) {
1485  double dR = reco::deltaR(pTrack->eta(), pTrack->phi(), pTrack0->eta(), pTrack0->phi());
1486  if (dR < 0.1) {
1487  flag = false;
1488  break;
1489  }
1490  }
1491  }
1492  }
1493  return flag;
1494 }
1495 
1496 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
const std::string labelHBHE_
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
const std::vector< std::string > trigNames_
double eCone_hcal(const CaloGeometry *geo, edm::Handle< T > &hits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int detOnly=-1, int useRaw=0, bool debug=false)
Log< level::Info, true > LogVerbatim
spr::trackSelectionParameters selectionParameter_
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
const edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, const std::string &theTrackQuality, bool debug=false)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
~HcalIsoTrkAnalyzer() override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::string l1TrigName_
const double maxRestrictionP_
const std::string modnam_
std::vector< int > oldEta_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
HcalDetId mergedDepthDetId(const HcalDetId &id) const
const std::string labelRecVtx_
constexpr int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
const Point & position() const
position
Definition: BeamSpot.h:59
const edm::ESGetToken< EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd > tok_ecalPFRecHitThresholds_
TrackQuality
track quality
Definition: TrackBase.h:150
constexpr int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
const std::string labelTower_
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:640
double p() const
momentum vector magnitude
Definition: TrackBase.h:631
std::vector< int > * t_ietaAll
const edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_htopo_
T const * product() const
Definition: Handle.h:70
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< int > oldDepth_
const edm::ESGetToken< EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd > tok_sevlv_
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:643
const std::string labelBS_
const edm::EDGetTokenT< CaloTowerCollection > tok_cala_
std::vector< double > * t_HitEnergies
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::string const & label() const
Definition: InputTag.h:36
const edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
void storeEnergy(int indx, const HcalRespCorrs *respCorrs, const std::vector< DetId > &ids, std::vector< double > &edet, double &eHcal, std::vector< unsigned int > *detIds, std::vector< double > *hitEnergies)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const edm::EDGetTokenT< GenEventInfoProduct > tok_ew_
std::vector< Vertex > VertexCollection
Definition: Vertex.h:31
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
std::vector< double > etabins_
float energy() const
Definition: TriggerObject.h:61
std::vector< unsigned int > * t_DetIds
const std::string names[nVars_]
const edm::EDGetTokenT< reco::BeamSpot > tok_bs_
std::vector< double > * t_HitEnergies1
void analyze(edm::Event const &, edm::EventSetup const &) override
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > tok_caloTopology_
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
const Item * getValues(DetId fId, bool throwOnFail=true) const
const edm::InputTag extTag_
const edm::InputTag algTag_
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double pt() const
track transverse momentum
Definition: TrackBase.h:637
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
char const * label
const EcalPFRecHitThresholds * eThresholds_
const edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
double chargeIsolationEcal(unsigned int trkIndex, std::vector< spr::propagatedTrackID > &vdetIds, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, bool debug=false)
int iEvent
Definition: GenABIO.cc:224
std::vector< double > * t_HitEnergies3
RunNumber_t run() const
Definition: RunBase.h:40
const std::string labelGenTrack_
dictionary corr
double trackP(const reco::Track *, const edm::Handle< reco::GenParticleCollection > &)
std::array< int, 3 > fillTree(std::vector< math::XYZTLorentzVector > &vecL1, std::vector< math::XYZTLorentzVector > &vecL3, math::XYZPoint &leadPV, std::vector< spr::propagatedTrackDirection > &trkCaloDirections, std::vector< spr::propagatedTrackID > &trkCaloDets, const CaloGeometry *geo, const CaloTopology *topo, const HcalTopology *theHBHETopology, const EcalChannelStatus *theEcalChStatus, const EcalSeverityLevelAlgo *theEcalSevlv, edm::Handle< EcalRecHitCollection > &barrelRecHitsHandle, edm::Handle< EcalRecHitCollection > &endcapRecHitsHandle, edm::Handle< HBHERecHitCollection > &hbhe, edm::Handle< CaloTowerCollection > &towerHandle, edm::Handle< reco::GenParticleCollection > &genParticles, const HcalRespCorrs *respCorrs, const edm::Handle< reco::MuonCollection > &muonh)
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
unsigned int size() const
number of trigger paths in trigger table
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
std::vector< double > vec1
Definition: HCALResponse.h:15
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
l1t::L1TGlobalUtil * l1GtUtils_
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< bool > * t_hltbits
const edm::EDGetTokenT< reco::GenParticleCollection > tok_parts_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Transition
Definition: Transition.h:12
int id() const
getters
Definition: TriggerObject.h:51
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
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)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
static std::string const triggerResults
Definition: EdmProvDump.cc:47
HLTConfigProvider hltConfig_
const std::string l3Filter_
#define M_PI
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
const edm::ESGetToken< HcalRespCorrs, HcalRespCorrsRcd > tok_resp_
const edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
std::vector< bool > * t_trgbits
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
const double slopeRestrictionP_
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
Definition: DetId.h:17
const std::vector< int > debEvents_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:126
const std::string l2Filter_
const edm::EDGetTokenT< trigger::TriggerEvent > tok_trigEvt_
const std::string processName_
const edm::EDGetTokenT< reco::MuonCollection > tok_Muon_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< size_type > Keys
const edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
const std::string labelEB_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:646
std::vector< double > phibins_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double rhoh(const edm::Handle< CaloTowerCollection > &)
double dR(math::XYZTLorentzVector &, math::XYZTLorentzVector &)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tok_bFieldH_
const edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< int > oldDet_
const edm::InputTag theTriggerResultsLabel_
bool isValid() const
Definition: HandleBase.h:70
void endRun(edm::Run const &, edm::EventSetup const &) override
fixed size matrix
HLT enums.
HcalIsoTrkAnalyzer(edm::ParameterSet const &)
const edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > tok_ecalChStatus_
const HcalDDDRecConstants * hdc_
reco::TrackBase::TrackQuality minQuality
const edm::EDGetTokenT< BXVector< GlobalAlgBlk > > tok_alg_
const edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_ddrec_
const std::vector< std::pair< std::string, bool > > & decisionsFinal()
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
std::vector< unsigned int > * t_DetIds1
const std::string prdnam_
Definition: tree.py:1
const std::vector< int > newDepth_
const edm::InputTag triggerEvent_
Log< level::Warning, false > LogWarning
std::vector< int > * t_ietaGood
void beginJob() override
std::vector< vec1 > vec2
Definition: HCALResponse.h:16
std::vector< unsigned int > * t_DetIds3
double eThreshold(const DetId &id, const CaloGeometry *geo) const
const std::vector< int > oldID_
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
int events
const std::string labelEE_
const std::string labelMuon_
void retrieveL1(const edm::Event &iEvent, const edm::EventSetup &evSetup)
initialize the class (mainly reserve)
Definition: Run.h:45
bool notaMuon(const reco::Track *pTrack0, const edm::Handle< reco::MuonCollection > &muonh)
DetId newId(const DetId &)
const std::string l1Filter_
double eECALmatrix(const DetId &detId, edm::Handle< T > &hitsEB, edm::Handle< T > &hitsEE, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)
double eHCALmatrix(const HcalTopology *topology, const DetId &det, edm::Handle< T > &hits, int ieta, int iphi, bool includeHO=false, bool algoNew=true, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int useRaw=0, bool debug=false)
const std::string theTrackQuality_
std::vector< int > * t_trackType
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164