test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalHBHEMuonAnalyzer.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <iostream>
3 #include <vector>
4 #include <TFile.h>
5 #include <TTree.h>
6 #include "TPRegexp.h"
7 
8 // user include files
18 
25 
27 
37 
40 
44 
48 
58 
59 //#define DebugLog
60 
62 
63 public:
64 
67 
69  int ieta, depth;
70  double eta, thick;
71  HcalActiveLength(int ie=0, int d=0, double et=0,
72  double t=0) : ieta(ie), depth(d), eta(et), thick(t) {}
73  };
74 
75  std::vector<HcalActiveLength> getThickActive(const int type) const;
76 
77 private:
78 
79  std::vector<HcalActiveLength> actHB, actHE;
80 };
81 
82 
84  int ietaHB[18] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
85  11, 12, 13, 14, 15, 15, 16, 16};
86  int depthHB[18] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
87  1, 1, 1, 1, 1, 2, 1, 2};
88  double etaHB[18] = {0.0435, 0.1305, 0.2175, 0.3045, 0.3915, 0.4785,
89  0.5655, 0.6525, 0.7395, 0.8265, 0.9135, 1.0005,
90  1.0875, 1.1745, 1.2615, 1.2615, 1.3485, 1.3485};
91  double actLHB[18]= {7.35696, 7.41268, 7.52454, 7.69339, 7.92051, 8.20761,
92  8.55688, 8.97096, 9.45298, 10.0066, 10.6360, 11.3460,
93  12.1419, 13.0297, 10.1832, 3.83301, 2.61066, 5.32410};
94  actHB.clear();
95  for (int i=0; i<18; ++i) {
96  HcalDDDRecConstantsTemp::HcalActiveLength act(ietaHB[i],depthHB[i],etaHB[i],actLHB[i]);
97  actHB.push_back(act);
98  }
99 
100  int ietaHE[28] = {16, 17, 18, 18, 19, 19, 20, 20, 21, 21,
101  22, 22, 23, 23, 24, 24, 25, 25, 26, 26,
102  27, 27, 27, 28, 28, 28, 29, 29};
103  int depthHE[28] = {3, 1, 1, 2, 1, 2, 1, 2, 1, 2,
104  1, 2, 1, 2, 1, 2, 1, 2, 1, 2,
105  1, 2, 3, 1, 2, 3, 1, 2};
106  double etaHE[28] = {1.3485, 1.4355, 1.5225, 1.5225, 1.6095, 1.6095, 1.6965,
107  1.6965, 1.7850, 1.7850, 1.8800, 1.8800, 1.9865, 1.9865,
108  2.1075, 2.1075, 2.2470, 2.2470, 2.4110, 2.4110, 2.5750,
109  2.5750, 2.5750, 2.7590, 2.7590, 2.8250, 2.9340, 2.9340};
110  double actLHE[28]= {4.23487, 8.05342, 2.21090, 5.69774, 2.57831, 5.21078,
111  2.54554, 5.14455, 2.51790, 5.08871, 2.49347, 5.03933,
112  2.47129, 4.99449, 2.45137, 4.95424, 2.43380, 4.91873,
113  2.41863, 4.88808, 1.65913, 0.74863, 4.86612, 1.65322,
114  0.74596, 4.84396, 1.64930, 0.744198};
115  actHE.clear();
116  for (int i=0; i<28; ++i) {
117  HcalDDDRecConstantsTemp::HcalActiveLength act(ietaHE[i],depthHE[i],etaHE[i],actLHE[i]);
118  actHE.push_back(act);
119  }
120 }
121 
123 #ifdef DebugLog
124  edm::LogInfo("HcalHBHEMuon") << "HcalDDDRecConstantsTemp::destructed!!!";
125 #endif
126 }
127 
128 std::vector<HcalDDDRecConstantsTemp::HcalActiveLength>
130 
131  if (type == 0) return actHB;
132  else return actHE;
133 }
134 
136 
137 public:
138  explicit HcalHBHEMuonAnalyzer(const edm::ParameterSet&);
140 
141  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
142 
143 private:
144  virtual void beginJob() ;
145  virtual void analyze(const edm::Event&, const edm::EventSetup& );
146  virtual void endJob() ;
147  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
148  virtual void endRun(edm::Run const&, edm::EventSetup const&);
149  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
150  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
151  void clearVectors();
152  int matchId(const HcalDetId&, const HcalDetId&);
153  double activeLength(const DetId&);
154  bool isGoodVertex(const reco::Vertex& vtx);
155  // ----------member data ---------------------------
162 
169 
171  std::vector<double> PtGlob, EtaGlob, PhiGlob, chiGlobal;
179  std::vector<bool> innerTrack, OuterTrack, GlobalTrack;
180  std::vector<double> IsolationR04,IsolationR03;
183  std::vector<unsigned int> MuonEcalDetId,MuonHcalDetId,MuonEHcalDetId;
184  std::vector<double> MuonHcalHot,MuonHcalDepth1Energy;
192  std::vector<HcalDDDRecConstantsTemp::HcalActiveLength> actHB , actHE;
193  std::vector<std::string> all_triggers;
195 
196  TTree *TREE;
197  std::vector<bool> muon_is_good, muon_global, muon_tracker;
198  std::vector<int> hltresults;
200  };
201 
203  //now do what ever initialization is needed
204  HLTriggerResults_ = iConfig.getParameter<edm::InputTag>("HLTriggerResults");
205  labelVtx_ = iConfig.getParameter<std::string>("LabelVertex");
206  labelEBRecHit_ = iConfig.getParameter<std::string>("LabelEBRecHit");
207  labelEERecHit_ = iConfig.getParameter<std::string>("LabelEERecHit");
208  labelHBHERecHit_ = iConfig.getParameter<std::string>("LabelHBHERecHit");
209  labelMuon_ = iConfig.getParameter<std::string>("LabelMuon");
210  verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
211  maxDepth_ = iConfig.getUntrackedParameter<int>("MaxDepth",4);
212  if (maxDepth_ > 7) maxDepth_ = 7;
213  else if (maxDepth_ < 1) maxDepth_ = 4;
214  std::string modnam = iConfig.getUntrackedParameter<std::string>("ModuleName","");
215  std::string procnm = iConfig.getUntrackedParameter<std::string>("ProcessName","");
216 
217  tok_trigRes_ = consumes<edm::TriggerResults>(HLTriggerResults_);
218  if (modnam == "") {
219  tok_Vtx_ = consumes<reco::VertexCollection>(labelVtx_);
220  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit",labelEBRecHit_));
221  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit",labelEERecHit_));
222  tok_HBHE_ = consumes<HBHERecHitCollection>(labelHBHERecHit_);
223  tok_Muon_ = consumes<reco::MuonCollection>(labelMuon_);
224  edm::LogInfo("HcalHBHEMuon") << "Labels used " << HLTriggerResults_ << " "
225  << labelVtx_ << " " << labelEBRecHit_ << " "
226  << labelEERecHit_ << " " << labelHBHERecHit_
227  << " " << labelMuon_;
228  } else {
229  tok_Vtx_ = consumes<reco::VertexCollection>(edm::InputTag(modnam,labelVtx_,procnm));
230  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag(modnam,labelEBRecHit_,procnm));
231  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag(modnam,labelEERecHit_,procnm));
232  tok_HBHE_ = consumes<HBHERecHitCollection>(edm::InputTag(modnam,labelHBHERecHit_,procnm));
233  tok_Muon_ = consumes<reco::MuonCollection>(edm::InputTag(modnam,labelMuon_,procnm));
234  edm::LogInfo("HcalHBHEMuon") << "Labels used " << HLTriggerResults_
235  << "\n " << edm::InputTag(modnam,labelVtx_,procnm)
236  << "\n " << edm::InputTag(modnam,labelEBRecHit_,procnm)
237  << "\n " << edm::InputTag(modnam,labelEERecHit_,procnm)
238  << "\n " << edm::InputTag(modnam,labelHBHERecHit_,procnm)
239  << "\n " << edm::InputTag(modnam,labelMuon_,procnm);
240  }
241 }
242 
244  // do anything here that needs to be done at desctruction time
245  // (e.g. close files, deallocate resources etc.)
246 }
247 
248 //
249 // member functions
250 //
251 
252 // ------------ method called for each event ------------
254 
255  clearVectors();
256  RunNumber = iEvent.id().run();
257  EventNumber = iEvent.id().event();
258  LumiNumber = iEvent.id().luminosityBlock();
259  BXNumber = iEvent.bunchCrossing();
260 #ifdef DebugLog
261  edm::LogInfo("HcalHBHEMuon") << "Run " << RunNumber << " Event " << EventNumber
262  << " Lumi " << LumiNumber << " BX " << BXNumber;
263 #endif
265  iEvent.getByToken(tok_trigRes_, _Triggers);
266 #ifdef DebugLog
267  edm::LogInfo("HcalHBHEMuon") << "Size of all triggers " << all_triggers.size();
268 #endif
269  int Ntriggers = all_triggers.size();
270 #ifdef DebugLog
271  edm::LogInfo("HcalHBHEMuon") << "Size of HLT MENU: " << _Triggers->size();
272 #endif
273  if (_Triggers.isValid()) {
274  const edm::TriggerNames &triggerNames_ = iEvent.triggerNames(*_Triggers);
275  std::vector<int> index;
276  for (int i=0;i < Ntriggers;i++) {
277  index.push_back(triggerNames_.triggerIndex(all_triggers[i]));
278  int triggerSize = int( _Triggers->size());
279 #ifdef DebugLog
280  edm::LogInfo("HcalHBHEMuon") << "outside loop " << index[i]
281  << "\ntriggerSize " << triggerSize;
282 #endif
283  if (index[i] < triggerSize) {
284  hltresults.push_back(_Triggers->accept(index[i]));
285 #ifdef DebugLog
286  edm::LogInfo("HcalHBHEMuon") << "Trigger_info " << triggerSize
287  << " triggerSize " << index[i]
288  << " trigger_index " << hltresults.at(i)
289  << " hltresult";
290 #endif
291  } else {
292  edm::LogInfo("HcalHBHEMuon") << "Requested HLT path \"" << "\" does not exist";
293  }
294  }
295  }
296 
298  iSetup.get<CaloGeometryRecord>().get(pG);
299  const CaloGeometry* geo = pG.product();
300 
302  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
303  const MagneticField* bField = bFieldH.product();
304 
306  iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
307  const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
308 
310  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
311 
312  edm::ESHandle<CaloTopology> theCaloTopology;
313  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
314  const CaloTopology *caloTopology = theCaloTopology.product();
315 
317  iSetup.get<HcalRecNumberingRecord>().get(htopo);
318  const HcalTopology* theHBHETopology = htopo.product();
319 
320  // Relevant blocks from iEvent
322  iEvent.getByToken(tok_Vtx_, vtx);
323 
324  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
325  iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
326  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
327  iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
328 
330  iEvent.getByToken(tok_HBHE_, hbhe);
331 
333  iEvent.getByToken(tok_Muon_, _Muon);
334 
335  // get handles to calogeometry and calotopology
336  if (!(vtx.isValid())) return;
337  reco::VertexCollection::const_iterator firstGoodVertex = vtx->end();
338  for (reco::VertexCollection::const_iterator it = vtx->begin(); it != firstGoodVertex; it++) {
339  if (isGoodVertex(*it)) {
340  firstGoodVertex = it;
341  break;
342  }
343  }
344  // require a good vertex
345  if (firstGoodVertex == vtx->end()) return;
346 
347  bool accept(false);
348  if (_Muon.isValid() && barrelRecHitsHandle.isValid() &&
349  endcapRecHitsHandle.isValid() && hbhe.isValid()) {
350  for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon!= _Muon->end(); ++RecMuon) {
351 
352  if (RecMuon->p() > 10.0) accept = true;
353 
354  muon_is_good.push_back(RecMuon->isPFMuon());
355  muon_global.push_back(RecMuon->isGlobalMuon());
356  muon_tracker.push_back(RecMuon->isTrackerMuon());
357  PtGlob.push_back((RecMuon)->pt());
358  EtaGlob.push_back(RecMuon->eta());
359  PhiGlob.push_back(RecMuon->phi());
360  Energy.push_back(RecMuon->energy());
361  Pmuon.push_back(RecMuon->p());
362 #ifdef DebugLog
363  edm::LogInfo("HcalHBHEMuon") << "Energy:" << RecMuon->energy() << " P:"
364  << RecMuon->p();
365 #endif
366  // acessing tracker hits info
367  if (RecMuon->track().isNonnull()) {
368  TrackerLayer.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement());
369  } else {
370  TrackerLayer.push_back(-1);
371  }
372  if (RecMuon->innerTrack().isNonnull()) {
373  innerTrack.push_back(true);
374  NumPixelLayers.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
375  chiTracker.push_back(RecMuon->innerTrack()->normalizedChi2());
376  DxyTracker.push_back(fabs(RecMuon->innerTrack()->dxy((*firstGoodVertex).position())));
377  DzTracker.push_back(fabs(RecMuon->innerTrack()->dz((*firstGoodVertex).position())));
378  innerTrackpt.push_back(RecMuon->innerTrack()->pt());
379  innerTracketa.push_back(RecMuon->innerTrack()->eta());
380  innerTrackphi.push_back(RecMuon->innerTrack()->phi());
381  Tight_PixelHits.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
382  } else {
383  innerTrack.push_back(false);
384  NumPixelLayers.push_back(0);
385  chiTracker.push_back(0);
386  DxyTracker.push_back(0);
387  DzTracker.push_back(0);
388  innerTrackpt.push_back(0);
389  innerTracketa.push_back(0);
390  innerTrackphi.push_back(0);
391  Tight_PixelHits.push_back(0);
392  }
393  // outer track info
394  if (RecMuon->outerTrack().isNonnull()) {
395  OuterTrack.push_back(true);
396  OuterTrackPt.push_back(RecMuon->outerTrack()->pt());
397  OuterTrackEta.push_back(RecMuon->outerTrack()->eta());
398  OuterTrackPhi.push_back(RecMuon->outerTrack()->phi());
399  OuterTrackChi.push_back(RecMuon->outerTrack()->normalizedChi2());
400  OuterTrackHits.push_back(RecMuon->outerTrack()->numberOfValidHits());
401  OuterTrackRHits.push_back(RecMuon->outerTrack()->recHitsSize());
402  } else {
403  OuterTrack.push_back(false);
404  OuterTrackPt.push_back(0);
405  OuterTrackEta.push_back(0);
406  OuterTrackPhi.push_back(0);
407  OuterTrackChi.push_back(0);
408  OuterTrackHits.push_back(0);
409  OuterTrackRHits.push_back(0);
410  }
411  // Tight Muon cuts
412  if (RecMuon->globalTrack().isNonnull()) {
413  GlobalTrack.push_back(true);
414  chiGlobal.push_back(RecMuon->globalTrack()->normalizedChi2());
415  GlobalMuonHits.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
416  MatchedStat.push_back(RecMuon->numberOfMatchedStations());
417  GlobalTrckPt.push_back(RecMuon->globalTrack()->pt());
418  GlobalTrckEta.push_back(RecMuon->globalTrack()->eta());
419  GlobalTrckPhi.push_back(RecMuon->globalTrack()->phi());
420  Tight_TransImpara.push_back(fabs(RecMuon->muonBestTrack()->dxy((*firstGoodVertex).position())));
421  Tight_LongPara.push_back(fabs(RecMuon->muonBestTrack()->dz((*firstGoodVertex).position())));
422  } else {
423  GlobalTrack.push_back(false);
424  chiGlobal.push_back(0);
425  GlobalMuonHits.push_back(0);
426  MatchedStat.push_back(0);
427  GlobalTrckPt.push_back(0);
428  GlobalTrckEta.push_back(0);
429  GlobalTrckPhi.push_back(0);
430  Tight_TransImpara.push_back(0);
431  Tight_LongPara.push_back(0);
432  }
433 
434  IsolationR04.push_back(((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()) );
435 
436  IsolationR03.push_back(((RecMuon->pfIsolationR03().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt - (0.5 * RecMuon->pfIsolationR03().sumPUPt))) / RecMuon->pt()));
437 
438  MuonEcalEnergy.push_back(RecMuon->calEnergy().emS9);
439  MuonHcalEnergy.push_back(RecMuon->calEnergy().hadS9);
440  MuonHOEnergy.push_back(RecMuon->calEnergy().hoS9);
441 
442  double eEcal(0),eHcal(0),activeL(0),eHcalDepth[7],eHcalDepthHot[7];
443  unsigned int isHot = 0;
444  for (int i=0; i<7; ++i) eHcalDepth[i]=eHcalDepthHot[i]=-10000;
445 
446  if (RecMuon->innerTrack().isNonnull()) {
447  const reco::Track* pTrack = (RecMuon->innerTrack()).get();
448  spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, (((verbosity_/100)%10>0)));
449 
450  MuonEcalDetId.push_back((trackID.detIdECAL)());
451  MuonHcalDetId.push_back((trackID.detIdHCAL)());
452  MuonEHcalDetId.push_back((trackID.detIdEHCAL)());
453 
454  if (trackID.okECAL) {
455  const DetId isoCell(trackID.detIdECAL);
456  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);
457  eEcal = e3x3.first;
458  }
459 
460  if (trackID.okHCAL) {
461  const DetId closestCell(trackID.detIdHCAL);
462  eHcal = spr::eHCALmatrix(theHBHETopology, closestCell, hbhe,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.);
463  std::vector<std::pair<double,int> > ehdepth;
464  spr::energyHCALCell((HcalDetId) closestCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, (((verbosity_/1000)%10)>0));
465  for (unsigned int i=0; i<ehdepth.size(); ++i) {
466  eHcalDepth[ehdepth[i].second-1] = ehdepth[i].first;
467  }
468 
469  HcalDetId hcid0(closestCell.rawId());
470  activeL = activeLength(trackID.detIdHCAL);
471  HcalDetId hotCell;
472  spr::eHCALmatrix(geo,theHBHETopology, closestCell, hbhe, 1,1, hotCell, false, false);
473  isHot = matchId(closestCell,hotCell);
474  if (hotCell != HcalDetId()) {
475  std::vector<std::pair<double,int> > ehdepth;
476  spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, false);//(((verbosity_/1000)%10)>0 ));
477  for (unsigned int i=0; i<ehdepth.size(); ++i) {
478  eHcalDepthHot[ehdepth[i].second-1] = ehdepth[i].first;
479  }
480  }
481  }
482 
483  } else {
484  MuonEcalDetId.push_back(0);
485  MuonHcalDetId.push_back(0);
486  MuonEHcalDetId.push_back(0);
487  }
488 
489  MuonEcal3x3Energy.push_back(eEcal);
490  MuonHcal1x1Energy.push_back(eHcal);
491  MuonHcalDepth1Energy.push_back(eHcalDepth[0]);
492  MuonHcalDepth2Energy.push_back(eHcalDepth[1]);
493  MuonHcalDepth3Energy.push_back(eHcalDepth[2]);
494  MuonHcalDepth4Energy.push_back(eHcalDepth[3]);
495  MuonHcalDepth5Energy.push_back(eHcalDepth[4]);
496  MuonHcalDepth6Energy.push_back(eHcalDepth[5]);
497  MuonHcalDepth7Energy.push_back(eHcalDepth[6]);
498  MuonHcalDepth1HotEnergy.push_back(eHcalDepthHot[0]);
499  MuonHcalDepth2HotEnergy.push_back(eHcalDepthHot[1]);
500  MuonHcalDepth3HotEnergy.push_back(eHcalDepthHot[2]);
501  MuonHcalDepth4HotEnergy.push_back(eHcalDepthHot[3]);
502  MuonHcalDepth5HotEnergy.push_back(eHcalDepthHot[4]);
503  MuonHcalDepth6HotEnergy.push_back(eHcalDepthHot[5]);
504  MuonHcalDepth7HotEnergy.push_back(eHcalDepthHot[6]);
505  MuonHcalHot.push_back(isHot);
506  MuonHcalActiveLength.push_back(activeL);
507  }
508  }
509  if (accept) TREE->Fill();
510 }
511 
512 // ------------ method called once each job just before starting event loop ------------
514 
515  TREE = fs->make<TTree>("TREE", "TREE");
516  TREE->Branch("Event_No",&EventNumber);
517  TREE->Branch("Run_No",&RunNumber);
518  TREE->Branch("LumiNumber",&LumiNumber);
519  TREE->Branch("BXNumber",&BXNumber);
520  TREE->Branch("pt_of_muon",&PtGlob);
521  TREE->Branch("eta_of_muon",&EtaGlob);
522  TREE->Branch("phi_of_muon",&PhiGlob);
523  TREE->Branch("energy_of_muon",&Energy);
524  TREE->Branch("p_of_muon",&Pmuon);
525  TREE->Branch("PF_Muon",&muon_is_good);
526  TREE->Branch("Global_Muon",&muon_global);
527  TREE->Branch("Tracker_muon",&muon_tracker);
528 
529  TREE->Branch("hcal_3into3",&MuonHcalEnergy);
530  TREE->Branch("hcal_1x1",&MuonHcal1x1Energy);
531  TREE->Branch("hcal_detID",&MuonHcalDetId);
532  TREE->Branch("hcal_edepth1",&MuonHcalDepth1Energy);
533  TREE->Branch("hcal_edepth2",&MuonHcalDepth2Energy);
534  TREE->Branch("hcal_edepth3",&MuonHcalDepth3Energy);
535  TREE->Branch("hcal_edepth4",&MuonHcalDepth4Energy);
536  TREE->Branch("hcal_edepthHot1",&MuonHcalDepth1HotEnergy);
537  TREE->Branch("hcal_edepthHot2",&MuonHcalDepth2HotEnergy);
538  TREE->Branch("hcal_edepthHot3",&MuonHcalDepth3HotEnergy);
539  TREE->Branch("hcal_edepthHot4",&MuonHcalDepth4HotEnergy);
540 
541  if (maxDepth_ > 4) {
542  TREE->Branch("hcal_edepth5",&MuonHcalDepth5Energy);
543  TREE->Branch("hcal_edepthHot5",&MuonHcalDepth5HotEnergy);
544  if (maxDepth_ > 5) {
545  TREE->Branch("hcal_edepth6",&MuonHcalDepth6Energy);
546  TREE->Branch("hcal_edepthHot6",&MuonHcalDepth6HotEnergy);
547  if (maxDepth_ > 6) {
548  TREE->Branch("hcal_edepth7",&MuonHcalDepth7Energy);
549  TREE->Branch("hcal_edepthHot7",&MuonHcalDepth7HotEnergy);
550  }
551  }
552  }
553 
554 
555  TREE->Branch("TrackerLayer",&TrackerLayer);
556  TREE->Branch("innerTrack",&innerTrack);
557  TREE->Branch("innerTrackpt",&innerTrackpt);
558  TREE->Branch("innerTracketa",&innerTracketa);
559  TREE->Branch("innerTrackphi",&innerTrackphi);
560  TREE->Branch("MatchedStat",&MatchedStat);
561  TREE->Branch("GlobalTrckPt",&GlobalTrckPt);
562  TREE->Branch("GlobalTrckEta",&GlobalTrckEta);
563  TREE->Branch("GlobalTrckPhi",&GlobalTrckPhi);
564  TREE->Branch("NumPixelLayers",&NumPixelLayers);
565  TREE->Branch("chiTracker",&chiTracker);
566  TREE->Branch("DxyTracker",&DxyTracker);
567  TREE->Branch("DzTracker",&DzTracker);
568  TREE->Branch("OuterTrack",&OuterTrack);
569  TREE->Branch("OuterTrackPt",&OuterTrackPt);
570  TREE->Branch("OuterTrackEta",&OuterTrackEta);
571  TREE->Branch("OuterTrackPhi",&OuterTrackPhi);
572  TREE->Branch("OuterTrackHits",&OuterTrackHits);
573  TREE->Branch("OuterTrackRHits",&OuterTrackRHits);
574  TREE->Branch("OuterTrackChi",&OuterTrackChi);
575  TREE->Branch("GlobalTrack",&GlobalTrack);
576  TREE->Branch("GlobTrack_Chi",&chiGlobal);
577  TREE->Branch("Global_Muon_Hits",&GlobalMuonHits);
578  TREE->Branch("MatchedStations",&MatchedStat);
579  TREE->Branch("Global_Track_Pt",&GlobalTrckPt);
580  TREE->Branch("Global_Track_Eta",&GlobalTrckEta);
581  TREE->Branch("Global_Track_Phi",&GlobalTrckPhi);
583  TREE->Branch("Tight_LongitudinalImpactparameter",&Tight_LongPara);
584  TREE->Branch("Tight_TransImpactparameter",&Tight_TransImpara);
585  TREE->Branch("InnerTrackPixelHits",&Tight_PixelHits);
586  TREE->Branch("IsolationR04",&IsolationR04);
587  TREE->Branch("IsolationR03",&IsolationR03);
588 
589  TREE->Branch("hcal_cellHot",&MuonHcalHot);
590  TREE->Branch("ecal_3into3",&MuonEcalEnergy);
591  TREE->Branch("ecal_3x3",&MuonEcal3x3Energy);
592  TREE->Branch("ecal_detID",&MuonEcalDetId);
593  TREE->Branch("ehcal_detID",&MuonEHcalDetId);
594  TREE->Branch("tracker_3into3",&MuonHOEnergy);
595  TREE->Branch("activeLength",&MuonHcalActiveLength);
596 
598  TREE->Branch("hltresults",&hltresults);
599  TREE->Branch("all_triggers",&all_triggers);
600 
601 }
602 
603 // ------------ method called once each job just after ending the event loop ------------
605 
606 // ------------ method called when starting to processes a run ------------
607 void HcalHBHEMuonAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
608 
609  /* edm::ESHandle<HcalDDDRecConstants> pHRNDC;
610  iSetup.get<HcalRecNumberingRecord>().get(pHRNDC);
611  const HcalDDDRecConstants & hdc = (*pHRNDC);
612  */
613 
615  actHB.clear();
616  actHE.clear();
617  actHB = hdc.getThickActive(0);
618  actHE = hdc.getThickActive(1);
619 
620  bool changed = true;
621  all_triggers.clear();
622  if (hltConfig_.init(iRun, iSetup,"HLT" , changed)) {
623  // if init returns TRUE, initialisation has succeeded!
624 #ifdef DebugLog
625  edm::LogInfo("TriggerBlock") << "HLT config with process name "
626  << "HLT" << " successfully extracted";
627 #endif
628 // std::string string_search[5]={"HLT_IsoMu_","HLT_L1SingleMu_","HLT_L2Mu","HLT_Mu","HLT_RelIso1p0Mu"};
629  std::string string_search[6]={"HLT_IsoMu17","HLT_IsoMu20","HLT_IsoMu24","HLT_IsoMu27","HLT_Mu45","HLT_Mu50"};
630 
631  unsigned int ntriggers = hltConfig_.size();
632  for (unsigned int t=0;t<ntriggers;++t) {
634  for (unsigned int ik=0; ik<6; ++ik) {
635  if (hltname.find(string_search[ik])!=std::string::npos ){
636  all_triggers.push_back(hltname);
637  break;
638  }
639  }
640  }//loop over ntriggers
641  edm::LogInfo("HcalHBHEMuon") << "All triggers size in begin run "
642  << all_triggers.size();
643  } else {
644  edm::LogError("HcalHBHEMuon") << "Error! HLT config extraction with process name "
645  << "HLT"<< " failed";
646  }
647 
648 }
649 
650 
651 // ------------ method called when ending the processing of a run ------------
653 
654 // ------------ method called when starting to processes a luminosity block ------------
656 
657 // ------------ method called when ending the processing of a luminosity block ------------
659 
660 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
662  //The following says we do not know what parameters are allowed so do no validation
663  // Please change this to state exactly what you do use, even if it is no parameters
665  desc.setUnknown();
666  descriptions.addDefault(desc);
667 }
668 
671  EventNumber = -99999;
672  RunNumber = -99999;
673  LumiNumber = -99999;
674  BXNumber = -99999;
675  muon_is_good.clear();
676  muon_global.clear();
677  muon_tracker.clear();
678  PtGlob.clear();
679  EtaGlob.clear();
680  PhiGlob.clear();
681  Energy.clear();
682  Pmuon.clear();
683  TrackerLayer.clear();
684  innerTrack.clear();
685  NumPixelLayers.clear();
686  chiTracker.clear();
687  DxyTracker.clear();
688  DzTracker.clear();
689  innerTrackpt.clear();
690  innerTracketa.clear();
691  innerTrackphi.clear();
692  Tight_PixelHits.clear();
693  OuterTrack.clear();
694  OuterTrackPt.clear();
695  OuterTrackEta.clear();
696  OuterTrackPhi.clear();
697  OuterTrackHits.clear();
698  OuterTrackRHits.clear();
699  OuterTrackChi.clear();
700  GlobalTrack.clear();
701  chiGlobal.clear();
702  GlobalMuonHits.clear();
703  MatchedStat.clear();
704  GlobalTrckPt.clear();
705  GlobalTrckEta.clear();
706  GlobalTrckPhi.clear();
707  Tight_TransImpara.clear();
708  Tight_LongPara.clear();
709 
710  IsolationR04.clear();
711  IsolationR03.clear();
712  MuonEcalEnergy.clear();
713  MuonHcalEnergy.clear();
714  MuonHOEnergy.clear();
715  MuonEcalDetId.clear();
716  MuonHcalDetId.clear();
717  MuonEHcalDetId.clear();
718  MuonEcal3x3Energy.clear();
719  MuonHcal1x1Energy.clear();
720  MuonHcalDepth1Energy.clear();
721  MuonHcalDepth2Energy.clear();
722  MuonHcalDepth3Energy.clear();
723  MuonHcalDepth4Energy.clear();
724  MuonHcalDepth5Energy.clear();
725  MuonHcalDepth6Energy.clear();
726  MuonHcalDepth7Energy.clear();
727 
728  MuonHcalDepth1HotEnergy.clear();
729  MuonHcalDepth2HotEnergy.clear();
730  MuonHcalDepth3HotEnergy.clear();
731  MuonHcalDepth4HotEnergy.clear();
732  MuonHcalDepth5HotEnergy.clear();
733  MuonHcalDepth6HotEnergy.clear();
734  MuonHcalDepth7HotEnergy.clear();
735  MuonHcalHot.clear();
736  MuonHcalActiveLength.clear();
737  hltresults.clear();
738 }
739 
740 int HcalHBHEMuonAnalyzer::matchId(const HcalDetId& id1, const HcalDetId& id2) {
741 
742  HcalDetId kd1(id1.subdet(),id1.ieta(),id1.iphi(),1);
743  HcalDetId kd2(id2.subdet(),id2.ieta(),id2.iphi(),1);
744  int match = ((kd1 == kd2) ? 1 : 0);
745  return match;
746 }
747 
749  HcalDetId id(id_);
750  int ieta = id.ietaAbs();
751  int depth= id.depth();
752  double lx(0);
753  if (id.subdet() == HcalBarrel) {
754  for (unsigned int i=0; i<actHB.size(); ++i) {
755  if (ieta == actHB[i].ieta && depth == actHB[i].depth) {
756  lx = actHB[i].thick;
757  break;
758  }
759  }
760  } else {
761  for (unsigned int i=0; i<actHE.size(); ++i) {
762  if (ieta == actHE[i].ieta && depth == actHE[i].depth) {
763  lx = actHE[i].thick;
764  break;
765  }
766  }
767  }
768  return lx;
769 }
770 
772  if (vtx.isFake()) return false;
773  if (vtx.ndof() < 4) return false;
774  if (vtx.position().Rho() > 2.) return false;
775  if (fabs(vtx.position().Z()) > 24.) return false;
776  return true;
777 }
778 
779 //define this as a plug-in
781 
783 
RunNumber_t run() const
Definition: EventID.h:39
unsigned int size() const
number of trigger paths in trigger table
type
Definition: HCALResponse.h:21
std::vector< double > Tight_LongPara
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
HcalHBHEMuonAnalyzer(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< double > MuonEcal3x3Energy
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:220
HcalActiveLength(int ie=0, int d=0, double et=0, double t=0)
std::vector< double > GlobalTrckPhi
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
std::vector< double > TrackerLayer
std::vector< double > MuonHcalDepth7HotEnergy
std::vector< double > OuterTrackHits
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:45
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< double > Pmuon
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< double > OuterTrackPt
std::vector< HcalActiveLength > actHB
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< double > GlobalTrckPt
std::vector< double > DxyTracker
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< double > MuonHcalEnergy
std::vector< bool > GlobalTrack
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
std::vector< double > MuonHOEnergy
std::vector< double > MuonHcalHot
std::vector< bool > muon_global
std::vector< double > MuonHcalDepth1Energy
int bunchCrossing() const
Definition: EventBase.h:66
std::vector< double > GlobalMuonHits
std::vector< double > chiGlobal
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< bool > innerTrack
std::vector< double > MuonHcalDepth3Energy
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:24
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
std::vector< HcalDDDRecConstantsTemp::HcalActiveLength > actHE
std::vector< double > PtGlob
const Point & position() const
position
Definition: Vertex.h:106
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::vector< double > MuonHcalDepth2HotEnergy
std::vector< HcalActiveLength > getThickActive(const int type) const
std::vector< double > OuterTrackRHits
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< double > OuterTrackEta
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 debug=false)
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 debug=false)
tuple d
Definition: ztail.py:151
edm::EDGetTokenT< reco::VertexCollection > tok_Vtx_
int iEvent
Definition: GenABIO.cc:230
std::vector< unsigned int > MuonEHcalDetId
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< double > MuonHcalDepth1HotEnergy
std::vector< double > PhiGlob
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
std::vector< double > MuonHcalActiveLength
std::vector< HcalActiveLength > actHE
std::vector< double > MuonHcalDepth7Energy
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
std::vector< double > MuonHcalDepth2Energy
std::vector< double > IsolationR03
bool isValid() const
Definition: HandleBase.h:75
double activeLength(const DetId &)
edm::EDGetTokenT< reco::MuonCollection > tok_Muon_
std::vector< double > IsolationR04
std::vector< double > MuonHcalDepth3HotEnergy
std::vector< double > DzTracker
double ndof() const
Definition: Vertex.h:102
virtual void endRun(edm::Run const &, edm::EventSetup const &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< HcalDDDRecConstantsTemp::HcalActiveLength > actHB
std::vector< double > Tight_TransImpara
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
Definition: DetId.h:18
bool isFake() const
Definition: Vertex.h:64
std::vector< double > MuonHcalDepth4Energy
std::vector< int > hltresults
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::vector< bool > OuterTrack
const T & get() const
Definition: EventSetup.h:56
std::vector< double > GlobalTrckEta
T const * product() const
Definition: ESHandle.h:86
std::vector< double > MuonHcal1x1Energy
std::vector< std::string > all_triggers
std::vector< unsigned int > MuonHcalDetId
std::vector< double > innerTracketa
std::vector< double > MatchedStat
std::vector< double > MuonHcalDepth5Energy
int matchId(const HcalDetId &, const HcalDetId &)
edm::EventID id() const
Definition: EventBase.h:60
std::vector< double > MuonHcalDepth5HotEnergy
std::vector< double > innerTrackphi
std::vector< double > OuterTrackChi
HLTConfigProvider hltConfig_
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< double > innerTrackpt
std::vector< double > MuonEcalEnergy
std::vector< double > Tight_PixelHits
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
std::vector< double > OuterTrackPhi
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< double > MuonHcalDepth4HotEnergy
std::vector< double > chiTracker
std::vector< double > MuonHcalDepth6HotEnergy
edm::EDGetTokenT< HBHERecHitCollection > tok_HBHE_
std::vector< bool > muon_tracker
std::vector< double > MuonHcalDepth6Energy
edm::Service< TFileService > fs
std::vector< double > NumPixelLayers
std::vector< double > Energy
cond::RealTimeType< cond::runnumber >::type RunNumber
std::vector< bool > muon_is_good
Definition: Run.h:43
std::vector< unsigned int > MuonEcalDetId
std::vector< double > EtaGlob
bool isGoodVertex(const reco::Vertex &vtx)
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)