CMS 3D CMS Logo

HcalHBHEMuonAnalyzer.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <iostream>
3 #include <fstream>
4 #include <vector>
5 #include <TFile.h>
6 #include <TTree.h>
7 #include "TPRegexp.h"
8 
9 // user include files
19 
27 
29 
39 
42 
45 
49 
53 
57 
69 
70 //#define EDM_ML_DEBUG
71 
72 class HcalHBHEMuonAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchRuns,edm::one::SharedResources> {
73 
74 public:
75  explicit HcalHBHEMuonAnalyzer(const edm::ParameterSet&);
76 
77  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
78 
79 private:
80  void beginJob() override;
81  void analyze(edm::Event const&, edm::EventSetup const&) override;
82  void beginRun(edm::Run const&, edm::EventSetup const&) override;
83  void endRun(edm::Run const&, edm::EventSetup const&) override {}
86  void clearVectors();
87  int matchId(const HcalDetId&, const HcalDetId&);
88  double activeLength(const DetId&);
89  bool isGoodVertex(const reco::Vertex& vtx);
90  double respCorr(const DetId& id);
91  double gainFactor(const edm::ESHandle<HcalDbService>&, const HcalDetId& id);
92  int depth16HE(int ieta, int iphi);
93 
94  // ----------member data ---------------------------
100  std::vector<std::string> triggers_;
105  static const int depthMax_=7;
109 
117 
120  std::vector<double> ptGlob_, etaGlob_, phiGlob_, chiGlobal_;
124  std::vector<double> matchedId_,numPixelLayers_;
125  std::vector<double> chiTracker_,dxyTracker_,dzTracker_;
129  std::vector<bool> innerTrack_, outerTrack_, globalTrack_;
130  std::vector<double> isolationR04_,isolationR03_;
133  std::vector<unsigned int> ecalDetId_,hcalDetId_,ehcalDetId_;
134  std::vector<double> hcalDepthEnergy_[depthMax_];
135  std::vector<double> hcalDepthActiveLength_[depthMax_];
136  std::vector<double> hcalDepthEnergyHot_[depthMax_];
137  std::vector<double> hcalDepthActiveLengthHot_[depthMax_];
138  std::vector<double> hcalDepthChargeHot_[depthMax_];
139  std::vector<double> hcalDepthChargeHotBG_[depthMax_];
140  std::vector<double> hcalDepthEnergyCorr_[depthMax_];
141  std::vector<double> hcalDepthEnergyHotCorr_[depthMax_];
143  std::vector<HcalDDDRecConstants::HcalActiveLength> actHB, actHE;
144  std::vector<std::string> all_triggers;
145  std::map<DetId,double> corrValue_;
147 
148  TTree *tree_;
150  std::vector<int> hltresults;
152 };
153 
155 
156  usesResource(TFileService::kSharedResource);
157  //now do what ever initialization is needed
158  kount_ = 0;
159  HLTriggerResults_ = iConfig.getParameter<edm::InputTag>("HLTriggerResults");
160  labelBS_ = iConfig.getParameter<std::string>("LabelBeamSpot");
161  labelVtx_ = iConfig.getParameter<std::string>("LabelVertex");
162  labelEBRecHit_ = iConfig.getParameter<edm::InputTag>("LabelEBRecHit");
163  labelEERecHit_ = iConfig.getParameter<edm::InputTag>("LabelEERecHit");
164  labelHBHERecHit_ = iConfig.getParameter<edm::InputTag>("LabelHBHERecHit");
165  labelMuon_ = iConfig.getParameter<std::string>("LabelMuon");
166  triggers_ = iConfig.getParameter<std::vector<std::string>>("Triggers");
167  useRaw_ = iConfig.getParameter<bool>("UseRaw");
168  unCorrect_ = iConfig.getParameter<bool>("UnCorrect");
169  getCharge_ = iConfig.getParameter<bool>("GetCharge");
170  collapseDepth_ = iConfig.getParameter<bool>("CollapseDepth");
171  isItPlan1_ = iConfig.getParameter<bool>("IsItPlan1");
172  ignoreHECorr_ = iConfig.getUntrackedParameter<bool>("IgnoreHECorr",false);
173  isItPreRecHit_ = iConfig.getUntrackedParameter<bool>("IsItPreRecHit",false);
174  verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
175  maxDepth_ = iConfig.getUntrackedParameter<int>("MaxDepth",4);
176  if (maxDepth_ > depthMax_) maxDepth_ = depthMax_;
177  else if (maxDepth_ < 1) maxDepth_ = 4;
178  std::string modnam = iConfig.getUntrackedParameter<std::string>("ModuleName","");
179  std::string procnm = iConfig.getUntrackedParameter<std::string>("ProcessName","");
180  fileInCorr_ = iConfig.getUntrackedParameter<std::string>("FileInCorr","");
181  writeRespCorr_ = iConfig.getUntrackedParameter<bool>("WriteRespCorr",false);
182 
183  mergedDepth_ = (!isItPreRecHit_) || (collapseDepth_);
184  tok_trigRes_ = consumes<edm::TriggerResults>(HLTriggerResults_);
185  tok_bs_ = consumes<reco::BeamSpot>(labelBS_);
186  tok_EB_ = consumes<EcalRecHitCollection>(labelEBRecHit_);
187  tok_EE_ = consumes<EcalRecHitCollection>(labelEERecHit_);
188  tok_HBHE_ = consumes<HBHERecHitCollection>(labelHBHERecHit_);
189  if (modnam == "") {
190  tok_Vtx_ = consumes<reco::VertexCollection>(labelVtx_);
191  tok_Muon_ = consumes<reco::MuonCollection>(labelMuon_);
192  edm::LogVerbatim("HBHEMuon") << "Labels used: Trig " << HLTriggerResults_
193  << " Vtx " << labelVtx_ << " EB "
194  << labelEBRecHit_ << " EE "
195  << labelEERecHit_ << " HBHE "
196  << labelHBHERecHit_ << " MU " << labelMuon_;
197  } else {
198  tok_Vtx_ = consumes<reco::VertexCollection>(edm::InputTag(modnam,labelVtx_,procnm));
199  tok_Muon_ = consumes<reco::MuonCollection>(edm::InputTag(modnam,labelMuon_,procnm));
200  edm::LogVerbatim("HBHEMuon") << "Labels used Trig " << HLTriggerResults_
201  << "\n Vtx " << edm::InputTag(modnam,labelVtx_,procnm)
202  << "\n EB " << labelEBRecHit_
203  << "\n EE " << labelEERecHit_
204  << "\n HBHE " << labelHBHERecHit_
205  << "\n MU " << edm::InputTag(modnam,labelMuon_,procnm);
206  }
207 
208  if (fileInCorr_ != "") {
209  std::ifstream infile(fileInCorr_.c_str());
210  if (infile.is_open()) {
211  while (true) {
212  unsigned int id;
213  double cfac;
214  infile >> id >> cfac;
215  if (!infile.good()) break;
216  corrValue_[DetId(id)] = cfac;
217  }
218  infile.close();
219  }
220  }
221  useMyCorr_ = (!corrValue_.empty());
222  edm::LogVerbatim("HBHEMuon") << "Flags used: UseRaw " << useRaw_
223  << " GetCharge " << getCharge_ << " UnCorrect "
224  << unCorrect_ << " IgnoreHECorr "
225  << ignoreHECorr_ << " CollapseDepth "
226  << collapseDepth_ << ":" << mergedDepth_
227  << " IsItPlan1 " << isItPlan1_
228  << " IsItPreRecHit " << isItPreRecHit_
229  << " UseMyCorr " << useMyCorr_;
230 }
231 
232 //
233 // member functions
234 //
235 
236 // ------------ method called for each event ------------
238  ++kount_;
239  clearVectors();
240  runNumber_ = iEvent.id().run();
241  eventNumber_ = iEvent.id().event();
242  lumiNumber_ = iEvent.id().luminosityBlock();
243  bxNumber_ = iEvent.bunchCrossing();
244 #ifdef EDM_ML_DEBUG
245  edm::LogVerbatim("HBHEMuon") << "Run " << runNumber_ << " Event "
246  << eventNumber_ << " Lumi " << lumiNumber_
247  << " BX " << bxNumber_ << std::endl;
248 #endif
250  iEvent.getByToken(tok_trigRes_, _Triggers);
251 #ifdef EDM_ML_DEBUG
252  if ((verbosity_/10000)%10>0)
253  edm::LogVerbatim("HBHEMuon") << "Size of all triggers "
254  << all_triggers.size() << std::endl;
255 #endif
256  int Ntriggers = all_triggers.size();
257 #ifdef EDM_ML_DEBUG
258  if ((verbosity_/10000)%10>0)
259  edm::LogVerbatim("HBHEMuon") << "Size of HLT MENU: " << _Triggers->size()
260  << std::endl;
261 #endif
262  if (_Triggers.isValid()) {
263  const edm::TriggerNames &triggerNames_ = iEvent.triggerNames(*_Triggers);
264  std::vector<int> index;
265  for (int i=0; i<Ntriggers; i++) {
266  index.push_back(triggerNames_.triggerIndex(all_triggers[i]));
267  int triggerSize = int( _Triggers->size());
268 #ifdef EDM_ML_DEBUG
269  if ((verbosity_/10000)%10>0)
270  edm::LogVerbatim("HBHEMuon") << "outside loop " << index[i]
271  << "\ntriggerSize " << triggerSize
272  << std::endl;
273 #endif
274  if (index[i] < triggerSize) {
275  hltresults.push_back(_Triggers->accept(index[i]));
276 #ifdef EDM_ML_DEBUG
277  if ((verbosity_/10000)%10>0)
278  edm::LogVerbatim("HBHEMuon") << "Trigger_info " << triggerSize
279  << " triggerSize " << index[i]
280  << " trigger_index " << hltresults.at(i)
281  << " hltresult" << std::endl;
282 #endif
283  } else {
284  if ((verbosity_/10000)%10>0)
285  edm::LogVerbatim("HBHEMuon") << "Requested HLT path \""
286  << "\" does not exist\n";
287  }
288  }
289  }
290 
291  // get handles to calogeometry and calotopology
293  iSetup.get<CaloGeometryRecord>().get(pG);
294  const CaloGeometry* geo = pG.product();
295 
297  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
298  const MagneticField* bField = bFieldH.product();
299 
301  iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
302  const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
303 
305  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
306 
307  edm::ESHandle<CaloTopology> theCaloTopology;
308  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
309  const CaloTopology *caloTopology = theCaloTopology.product();
310 
311  edm::ESHandle<HcalDbService> conditions;
312  iSetup.get<HcalDbRecord>().get(conditions);
313 
314  // Relevant blocks from iEvent
316  iEvent.getByToken(tok_Vtx_, vtx);
317  edm::Handle<reco::BeamSpot> beamSpotH;
318  iEvent.getByToken(tok_bs_, beamSpotH);
319 
320  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
321  iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
322  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
323  iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
324 
326  iEvent.getByToken(tok_HBHE_, hbhe);
327 
329  iEvent.getByToken(tok_Muon_, _Muon);
330 
331  // require a good vertex
332  math::XYZPoint pvx;
333  bool goodVtx(false);
334  if (vtx.isValid()) {
335  reco::VertexCollection::const_iterator firstGoodVertex = vtx->end();
336  for (reco::VertexCollection::const_iterator it = vtx->begin();
337  it != firstGoodVertex; it++) {
338  if (isGoodVertex(*it)) {
339  firstGoodVertex = it;
340  break;
341  }
342  }
343  if (firstGoodVertex != vtx->end()) {
344  pvx = firstGoodVertex->position();
345  goodVtx = true;
346  }
347  }
348  if (!goodVtx) {
349  if (beamSpotH.isValid()) {
350  pvx = beamSpotH->position();
351  goodVtx = true;
352  }
353  }
354  if (!goodVtx) {
355 #ifdef EDM_ML_DEBUG
356  edm::LogVerbatim("HBHEMuon") << "No Good Vertex found == Reject\n";
357 #endif
358  return;
359  }
360 
361  bool accept(false);
362  if (_Muon.isValid() && barrelRecHitsHandle.isValid() &&
363  endcapRecHitsHandle.isValid() && hbhe.isValid()) {
364  for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon!= _Muon->end(); ++RecMuon) {
365 
366  if ((RecMuon->p()>10.0) && (RecMuon->track().isNonnull())) accept = true;
367 
368  muon_is_good_.push_back(RecMuon->isPFMuon());
369  muon_global_.push_back(RecMuon->isGlobalMuon());
370  muon_tracker_.push_back(RecMuon->isTrackerMuon());
371  ptGlob_.push_back((RecMuon)->pt());
372  etaGlob_.push_back(RecMuon->eta());
373  phiGlob_.push_back(RecMuon->phi());
374  energyMuon_.push_back(RecMuon->energy());
375  pMuon_.push_back(RecMuon->p());
376 #ifdef EDM_ML_DEBUG
377  edm::LogVerbatim("HBHEMuon") << "Energy:" << RecMuon->energy() << " P:"
378  << RecMuon->p() << std::endl;
379 #endif
380  muon_trkKink.push_back(RecMuon->combinedQuality().trkKink);
381  muon_chi2LocalPosition.push_back(RecMuon->combinedQuality().chi2LocalPosition);
382  muon_segComp.push_back(muon::segmentCompatibility(*RecMuon));
383  // acessing tracker hits info
384  if (RecMuon->track().isNonnull()) {
385  trackerLayer_.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement());
386  } else {
387  trackerLayer_.push_back(-1);
388  }
389  if (RecMuon->innerTrack().isNonnull()) {
390  innerTrack_.push_back(true);
391  numPixelLayers_.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
392  chiTracker_.push_back(RecMuon->innerTrack()->normalizedChi2());
393  dxyTracker_.push_back(fabs(RecMuon->innerTrack()->dxy(pvx)));
394  dzTracker_.push_back(fabs(RecMuon->innerTrack()->dz(pvx)));
395  innerTrackpt_.push_back(RecMuon->innerTrack()->pt());
396  innerTracketa_.push_back(RecMuon->innerTrack()->eta());
397  innerTrackphi_.push_back(RecMuon->innerTrack()->phi());
398  tight_PixelHits_.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
399  tight_validFraction_.push_back(RecMuon->innerTrack()->validFraction());
400  } else {
401  innerTrack_.push_back(false);
402  numPixelLayers_.push_back(0);
403  chiTracker_.push_back(0);
404  dxyTracker_.push_back(0);
405  dzTracker_.push_back(0);
406  innerTrackpt_.push_back(0);
407  innerTracketa_.push_back(0);
408  innerTrackphi_.push_back(0);
409  tight_PixelHits_.push_back(0);
410  tight_validFraction_.push_back(-99);
411  }
412  // outer track info
413  if (RecMuon->outerTrack().isNonnull()) {
414  outerTrack_.push_back(true);
415  outerTrackPt_.push_back(RecMuon->outerTrack()->pt());
416  outerTrackEta_.push_back(RecMuon->outerTrack()->eta());
417  outerTrackPhi_.push_back(RecMuon->outerTrack()->phi());
418  outerTrackChi_.push_back(RecMuon->outerTrack()->normalizedChi2());
419  outerTrackHits_.push_back(RecMuon->outerTrack()->numberOfValidHits());
420  outerTrackRHits_.push_back(RecMuon->outerTrack()->recHitsSize());
421  } else {
422  outerTrack_.push_back(false);
423  outerTrackPt_.push_back(0);
424  outerTrackEta_.push_back(0);
425  outerTrackPhi_.push_back(0);
426  outerTrackChi_.push_back(0);
427  outerTrackHits_.push_back(0);
428  outerTrackRHits_.push_back(0);
429  }
430  // Tight Muon cuts
431  if (RecMuon->globalTrack().isNonnull()) {
432  globalTrack_.push_back(true);
433  chiGlobal_.push_back(RecMuon->globalTrack()->normalizedChi2());
434  globalMuonHits_.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
435  matchedStat_.push_back(RecMuon->numberOfMatchedStations());
436  globalTrckPt_.push_back(RecMuon->globalTrack()->pt());
437  globalTrckEta_.push_back(RecMuon->globalTrack()->eta());
438  globalTrckPhi_.push_back(RecMuon->globalTrack()->phi());
439  tight_TransImpara_.push_back(fabs(RecMuon->muonBestTrack()->dxy(pvx)));
440  tight_LongPara_.push_back(fabs(RecMuon->muonBestTrack()->dz(pvx)));
441  } else {
442  globalTrack_.push_back(false);
443  chiGlobal_.push_back(0);
444  globalMuonHits_.push_back(0);
445  matchedStat_.push_back(0);
446  globalTrckPt_.push_back(0);
447  globalTrckEta_.push_back(0);
448  globalTrckPhi_.push_back(0);
449  tight_TransImpara_.push_back(0);
450  tight_LongPara_.push_back(0);
451  }
452 
453  isolationR04_.push_back(((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()) );
454 
455  isolationR03_.push_back(((RecMuon->pfIsolationR03().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt - (0.5 * RecMuon->pfIsolationR03().sumPUPt))) / RecMuon->pt()));
456 
457  ecalEnergy_.push_back(RecMuon->calEnergy().emS9);
458  hcalEnergy_.push_back(RecMuon->calEnergy().hadS9);
459  hoEnergy_.push_back(RecMuon->calEnergy().hoS9);
460 
461  double eEcal(0), eHcal(0), activeLengthTot(0), activeLengthHotTot(0);
462  double eHcalDepth[depthMax_], eHcalDepthHot[depthMax_];
463  double eHcalDepthC[depthMax_], eHcalDepthHotC[depthMax_];
464  double cHcalDepthHot[depthMax_], cHcalDepthHotBG[depthMax_];
465  double activeL[depthMax_], activeHotL[depthMax_];
466  HcalDetId eHcalDetId[depthMax_];
467  unsigned int isHot(0);
468  bool tmpmatch(false);
469  for (int i=0; i<depthMax_; ++i) {
470  eHcalDepth[i] = eHcalDepthHot[i] = 0;
471  eHcalDepthC[i] = eHcalDepthHotC[i] = 0;
472  cHcalDepthHot[i] = cHcalDepthHotBG[i]= 0;
473  activeL[i] = activeHotL[i] = 0;
474  }
475  if (RecMuon->innerTrack().isNonnull()) {
476  const reco::Track* pTrack = (RecMuon->innerTrack()).get();
477  spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, (((verbosity_/100)%10>0)));
478 
479  ecalDetId_.push_back((trackID.detIdECAL)());
480  hcalDetId_.push_back((trackID.detIdHCAL)());
481  ehcalDetId_.push_back((trackID.detIdEHCAL)());
482 
484  std::pair<bool,HcalDetId> info = spr::propagateHCALBack(pTrack, geo, bField, (((verbosity_/100)%10>0)));
485  if (info.first) {
486  check = info.second;
487  }
488 
489  bool okE = trackID.okECAL;
490  if (okE) {
491  const DetId isoCell(trackID.detIdECAL);
492  std::pair<double,bool> e3x3 = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle,*theEcalChStatus,geo,caloTopology,sevlv.product(),1,1,-100.0,-100.0,-500.0,500.0,false);
493  eEcal = e3x3.first;
494  okE = e3x3.second;
495  }
496 #ifdef EDM_ML_DEBUG
497  edm::LogVerbatim("HBHEMuon") << "Propagate Track to ECAL: " << okE
498  << ":" << trackID.okECAL << " E "
499  << eEcal << std::endl;
500 #endif
501 
502  if (trackID.okHCAL) {
503  DetId closestCell(trackID.detIdHCAL);
504  HcalDetId hcidt(closestCell.rawId());
505  if ((hcidt.ieta() == check.ieta()) && (hcidt.iphi() == check.iphi()))
506  tmpmatch = true;
507 
508  HcalSubdetector subdet = hcidt.subdet();
509  int ieta = hcidt.ieta();
510  int iphi = hcidt.iphi();
511  bool hborhe = (std::abs(ieta) == 16);
512 
513  eHcal = spr::eHCALmatrix(theHBHETopology_, closestCell, hbhe,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.,useRaw_);
514  std::vector<std::pair<double,int> > ehdepth;
515  spr::energyHCALCell((HcalDetId)closestCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depth16HE(ieta,iphi), (((verbosity_/1000)%10)>0));
516  for (int i=0; i<depthMax_; ++i) eHcalDetId[i] = HcalDetId();
517  for (unsigned int i=0; i<ehdepth.size(); ++i) {
518  HcalSubdetector subdet0 = (hborhe) ? ((ehdepth[i].second >= depth16HE(ieta,iphi)) ? HcalEndcap : HcalBarrel) : subdet;
519  HcalDetId hcid0(subdet0,ieta,iphi,ehdepth[i].second);
520  double actL = activeLength(DetId(hcid0));
521  double ene = ehdepth[i].first;
522  if (ene > 0.00001) {
523  if (!(theHBHETopology_->validHcal(hcid0))) {
524  edm::LogWarning("HBHEMuon") << "(1) Invalid ID " << hcid0
525  << " with E = " << ene;
526  edm::LogWarning("HBHEMuon") << HcalDetId(closestCell)
527  << " with " << ehdepth.size()
528  << " depths:";
529  for (const auto& ehd : ehdepth)
530  edm::LogWarning("HBHEMuon") << " " << ehd.second << ":"
531  << ehd.first;
532  } else {
533  double enec(ene);
534  if (unCorrect_) {
535  double corr = (ignoreHECorr_ && (subdet0==HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0));
536  if (corr != 0) ene /= corr;
537 #ifdef EDM_ML_DEBUG
538  HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0;
539  edm::LogVerbatim("HBHEMuon") << hcid0 << ":" << id << " Corr "
540  << corr;
541 #endif
542  }
543  int depth = ehdepth[i].second - 1;
544  if (collapseDepth_) {
545  HcalDetId id = hdc_->mergedDepthDetId(hcid0);
546  depth = id.depth() - 1;
547  }
548  eHcalDepth[depth] += ene;
549  eHcalDepthC[depth]+= enec;
550  activeL[depth] += actL;
551  activeLengthTot += actL;
552 #ifdef EDM_ML_DEBUG
553  if ((verbosity_%10) > 0)
554  edm::LogVerbatim("HBHEMuon") << hcid0 << " E " << ene << ":"
555  << enec << " L " << actL;
556 #endif
557  }
558  }
559  }
560 
561  HcalDetId hotCell;
562  spr::eHCALmatrix(geo, theHBHETopology_, closestCell, hbhe, 1,1, hotCell, false, useRaw_, false);
563  isHot = matchId(closestCell,hotCell);
564  if (hotCell != HcalDetId()) {
565  subdet = HcalDetId(hotCell).subdet();
566  ieta = HcalDetId(hotCell).ieta();
567  iphi = HcalDetId(hotCell).iphi();
568  hborhe = (std::abs(ieta) == 16);
569  std::vector<std::pair<double,int> > ehdepth;
570  spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depth16HE(ieta,iphi), false);//(((verbosity_/1000)%10)>0 ));
571  for (int i=0; i<depthMax_; ++i) eHcalDetId[i] = HcalDetId();
572  for (unsigned int i=0; i<ehdepth.size(); ++i) {
573  HcalSubdetector subdet0 = (hborhe) ? ((ehdepth[i].second >= depth16HE(ieta,iphi)) ? HcalEndcap : HcalBarrel) : subdet;
574  HcalDetId hcid0(subdet0,ieta,iphi,ehdepth[i].second);
575  double actL = activeLength(DetId(hcid0));
576  double ene = ehdepth[i].first;
577  if (ene > 0.00001) {
578  if (!(theHBHETopology_->validHcal(hcid0))) {
579  edm::LogWarning("HBHEMuon") << "(2) Invalid ID " << hcid0
580  << " with E = " << ene;
581  edm::LogWarning("HBHEMuon") << HcalDetId(hotCell)
582  << " with " << ehdepth.size()
583  << " depths:";
584  for (const auto& ehd : ehdepth)
585  edm::LogWarning("HBHEMuon") << " " << ehd.second << ":"
586  << ehd.first;
587  } else {
588  double chg(ene), enec(ene);
589  if (unCorrect_) {
590  double corr = (ignoreHECorr_ && (subdet0==HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0));
591  if (corr != 0) {ene /= corr; chg /= corr;}
592 #ifdef EDM_ML_DEBUG
593  HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0;
594  edm::LogVerbatim("HBHEMuon") << hcid0 << ":" << id
595  << " Corr " << corr << " E "
596  << ene << ":" << enec;
597 #endif
598  }
599  if (getCharge_) {
600  double gain = gainFactor(conditions,hcid0);
601  if (gain != 0) chg /= gain;
602 #ifdef EDM_ML_DEBUG
603  edm::LogVerbatim("HBHEMuon") << hcid0 << " Gain " << gain
604  << " C " << chg;
605 #endif
606  }
607  int depth = ehdepth[i].second - 1;
608  if (collapseDepth_) {
609  HcalDetId id = hdc_->mergedDepthDetId(hcid0);
610  depth = id.depth() - 1;
611  }
612  eHcalDepthHot[depth] += ene;
613  eHcalDepthHotC[depth] += enec;
614  cHcalDepthHot[depth] += chg;
615  activeHotL[depth] += actL;
616  activeLengthHotTot += actL;
617 #ifdef EDM_ML_DEBUG
618  if ((verbosity_%10) > 0)
619  edm::LogVerbatim("HBHEMuon") << hcid0 << " depth " << depth
620  << " E " << ene << ":" << enec
621  << " C " << chg << " L "
622  << actL;
623 #endif
624  }
625  }
626  }
627 
628  HcalDetId oppCell(subdet,-ieta,iphi,HcalDetId(hotCell).depth());
629  std::vector<std::pair<double,int> > ehdeptho;
630  spr::energyHCALCell(oppCell, hbhe, ehdeptho, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depth16HE(-ieta,iphi), false); //(((verbosity_/1000)%10)>0));
631  for (unsigned int i=0; i<ehdeptho.size(); ++i) {
632  HcalSubdetector subdet0 = (hborhe) ? ((ehdeptho[i].second >= depth16HE(-ieta,iphi)) ? HcalEndcap : HcalBarrel) : subdet;
633  HcalDetId hcid0(subdet0,-ieta,iphi,ehdeptho[i].second);
634  double ene = ehdeptho[i].first;
635  if (ene > 0.001) {
636  if (!(theHBHETopology_->validHcal(hcid0))) {
637  edm::LogWarning("HBHEMuon") << "(3) Invalid ID " << hcid0
638  << " with E = " << ene;
639  edm::LogWarning("HBHEMuon") << oppCell << " with "
640  << ehdeptho.size() << " depths:";
641  for (const auto& ehd : ehdeptho)
642  edm::LogWarning("HBHEMuon") << " " << ehd.second << ":"
643  << ehd.first;
644  } else {
645  double chg(ene);
646  if (unCorrect_) {
647  double corr = (ignoreHECorr_ && (subdet0==HcalEndcap)) ? 1.0 : respCorr(DetId(hcid0));
648  if (corr != 0) {ene /= corr; chg /= corr;}
649 #ifdef EDM_ML_DEBUG
650  HcalDetId id = (isItPlan1_ && isItPreRecHit_) ? hdc_->mergedDepthDetId(hcid0) : hcid0;
651  edm::LogVerbatim("HBHEMuon") << hcid0 << ":" << id
652  << " Corr " << corr << " E "
653  << ene << ":"
654  << ehdeptho[i].first;
655 #endif
656  }
657  if (getCharge_) {
658  double gain = gainFactor(conditions,hcid0);
659  if (gain != 0) chg /= gain;
660 #ifdef EDM_ML_DEBUG
661  edm::LogVerbatim("HBHEMuon") << hcid0 << " Gain " << gain
662  << " C " << chg;
663 #endif
664  }
665  int depth = ehdeptho[i].second - 1;
666  if (collapseDepth_) {
667  HcalDetId id = hdc_->mergedDepthDetId(hcid0);
668  depth = id.depth() - 1;
669  }
670  cHcalDepthHotBG[depth] += chg;
671 #ifdef EDM_ML_DEBUG
672  if ((verbosity_%10) > 0)
673  edm::LogVerbatim("HBHEMuon") << hcid0 << " Depth " << depth
674  << " E " << ene << " C "
675  << chg;
676 #endif
677  }
678  }
679  }
680  }
681  }
682 #ifdef EDM_ML_DEBUG
683  edm::LogVerbatim("HBHEMuon") << "Propagate Track to HCAL: "
684  << trackID.okHCAL << " Match " << tmpmatch
685  << " Hot " << isHot << " Energy "
686  << eHcal << std::endl;
687 #endif
688 
689  } else {
690  ecalDetId_.push_back(0);
691  hcalDetId_.push_back(0);
692  ehcalDetId_.push_back(0);
693  }
694 
695  matchedId_.push_back(tmpmatch);
696  ecal3x3Energy_.push_back(eEcal);
697  hcal1x1Energy_.push_back(eHcal);
698  for (int i=0; i<depthMax_; ++i) {
699  hcalDepthEnergy_[i].push_back(eHcalDepth[i]);
700  hcalDepthActiveLength_[i].push_back(activeL[i]);
701  hcalDepthEnergyHot_[i].push_back(eHcalDepthHot[i]);
702  hcalDepthActiveLengthHot_[i].push_back(activeHotL[i]);
703  hcalDepthEnergyCorr_[i].push_back(eHcalDepthC[i]);
704  hcalDepthEnergyHotCorr_[i].push_back(eHcalDepthHotC[i]);
705  hcalDepthChargeHot_[i].push_back(cHcalDepthHot[i]);
706  hcalDepthChargeHotBG_[i].push_back(cHcalDepthHotBG[i]);
707  }
708  hcalActiveLength_.push_back(activeLengthTot);
709  hcalHot_.push_back(isHot);
710  hcalActiveLengthHot_.push_back(activeLengthHotTot);
711  }
712  }
713  if (accept) tree_->Fill();
714 }
715 
716 // ------------ method called once each job just before starting event loop ------------
718 
719  tree_ = fs->make<TTree>("TREE", "TREE");
720  tree_->Branch("Event_No", &eventNumber_);
721  tree_->Branch("Run_No", &runNumber_);
722  tree_->Branch("LumiNumber", &lumiNumber_);
723  tree_->Branch("BXNumber", &bxNumber_);
724  tree_->Branch("pt_of_muon", &ptGlob_);
725  tree_->Branch("eta_of_muon", &etaGlob_);
726  tree_->Branch("phi_of_muon", &phiGlob_);
727  tree_->Branch("energy_of_muon", &energyMuon_);
728  tree_->Branch("p_of_muon", &pMuon_);
729  tree_->Branch("PF_Muon", &muon_is_good_);
730  tree_->Branch("Global_Muon", &muon_global_);
731  tree_->Branch("Tracker_muon", &muon_tracker_);
732 
733  tree_->Branch("hcal_3into3", &hcalEnergy_);
734  tree_->Branch("hcal_1x1", &hcal1x1Energy_);
735  tree_->Branch("hcal_detID", &hcalDetId_);
736  tree_->Branch("hcal_cellHot", &hcalHot_);
737  tree_->Branch("activeLength", &hcalActiveLength_);
738  tree_->Branch("activeLengthHot", &hcalActiveLengthHot_);
739  char name[100];
740  for (int k=0; k<maxDepth_; ++k) {
741  sprintf (name, "hcal_edepth%d", (k+1));
742  tree_->Branch(name, &hcalDepthEnergy_[k]);
743  sprintf (name, "hcal_activeL%d", (k+1));
744  tree_->Branch(name, &hcalDepthActiveLength_[k]);
745  sprintf (name, "hcal_edepthHot%d", (k+1));
746  tree_->Branch(name, &hcalDepthEnergyHot_[k]);
747  sprintf (name, "hcal_activeHotL%d", (k+1));
748  tree_->Branch(name, &hcalDepthActiveLengthHot_[k]);
749  sprintf (name, "hcal_edepthCorrect%d", (k+1));
750  tree_->Branch(name, &hcalDepthEnergyCorr_[k]);
751  sprintf (name, "hcal_edepthHotCorrect%d", (k+1));
752  tree_->Branch(name, &hcalDepthEnergyHotCorr_[k]);
753  sprintf (name, "hcal_cdepthHot%d", (k+1));
754  tree_->Branch(name, &hcalDepthChargeHot_[k]);
755  sprintf (name, "hcal_cdepthHotBG%d", (k+1));
756  tree_->Branch(name, &hcalDepthChargeHotBG_[k]);
757  }
758 
759  tree_->Branch("TrackerLayer", &trackerLayer_);
760  tree_->Branch("matchedId", &matchedId_);
761  tree_->Branch("innerTrack", &innerTrack_);
762  tree_->Branch("innerTrackpt", &innerTrackpt_);
763  tree_->Branch("innerTracketa", &innerTracketa_);
764  tree_->Branch("innerTrackphi", &innerTrackphi_);
765  tree_->Branch("MatchedStat", &matchedStat_);
766  tree_->Branch("GlobalTrckPt", &globalTrckPt_);
767  tree_->Branch("GlobalTrckEta", &globalTrckEta_);
768  tree_->Branch("GlobalTrckPhi", &globalTrckPhi_);
769  tree_->Branch("NumPixelLayers", &numPixelLayers_);
770  tree_->Branch("chiTracker", &chiTracker_);
771  tree_->Branch("DxyTracker", &dxyTracker_);
772  tree_->Branch("DzTracker", &dzTracker_);
773  tree_->Branch("OuterTrack", &outerTrack_);
774  tree_->Branch("OuterTrackPt", &outerTrackPt_);
775  tree_->Branch("OuterTrackEta", &outerTrackEta_);
776  tree_->Branch("OuterTrackPhi", &outerTrackPhi_);
777  tree_->Branch("OuterTrackHits", &outerTrackHits_);
778  tree_->Branch("OuterTrackRHits", &outerTrackRHits_);
779  tree_->Branch("OuterTrackChi", &outerTrackChi_);
780  tree_->Branch("GlobalTrack", &globalTrack_);
781  tree_->Branch("GlobTrack_Chi", &chiGlobal_);
782  tree_->Branch("Global_Muon_Hits", &globalMuonHits_);
783  tree_->Branch("MatchedStations", &matchedStat_);
784  tree_->Branch("Global_Track_Pt", &globalTrckPt_);
785  tree_->Branch("Global_Track_Eta", &globalTrckEta_);
786  tree_->Branch("Global_Track_Phi", &globalTrckPhi_);
788  tree_->Branch("Tight_LongitudinalImpactparameter",&tight_LongPara_);
789  tree_->Branch("Tight_TransImpactparameter", &tight_TransImpara_);
790  tree_->Branch("InnerTrackPixelHits", &tight_PixelHits_);
791  tree_->Branch("IsolationR04", &isolationR04_);
792  tree_->Branch("IsolationR03", &isolationR03_);
793 
794  tree_->Branch("ecal_3into3", &ecalEnergy_);
795  tree_->Branch("ecal_3x3", &ecal3x3Energy_);
796  tree_->Branch("ecal_detID", &ecalDetId_);
797  tree_->Branch("ehcal_detID", &ehcalDetId_);
798  tree_->Branch("tracker_3into3", &hoEnergy_);
799 
801  tree_->Branch("hltresults", &hltresults);
802  tree_->Branch("all_triggers", &all_triggers);
803 
804  tree_->Branch("muon_trkKink", &muon_trkKink);
805  tree_->Branch("muon_chi2LocalPosition", &muon_chi2LocalPosition);
806  tree_->Branch("muon_segComp", &muon_segComp);
807  tree_->Branch("tight_validFraction", &tight_validFraction_);
808 }
809 
810 // ------------ method called when starting to processes a run ------------
811 void HcalHBHEMuonAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
812 
814  iSetup.get<HcalRecNumberingRecord>().get(pHRNDC);
815  hdc_ = pHRNDC.product();
816  actHB.clear();
817  actHE.clear();
818  actHB = hdc_->getThickActive(0);
819  actHE = hdc_->getThickActive(1);
820 #ifdef EDM_ML_DEBUG
821  unsigned int k1(0), k2(0);
822  edm::LogVerbatim("HBHEMuon") << actHB.size() << " Active Length for HB";
823  for (const auto& act : actHB) {
824  edm::LogVerbatim("HBHEMuon") << "[" << k1 << "] ieta " << act.ieta
825  << " depth " << act.depth << " zside "
826  << act.zside << " type " << act.stype
827  << " phi " << act.iphis.size() << ":"
828  << act.iphis[0] << " L " << act.thick;
829  HcalDetId hcid1(HcalBarrel,(act.ieta)*(act.zside),act.iphis[0],act.depth);
830  HcalDetId hcid2 = mergedDepth_ ? hdc_->mergedDepthDetId(hcid1) : hcid1;
831  edm::LogVerbatim("HBHEMuon") << hcid1 << " | " << hcid2 << " L "
832  << activeLength(DetId(hcid2));
833  ++k1;
834  }
835  edm::LogVerbatim("HBHEMuon") << actHE.size() << " Active Length for HE";
836  for (const auto& act : actHE) {
837  edm::LogVerbatim("HBHEMuon") << "[" << k2 << "] ieta " << act.ieta
838  << " depth " << act.depth << " zside "
839  << act.zside << " type " << act.stype
840  << " phi " << act.iphis.size() << ":"
841  << act.iphis[0] << " L " << act.thick;
842  HcalDetId hcid1(HcalEndcap,(act.ieta)*(act.zside),act.iphis[0],act.depth);
843  HcalDetId hcid2 = mergedDepth_ ? hdc_->mergedDepthDetId(hcid1) : hcid1;
844  edm::LogVerbatim("HBHEMuon") << hcid1 << " | " << hcid2 << " L "
845  << activeLength(DetId(hcid2));
846  ++k2;
847  }
848 #endif
849 
850  bool changed = true;
851  all_triggers.clear();
852  if (hltConfig_.init(iRun, iSetup,"HLT" , changed)) {
853  // if init returns TRUE, initialisation has succeeded!
854 #ifdef EDM_ML_DEBUG
855  edm::LogVerbatim("HBHEMuon") << "HLT config with process name "
856  << "HLT" << " successfully extracted"
857  << std::endl;
858 #endif
859  unsigned int ntriggers = hltConfig_.size();
860  for (unsigned int t=0;t<ntriggers;++t) {
862  for (unsigned int ik=0; ik<6; ++ik) {
863  if (hltname.find(triggers_[ik])!=std::string::npos ){
864  all_triggers.push_back(hltname);
865  break;
866  }
867  }
868  }//loop over ntriggers
869  edm::LogVerbatim("HBHEMuon") << "All triggers size in begin run "
870  << all_triggers.size() << std::endl;
871  } else {
872  edm::LogError("HBHEMuon") << "Error! HLT config extraction with process name "
873  << "HLT" << " failed";
874  }
875 
877  iSetup.get<HcalRecNumberingRecord>().get(htopo);
878  theHBHETopology_ = htopo.product();
879 
881  iSetup.get<HcalRespCorrsRcd>().get(resp);
882  respCorrs_ = new HcalRespCorrs(*resp.product());
884 
885  // Write correction factors for all HB/HE events
886  if (writeRespCorr_) {
888  iSetup.get<CaloGeometryRecord>().get(pG);
889  const CaloGeometry* geo = pG.product();
891  const std::vector<DetId>& ids = gHcal->getValidDetIds(DetId::Hcal,0);
892  edm::LogVerbatim("HBHEMuon") << "\nTable of Correction Factors for Run "
893  << iRun.run() << "\n";
894  for (auto const& id: ids) {
895  if ((id.det() == DetId::Hcal) &&
896  ((id.subdetId() == HcalBarrel) || (id.subdetId() == HcalEndcap))) {
897  edm::LogVerbatim("HBHEMuon") << HcalDetId(id) << " " << id.rawId() <<" "
898  << (respCorrs_->getValues(id))->getValue();
899  }
900  }
901  }
902 }
903 
904 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
907  desc.add<edm::InputTag>("HLTriggerResults",edm::InputTag("TriggerResults","","HLT"));
908  desc.add<std::string>("LabelBeamSpot","offlineBeamSpot");
909  desc.add<std::string>("LabelVertex","offlinePrimaryVertices");
910  desc.add<edm::InputTag>("LabelEBRecHit",edm::InputTag("ecalRecHit","EcalRecHitsEB"));
911  desc.add<edm::InputTag>("LabelEERecHit",edm::InputTag("ecalRecHit","EcalRecHitsEE"));
912  desc.add<edm::InputTag>("LabelHBHERecHit",edm::InputTag("hbhereco"));
913  desc.add<std::string>("LabelMuon","muons");
914 // std::vector<std::string> trig = {"HLT_IsoMu_","HLT_L1SingleMu_","HLT_L2Mu","HLT_Mu","HLT_RelIso1p0Mu"};
915  std::vector<std::string> trig = {"HLT_IsoMu17","HLT_IsoMu20",
916  "HLT_IsoMu24","HLT_IsoMu27",
917  "HLT_Mu45","HLT_Mu50"};
918  desc.add<std::vector<std::string>>("Triggers",trig);
919  desc.add<bool>("UseRaw",false);
920  desc.add<bool>("UnCorrect",false);
921  desc.add<bool>("GetCharge",false);
922  desc.add<bool>("CollapseDepth",false);
923  desc.add<bool>("IsItPlan1",false);
924  desc.addUntracked<bool>("IgnoreHECorr",false);
925  desc.addUntracked<bool>("IsItPreRecHit",false);
926  desc.addUntracked<std::string>("ModuleName","");
927  desc.addUntracked<std::string>("ProcessName","");
928  desc.addUntracked<int>("Verbosity",0);
929  desc.addUntracked<int>("MaxDepth",4);
930  desc.addUntracked<std::string>("FileInCorr","");
931  desc.addUntracked<bool>("WriteRespCorr",false);
932  descriptions.add("hcalHBHEMuon",desc);
933 }
934 
937  eventNumber_ = -99999;
938  runNumber_ = -99999;
939  lumiNumber_ = -99999;
940  bxNumber_ = -99999;
941  muon_is_good_.clear();
942  muon_global_.clear();
943  muon_tracker_.clear();
944  ptGlob_.clear();
945  etaGlob_.clear();
946  phiGlob_.clear();
947  energyMuon_.clear();
948  pMuon_.clear();
949  trackerLayer_.clear();
950  matchedId_.clear();
951  innerTrack_.clear();
952  numPixelLayers_.clear();
953  chiTracker_.clear();
954  dxyTracker_.clear();
955  dzTracker_.clear();
956  innerTrackpt_.clear();
957  innerTracketa_.clear();
958  innerTrackphi_.clear();
959  tight_PixelHits_.clear();
960  outerTrack_.clear();
961  outerTrackPt_.clear();
962  outerTrackEta_.clear();
963  outerTrackPhi_.clear();
964  outerTrackHits_.clear();
965  outerTrackRHits_.clear();
966  outerTrackChi_.clear();
967  globalTrack_.clear();
968  chiGlobal_.clear();
969  globalMuonHits_.clear();
970  matchedStat_.clear();
971  globalTrckPt_.clear();
972  globalTrckEta_.clear();
973  globalTrckPhi_.clear();
974  tight_TransImpara_.clear();
975  tight_LongPara_.clear();
976 
977  isolationR04_.clear();
978  isolationR03_.clear();
979  ecalEnergy_.clear();
980  hcalEnergy_.clear();
981  hoEnergy_.clear();
982  ecalDetId_.clear();
983  hcalDetId_.clear();
984  ehcalDetId_.clear();
985  ecal3x3Energy_.clear();
986  hcal1x1Energy_.clear();
987  hcalHot_.clear();
988  hcalActiveLengthHot_.clear();
989  for (int i=0; i<maxDepth_; ++i) {
990  hcalDepthEnergy_[i].clear();
991  hcalDepthActiveLength_[i].clear();
992  hcalDepthEnergyHot_[i].clear();
993  hcalDepthActiveLengthHot_[i].clear();
994  hcalDepthEnergyCorr_[i].clear();
995  hcalDepthEnergyHotCorr_[i].clear();
996  hcalDepthChargeHot_[i].clear();
997  hcalDepthChargeHotBG_[i].clear();
998  }
999  hltresults.clear();
1000  muon_trkKink.clear();
1001  muon_chi2LocalPosition.clear();
1002  muon_segComp.clear();
1003  tight_validFraction_.clear();
1004 }
1005 
1007 
1008  HcalDetId kd1(id1.subdet(),id1.ieta(),id1.iphi(),1);
1009  HcalDetId kd2(id2.subdet(),id2.ieta(),id2.iphi(),1);
1010  int match = ((kd1 == kd2) ? 1 : 0);
1011  return match;
1012 }
1013 
1015  HcalDetId id(id_);
1016  int ieta = id.ietaAbs();
1017  int zside= id.zside();
1018  int iphi = id.iphi();
1019  std::vector<int> dpths;
1020  if (mergedDepth_) {
1021  std::vector<HcalDetId> ids;
1022  hdc_->unmergeDepthDetId(id,ids);
1023  for (auto idh : ids)
1024  dpths.emplace_back(idh.depth());
1025  } else {
1026  dpths.emplace_back(id.depth());
1027  }
1028  double lx(0);
1029  if (id.subdet() == HcalBarrel) {
1030  for (unsigned int i=0; i<actHB.size(); ++i) {
1031  if ((ieta == actHB[i].ieta) && (zside == actHB[i].zside) &&
1032  (std::find(dpths.begin(),dpths.end(),actHB[i].depth) != dpths.end())&&
1033  (std::find(actHB[i].iphis.begin(),actHB[i].iphis.end(),iphi) !=
1034  actHB[i].iphis.end())) {
1035  lx += actHB[i].thick;
1036  }
1037  }
1038  } else {
1039  for (unsigned int i=0; i<actHE.size(); ++i) {
1040  if ((ieta == actHE[i].ieta) && (zside == actHE[i].zside) &&
1041  (std::find(dpths.begin(),dpths.end(),actHE[i].depth) != dpths.end())&&
1042  (std::find(actHE[i].iphis.begin(),actHE[i].iphis.end(),iphi) !=
1043  actHE[i].iphis.end())) {
1044  lx += actHE[i].thick;
1045  }
1046  }
1047  }
1048  return lx;
1049 }
1050 
1052  if (vtx.isFake()) return false;
1053  if (vtx.ndof() < 4) return false;
1054  if (vtx.position().Rho() > 2.) return false;
1055  if (fabs(vtx.position().Z()) > 24.) return false;
1056  return true;
1057 }
1058 
1060  double cfac(1.0);
1061  if (useMyCorr_) {
1062  auto itr = corrValue_.find(id);
1063  if (itr != corrValue_.end()) cfac = itr->second;
1064  } else if (respCorrs_ != nullptr) {
1065  cfac = (respCorrs_->getValues(id))->getValue();
1066  }
1067  return cfac;
1068 }
1069 
1071  double gain(0.0);
1072  const HcalCalibrations& calibs=conditions->getHcalCalibrations(id);
1073  for (int capid=0; capid<4; ++capid)
1074  gain += (0.25*calibs.respcorrgain(capid));
1075  return gain;
1076 }
1077 
1078 int HcalHBHEMuonAnalyzer::depth16HE(int ieta, int iphi) {
1079  // Transition between HB/HE is special
1080  // For Run 1 or for Plan1 standard reconstruction it is 3
1081  // For runs beyond 2018 or in Plan1 for HEP17 it is 4
1082  int zside = (ieta > 0) ? 1 : -1;
1083  int depth = theHBHETopology_->dddConstants()->getMinDepth(1,16,iphi,zside);
1084  if (isItPlan1_ && (!isItPreRecHit_)) depth = 3;
1085 #ifdef EDM_ML_DEBUG
1086  edm::LogVerbatim("HBHEMuon") << "Plan1 " << isItPlan1_ << " PreRecHit "
1087  << isItPreRecHit_ << " phi " << iphi
1088  << " depth " << depth;
1089 #endif
1090  return depth;
1091 }
1092 
1093 //define this as a plug-in
1095 
RunNumber_t run() const
Definition: EventID.h:39
unsigned int size() const
number of trigger paths in trigger table
static const std::string kSharedResource
Definition: TFileService.h:76
std::vector< double > tight_validFraction_
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
EventNumber_t event() const
Definition: EventID.h:41
std::vector< double > innerTrackphi_
HcalHBHEMuonAnalyzer(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
const HcalTopology * theHBHETopology_
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:161
static const TGPicture * info(bool iBackgroundIsBlack)
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
std::vector< double > hcalHot_
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
std::vector< std::string > triggers_
std::vector< double > dzTracker_
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
RunNumber_t run() const
Definition: RunBase.h:40
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void analyze(edm::Event const &, edm::EventSetup const &) override
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< double > muon_chi2LocalPosition
std::vector< double > outerTrackChi_
const float chg[109]
Definition: CoreSimTrack.cc:5
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
std::vector< double > matchedStat_
HcalDetId mergedDepthDetId(const HcalDetId &id) const
std::vector< double > hcalDepthChargeHotBG_[depthMax_]
std::vector< double > tight_LongPara_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< double > muon_trkKink
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
std::vector< unsigned int > ecalDetId_
const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const override
Get a list of valid detector ids (for the given subdetector)
Definition: HcalGeometry.cc:76
std::vector< double > pMuon_
bool accept() const
Has at least one path accepted the event?
std::vector< double > globalTrckPhi_
std::vector< double > outerTrackHits_
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, bool useRaw=false, bool debug=false)
int bunchCrossing() const
Definition: EventBase.h:66
double respCorr(const DetId &id)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
const Item * getValues(DetId fId, bool throwOnFail=true) const
std::vector< HcalDDDRecConstants::HcalActiveLength > actHE
bool validHcal(const HcalDetId &id) const
std::vector< double > isolationR03_
#define nullptr
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
const Point & position() const
position
Definition: Vertex.h:109
double gainFactor(const edm::ESHandle< HcalDbService > &, const HcalDetId &id)
std::vector< bool > muon_global_
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::vector< double > hcalDepthEnergy_[depthMax_]
std::vector< double > outerTrackPt_
std::map< DetId, double > corrValue_
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
U second(std::pair< T, U > const &p)
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
edm::EDGetTokenT< reco::VertexCollection > tok_Vtx_
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::vector< double > globalTrckPt_
int depth() const
get the tower depth
Definition: HcalDetId.cc:129
int iEvent
Definition: GenABIO.cc:230
std::vector< bool > muon_tracker_
std::vector< double > ecalEnergy_
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
spr::propagatedTrackDirection propagateHCALBack(unsigned int thisTrk, edm::Handle< edm::SimTrackContainer > &SimTk, edm::Handle< edm::SimVertexContainer > &SimVtx, const CaloGeometry *geo, const MagneticField *bField, bool debug=false)
std::vector< double > hcalActiveLengthHot_
std::vector< double > innerTracketa_
std::vector< double > globalTrckEta_
std::vector< double > isolationR04_
unsigned int size() const
Get number of paths stored.
std::vector< double > hcalDepthActiveLengthHot_[depthMax_]
std::vector< double > hcalDepthEnergyHotCorr_[depthMax_]
int getMinDepth(const int &itype, const int &ieta, const int &iphi, const int &zside) const
std::vector< double > ptGlob_
std::vector< unsigned int > ehcalDetId_
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
void energyHCALCell(HcalDetId detId, edm::Handle< T > &hits, std::vector< std::pair< double, int > > &energyCell, int maxDepth=1, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, bool useRaw=false, int depthHE=3, bool debug=false)
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > tight_PixelHits_
float segmentCompatibility(const reco::Muon &muon, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
std::vector< double > hcalEnergy_
std::vector< double > trackerLayer_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< double > outerTrackEta_
bool isValid() const
Definition: HandleBase.h:74
double activeLength(const DetId &)
std::vector< bool > globalTrack_
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< double > outerTrackRHits_
std::vector< double > hcal1x1Energy_
edm::EDGetTokenT< reco::MuonCollection > tok_Muon_
double ndof() const
Definition: Vertex.h:105
JetCorrectorParameters corr
Definition: classes.h:5
int k[5][pyjets_maxn]
std::vector< bool > muon_is_good_
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:124
Definition: DetId.h:18
std::vector< double > chiGlobal_
std::vector< HcalDDDRecConstants::HcalActiveLength > actHB
int depth16HE(int ieta, int iphi)
std::vector< unsigned int > hcalDetId_
bool isFake() const
Definition: Vertex.h:72
std::vector< double > hcalDepthEnergyHot_[depthMax_]
void endRun(edm::Run const &, edm::EventSetup const &) override
std::vector< int > hltresults
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::vector< double > hcalDepthEnergyCorr_[depthMax_]
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
const T & get() const
Definition: EventSetup.h:55
void unmergeDepthDetId(const HcalDetId &id, std::vector< HcalDetId > &ids) const
std::vector< std::string > all_triggers
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< double > globalMuonHits_
std::vector< double > hcalDepthActiveLength_[depthMax_]
std::vector< double > hoEnergy_
int matchId(const HcalDetId &, const HcalDetId &)
const HcalDDDRecConstants * hdc_
edm::EventID id() const
Definition: EventBase.h:60
std::vector< double > phiGlob_
HLTConfigProvider hltConfig_
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< double > hcalActiveLength_
std::vector< double > chiTracker_
std::vector< double > hcalDepthChargeHot_[depthMax_]
std::vector< double > matchedId_
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
std::vector< HcalActiveLength > getThickActive(const int &type) const
const Point & position() const
position
Definition: BeamSpot.h:62
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< bool > outerTrack_
std::vector< double > muon_segComp
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
def check(config)
Definition: trackerTree.py:14
std::vector< double > numPixelLayers_
edm::EDGetTokenT< HBHERecHitCollection > tok_HBHE_
edm::Service< TFileService > fs
T const * product() const
Definition: ESHandle.h:86
std::vector< double > dxyTracker_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:272
std::vector< double > ecal3x3Energy_
void setTopo(const HcalTopology *topo)
std::vector< double > tight_TransImpara_
std::vector< double > energyMuon_
std::vector< double > etaGlob_
Definition: Run.h:43
bool isGoodVertex(const reco::Vertex &vtx)
std::vector< double > outerTrackPhi_
std::vector< double > innerTrackpt_
std::vector< bool > innerTrack_
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)