CMS 3D CMS Logo

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