CMS 3D CMS Logo

HcalRaddamMuon.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <iostream>
3 #include <vector>
4 
5 #include <TTree.h>
6 
7 // user include files
33 
37 
38 
42 
54 
56 
57 public:
58  explicit HcalRaddamMuon(const edm::ParameterSet&);
59  ~HcalRaddamMuon() override;
60 
61  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
62 
63 private:
64  void beginJob() override ;
65  void analyze(const edm::Event&, const edm::EventSetup& ) override;
66  void endJob() override ;
67  void beginRun(edm::Run const&, edm::EventSetup const&) override;
68  void endRun(edm::Run const&, edm::EventSetup const&) override;
69  void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
70  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
71  void clearVectors();
72  int matchId(const HcalDetId&, const HcalDetId&);
73  double activeLength(const DetId&);
74 
75  // ----------member data ---------------------------
77 
79  std::vector<double> EtaGlob;
86  std::vector<bool> innerTrack, OuterTrack, GlobalTrack;
87  std::vector<double> IsolationR04,IsolationR03;
92 
93  //
96 
97  //
98  std::vector<double> MuonHcalActiveLength;
99  std::vector<HcalDDDRecConstants::HcalActiveLength> actHB , actHE;
109 
110  std::vector<bool> isHB, isHE;
111  TTree *TREE;
112  std::vector<bool> all_ifTriggerpassed;
114  std::vector<int> hltresults;
115  std::vector<float> energy_hb,time_hb;
116  std::vector<std::string> hltpaths,TrigName_;
117  std::vector<int> v_RH_h3x3_ieta;
118  std::vector<int> v_RH_h3x3_iphi;
119  std::vector<double> v_RH_h3x3_ene, PxGlob, PyGlob,PzGlob,Pthetha;
121  std::vector<bool> NTrkQuality;
122  double h3x3, h3x3Calo;
130 
139 };
140 
142  //now do what ever initialization is needed
143  HLTriggerResults_ = iConfig.getUntrackedParameter<edm::InputTag>("HLTriggerResults_");
144  muonsrc_ = iConfig.getUntrackedParameter<edm::InputTag>("MuonSource");
145  verbosity_ = iConfig.getUntrackedParameter<int>("Verbosity",0);
146  isAOD_ = iConfig.getUntrackedParameter<bool>("IsAOD",false);
147  maxDepth_ = iConfig.getUntrackedParameter<int>("MaxDepth",4);
148  useRaw_ = iConfig.getUntrackedParameter<bool>("UseRaw",false);
149 
150  if (maxDepth_ > 7) maxDepth_ = 7;
151  else if (maxDepth_ < 1) maxDepth_ = 4;
152 
153  tok_hcal_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","HcalHits"));
154  tok_trigRes_ = consumes<edm::TriggerResults>(HLTriggerResults_);
155  tok_recVtx_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
156  tok_bs_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
157  if (isAOD_) {
158  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
159  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
160  tok_hbhe_= consumes<HBHERecHitCollection>(edm::InputTag("reducedHcalRecHits", "hbhereco"));
161  } else {
162  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEB"));
163  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEE"));
164  tok_hbhe_= consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"));
165  }
166  tok_muon_ = consumes<reco::MuonCollection>(muonsrc_);
167 }
168 
170  // do anything here that needs to be done at desctruction time
171  // (e.g. close files, deallocate resources etc.)
172 }
173 
174 
175 
176 //
177 // member functions
178 //
179 
180 // ------------ method called for each event ------------
182 
183  clearVectors();
184  RunNumber = iEvent.id().run();
185  EventNumber = iEvent.id().event();
186  LumiNumber = iEvent.id().luminosityBlock();
187  BXNumber = iEvent.bunchCrossing();
188 
190  iEvent.getByToken(tok_hcal_,calosimhits);
191 
193  iEvent.getByToken(tok_trigRes_,_Triggers);
194 
195  if ((verbosity_%10)>1) std::cout << "size of all triggers "
196  << all_triggers.size() << std::endl;
197  int Ntriggers = all_triggers.size();
198 
199  if ((verbosity_%10)>1) std::cout << "size of HLT MENU: "
200  << _Triggers->size() << std::endl;
201 
202  if (_Triggers.isValid()) {
203  const edm::TriggerNames &triggerNames_ = iEvent.triggerNames(*_Triggers);
204 
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  if ((verbosity_%10)>2) std::cout << "outside loop " << index[i]
210  << "\ntriggerSize " << triggerSize
211  << std::endl;
212  if (index[i] < triggerSize) {
213  hltresults.push_back(_Triggers->accept(index[i])) ;
214  if ((verbosity_%10)>2) std::cout << "trigger_info " << triggerSize
215  << " triggerSize " << index[i]
216  << " trigger_index " << hltresults.at(i)
217  << " hltresult " << std::endl;
218  } else {
219  edm::LogInfo("TriggerBlock") << "Requested HLT path \"" << "\" does not exist";
220  }
221  }
222  }
223 
224  // get handles to calogeometry and calotopology
226  iSetup.get<CaloGeometryRecord>().get(pG);
227  const CaloGeometry* geo = pG.product();
228 
230  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
231  const MagneticField* bField = bFieldH.product();
232 
234  iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
235  const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
236 
238  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
239 
240  edm::ESHandle<CaloTopology> theCaloTopology;
241  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
242  const CaloTopology *caloTopology = theCaloTopology.product();
243 
245  iSetup.get<HcalRecNumberingRecord>().get(htopo);
246  const HcalTopology* theHBHETopology = htopo.product();
247 
249  iEvent.getByToken(tok_bs_,bmspot);
250 
252  iEvent.getByToken(tok_recVtx_,vtx);
253 
254  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
255  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
256  iEvent.getByToken(tok_EB_,barrelRecHitsHandle);
257  iEvent.getByToken(tok_EE_,endcapRecHitsHandle);
258 
260  iEvent.getByToken(tok_hbhe_,hbhe);
261 
263  iEvent.getByToken(tok_muon_,_Muon);
264  const reco::Vertex& vertex = (*(vtx)->begin());
265 
266  math::XYZPoint bspot;
267  bspot= (bmspot.isValid()) ? bmspot->position() : math::XYZPoint(0,0,0);
268 
269  if (_Muon.isValid()) {
270  for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon!= _Muon->end(); ++RecMuon) {
271  muon_is_good.push_back(RecMuon->isPFMuon());
272  muon_global.push_back(RecMuon->isGlobalMuon());
273  muon_tracker.push_back(RecMuon->isTrackerMuon());
274  PtGlob.push_back((RecMuon)->pt());
275  EtaGlob.push_back(RecMuon->eta());
276  PhiGlob.push_back(RecMuon->phi());
277  Energy.push_back(RecMuon->energy());
278  Pmuon.push_back(RecMuon->p());
279  // if (RecMuon->isPFMuon()) goodEvent = true;
280  // acessing tracker hits info
281  if (RecMuon->track().isNonnull()) {
282  TrackerLayer.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement());
283  } else {
284  TrackerLayer.push_back(-1);
285  }
286  if (RecMuon->innerTrack().isNonnull()) {
287  innerTrack.push_back(true);
288  NumPixelLayers.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
289  chiTracker.push_back(RecMuon->innerTrack()->normalizedChi2());
290  DxyTracker.push_back(fabs(RecMuon->innerTrack()->dxy((vertex).position())));
291  DzTracker.push_back(fabs(RecMuon->innerTrack()->dz((vertex).position())));
292  innerTrackpt.push_back(RecMuon->innerTrack()->pt());
293  innerTracketa.push_back(RecMuon->innerTrack()->eta());
294  innerTrackphi.push_back(RecMuon->innerTrack()->phi());
295  Tight_PixelHits.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
296  } else {
297  innerTrack.push_back(false);
298  NumPixelLayers.push_back(0);
299  chiTracker.push_back(0);
300  DxyTracker.push_back(0);
301  DzTracker.push_back(0);
302  innerTrackpt.push_back(0);
303  innerTracketa.push_back(0);
304  innerTrackphi.push_back(0);
305  Tight_PixelHits.push_back(0);
306  }
307  // outer track info
308 
309  if (RecMuon->outerTrack().isNonnull()) {
310  OuterTrack.push_back(true);
311  OuterTrackPt.push_back(RecMuon->outerTrack()->pt());
312  OuterTrackEta.push_back(RecMuon->outerTrack()->eta());
313  OuterTrackPhi.push_back(RecMuon->outerTrack()->phi());
314  OuterTrackChi.push_back(RecMuon->outerTrack()->normalizedChi2());
315  OuterTrackHits.push_back(RecMuon->outerTrack()->numberOfValidHits());
316  OuterTrackRHits.push_back(RecMuon->outerTrack()->recHitsSize());
317  } else {
318  OuterTrack.push_back(false);
319  OuterTrackPt.push_back(0);
320  OuterTrackEta.push_back(0);
321  OuterTrackPhi.push_back(0);
322  OuterTrackChi.push_back(0);
323  OuterTrackHits.push_back(0);
324  OuterTrackRHits.push_back(0);
325  }
326  // Tight Muon cuts
327  if (RecMuon->globalTrack().isNonnull()) {
328  GlobalTrack.push_back(true);
329  chiGlobal.push_back(RecMuon->globalTrack()->normalizedChi2());
330  GlobalMuonHits.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
331  MatchedStat.push_back(RecMuon->numberOfMatchedStations());
332  GlobalTrckPt.push_back(RecMuon->globalTrack()->pt());
333  GlobalTrckEta.push_back(RecMuon->globalTrack()->eta());
334  GlobalTrckPhi.push_back(RecMuon->globalTrack()->phi());
335  Tight_TransImpara.push_back(fabs(RecMuon->muonBestTrack()->dxy(vertex.position())));
336  Tight_LongPara.push_back(fabs(RecMuon->muonBestTrack()->dz(vertex.position())));
337  } else {
338  GlobalTrack.push_back(false);
339  chiGlobal.push_back(0);
340  GlobalMuonHits.push_back(0);
341  MatchedStat.push_back(0);
342  GlobalTrckPt.push_back(0);
343  GlobalTrckEta.push_back(0);
344  GlobalTrckPhi.push_back(0);
345  Tight_TransImpara.push_back(0);
346  Tight_LongPara.push_back(0);
347  }
348 
349  IsolationR04.push_back(((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()) );
350 
351  IsolationR03.push_back(((RecMuon->pfIsolationR03().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt - (0.5 * RecMuon->pfIsolationR03().sumPUPt))) / RecMuon->pt()));
352 
353  MuonEcalEnergy.push_back(RecMuon->calEnergy().emS9);
354  MuonHcalEnergy.push_back(RecMuon->calEnergy().hadS9);
355  MuonHOEnergy.push_back(RecMuon->calEnergy().hoS9);
356 
357  double eEcal(0),eHcal(0),activeL(0),eHcalDepth[7],eHcalDepthHot[7],eHcalDepthCalo[7],eHcalDepthHotCalo[7];
358  unsigned int isHot = 0;
359  unsigned int isHotCalo = 0;
360 
361  for (int i=0; i<7; ++i) eHcalDepth[i]=eHcalDepthHot[i]=eHcalDepthCalo[i]=eHcalDepthHotCalo[i]=-10000 ;
362 
363  if (RecMuon->innerTrack().isNonnull()) {
364  const reco::Track* pTrack = (RecMuon->innerTrack()).get();
365  spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, (((verbosity_/100)%10>0)));
366 
367  MuonEcalDetId.push_back((trackID.detIdECAL)());
368  MuonHcalDetId.push_back((trackID.detIdHCAL)());
369  MuonEHcalDetId.push_back((trackID.detIdEHCAL)());
370 
371  if(trackID.okECAL){
372  const DetId isoCell(trackID.detIdECAL);
373  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);
374 
375  eEcal = e3x3.first;
376  //std::cout<<"eEcal"<<eEcal<<std::endl;
377  }
378 
379  if (trackID.okHCAL) {
380  const DetId closestCell(trackID.detIdHCAL);
381  eHcal = spr::eHCALmatrix(theHBHETopology, closestCell, hbhe,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.,useRaw_);
382 
383  int iphi = ((HcalDetId)(closestCell)).iphi();
384  int zside = ((HcalDetId)(closestCell)).iphi();
385  int depthHE = theHBHETopology->dddConstants()->getMinDepth(1,16,iphi,zside);
386  //std::cout<<"eHcal"<<eHcal<<std::endl;
387  std::vector<std::pair<double,int> > ehdepth;
388  spr::energyHCALCell((HcalDetId) closestCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depthHE, (((verbosity_/1000)%10)>0));
389  for (unsigned int i=0; i<ehdepth.size(); ++i) {
390  eHcalDepth[ehdepth[i].second-1] = ehdepth[i].first;
391  //std::cout<<eHcalDepth[ehdepth[i].second-1]<<std::endl;
392  }
393 
394  eHcal = spr::eHCALmatrix(theHBHETopology, closestCell, calosimhits,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.,useRaw_);
395 
396  //std::cout<<"eHcal"<<eHcal<<std::endl;
397  const DetId closestCellCalo(trackID.detIdHCAL);
398  iphi = ((HcalDetId)(closestCellCalo)).iphi();
399  zside = ((HcalDetId)(closestCellCalo)).iphi();
400  depthHE = theHBHETopology->dddConstants()->getMinDepth(1,16,iphi,zside);
401  std::vector<std::pair<double,int> > ehdepthCalo;
402  spr::energyHCALCell((HcalDetId) closestCellCalo, calosimhits, ehdepthCalo, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depthHE, (((verbosity_/1000)%10)>0));
403  for (unsigned int i=0; i<ehdepthCalo.size(); ++i) {
404  eHcalDepthCalo[ehdepthCalo[i].second-1] = ehdepthCalo[i].first;
405  //std::cout<<eHcalDepth[ehdepth[i].second-1]<<std::endl;
406  }
407 
408  HcalDetId hcid0(closestCell.rawId());
409  activeL = activeLength(trackID.detIdHCAL);
410 
411  std::cout<<activeL<<std::endl;
412  HcalDetId hotCell, hotCellCalo;
413  h3x3 = spr::eHCALmatrix(geo,theHBHETopology, closestCell, hbhe, 1,1, hotCell, false, useRaw_, false);
414  h3x3Calo = spr::eHCALmatrix(geo,theHBHETopology, closestCellCalo, calosimhits, 1,1, hotCellCalo, false, useRaw_, false);
415 
416  isHot = matchId(closestCell,hotCell);
417  isHotCalo = matchId(closestCellCalo,hotCellCalo);
418 
419  // std::cout<<"hcal 3X3 < "<<h3x3<<">" << " ClosestCell <" << (HcalDetId)(closestCell) << "> hotCell id < " << hotCell << "> isHot" << isHot << std::endl;
420  if (hotCell != HcalDetId()) {
421  iphi = ((HcalDetId)(hotCell)).iphi();
422  zside = ((HcalDetId)(hotCell)).iphi();
423  depthHE = theHBHETopology->dddConstants()->getMinDepth(1,16,iphi,zside);
424  std::vector<std::pair<double,int> > ehdepth;
425  spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, depthHE, false);//(((verbosity_/1000)%10)>0));
426  for (unsigned int i=0; i<ehdepth.size(); ++i) {
427  eHcalDepthHot[ehdepth[i].second-1] = ehdepth[i].first;
428  // std::cout<<eHcalDepthHot[ehdepth[i].second-1]<<std::endl;
429  }
430  }
431 
432  if (hotCellCalo != HcalDetId()) {
433  iphi = ((HcalDetId)(hotCellCalo)).iphi();
434  zside = ((HcalDetId)(hotCellCalo)).iphi();
435  depthHE = theHBHETopology->dddConstants()->getMinDepth(1,16,iphi,zside);
436  std::vector<std::pair<double,int> > ehdepthCalo;
437 
438  spr::energyHCALCell(hotCellCalo, calosimhits, ehdepthCalo, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depthHE, false);
439  for (unsigned int i=0; i<ehdepthCalo.size(); ++i) {
440  eHcalDepthHotCalo[ehdepthCalo[i].second-1] = ehdepthCalo[i].first;
441  // std::cout<<eHcalDepthHot[ehdepth[i].second-1]<<std::endl;
442  }
443  }
444  }
445  } else {
446  MuonEcalDetId.push_back(0);
447  MuonHcalDetId.push_back(0);
448  MuonEHcalDetId.push_back(0);
449  }
450 
451  MuonEcal3x3Energy.push_back(eEcal);
452  MuonHcal1x1Energy.push_back(eHcal);
453  MuonHcalDepth1Energy.push_back(eHcalDepth[0]);
454  MuonHcalDepth2Energy.push_back(eHcalDepth[1]);
455  MuonHcalDepth3Energy.push_back(eHcalDepth[2]);
456  MuonHcalDepth4Energy.push_back(eHcalDepth[3]);
457  MuonHcalDepth5Energy.push_back(eHcalDepth[4]);
458  MuonHcalDepth6Energy.push_back(eHcalDepth[5]);
459  MuonHcalDepth7Energy.push_back(eHcalDepth[6]);
460  MuonHcalDepth1HotEnergy.push_back(eHcalDepthHot[0]);
461  MuonHcalDepth2HotEnergy.push_back(eHcalDepthHot[1]);
462  MuonHcalDepth3HotEnergy.push_back(eHcalDepthHot[2]);
463  MuonHcalDepth4HotEnergy.push_back(eHcalDepthHot[3]);
464  MuonHcalDepth5HotEnergy.push_back(eHcalDepthHot[4]);
465  MuonHcalDepth6HotEnergy.push_back(eHcalDepthHot[5]);
466  MuonHcalDepth7HotEnergy.push_back(eHcalDepthHot[6]);
467  MuonHcalHot.push_back(isHot);
468 
469  //
470  MuonHcalDepth1EnergyCalo.push_back(eHcalDepthCalo[0]);
471  MuonHcalDepth2EnergyCalo.push_back(eHcalDepthCalo[1]);
472  MuonHcalDepth3EnergyCalo.push_back(eHcalDepthCalo[2]);
473  MuonHcalDepth4EnergyCalo.push_back(eHcalDepthCalo[3]);
474  MuonHcalDepth5EnergyCalo.push_back(eHcalDepthCalo[4]);
475  MuonHcalDepth6EnergyCalo.push_back(eHcalDepthCalo[5]);
476  MuonHcalDepth7EnergyCalo.push_back(eHcalDepthCalo[6]);
477  MuonHcalDepth1HotEnergyCalo.push_back(eHcalDepthHotCalo[0]);
478  MuonHcalDepth2HotEnergyCalo.push_back(eHcalDepthHotCalo[1]);
479  MuonHcalDepth3HotEnergyCalo.push_back(eHcalDepthHotCalo[2]);
480  MuonHcalDepth4HotEnergyCalo.push_back(eHcalDepthHotCalo[3]);
481  MuonHcalDepth5HotEnergyCalo.push_back(eHcalDepthHotCalo[4]);
482  MuonHcalDepth6HotEnergyCalo.push_back(eHcalDepthHotCalo[5]);
483  MuonHcalDepth7HotEnergyCalo.push_back(eHcalDepthHotCalo[6]);
484  MuonHcalHotCalo.push_back(isHotCalo);
485 
486  //
487  MuonHcalActiveLength.push_back(activeL);
488  }
489  }
490  TREE->Fill();
491 }
492 
493 // ------------ method called once each job just before starting event loop ------------
495 
496  TREE = fs->make<TTree>("TREE", "TREE");
497  TREE->Branch("Event_No",&EventNumber);
498  TREE->Branch("Run_No",&RunNumber);
499  TREE->Branch("LumiNumber",&LumiNumber);
500  TREE->Branch("BXNumber",&BXNumber);
501  TREE->Branch("pt_of_muon",&PtGlob);
502  TREE->Branch("eta_of_muon",&EtaGlob);
503  TREE->Branch("phi_of_muon",&PhiGlob);
504  TREE->Branch("energy_of_muon",&Energy);
505  TREE->Branch("p_of_muon",&Pmuon);
506  TREE->Branch("PF_Muon",&muon_is_good);
507  TREE->Branch("Global_Muon",&muon_global);
508  TREE->Branch("Tracker_muon",&muon_tracker);
509 
510 
511  TREE->Branch("hcal_3into3",&MuonHcalEnergy);
512  TREE->Branch("hcal_1x1",&MuonHcal1x1Energy);
513  TREE->Branch("hcal_detID",&MuonHcalDetId);
514  TREE->Branch("hcal_edepth1",&MuonHcalDepth1Energy);
515  TREE->Branch("hcal_edepth2",&MuonHcalDepth2Energy);
516  TREE->Branch("hcal_edepth3",&MuonHcalDepth3Energy);
517  TREE->Branch("hcal_edepth4",&MuonHcalDepth4Energy);
518  TREE->Branch("hcal_edepthHot1",&MuonHcalDepth1HotEnergy);
519  TREE->Branch("hcal_edepthHot2",&MuonHcalDepth2HotEnergy);
520  TREE->Branch("hcal_edepthHot3",&MuonHcalDepth3HotEnergy);
521  TREE->Branch("hcal_edepthHot4",&MuonHcalDepth4HotEnergy);
522 
523  TREE->Branch("hcal_edepth1PSim",&MuonHcalDepth1EnergyCalo);
524  TREE->Branch("hcal_edepth2PSim",&MuonHcalDepth2EnergyCalo);
525  TREE->Branch("hcal_edepth3PSim",&MuonHcalDepth3EnergyCalo);
526  TREE->Branch("hcal_edepth4PSim",&MuonHcalDepth4EnergyCalo);
527  TREE->Branch("hcal_edepthHot1PSim",&MuonHcalDepth1HotEnergyCalo);
528  TREE->Branch("hcal_edepthHot2PSim",&MuonHcalDepth2HotEnergyCalo);
529  TREE->Branch("hcal_edepthHot3PSim",&MuonHcalDepth3HotEnergyCalo);
530  TREE->Branch("hcal_edepthHot4PSim",&MuonHcalDepth4HotEnergyCalo);
531 
532  if (maxDepth_ > 4) {
533  TREE->Branch("hcal_edepth5PSim",&MuonHcalDepth5EnergyCalo);
534  TREE->Branch("hcal_edepthHot5PSim",&MuonHcalDepth5HotEnergyCalo);
535  if (maxDepth_ > 5) {
536  TREE->Branch("hcal_edepth6PSim",&MuonHcalDepth6EnergyCalo);
537  TREE->Branch("hcal_edepthHot6PSim",&MuonHcalDepth6HotEnergyCalo);
538  if (maxDepth_ > 6) {
539  TREE->Branch("hcal_edepth7PSim",&MuonHcalDepth7EnergyCalo);
540  TREE->Branch("hcal_edepthHot7PSim",&MuonHcalDepth7HotEnergyCalo);
541  }
542  }
543  }
544 
545  TREE->Branch("TrackerLayer",&TrackerLayer);
546  TREE->Branch("innerTrack",&innerTrack);
547  TREE->Branch("innerTrackpt",&innerTrackpt);
548  TREE->Branch("innerTracketa",&innerTracketa);
549  TREE->Branch("innerTrackphi",&innerTrackphi);
550  TREE->Branch("MatchedStat",&MatchedStat);
551  TREE->Branch("GlobalTrckPt",&GlobalTrckPt);
552  TREE->Branch("GlobalTrckEta",&GlobalTrckEta);
553  TREE->Branch("GlobalTrckPhi",&GlobalTrckPhi);
554  TREE->Branch("NumPixelLayers",&NumPixelLayers);
555  TREE->Branch("chiTracker",&chiTracker);
556  TREE->Branch("DxyTracker",&DxyTracker);
557  TREE->Branch("DzTracker",&DzTracker);
558  TREE->Branch("OuterTrack",&OuterTrack);
559  TREE->Branch("OuterTrackPt",&OuterTrackPt);
560  TREE->Branch("OuterTrackEta",&OuterTrackEta);
561  TREE->Branch("OuterTrackPhi",&OuterTrackPhi);
562  TREE->Branch("OuterTrackHits",&OuterTrackHits);
563  TREE->Branch("OuterTrackRHits",&OuterTrackRHits);
564  TREE->Branch("OuterTrackChi",&OuterTrackChi);
565  TREE->Branch("GlobalTrack",&GlobalTrack);
566  TREE->Branch("GlobTrack_Chi",&chiGlobal);
567  TREE->Branch("Global_Muon_Hits",&GlobalMuonHits);
568  TREE->Branch("MatchedStations",&MatchedStat);
569  TREE->Branch("Global_Track_Pt",&GlobalTrckPt);
570  TREE->Branch("Global_Track_Eta",&GlobalTrckEta);
571  TREE->Branch("Global_Track_Phi",&GlobalTrckPhi);
573  TREE->Branch("Tight_LongitudinalImpactparameter",&Tight_LongPara);
574  TREE->Branch("Tight_TransImpactparameter",&Tight_TransImpara);
575  TREE->Branch("InnerTrackPixelHits",&Tight_PixelHits);
576  TREE->Branch("IsolationR04",&IsolationR04);
577  TREE->Branch("IsolationR03",&IsolationR03);
578 
579  TREE->Branch("hcal_cellHot",&MuonHcalHot);
580  TREE->Branch("hcal_cellHotPSim",&MuonHcalHotCalo);
581 
582  TREE->Branch("ecal_3into3",&MuonEcalEnergy);
583  TREE->Branch("ecal_3x3",&MuonEcal3x3Energy);
584  TREE->Branch("ecal_detID",&MuonEcalDetId);
585  TREE->Branch("ehcal_detID",&MuonEHcalDetId);
586  TREE->Branch("tracker_3into3",&MuonHOEnergy);
587  TREE->Branch("activeLength",&MuonHcalActiveLength);
588 
589 
591  TREE->Branch("hltresults",&hltresults);
592  TREE->Branch("all_triggers",&all_triggers);
593  TREE->Branch("rechit_energy",&energy_hb);
594  TREE->Branch("rechit_time",&time_hb);
595 }
596 
597 // ------------ method called once each job just after ending the event loop ------------
599 
600 // ------------ method called when starting to processes a run ------------
601 void HcalRaddamMuon::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
602 
604  iSetup.get<HcalRecNumberingRecord>().get(pHRNDC);
605  const HcalDDDRecConstants & hdc = (*pHRNDC);
606  actHB.clear();
607  actHE.clear();
608  actHB = hdc.getThickActive(0);
609  actHE = hdc.getThickActive(1);
610 
611  bool changed = true;
612  all_triggers.clear();
613  if (hltConfig_.init(iRun, iSetup,"HLT" , changed)) {
614  // if init returns TRUE, initialisation has succeeded!
615  edm::LogInfo("TriggerBlock") << "HLT config with process name "
616  << "HLT" << " successfully extracted";
617  std::string string_search[5]={"HLT_IsoMu_","HLT_L1SingleMu_","HLT_L2Mu","HLT_Mu","HLT_RelIso1p0Mu"};
618  unsigned int ntriggers = hltConfig_.size();
619  for(unsigned int t=0;t<ntriggers;++t){
621  for (unsigned int ik=0; ik<5; ++ik) {
622  if (hltname.find(string_search[ik])!=std::string::npos ){
623  all_triggers.push_back(hltname);
624  break;
625  }
626  }
627  }//loop over ntriggers
628  // std::cout<<"all triggers size in begin run"<<all_triggers.size()<<std::endl;
629  } else {
630  edm::LogError("TriggerBlock") << "Error! HLT config extraction with process name "
631  << "HLT"<< " failed";
632  }
633 
634 }//firstmethod
635 
636 
637 // ------------ method called when ending the processing of a run ------------
639 
640 // ------------ method called when starting to processes a luminosity block ------------
642 
643 // ------------ method called when ending the processing of a luminosity block ------------
645 
646 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
648  //The following says we do not know what parameters are allowed so do no validation
649  // Please change this to state exactly what you do use, even if it is no parameters
651  desc.setUnknown();
652  descriptions.addDefault(desc);
653 }
654 
657  EventNumber = -99999;
658  RunNumber = -99999;
659  LumiNumber = -99999;
660  BXNumber = -99999;
661  energy_hb.clear();
662  time_hb.clear();
663  muon_is_good.clear();
664  muon_global.clear();
665  muon_tracker.clear();
666  PtGlob.clear();
667  EtaGlob.clear();
668  PhiGlob.clear();
669  Energy.clear();
670  Pmuon.clear();
671  TrackerLayer.clear();
672  innerTrack.clear();
673  NumPixelLayers.clear();
674  chiTracker.clear();
675  DxyTracker.clear();
676  DzTracker.clear();
677  innerTrackpt.clear();
678  innerTracketa.clear();
679  innerTrackphi.clear();
680  Tight_PixelHits.clear();
681  OuterTrack.clear();
682  OuterTrackPt.clear();
683  OuterTrackEta.clear();
684  OuterTrackPhi.clear();
685  OuterTrackHits.clear();
686  OuterTrackRHits.clear();
687  OuterTrackChi.clear();
688  GlobalTrack.clear();
689  chiGlobal.clear();
690  GlobalMuonHits.clear();
691  MatchedStat.clear();
692  GlobalTrckPt.clear();
693  GlobalTrckEta.clear();
694  GlobalTrckPhi.clear();
695  Tight_TransImpara.clear();
696  Tight_LongPara.clear();
697 
698  IsolationR04.clear();
699  IsolationR03.clear();
700  MuonEcalEnergy.clear();
701  MuonHcalEnergy.clear();
702  MuonHOEnergy.clear();
703  MuonEcalDetId.clear();
704  MuonHcalDetId.clear();
705  MuonEHcalDetId.clear();
706  MuonEcal3x3Energy.clear();
707  MuonHcal1x1Energy.clear();
708  MuonHcalDepth1Energy.clear();
709  MuonHcalDepth2Energy.clear();
710  MuonHcalDepth3Energy.clear();
711  MuonHcalDepth4Energy.clear();
712  MuonHcalDepth5Energy.clear();
713  MuonHcalDepth6Energy.clear();
714  MuonHcalDepth7Energy.clear();
715 
716  MuonHcalDepth1HotEnergy.clear();
717  MuonHcalDepth2HotEnergy.clear();
718  MuonHcalDepth3HotEnergy.clear();
719  MuonHcalDepth4HotEnergy.clear();
720  MuonHcalDepth5HotEnergy.clear();
721  MuonHcalDepth6HotEnergy.clear();
722  MuonHcalDepth7HotEnergy.clear();
723  MuonHcalHot.clear();
724  MuonHcalActiveLength.clear();
725  hltresults.clear();
726 }
727 
729 
730  HcalDetId kd1(id1.subdet(),id1.ieta(),id1.iphi(),1);
731  HcalDetId kd2(id2.subdet(),id2.ieta(),id2.iphi(),1);
732  int match = ((kd1 == kd2) ? 1 : 0);
733  return match;
734 }
735 
737  HcalDetId id(id_);
738  int ieta = id.ietaAbs();
739  int depth= id.depth();
740  double lx(0);
741  if (id.subdet() == HcalBarrel) {
742  // std::cout<<"actHB.size()"<<actHB.size()<<std::endl;
743  for (unsigned int i=0; i<actHB.size(); ++i) {
744  if (ieta == actHB[i].ieta && depth == actHB[i].depth) {
745  lx = actHB[i].thick;
746  break;
747  }
748  }
749  } else {
750  // std::cout<<"actHE.size()"<<actHE.size()<<std::endl;
751  for (unsigned int i=0; i<actHE.size(); ++i) {
752  if (ieta == actHE[i].ieta && depth == actHE[i].depth) {
753  lx = actHE[i].thick;
754 // std::cout<<"actHE[i].thick"<<actHE[i].thick<<std::endl;
755  break;
756  }
757  }
758  }
759  return lx;
760 }
761 
762 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
unsigned int size() const
number of trigger paths in trigger table
double _RecoMuon1TrackIsoSumPtMaxCutValue_03
std::vector< double > MuonHcalDepth1HotEnergy
EventNumber_t event() const
Definition: EventID.h:41
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hcal_
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > track_cosmic_positionOY
std::vector< double > NQOverP
std::vector< float > energy_hb
~HcalRaddamMuon() override
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:161
std::vector< double > dzWithBS
std::vector< double > GlobalMuonHits
std::vector< bool > muon_tracker
std::vector< double > MuonHcalDepth3HotEnergyCalo
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
std::vector< bool > muon_global
std::vector< double > PNormalizedChi2
std::vector< double > MuonEcal3x3Energy
std::vector< int > v_RH_h3x3_iphi
std::vector< double > PdzTrack
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< double > OuterTrackChi
std::vector< double > PCharge
std::vector< double > MuonHcalDepth4EnergyCalo
std::vector< double > NPvy
std::vector< double > Pmuon
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< bool > OuterTrack
std::vector< double > MuonHcalActiveLength
std::vector< double > GlobalTrckPhi
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
std::vector< double > DzTracker
std::vector< bool > muon_is_good
std::vector< std::string > hltpaths
std::vector< double > track_cosmic_rad
std::vector< double > NormChi2
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< double > PxGlob
std::vector< int > v_RH_h3x3_ieta
std::vector< double > MuonHcalDepth6HotEnergy
std::vector< unsigned int > MuonHcalDetId
std::vector< double > MuonHcalDepth6EnergyCalo
double activeLength(const DetId &)
std::vector< unsigned int > MuonEcalDetId
bool accept() const
Has at least one path accepted the event?
std::vector< double > PChi2
std::vector< double > MuonHcalDepth5HotEnergyCalo
std::vector< double > MuonHcal1x1Energy
std::vector< double > MuonHcalDepth4HotEnergyCalo
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
std::vector< unsigned int > MuonEHcalDetId
std::vector< double > track_cosmic_momentumIZ
double eHCALmatrix(const HcalTopology *topology, const DetId &det, edm::Handle< T > &hits, int ieta, int iphi, bool includeHO=false, bool algoNew=true, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, bool useRaw=false, bool debug=false)
int bunchCrossing() const
Definition: EventBase.h:66
std::vector< double > NPvz
std::vector< double > OuterTrackEta
std::vector< double > MuonHcalDepth1HotEnergyCalo
std::vector< double > MuonHcalDepth1EnergyCalo
std::string theTrackQuality
std::vector< HcalDDDRecConstants::HcalActiveLength > actHB
std::vector< double > MuonHcalDepth7Energy
edm::InputTag muonsrc_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< float > time_hb
std::vector< double > OuterTrackPt
std::vector< std::string > TrigName_
std::vector< unsigned int > MuonHcalHot
std::vector< std::string > all_triggers5
std::vector< std::string > all_triggers1
std::vector< double > PzGlob
std::vector< double > Tight_LongPara
std::vector< double > NPvx
std::string hltlabel_
std::vector< double > innerTrackphi
std::vector< double > TrackerLayer
std::vector< double > NRefPointZ
std::vector< double > MuonHcalDepth1Energy
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
std::vector< unsigned int > MuonHcalHotCalo
std::vector< double > MuonHcalDepth4Energy
const Point & position() const
position
Definition: Vertex.h:109
std::vector< double > MuonHcalDepth3HotEnergy
void endJob() override
std::vector< double > EtaGlob
std::vector< double > track_cosmic_momentumOZ
std::vector< double > NQOverPError
std::vector< double > track_cosmic_momentumIX
std::vector< double > PNDoF
std::vector< double > PD0
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
std::vector< double > track_cosmic_ymomentum
std::vector< double > innerTracketa
std::vector< std::string > all_triggers2
std::vector< double > PdxyTrack
std::vector< double > OuterTrackRHits
std::vector< double > MuonHcalDepth5HotEnergy
int iEvent
Definition: GenABIO.cc:230
std::vector< double > MuonEcalEnergy
std::vector< double > trackerlayer_hits
std::vector< double > Tight_GlobalMuonTrkFit
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< double > track_cosmic_xmomentum
std::vector< bool > all_ifTriggerpassed
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
std::vector< double > track_cosmic_positionIY
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
std::vector< double > PLostHits
std::vector< double > MuonHcalDepth2EnergyCalo
double _RecoMuon1TrackIsoSumPtMaxCutValue_04
std::vector< double > track_cosmic_momentumIY
std::vector< double > Energy
std::vector< double > MuonHcalDepth2Energy
unsigned int LumiNumber
std::vector< double > MuonHOEnergy
std::vector< double > track_cosmic_positionIZ
unsigned int size() const
Get number of paths stored.
int getMinDepth(const int &itype, const int &ieta, const int &iphi, const int &zside) const
HLTConfigProvider hltConfig_
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
std::vector< double > MuonHcalDepth5EnergyCalo
void energyHCALCell(HcalDetId detId, edm::Handle< T > &hits, std::vector< std::pair< double, int > > &energyCell, int maxDepth=1, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, bool useRaw=false, int depthHE=3, bool debug=false)
std::vector< double > High_TrackLayers
std::vector< double > track_cosmic_positionOZ
std::vector< double > Tight_TransImpara
std::vector< double > track_cosmic_detid
std::vector< double > Tight_MuonHits
unsigned int RunNumber
std::vector< double > track_cosmic_momentumOX
std::vector< double > track_cosmic_yposition
std::vector< double > track_cosmic_positionIX
bool isValid() const
Definition: HandleBase.h:74
std::vector< double > track_cosmic_momentumOY
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
std::vector< double > DxyTracker
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::vector< bool > innerTrack
std::vector< std::string > all_triggers
std::vector< double > MuonHcalDepth7EnergyCalo
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:124
Definition: DetId.h:18
std::vector< HcalDDDRecConstants::HcalActiveLength > actHE
std::vector< double > innerTrackpt
std::vector< double > track_cosmic_detIDinner
std::vector< bool > Trk_match_MuStat
std::vector< double > MuonHcalDepth3EnergyCalo
std::vector< bool > NTrkQuality
std::vector< double > MuonHcalDepth2HotEnergyCalo
std::vector< bool > isHE
std::vector< double > MuonHcalDepth7HotEnergyCalo
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< double > MuonHcalDepth7HotEnergy
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
HcalRaddamMuon(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:55
std::vector< double > v_RH_h3x3_ene
std::vector< double > track_cosmic_detIDouter
std::vector< double > Tight_TrkerLayers
edm::InputTag HLTriggerResults_
std::vector< double > chiTracker
std::vector< bool > GlobalTrack
std::vector< double > dxyWithBS
std::vector< double > MuonHcalDepth6HotEnergyCalo
std::vector< double > MuonHcalDepth2HotEnergy
std::vector< double > No_pixelLayers
std::vector< double > Tight_MatchedStations
unsigned int EventNumber
std::vector< double > GlobalTrckPt
std::vector< double > MuonHcalDepth5Energy
std::vector< double > Pthetha
std::vector< double > OuterTrackPhi
unsigned int BXNumber
std::vector< double > Tight_PixelHits
edm::EventID id() const
Definition: EventBase.h:60
std::vector< std::string > all_triggers3
std::vector< double > NRefPointX
edm::EDGetTokenT< reco::MuonCollection > tok_muon_
#define begin
Definition: vmac.h:30
std::vector< double > PValidHits
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< double > track_cosmic_zmomentum
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
std::vector< double > track_cosmic_xposition
std::vector< double > MuonHcalDepth4HotEnergy
std::vector< bool > isHB
std::vector< double > PhiGlob
std::vector< std::string > all_triggers4
std::vector< HcalActiveLength > getThickActive(const int &type) const
void beginJob() override
std::vector< double > NTrkMomentum
std::vector< double > NumPixelLayers
const Point & position() const
position
Definition: BeamSpot.h:62
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::vector< double > OuterTrackHits
int matchId(const HcalDetId &, const HcalDetId &)
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
std::vector< double > chiGlobal
std::vector< double > PyGlob
std::vector< double > IsolationR03
std::vector< double > MuonHcalEnergy
std::vector< double > MuonHcalDepth3Energy
T const * product() const
Definition: ESHandle.h:86
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
std::vector< double > PD0Error
std::vector< int > hltresults
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:272
std::vector< double > MuonHcalDepth6Energy
std::vector< double > PtGlob
std::vector< double > track_cosmic_zposition
std::vector< double > NRefPointY
Definition: Run.h:43
void endRun(edm::Run const &, edm::EventSetup const &) override
edm::Service< TFileService > fs
std::vector< double > IsolationR04
std::vector< double > GlobalTrckEta
std::vector< double > track_cosmic_positionOX
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 > ImpactParameter
std::vector< double > MatchedStat
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)