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 
59 
60 //#define DebugLog
61 
63 
64 public:
65  explicit HcalHBHEMuonAnalyzer(const edm::ParameterSet&);
67 
68  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
69 
70 private:
71  virtual void beginJob() ;
72  virtual void analyze(const edm::Event&, const edm::EventSetup& );
73  virtual void endJob() ;
74  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
75  virtual void endRun(edm::Run const&, edm::EventSetup const&);
76  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
77  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
78  void clearVectors();
79  int matchId(const HcalDetId&, const HcalDetId&);
80  double activeLength(const DetId&);
81  bool isGoodVertex(const reco::Vertex& vtx);
82  // ----------member data ---------------------------
89  bool useRaw_;
90 
97 
99  std::vector<double> PtGlob, EtaGlob, PhiGlob, chiGlobal;
107  std::vector<bool> innerTrack, OuterTrack, GlobalTrack;
108  std::vector<double> IsolationR04,IsolationR03;
111  std::vector<unsigned int> MuonEcalDetId,MuonHcalDetId,MuonEHcalDetId;
112  std::vector<double> MuonHcalHot,MuonHcalDepth1Energy;
120  std::vector<HcalDDDRecConstants::HcalActiveLength> actHB, actHE;
121  std::vector<std::string> all_triggers;
123 
124  TTree *TREE;
125  std::vector<bool> muon_is_good, muon_global, muon_tracker;
126  std::vector<int> hltresults;
128  };
129 
131  //now do what ever initialization is needed
132  HLTriggerResults_ = iConfig.getParameter<edm::InputTag>("HLTriggerResults");
133  labelVtx_ = iConfig.getParameter<std::string>("LabelVertex");
134  labelEBRecHit_ = iConfig.getParameter<std::string>("LabelEBRecHit");
135  labelEERecHit_ = iConfig.getParameter<std::string>("LabelEERecHit");
136  labelHBHERecHit_ = iConfig.getParameter<std::string>("LabelHBHERecHit");
137  labelMuon_ = iConfig.getParameter<std::string>("LabelMuon");
138  verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
139  maxDepth_ = iConfig.getUntrackedParameter<int>("MaxDepth",4);
140  if (maxDepth_ > 7) maxDepth_ = 7;
141  else if (maxDepth_ < 1) maxDepth_ = 4;
142  std::string modnam = iConfig.getUntrackedParameter<std::string>("ModuleName","");
143  std::string procnm = iConfig.getUntrackedParameter<std::string>("ProcessName","");
144  useRaw_ = iConfig.getUntrackedParameter<bool>("UseRaw",false);
145 
146  tok_trigRes_ = consumes<edm::TriggerResults>(HLTriggerResults_);
147  if (modnam == "") {
148  tok_Vtx_ = consumes<reco::VertexCollection>(labelVtx_);
149  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit",labelEBRecHit_));
150  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit",labelEERecHit_));
151  tok_HBHE_ = consumes<HBHERecHitCollection>(labelHBHERecHit_);
152  tok_Muon_ = consumes<reco::MuonCollection>(labelMuon_);
153  edm::LogInfo("HcalHBHEMuon") << "Labels used " << HLTriggerResults_ << " "
154  << labelVtx_ << " " << labelEBRecHit_ << " "
155  << labelEERecHit_ << " " << labelHBHERecHit_
156  << " " << labelMuon_;
157  } else {
158  tok_Vtx_ = consumes<reco::VertexCollection>(edm::InputTag(modnam,labelVtx_,procnm));
159  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag(modnam,labelEBRecHit_,procnm));
160  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag(modnam,labelEERecHit_,procnm));
161  tok_HBHE_ = consumes<HBHERecHitCollection>(edm::InputTag(modnam,labelHBHERecHit_,procnm));
162  tok_Muon_ = consumes<reco::MuonCollection>(edm::InputTag(modnam,labelMuon_,procnm));
163  edm::LogInfo("HcalHBHEMuon") << "Labels used " << HLTriggerResults_
164  << "\n " << edm::InputTag(modnam,labelVtx_,procnm)
165  << "\n " << edm::InputTag(modnam,labelEBRecHit_,procnm)
166  << "\n " << edm::InputTag(modnam,labelEERecHit_,procnm)
167  << "\n " << edm::InputTag(modnam,labelHBHERecHit_,procnm)
168  << "\n " << edm::InputTag(modnam,labelMuon_,procnm);
169  }
170 }
171 
173  // do anything here that needs to be done at desctruction time
174  // (e.g. close files, deallocate resources etc.)
175 }
176 
177 //
178 // member functions
179 //
180 
181 // ------------ method called for each event ------------
183 
184  clearVectors();
185  RunNumber = iEvent.id().run();
186  EventNumber = iEvent.id().event();
187  LumiNumber = iEvent.id().luminosityBlock();
188  BXNumber = iEvent.bunchCrossing();
189 #ifdef DebugLog
190  edm::LogInfo("HcalHBHEMuon") << "Run " << RunNumber << " Event " << EventNumber
191  << " Lumi " << LumiNumber << " BX " << BXNumber;
192 #endif
194  iEvent.getByToken(tok_trigRes_, _Triggers);
195 #ifdef DebugLog
196  edm::LogInfo("HcalHBHEMuon") << "Size of all triggers " << all_triggers.size();
197 #endif
198  int Ntriggers = all_triggers.size();
199 #ifdef DebugLog
200  edm::LogInfo("HcalHBHEMuon") << "Size of HLT MENU: " << _Triggers->size();
201 #endif
202  if (_Triggers.isValid()) {
203  const edm::TriggerNames &triggerNames_ = iEvent.triggerNames(*_Triggers);
204  std::vector<int> index;
205  for (int i=0;i < Ntriggers;i++) {
206  index.push_back(triggerNames_.triggerIndex(all_triggers[i]));
207  int triggerSize = int( _Triggers->size());
208 #ifdef DebugLog
209  edm::LogInfo("HcalHBHEMuon") << "outside loop " << index[i]
210  << "\ntriggerSize " << triggerSize;
211 #endif
212  if (index[i] < triggerSize) {
213  hltresults.push_back(_Triggers->accept(index[i]));
214 #ifdef DebugLog
215  edm::LogInfo("HcalHBHEMuon") << "Trigger_info " << triggerSize
216  << " triggerSize " << index[i]
217  << " trigger_index " << hltresults.at(i)
218  << " hltresult";
219 #endif
220  } else {
221  edm::LogInfo("HcalHBHEMuon") << "Requested HLT path \"" << "\" does not exist";
222  }
223  }
224  }
225 
227  iSetup.get<CaloGeometryRecord>().get(pG);
228  const CaloGeometry* geo = pG.product();
229 
231  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
232  const MagneticField* bField = bFieldH.product();
233 
235  iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
236  const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
237 
239  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
240 
241  edm::ESHandle<CaloTopology> theCaloTopology;
242  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
243  const CaloTopology *caloTopology = theCaloTopology.product();
244 
246  iSetup.get<HcalRecNumberingRecord>().get(htopo);
247  const HcalTopology* theHBHETopology = htopo.product();
248 
249  // Relevant blocks from iEvent
251  iEvent.getByToken(tok_Vtx_, vtx);
252 
253  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
254  iEvent.getByToken(tok_EB_, barrelRecHitsHandle);
255  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
256  iEvent.getByToken(tok_EE_, endcapRecHitsHandle);
257 
259  iEvent.getByToken(tok_HBHE_, hbhe);
260 
262  iEvent.getByToken(tok_Muon_, _Muon);
263 
264  // get handles to calogeometry and calotopology
265  if (!(vtx.isValid())) return;
266  reco::VertexCollection::const_iterator firstGoodVertex = vtx->end();
267  for (reco::VertexCollection::const_iterator it = vtx->begin(); it != firstGoodVertex; it++) {
268  if (isGoodVertex(*it)) {
269  firstGoodVertex = it;
270  break;
271  }
272  }
273  // require a good vertex
274  if (firstGoodVertex == vtx->end()) return;
275 
276  bool accept(false);
277  if (_Muon.isValid() && barrelRecHitsHandle.isValid() &&
278  endcapRecHitsHandle.isValid() && hbhe.isValid()) {
279  for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon!= _Muon->end(); ++RecMuon) {
280 
281  if (RecMuon->p() > 10.0) accept = true;
282 
283  muon_is_good.push_back(RecMuon->isPFMuon());
284  muon_global.push_back(RecMuon->isGlobalMuon());
285  muon_tracker.push_back(RecMuon->isTrackerMuon());
286  PtGlob.push_back((RecMuon)->pt());
287  EtaGlob.push_back(RecMuon->eta());
288  PhiGlob.push_back(RecMuon->phi());
289  Energy.push_back(RecMuon->energy());
290  Pmuon.push_back(RecMuon->p());
291 #ifdef DebugLog
292  edm::LogInfo("HcalHBHEMuon") << "Energy:" << RecMuon->energy() << " P:"
293  << RecMuon->p();
294 #endif
295  // acessing tracker hits info
296  if (RecMuon->track().isNonnull()) {
297  TrackerLayer.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement());
298  } else {
299  TrackerLayer.push_back(-1);
300  }
301  if (RecMuon->innerTrack().isNonnull()) {
302  innerTrack.push_back(true);
303  NumPixelLayers.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
304  chiTracker.push_back(RecMuon->innerTrack()->normalizedChi2());
305  DxyTracker.push_back(fabs(RecMuon->innerTrack()->dxy((*firstGoodVertex).position())));
306  DzTracker.push_back(fabs(RecMuon->innerTrack()->dz((*firstGoodVertex).position())));
307  innerTrackpt.push_back(RecMuon->innerTrack()->pt());
308  innerTracketa.push_back(RecMuon->innerTrack()->eta());
309  innerTrackphi.push_back(RecMuon->innerTrack()->phi());
310  Tight_PixelHits.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
311  } else {
312  innerTrack.push_back(false);
313  NumPixelLayers.push_back(0);
314  chiTracker.push_back(0);
315  DxyTracker.push_back(0);
316  DzTracker.push_back(0);
317  innerTrackpt.push_back(0);
318  innerTracketa.push_back(0);
319  innerTrackphi.push_back(0);
320  Tight_PixelHits.push_back(0);
321  }
322  // outer track info
323  if (RecMuon->outerTrack().isNonnull()) {
324  OuterTrack.push_back(true);
325  OuterTrackPt.push_back(RecMuon->outerTrack()->pt());
326  OuterTrackEta.push_back(RecMuon->outerTrack()->eta());
327  OuterTrackPhi.push_back(RecMuon->outerTrack()->phi());
328  OuterTrackChi.push_back(RecMuon->outerTrack()->normalizedChi2());
329  OuterTrackHits.push_back(RecMuon->outerTrack()->numberOfValidHits());
330  OuterTrackRHits.push_back(RecMuon->outerTrack()->recHitsSize());
331  } else {
332  OuterTrack.push_back(false);
333  OuterTrackPt.push_back(0);
334  OuterTrackEta.push_back(0);
335  OuterTrackPhi.push_back(0);
336  OuterTrackChi.push_back(0);
337  OuterTrackHits.push_back(0);
338  OuterTrackRHits.push_back(0);
339  }
340  // Tight Muon cuts
341  if (RecMuon->globalTrack().isNonnull()) {
342  GlobalTrack.push_back(true);
343  chiGlobal.push_back(RecMuon->globalTrack()->normalizedChi2());
344  GlobalMuonHits.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
345  MatchedStat.push_back(RecMuon->numberOfMatchedStations());
346  GlobalTrckPt.push_back(RecMuon->globalTrack()->pt());
347  GlobalTrckEta.push_back(RecMuon->globalTrack()->eta());
348  GlobalTrckPhi.push_back(RecMuon->globalTrack()->phi());
349  Tight_TransImpara.push_back(fabs(RecMuon->muonBestTrack()->dxy((*firstGoodVertex).position())));
350  Tight_LongPara.push_back(fabs(RecMuon->muonBestTrack()->dz((*firstGoodVertex).position())));
351  } else {
352  GlobalTrack.push_back(false);
353  chiGlobal.push_back(0);
354  GlobalMuonHits.push_back(0);
355  MatchedStat.push_back(0);
356  GlobalTrckPt.push_back(0);
357  GlobalTrckEta.push_back(0);
358  GlobalTrckPhi.push_back(0);
359  Tight_TransImpara.push_back(0);
360  Tight_LongPara.push_back(0);
361  }
362 
363  IsolationR04.push_back(((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()) );
364 
365  IsolationR03.push_back(((RecMuon->pfIsolationR03().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt - (0.5 * RecMuon->pfIsolationR03().sumPUPt))) / RecMuon->pt()));
366 
367  MuonEcalEnergy.push_back(RecMuon->calEnergy().emS9);
368  MuonHcalEnergy.push_back(RecMuon->calEnergy().hadS9);
369  MuonHOEnergy.push_back(RecMuon->calEnergy().hoS9);
370 
371  double eEcal(0),eHcal(0),activeL(0),eHcalDepth[7],eHcalDepthHot[7];
372  bool tmpmatch = false;
373  unsigned int isHot = 0;
374  for (int i=0; i<7; ++i) eHcalDepth[i]=eHcalDepthHot[i]=-10000;
375 
376  if (RecMuon->innerTrack().isNonnull()) {
377  const reco::Track* pTrack = (RecMuon->innerTrack()).get();
378  spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, (((verbosity_/100)%10>0)));
379 
380  MuonEcalDetId.push_back((trackID.detIdECAL)());
381  MuonHcalDetId.push_back((trackID.detIdHCAL)());
382  MuonEHcalDetId.push_back((trackID.detIdEHCAL)());
383 
385  std::pair<bool,HcalDetId> info = spr::propagateHCALBack(pTrack, geo, bField, (((verbosity_/100)%10>0)));
386  if (info.first) {
387  check = info.second;
388  }
389 
390  if (trackID.okECAL) {
391  const DetId isoCell(trackID.detIdECAL);
392  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);
393  eEcal = e3x3.first;
394  }
395 
396  if (trackID.okHCAL) {
397  const DetId closestCell(trackID.detIdHCAL);
398  HcalDetId hcidt(closestCell.rawId());
399  if ((hcidt.ieta() == check.ieta()) && (hcidt.iphi() == check.iphi()))
400  tmpmatch= true;
401 
402  eHcal = spr::eHCALmatrix(theHBHETopology, closestCell, hbhe,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.,useRaw_);
403  std::vector<std::pair<double,int> > ehdepth;
404  spr::energyHCALCell((HcalDetId) closestCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, (((verbosity_/1000)%10)>0));
405  for (unsigned int i=0; i<ehdepth.size(); ++i) {
406  eHcalDepth[ehdepth[i].second-1] = ehdepth[i].first;
407  }
408 
409  HcalDetId hcid0(closestCell.rawId());
410  activeL = activeLength(trackID.detIdHCAL);
411  HcalDetId hotCell;
412  spr::eHCALmatrix(geo, theHBHETopology, closestCell, hbhe, 1,1, hotCell, false, useRaw_, false);
413  isHot = matchId(closestCell,hotCell);
414  if (hotCell != HcalDetId()) {
415  std::vector<std::pair<double,int> > ehdepth;
416  spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, false);//(((verbosity_/1000)%10)>0 ));
417  for (unsigned int i=0; i<ehdepth.size(); ++i) {
418  eHcalDepthHot[ehdepth[i].second-1] = ehdepth[i].first;
419  }
420  }
421  }
422 
423  } else {
424  MuonEcalDetId.push_back(0);
425  MuonHcalDetId.push_back(0);
426  MuonEHcalDetId.push_back(0);
427  }
428 
429  matchedId.push_back(tmpmatch);
430  MuonEcal3x3Energy.push_back(eEcal);
431  MuonHcal1x1Energy.push_back(eHcal);
432  MuonHcalDepth1Energy.push_back(eHcalDepth[0]);
433  MuonHcalDepth2Energy.push_back(eHcalDepth[1]);
434  MuonHcalDepth3Energy.push_back(eHcalDepth[2]);
435  MuonHcalDepth4Energy.push_back(eHcalDepth[3]);
436  MuonHcalDepth5Energy.push_back(eHcalDepth[4]);
437  MuonHcalDepth6Energy.push_back(eHcalDepth[5]);
438  MuonHcalDepth7Energy.push_back(eHcalDepth[6]);
439  MuonHcalDepth1HotEnergy.push_back(eHcalDepthHot[0]);
440  MuonHcalDepth2HotEnergy.push_back(eHcalDepthHot[1]);
441  MuonHcalDepth3HotEnergy.push_back(eHcalDepthHot[2]);
442  MuonHcalDepth4HotEnergy.push_back(eHcalDepthHot[3]);
443  MuonHcalDepth5HotEnergy.push_back(eHcalDepthHot[4]);
444  MuonHcalDepth6HotEnergy.push_back(eHcalDepthHot[5]);
445  MuonHcalDepth7HotEnergy.push_back(eHcalDepthHot[6]);
446  MuonHcalHot.push_back(isHot);
447  MuonHcalActiveLength.push_back(activeL);
448  }
449  }
450  if (accept) TREE->Fill();
451 }
452 
453 // ------------ method called once each job just before starting event loop ------------
455 
456  TREE = fs->make<TTree>("TREE", "TREE");
457  TREE->Branch("Event_No",&EventNumber);
458  TREE->Branch("Run_No",&RunNumber);
459  TREE->Branch("LumiNumber",&LumiNumber);
460  TREE->Branch("BXNumber",&BXNumber);
461  TREE->Branch("pt_of_muon",&PtGlob);
462  TREE->Branch("eta_of_muon",&EtaGlob);
463  TREE->Branch("phi_of_muon",&PhiGlob);
464  TREE->Branch("energy_of_muon",&Energy);
465  TREE->Branch("p_of_muon",&Pmuon);
466  TREE->Branch("PF_Muon",&muon_is_good);
467  TREE->Branch("Global_Muon",&muon_global);
468  TREE->Branch("Tracker_muon",&muon_tracker);
469 
470  TREE->Branch("hcal_3into3",&MuonHcalEnergy);
471  TREE->Branch("hcal_1x1",&MuonHcal1x1Energy);
472  TREE->Branch("hcal_detID",&MuonHcalDetId);
473  TREE->Branch("hcal_edepth1",&MuonHcalDepth1Energy);
474  TREE->Branch("hcal_edepth2",&MuonHcalDepth2Energy);
475  TREE->Branch("hcal_edepth3",&MuonHcalDepth3Energy);
476  TREE->Branch("hcal_edepth4",&MuonHcalDepth4Energy);
477  TREE->Branch("hcal_edepthHot1",&MuonHcalDepth1HotEnergy);
478  TREE->Branch("hcal_edepthHot2",&MuonHcalDepth2HotEnergy);
479  TREE->Branch("hcal_edepthHot3",&MuonHcalDepth3HotEnergy);
480  TREE->Branch("hcal_edepthHot4",&MuonHcalDepth4HotEnergy);
481 
482  if (maxDepth_ > 4) {
483  TREE->Branch("hcal_edepth5",&MuonHcalDepth5Energy);
484  TREE->Branch("hcal_edepthHot5",&MuonHcalDepth5HotEnergy);
485  if (maxDepth_ > 5) {
486  TREE->Branch("hcal_edepth6",&MuonHcalDepth6Energy);
487  TREE->Branch("hcal_edepthHot6",&MuonHcalDepth6HotEnergy);
488  if (maxDepth_ > 6) {
489  TREE->Branch("hcal_edepth7",&MuonHcalDepth7Energy);
490  TREE->Branch("hcal_edepthHot7",&MuonHcalDepth7HotEnergy);
491  }
492  }
493  }
494 
495 
496  TREE->Branch("TrackerLayer",&TrackerLayer);
497  TREE->Branch("matchedId",&matchedId);
498  TREE->Branch("innerTrack",&innerTrack);
499  TREE->Branch("innerTrackpt",&innerTrackpt);
500  TREE->Branch("innerTracketa",&innerTracketa);
501  TREE->Branch("innerTrackphi",&innerTrackphi);
502  TREE->Branch("MatchedStat",&MatchedStat);
503  TREE->Branch("GlobalTrckPt",&GlobalTrckPt);
504  TREE->Branch("GlobalTrckEta",&GlobalTrckEta);
505  TREE->Branch("GlobalTrckPhi",&GlobalTrckPhi);
506  TREE->Branch("NumPixelLayers",&NumPixelLayers);
507  TREE->Branch("chiTracker",&chiTracker);
508  TREE->Branch("DxyTracker",&DxyTracker);
509  TREE->Branch("DzTracker",&DzTracker);
510  TREE->Branch("OuterTrack",&OuterTrack);
511  TREE->Branch("OuterTrackPt",&OuterTrackPt);
512  TREE->Branch("OuterTrackEta",&OuterTrackEta);
513  TREE->Branch("OuterTrackPhi",&OuterTrackPhi);
514  TREE->Branch("OuterTrackHits",&OuterTrackHits);
515  TREE->Branch("OuterTrackRHits",&OuterTrackRHits);
516  TREE->Branch("OuterTrackChi",&OuterTrackChi);
517  TREE->Branch("GlobalTrack",&GlobalTrack);
518  TREE->Branch("GlobTrack_Chi",&chiGlobal);
519  TREE->Branch("Global_Muon_Hits",&GlobalMuonHits);
520  TREE->Branch("MatchedStations",&MatchedStat);
521  TREE->Branch("Global_Track_Pt",&GlobalTrckPt);
522  TREE->Branch("Global_Track_Eta",&GlobalTrckEta);
523  TREE->Branch("Global_Track_Phi",&GlobalTrckPhi);
525  TREE->Branch("Tight_LongitudinalImpactparameter",&Tight_LongPara);
526  TREE->Branch("Tight_TransImpactparameter",&Tight_TransImpara);
527  TREE->Branch("InnerTrackPixelHits",&Tight_PixelHits);
528  TREE->Branch("IsolationR04",&IsolationR04);
529  TREE->Branch("IsolationR03",&IsolationR03);
530 
531  TREE->Branch("hcal_cellHot",&MuonHcalHot);
532  TREE->Branch("ecal_3into3",&MuonEcalEnergy);
533  TREE->Branch("ecal_3x3",&MuonEcal3x3Energy);
534  TREE->Branch("ecal_detID",&MuonEcalDetId);
535  TREE->Branch("ehcal_detID",&MuonEHcalDetId);
536  TREE->Branch("tracker_3into3",&MuonHOEnergy);
537  TREE->Branch("activeLength",&MuonHcalActiveLength);
538 
540  TREE->Branch("hltresults",&hltresults);
541  TREE->Branch("all_triggers",&all_triggers);
542 
543 }
544 
545 // ------------ method called once each job just after ending the event loop ------------
547 
548 // ------------ method called when starting to processes a run ------------
549 void HcalHBHEMuonAnalyzer::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
550 
552  iSetup.get<HcalRecNumberingRecord>().get(pHRNDC);
553  const HcalDDDRecConstants & hdc = (*pHRNDC);
554  actHB.clear();
555  actHE.clear();
556  actHB = hdc.getThickActive(0);
557  actHE = hdc.getThickActive(1);
558 
559  bool changed = true;
560  all_triggers.clear();
561  if (hltConfig_.init(iRun, iSetup,"HLT" , changed)) {
562  // if init returns TRUE, initialisation has succeeded!
563 #ifdef DebugLog
564  edm::LogInfo("TriggerBlock") << "HLT config with process name "
565  << "HLT" << " successfully extracted";
566 #endif
567 // std::string string_search[5]={"HLT_IsoMu_","HLT_L1SingleMu_","HLT_L2Mu","HLT_Mu","HLT_RelIso1p0Mu"};
568  std::string string_search[6]={"HLT_IsoMu17","HLT_IsoMu20","HLT_IsoMu24","HLT_IsoMu27","HLT_Mu45","HLT_Mu50"};
569 
570  unsigned int ntriggers = hltConfig_.size();
571  for (unsigned int t=0;t<ntriggers;++t) {
573  for (unsigned int ik=0; ik<6; ++ik) {
574  if (hltname.find(string_search[ik])!=std::string::npos ){
575  all_triggers.push_back(hltname);
576  break;
577  }
578  }
579  }//loop over ntriggers
580  edm::LogInfo("HcalHBHEMuon") << "All triggers size in begin run "
581  << all_triggers.size();
582  } else {
583  edm::LogError("HcalHBHEMuon") << "Error! HLT config extraction with process name "
584  << "HLT"<< " failed";
585  }
586 
587 }
588 
589 
590 // ------------ method called when ending the processing of a run ------------
592 
593 // ------------ method called when starting to processes a luminosity block ------------
595 
596 // ------------ method called when ending the processing of a luminosity block ------------
598 
599 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
601  //The following says we do not know what parameters are allowed so do no validation
602  // Please change this to state exactly what you do use, even if it is no parameters
604  desc.setUnknown();
605  descriptions.addDefault(desc);
606 }
607 
610  EventNumber = -99999;
611  RunNumber = -99999;
612  LumiNumber = -99999;
613  BXNumber = -99999;
614  muon_is_good.clear();
615  muon_global.clear();
616  muon_tracker.clear();
617  PtGlob.clear();
618  EtaGlob.clear();
619  PhiGlob.clear();
620  Energy.clear();
621  Pmuon.clear();
622  TrackerLayer.clear();
623  matchedId.clear();
624  innerTrack.clear();
625  NumPixelLayers.clear();
626  chiTracker.clear();
627  DxyTracker.clear();
628  DzTracker.clear();
629  innerTrackpt.clear();
630  innerTracketa.clear();
631  innerTrackphi.clear();
632  Tight_PixelHits.clear();
633  OuterTrack.clear();
634  OuterTrackPt.clear();
635  OuterTrackEta.clear();
636  OuterTrackPhi.clear();
637  OuterTrackHits.clear();
638  OuterTrackRHits.clear();
639  OuterTrackChi.clear();
640  GlobalTrack.clear();
641  chiGlobal.clear();
642  GlobalMuonHits.clear();
643  MatchedStat.clear();
644  GlobalTrckPt.clear();
645  GlobalTrckEta.clear();
646  GlobalTrckPhi.clear();
647  Tight_TransImpara.clear();
648  Tight_LongPara.clear();
649 
650  IsolationR04.clear();
651  IsolationR03.clear();
652  MuonEcalEnergy.clear();
653  MuonHcalEnergy.clear();
654  MuonHOEnergy.clear();
655  MuonEcalDetId.clear();
656  MuonHcalDetId.clear();
657  MuonEHcalDetId.clear();
658  MuonEcal3x3Energy.clear();
659  MuonHcal1x1Energy.clear();
660  MuonHcalDepth1Energy.clear();
661  MuonHcalDepth2Energy.clear();
662  MuonHcalDepth3Energy.clear();
663  MuonHcalDepth4Energy.clear();
664  MuonHcalDepth5Energy.clear();
665  MuonHcalDepth6Energy.clear();
666  MuonHcalDepth7Energy.clear();
667 
668  MuonHcalDepth1HotEnergy.clear();
669  MuonHcalDepth2HotEnergy.clear();
670  MuonHcalDepth3HotEnergy.clear();
671  MuonHcalDepth4HotEnergy.clear();
672  MuonHcalDepth5HotEnergy.clear();
673  MuonHcalDepth6HotEnergy.clear();
674  MuonHcalDepth7HotEnergy.clear();
675  MuonHcalHot.clear();
676  MuonHcalActiveLength.clear();
677  hltresults.clear();
678 }
679 
680 int HcalHBHEMuonAnalyzer::matchId(const HcalDetId& id1, const HcalDetId& id2) {
681 
682  HcalDetId kd1(id1.subdet(),id1.ieta(),id1.iphi(),1);
683  HcalDetId kd2(id2.subdet(),id2.ieta(),id2.iphi(),1);
684  int match = ((kd1 == kd2) ? 1 : 0);
685  return match;
686 }
687 
689  HcalDetId id(id_);
690  int ieta = id.ietaAbs();
691  int depth= id.depth();
692  double lx(0);
693  if (id.subdet() == HcalBarrel) {
694  for (unsigned int i=0; i<actHB.size(); ++i) {
695  if (ieta == actHB[i].ieta && depth == actHB[i].depth) {
696  lx = actHB[i].thick;
697  break;
698  }
699  }
700  } else {
701  for (unsigned int i=0; i<actHE.size(); ++i) {
702  if (ieta == actHE[i].ieta && depth == actHE[i].depth) {
703  lx = actHE[i].thick;
704  break;
705  }
706  }
707  }
708  return lx;
709 }
710 
712  if (vtx.isFake()) return false;
713  if (vtx.ndof() < 4) return false;
714  if (vtx.position().Rho() > 2.) return false;
715  if (fabs(vtx.position().Z()) > 24.) return false;
716  return true;
717 }
718 
719 //define this as a plug-in
721 
723 
RunNumber_t run() const
Definition: EventID.h:39
unsigned int size() const
number of trigger paths in trigger table
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:215
std::vector< double > GlobalTrckPhi
static const TGPicture * info(bool iBackgroundIsBlack)
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 > matchedId
std::vector< double > OuterTrackHits
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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
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)
std::vector< double > MuonHcalDepth1Energy
int bunchCrossing() const
Definition: EventBase.h:65
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< HcalDDDRecConstants::HcalActiveLength > actHE
std::vector< double > MuonHcalDepth3Energy
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
std::vector< double > PtGlob
const Point & position() const
position
Definition: Vertex.h:99
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::vector< double > MuonHcalDepth2HotEnergy
std::vector< double > OuterTrackRHits
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< double > OuterTrackEta
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
bool check(const std::string &)
std::vector< double > MuonHcalActiveLength
std::vector< double > MuonHcalDepth7Energy
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
std::pair< bool, HcalDetId > propagateHCALBack(const reco::Track *, const CaloGeometry *geo, const MagneticField *bField, bool debug=false)
std::vector< double > MuonHcalDepth2Energy
std::vector< double > IsolationR03
bool isValid() const
Definition: HandleBase.h:75
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, bool debug=false)
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:95
virtual void endRun(edm::Run const &, edm::EventSetup const &)
std::vector< HcalActiveLength > getThickActive(const int type) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::vector< double > Tight_TransImpara
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:101
Definition: DetId.h:18
std::vector< HcalDDDRecConstants::HcalActiveLength > actHB
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:59
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)