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