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