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 
55 class HcalRaddamMuon : public edm::one::EDAnalyzer<edm::one::WatchRuns,edm::one::SharedResources> {
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 clearVectors();
70  int matchId(const HcalDetId&, const HcalDetId&);
71  double activeLength(const DetId&);
72 
73  // ----------member data ---------------------------
75 
77  std::vector<double> EtaGlob;
84  std::vector<bool> innerTrack, OuterTrack, GlobalTrack;
85  std::vector<double> IsolationR04,IsolationR03;
90 
91  //
94 
95  //
96  std::vector<double> MuonHcalActiveLength;
97  std::vector<HcalDDDRecConstants::HcalActiveLength> actHB , actHE;
103  const int verbosity_, useRaw_;
104  const bool isAOD_;
108 
109  std::vector<bool> isHB, isHE;
110  TTree *TREE;
111  std::vector<bool> all_ifTriggerpassed;
113  std::vector<int> hltresults;
114  std::vector<float> energy_hb,time_hb;
115  std::vector<std::string> hltpaths,TrigName_;
116  std::vector<int> v_RH_h3x3_ieta;
117  std::vector<int> v_RH_h3x3_iphi;
118  std::vector<double> v_RH_h3x3_ene, PxGlob, PyGlob,PzGlob,Pthetha;
120  double h3x3, h3x3Calo;
125 
134 };
135 
137  hlTriggerResults_(iConfig.getUntrackedParameter<edm::InputTag>("hlTriggerResults_")),
138  muonsrc_(iConfig.getUntrackedParameter<edm::InputTag>("muonSource")),
139  verbosity_(iConfig.getUntrackedParameter<int>("verbosity",0)),
140  useRaw_(iConfig.getUntrackedParameter<int>("UseRaw",0)),
141  isAOD_(iConfig.getUntrackedParameter<bool>("IsAOD",false)) {
142 
143  usesResource(TFileService::kSharedResource);
144 
145  //now do what ever initialization is needed
146  maxDepth_ = iConfig.getUntrackedParameter<int>("MaxDepth",4);
147  if (maxDepth_ > 7) maxDepth_ = 7;
148  else if (maxDepth_ < 1) maxDepth_ = 4;
149 
150  tok_hcal_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits","HcalHits"));
151  tok_trigRes_ = consumes<edm::TriggerResults>(hlTriggerResults_);
152  tok_recVtx_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
153  tok_bs_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
154  if (isAOD_) {
155  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEB"));
156  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("reducedEcalRecHitsEE"));
157  tok_hbhe_= consumes<HBHERecHitCollection>(edm::InputTag("reducedHcalRecHits", "hbhereco"));
158  } else {
159  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEB"));
160  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEE"));
161  tok_hbhe_= consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"));
162  }
163  tok_muon_ = consumes<reco::MuonCollection>(muonsrc_);
164 }
165 
167  // do anything here that needs to be done at desctruction time
168  // (e.g. close files, deallocate resources etc.)
169 }
170 
171 
172 
173 //
174 // member functions
175 //
176 
177 // ------------ method called for each event ------------
179 
180  clearVectors();
181  RunNumber = iEvent.id().run();
182  EventNumber = iEvent.id().event();
183  LumiNumber = iEvent.id().luminosityBlock();
184  BXNumber = iEvent.bunchCrossing();
185 
187  iEvent.getByToken(tok_hcal_,calosimhits);
188 
190  iEvent.getByToken(tok_trigRes_,_Triggers);
191 
192  if ((verbosity_%10)>1) std::cout << "size of all triggers "
193  << all_triggers.size() << std::endl;
194  int Ntriggers = all_triggers.size();
195 
196  if ((verbosity_%10)>1) std::cout << "size of HLT MENU: "
197  << _Triggers->size() << std::endl;
198 
199  if (_Triggers.isValid()) {
200  const edm::TriggerNames &triggerNames_ = iEvent.triggerNames(*_Triggers);
201 
202  std::vector<int> index;
203  for (int i=0;i < Ntriggers;i++) {
204  index.push_back(triggerNames_.triggerIndex(all_triggers[i]));
205  int triggerSize =int( _Triggers->size());
206  if ((verbosity_%10)>2) std::cout << "outside loop " << index[i]
207  << "\ntriggerSize " << triggerSize
208  << std::endl;
209  if (index[i] < triggerSize) {
210  hltresults.push_back(_Triggers->accept(index[i])) ;
211  if ((verbosity_%10)>2) std::cout << "trigger_info " << triggerSize
212  << " triggerSize " << index[i]
213  << " trigger_index " << hltresults.at(i)
214  << " hltresult " << std::endl;
215  } else {
216  edm::LogInfo("TriggerBlock") << "Requested HLT path \"" << "\" does not exist";
217  }
218  }
219  }
220 
221  // get handles to calogeometry and calotopology
223  iSetup.get<CaloGeometryRecord>().get(pG);
224  const CaloGeometry* geo = pG.product();
225 
227  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
228  const MagneticField* bField = bFieldH.product();
229 
231  iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
232  const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
233 
235  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
236 
237  edm::ESHandle<CaloTopology> theCaloTopology;
238  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
239  const CaloTopology *caloTopology = theCaloTopology.product();
240 
242  iSetup.get<HcalRecNumberingRecord>().get(htopo);
243  const HcalTopology* theHBHETopology = htopo.product();
244 
246  iEvent.getByToken(tok_bs_,bmspot);
247 
249  iEvent.getByToken(tok_recVtx_,vtx);
250 
251  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
252  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
253  iEvent.getByToken(tok_EB_,barrelRecHitsHandle);
254  iEvent.getByToken(tok_EE_,endcapRecHitsHandle);
255 
257  iEvent.getByToken(tok_hbhe_,hbhe);
258 
260  iEvent.getByToken(tok_muon_,_Muon);
261  const reco::Vertex& vertex = (*(vtx)->begin());
262 
263  math::XYZPoint bspot;
264  bspot= (bmspot.isValid()) ? bmspot->position() : math::XYZPoint(0,0,0);
265 
266  if (_Muon.isValid()) {
267  for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon!= _Muon->end(); ++RecMuon) {
268  muon_is_good.push_back(RecMuon->isPFMuon());
269  muon_global.push_back(RecMuon->isGlobalMuon());
270  muon_tracker.push_back(RecMuon->isTrackerMuon());
271  PtGlob.push_back((RecMuon)->pt());
272  EtaGlob.push_back(RecMuon->eta());
273  PhiGlob.push_back(RecMuon->phi());
274  Energy.push_back(RecMuon->energy());
275  Pmuon.push_back(RecMuon->p());
276  // if (RecMuon->isPFMuon()) goodEvent = true;
277  // acessing tracker hits info
278  if (RecMuon->track().isNonnull()) {
279  TrackerLayer.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement());
280  } else {
281  TrackerLayer.push_back(-1);
282  }
283  if (RecMuon->innerTrack().isNonnull()) {
284  innerTrack.push_back(true);
285  NumPixelLayers.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
286  chiTracker.push_back(RecMuon->innerTrack()->normalizedChi2());
287  DxyTracker.push_back(fabs(RecMuon->innerTrack()->dxy((vertex).position())));
288  DzTracker.push_back(fabs(RecMuon->innerTrack()->dz((vertex).position())));
289  innerTrackpt.push_back(RecMuon->innerTrack()->pt());
290  innerTracketa.push_back(RecMuon->innerTrack()->eta());
291  innerTrackphi.push_back(RecMuon->innerTrack()->phi());
292  Tight_PixelHits.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
293  } else {
294  innerTrack.push_back(false);
295  NumPixelLayers.push_back(0);
296  chiTracker.push_back(0);
297  DxyTracker.push_back(0);
298  DzTracker.push_back(0);
299  innerTrackpt.push_back(0);
300  innerTracketa.push_back(0);
301  innerTrackphi.push_back(0);
302  Tight_PixelHits.push_back(0);
303  }
304  // outer track info
305 
306  if (RecMuon->outerTrack().isNonnull()) {
307  OuterTrack.push_back(true);
308  OuterTrackPt.push_back(RecMuon->outerTrack()->pt());
309  OuterTrackEta.push_back(RecMuon->outerTrack()->eta());
310  OuterTrackPhi.push_back(RecMuon->outerTrack()->phi());
311  OuterTrackChi.push_back(RecMuon->outerTrack()->normalizedChi2());
312  OuterTrackHits.push_back(RecMuon->outerTrack()->numberOfValidHits());
313  OuterTrackRHits.push_back(RecMuon->outerTrack()->recHitsSize());
314  } else {
315  OuterTrack.push_back(false);
316  OuterTrackPt.push_back(0);
317  OuterTrackEta.push_back(0);
318  OuterTrackPhi.push_back(0);
319  OuterTrackChi.push_back(0);
320  OuterTrackHits.push_back(0);
321  OuterTrackRHits.push_back(0);
322  }
323  // Tight Muon cuts
324  if (RecMuon->globalTrack().isNonnull()) {
325  GlobalTrack.push_back(true);
326  chiGlobal.push_back(RecMuon->globalTrack()->normalizedChi2());
327  GlobalMuonHits.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
328  MatchedStat.push_back(RecMuon->numberOfMatchedStations());
329  GlobalTrckPt.push_back(RecMuon->globalTrack()->pt());
330  GlobalTrckEta.push_back(RecMuon->globalTrack()->eta());
331  GlobalTrckPhi.push_back(RecMuon->globalTrack()->phi());
332  Tight_TransImpara.push_back(fabs(RecMuon->muonBestTrack()->dxy(vertex.position())));
333  Tight_LongPara.push_back(fabs(RecMuon->muonBestTrack()->dz(vertex.position())));
334  } else {
335  GlobalTrack.push_back(false);
336  chiGlobal.push_back(0);
337  GlobalMuonHits.push_back(0);
338  MatchedStat.push_back(0);
339  GlobalTrckPt.push_back(0);
340  GlobalTrckEta.push_back(0);
341  GlobalTrckPhi.push_back(0);
342  Tight_TransImpara.push_back(0);
343  Tight_LongPara.push_back(0);
344  }
345 
346  IsolationR04.push_back(((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()) );
347 
348  IsolationR03.push_back(((RecMuon->pfIsolationR03().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt - (0.5 * RecMuon->pfIsolationR03().sumPUPt))) / RecMuon->pt()));
349 
350  MuonEcalEnergy.push_back(RecMuon->calEnergy().emS9);
351  MuonHcalEnergy.push_back(RecMuon->calEnergy().hadS9);
352  MuonHOEnergy.push_back(RecMuon->calEnergy().hoS9);
353 
354  double eEcal(0),eHcal(0),activeL(0),eHcalDepth[7],eHcalDepthHot[7],eHcalDepthCalo[7],eHcalDepthHotCalo[7];
355  unsigned int isHot = 0;
356  unsigned int isHotCalo = 0;
357 
358  for (int i=0; i<7; ++i) eHcalDepth[i]=eHcalDepthHot[i]=eHcalDepthCalo[i]=eHcalDepthHotCalo[i]=-10000 ;
359 
360  if (RecMuon->innerTrack().isNonnull()) {
361  const reco::Track* pTrack = (RecMuon->innerTrack()).get();
362  spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, (((verbosity_/100)%10>0)));
363 
364  MuonEcalDetId.push_back((trackID.detIdECAL)());
365  MuonHcalDetId.push_back((trackID.detIdHCAL)());
366  MuonEHcalDetId.push_back((trackID.detIdEHCAL)());
367 
368  if(trackID.okECAL){
369  const DetId isoCell(trackID.detIdECAL);
370  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);
371 
372  eEcal = e3x3.first;
373  //std::cout<<"eEcal"<<eEcal<<std::endl;
374  }
375 
376  if (trackID.okHCAL) {
377  const DetId closestCell(trackID.detIdHCAL);
378  eHcal = spr::eHCALmatrix(theHBHETopology, closestCell, hbhe,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.,useRaw_);
379 
380  int iphi = ((HcalDetId)(closestCell)).iphi();
381  int zside = ((HcalDetId)(closestCell)).iphi();
382  int depthHE = theHBHETopology->dddConstants()->getMinDepth(1,16,iphi,zside);
383  //std::cout<<"eHcal"<<eHcal<<std::endl;
384  std::vector<std::pair<double,int> > ehdepth;
385  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));
386  for (unsigned int i=0; i<ehdepth.size(); ++i) {
387  eHcalDepth[ehdepth[i].second-1] = ehdepth[i].first;
388  //std::cout<<eHcalDepth[ehdepth[i].second-1]<<std::endl;
389  }
390 
391  eHcal = spr::eHCALmatrix(theHBHETopology, closestCell, calosimhits,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.,useRaw_);
392 
393  //std::cout<<"eHcal"<<eHcal<<std::endl;
394  const DetId closestCellCalo(trackID.detIdHCAL);
395  iphi = ((HcalDetId)(closestCellCalo)).iphi();
396  zside = ((HcalDetId)(closestCellCalo)).iphi();
397  depthHE = theHBHETopology->dddConstants()->getMinDepth(1,16,iphi,zside);
398  std::vector<std::pair<double,int> > ehdepthCalo;
399  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));
400  for (unsigned int i=0; i<ehdepthCalo.size(); ++i) {
401  eHcalDepthCalo[ehdepthCalo[i].second-1] = ehdepthCalo[i].first;
402  //std::cout<<eHcalDepth[ehdepth[i].second-1]<<std::endl;
403  }
404 
405  HcalDetId hcid0(closestCell.rawId());
406  activeL = activeLength(trackID.detIdHCAL);
407 
408  std::cout<<activeL<<std::endl;
409  HcalDetId hotCell, hotCellCalo;
410  h3x3 = spr::eHCALmatrix(geo,theHBHETopology, closestCell, hbhe, 1,1, hotCell, false, useRaw_, false);
411  h3x3Calo = spr::eHCALmatrix(geo,theHBHETopology, closestCellCalo, calosimhits, 1,1, hotCellCalo, false, useRaw_, false);
412 
413  isHot = matchId(closestCell,hotCell);
414  isHotCalo = matchId(closestCellCalo,hotCellCalo);
415 
416  // std::cout<<"hcal 3X3 < "<<h3x3<<">" << " ClosestCell <" << (HcalDetId)(closestCell) << "> hotCell id < " << hotCell << "> isHot" << isHot << std::endl;
417  if (hotCell != HcalDetId()) {
418  iphi = ((HcalDetId)(hotCell)).iphi();
419  zside = ((HcalDetId)(hotCell)).iphi();
420  depthHE = theHBHETopology->dddConstants()->getMinDepth(1,16,iphi,zside);
421  std::vector<std::pair<double,int> > ehdepth;
422  spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, depthHE, false);//(((verbosity_/1000)%10)>0));
423  for (unsigned int i=0; i<ehdepth.size(); ++i) {
424  eHcalDepthHot[ehdepth[i].second-1] = ehdepth[i].first;
425  // std::cout<<eHcalDepthHot[ehdepth[i].second-1]<<std::endl;
426  }
427  }
428 
429  if (hotCellCalo != HcalDetId()) {
430  iphi = ((HcalDetId)(hotCellCalo)).iphi();
431  zside = ((HcalDetId)(hotCellCalo)).iphi();
432  depthHE = theHBHETopology->dddConstants()->getMinDepth(1,16,iphi,zside);
433  std::vector<std::pair<double,int> > ehdepthCalo;
434 
435  spr::energyHCALCell(hotCellCalo, calosimhits, ehdepthCalo, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, depthHE, false);
436  for (unsigned int i=0; i<ehdepthCalo.size(); ++i) {
437  eHcalDepthHotCalo[ehdepthCalo[i].second-1] = ehdepthCalo[i].first;
438  // std::cout<<eHcalDepthHot[ehdepth[i].second-1]<<std::endl;
439  }
440  }
441  }
442  } else {
443  MuonEcalDetId.push_back(0);
444  MuonHcalDetId.push_back(0);
445  MuonEHcalDetId.push_back(0);
446  }
447 
448  MuonEcal3x3Energy.push_back(eEcal);
449  MuonHcal1x1Energy.push_back(eHcal);
450  MuonHcalDepth1Energy.push_back(eHcalDepth[0]);
451  MuonHcalDepth2Energy.push_back(eHcalDepth[1]);
452  MuonHcalDepth3Energy.push_back(eHcalDepth[2]);
453  MuonHcalDepth4Energy.push_back(eHcalDepth[3]);
454  MuonHcalDepth5Energy.push_back(eHcalDepth[4]);
455  MuonHcalDepth6Energy.push_back(eHcalDepth[5]);
456  MuonHcalDepth7Energy.push_back(eHcalDepth[6]);
457  MuonHcalDepth1HotEnergy.push_back(eHcalDepthHot[0]);
458  MuonHcalDepth2HotEnergy.push_back(eHcalDepthHot[1]);
459  MuonHcalDepth3HotEnergy.push_back(eHcalDepthHot[2]);
460  MuonHcalDepth4HotEnergy.push_back(eHcalDepthHot[3]);
461  MuonHcalDepth5HotEnergy.push_back(eHcalDepthHot[4]);
462  MuonHcalDepth6HotEnergy.push_back(eHcalDepthHot[5]);
463  MuonHcalDepth7HotEnergy.push_back(eHcalDepthHot[6]);
464  MuonHcalHot.push_back(isHot);
465 
466  //
467  MuonHcalDepth1EnergyCalo.push_back(eHcalDepthCalo[0]);
468  MuonHcalDepth2EnergyCalo.push_back(eHcalDepthCalo[1]);
469  MuonHcalDepth3EnergyCalo.push_back(eHcalDepthCalo[2]);
470  MuonHcalDepth4EnergyCalo.push_back(eHcalDepthCalo[3]);
471  MuonHcalDepth5EnergyCalo.push_back(eHcalDepthCalo[4]);
472  MuonHcalDepth6EnergyCalo.push_back(eHcalDepthCalo[5]);
473  MuonHcalDepth7EnergyCalo.push_back(eHcalDepthCalo[6]);
474  MuonHcalDepth1HotEnergyCalo.push_back(eHcalDepthHotCalo[0]);
475  MuonHcalDepth2HotEnergyCalo.push_back(eHcalDepthHotCalo[1]);
476  MuonHcalDepth3HotEnergyCalo.push_back(eHcalDepthHotCalo[2]);
477  MuonHcalDepth4HotEnergyCalo.push_back(eHcalDepthHotCalo[3]);
478  MuonHcalDepth5HotEnergyCalo.push_back(eHcalDepthHotCalo[4]);
479  MuonHcalDepth6HotEnergyCalo.push_back(eHcalDepthHotCalo[5]);
480  MuonHcalDepth7HotEnergyCalo.push_back(eHcalDepthHotCalo[6]);
481  MuonHcalHotCalo.push_back(isHotCalo);
482 
483  //
484  MuonHcalActiveLength.push_back(activeL);
485  }
486  }
487  TREE->Fill();
488 }
489 
490 // ------------ method called once each job just before starting event loop ------------
492 
493  TREE = fs->make<TTree>("TREE", "TREE");
494  TREE->Branch("Event_No",&EventNumber);
495  TREE->Branch("Run_No",&RunNumber);
496  TREE->Branch("LumiNumber",&LumiNumber);
497  TREE->Branch("BXNumber",&BXNumber);
498  TREE->Branch("pt_of_muon",&PtGlob);
499  TREE->Branch("eta_of_muon",&EtaGlob);
500  TREE->Branch("phi_of_muon",&PhiGlob);
501  TREE->Branch("energy_of_muon",&Energy);
502  TREE->Branch("p_of_muon",&Pmuon);
503  TREE->Branch("PF_Muon",&muon_is_good);
504  TREE->Branch("Global_Muon",&muon_global);
505  TREE->Branch("Tracker_muon",&muon_tracker);
506 
507 
508  TREE->Branch("hcal_3into3",&MuonHcalEnergy);
509  TREE->Branch("hcal_1x1",&MuonHcal1x1Energy);
510  TREE->Branch("hcal_detID",&MuonHcalDetId);
511  TREE->Branch("hcal_edepth1",&MuonHcalDepth1Energy);
512  TREE->Branch("hcal_edepth2",&MuonHcalDepth2Energy);
513  TREE->Branch("hcal_edepth3",&MuonHcalDepth3Energy);
514  TREE->Branch("hcal_edepth4",&MuonHcalDepth4Energy);
515  TREE->Branch("hcal_edepthHot1",&MuonHcalDepth1HotEnergy);
516  TREE->Branch("hcal_edepthHot2",&MuonHcalDepth2HotEnergy);
517  TREE->Branch("hcal_edepthHot3",&MuonHcalDepth3HotEnergy);
518  TREE->Branch("hcal_edepthHot4",&MuonHcalDepth4HotEnergy);
519 
520  TREE->Branch("hcal_edepth1PSim",&MuonHcalDepth1EnergyCalo);
521  TREE->Branch("hcal_edepth2PSim",&MuonHcalDepth2EnergyCalo);
522  TREE->Branch("hcal_edepth3PSim",&MuonHcalDepth3EnergyCalo);
523  TREE->Branch("hcal_edepth4PSim",&MuonHcalDepth4EnergyCalo);
524  TREE->Branch("hcal_edepthHot1PSim",&MuonHcalDepth1HotEnergyCalo);
525  TREE->Branch("hcal_edepthHot2PSim",&MuonHcalDepth2HotEnergyCalo);
526  TREE->Branch("hcal_edepthHot3PSim",&MuonHcalDepth3HotEnergyCalo);
527  TREE->Branch("hcal_edepthHot4PSim",&MuonHcalDepth4HotEnergyCalo);
528 
529  if (maxDepth_ > 4) {
530  TREE->Branch("hcal_edepth5PSim",&MuonHcalDepth5EnergyCalo);
531  TREE->Branch("hcal_edepthHot5PSim",&MuonHcalDepth5HotEnergyCalo);
532  if (maxDepth_ > 5) {
533  TREE->Branch("hcal_edepth6PSim",&MuonHcalDepth6EnergyCalo);
534  TREE->Branch("hcal_edepthHot6PSim",&MuonHcalDepth6HotEnergyCalo);
535  if (maxDepth_ > 6) {
536  TREE->Branch("hcal_edepth7PSim",&MuonHcalDepth7EnergyCalo);
537  TREE->Branch("hcal_edepthHot7PSim",&MuonHcalDepth7HotEnergyCalo);
538  }
539  }
540  }
541 
542  TREE->Branch("TrackerLayer",&TrackerLayer);
543  TREE->Branch("innerTrack",&innerTrack);
544  TREE->Branch("innerTrackpt",&innerTrackpt);
545  TREE->Branch("innerTracketa",&innerTracketa);
546  TREE->Branch("innerTrackphi",&innerTrackphi);
547  TREE->Branch("MatchedStat",&MatchedStat);
548  TREE->Branch("GlobalTrckPt",&GlobalTrckPt);
549  TREE->Branch("GlobalTrckEta",&GlobalTrckEta);
550  TREE->Branch("GlobalTrckPhi",&GlobalTrckPhi);
551  TREE->Branch("NumPixelLayers",&NumPixelLayers);
552  TREE->Branch("chiTracker",&chiTracker);
553  TREE->Branch("DxyTracker",&DxyTracker);
554  TREE->Branch("DzTracker",&DzTracker);
555  TREE->Branch("OuterTrack",&OuterTrack);
556  TREE->Branch("OuterTrackPt",&OuterTrackPt);
557  TREE->Branch("OuterTrackEta",&OuterTrackEta);
558  TREE->Branch("OuterTrackPhi",&OuterTrackPhi);
559  TREE->Branch("OuterTrackHits",&OuterTrackHits);
560  TREE->Branch("OuterTrackRHits",&OuterTrackRHits);
561  TREE->Branch("OuterTrackChi",&OuterTrackChi);
562  TREE->Branch("GlobalTrack",&GlobalTrack);
563  TREE->Branch("GlobTrack_Chi",&chiGlobal);
564  TREE->Branch("Global_Muon_Hits",&GlobalMuonHits);
565  TREE->Branch("MatchedStations",&MatchedStat);
566  TREE->Branch("Global_Track_Pt",&GlobalTrckPt);
567  TREE->Branch("Global_Track_Eta",&GlobalTrckEta);
568  TREE->Branch("Global_Track_Phi",&GlobalTrckPhi);
570  TREE->Branch("Tight_LongitudinalImpactparameter",&Tight_LongPara);
571  TREE->Branch("Tight_TransImpactparameter",&Tight_TransImpara);
572  TREE->Branch("InnerTrackPixelHits",&Tight_PixelHits);
573  TREE->Branch("IsolationR04",&IsolationR04);
574  TREE->Branch("IsolationR03",&IsolationR03);
575 
576  TREE->Branch("hcal_cellHot",&MuonHcalHot);
577  TREE->Branch("hcal_cellHotPSim",&MuonHcalHotCalo);
578 
579  TREE->Branch("ecal_3into3",&MuonEcalEnergy);
580  TREE->Branch("ecal_3x3",&MuonEcal3x3Energy);
581  TREE->Branch("ecal_detID",&MuonEcalDetId);
582  TREE->Branch("ehcal_detID",&MuonEHcalDetId);
583  TREE->Branch("tracker_3into3",&MuonHOEnergy);
584  TREE->Branch("activeLength",&MuonHcalActiveLength);
585 
586 
588  TREE->Branch("hltresults",&hltresults);
589  TREE->Branch("all_triggers",&all_triggers);
590  TREE->Branch("rechit_energy",&energy_hb);
591  TREE->Branch("rechit_time",&time_hb);
592 }
593 
594 // ------------ method called once each job just after ending the event loop ------------
596 
597 // ------------ method called when starting to processes a run ------------
598 void HcalRaddamMuon::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
599 
601  iSetup.get<HcalRecNumberingRecord>().get(pHRNDC);
602  const HcalDDDRecConstants & hdc = (*pHRNDC);
603  actHB.clear();
604  actHE.clear();
605  actHB = hdc.getThickActive(0);
606  actHE = hdc.getThickActive(1);
607 
608  bool changed = true;
609  all_triggers.clear();
610  if (hltConfig_.init(iRun, iSetup,"HLT" , changed)) {
611  // if init returns TRUE, initialisation has succeeded!
612  edm::LogInfo("TriggerBlock") << "HLT config with process name "
613  << "HLT" << " successfully extracted";
614  std::string string_search[5]={"HLT_IsoMu_","HLT_L1SingleMu_","HLT_L2Mu","HLT_Mu","HLT_RelIso1p0Mu"};
615  unsigned int ntriggers = hltConfig_.size();
616  for(unsigned int t=0;t<ntriggers;++t){
618  for (unsigned int ik=0; ik<5; ++ik) {
619  if (hltname.find(string_search[ik])!=std::string::npos ){
620  all_triggers.push_back(hltname);
621  break;
622  }
623  }
624  }//loop over ntriggers
625  // std::cout<<"all triggers size in begin run"<<all_triggers.size()<<std::endl;
626  } else {
627  edm::LogError("TriggerBlock") << "Error! HLT config extraction with process name "
628  << "HLT"<< " failed";
629  }
630 
631 }//firstmethod
632 
633 
634 // ------------ method called when ending the processing of a run ------------
636 
639  desc.addUntracked<edm::InputTag>("hlTriggerResults",edm::InputTag("TriggerResults","","HLT"));
640  desc.addUntracked<edm::InputTag>("muonSource",edm::InputTag("muons"));
641  desc.addUntracked<int>("verbosity",0);
642  desc.addUntracked<int>("useRaw",0);
643  desc.add<bool>("isAOD",false);
644  desc.addUntracked<int>("maxDepth",4);
645  descriptions.add("hcalRaddamMuon",desc);
646 }
647 
650  EventNumber = -99999;
651  RunNumber = -99999;
652  LumiNumber = -99999;
653  BXNumber = -99999;
654  energy_hb.clear();
655  time_hb.clear();
656  muon_is_good.clear();
657  muon_global.clear();
658  muon_tracker.clear();
659  PtGlob.clear();
660  EtaGlob.clear();
661  PhiGlob.clear();
662  Energy.clear();
663  Pmuon.clear();
664  TrackerLayer.clear();
665  innerTrack.clear();
666  NumPixelLayers.clear();
667  chiTracker.clear();
668  DxyTracker.clear();
669  DzTracker.clear();
670  innerTrackpt.clear();
671  innerTracketa.clear();
672  innerTrackphi.clear();
673  Tight_PixelHits.clear();
674  OuterTrack.clear();
675  OuterTrackPt.clear();
676  OuterTrackEta.clear();
677  OuterTrackPhi.clear();
678  OuterTrackHits.clear();
679  OuterTrackRHits.clear();
680  OuterTrackChi.clear();
681  GlobalTrack.clear();
682  chiGlobal.clear();
683  GlobalMuonHits.clear();
684  MatchedStat.clear();
685  GlobalTrckPt.clear();
686  GlobalTrckEta.clear();
687  GlobalTrckPhi.clear();
688  Tight_TransImpara.clear();
689  Tight_LongPara.clear();
690 
691  IsolationR04.clear();
692  IsolationR03.clear();
693  MuonEcalEnergy.clear();
694  MuonHcalEnergy.clear();
695  MuonHOEnergy.clear();
696  MuonEcalDetId.clear();
697  MuonHcalDetId.clear();
698  MuonEHcalDetId.clear();
699  MuonEcal3x3Energy.clear();
700  MuonHcal1x1Energy.clear();
701  MuonHcalDepth1Energy.clear();
702  MuonHcalDepth2Energy.clear();
703  MuonHcalDepth3Energy.clear();
704  MuonHcalDepth4Energy.clear();
705  MuonHcalDepth5Energy.clear();
706  MuonHcalDepth6Energy.clear();
707  MuonHcalDepth7Energy.clear();
708 
709  MuonHcalDepth1HotEnergy.clear();
710  MuonHcalDepth2HotEnergy.clear();
711  MuonHcalDepth3HotEnergy.clear();
712  MuonHcalDepth4HotEnergy.clear();
713  MuonHcalDepth5HotEnergy.clear();
714  MuonHcalDepth6HotEnergy.clear();
715  MuonHcalDepth7HotEnergy.clear();
716  MuonHcalHot.clear();
717  MuonHcalActiveLength.clear();
718  hltresults.clear();
719 }
720 
722 
723  HcalDetId kd1(id1.subdet(),id1.ieta(),id1.iphi(),1);
724  HcalDetId kd2(id2.subdet(),id2.ieta(),id2.iphi(),1);
725  int match = ((kd1 == kd2) ? 1 : 0);
726  return match;
727 }
728 
730  HcalDetId id(id_);
731  int ieta = id.ietaAbs();
732  int depth= id.depth();
733  double lx(0);
734  if (id.subdet() == HcalBarrel) {
735  // std::cout<<"actHB.size()"<<actHB.size()<<std::endl;
736  for (unsigned int i=0; i<actHB.size(); ++i) {
737  if (ieta == actHB[i].ieta && depth == actHB[i].depth) {
738  lx = actHB[i].thick;
739  break;
740  }
741  }
742  } else {
743  // std::cout<<"actHE.size()"<<actHE.size()<<std::endl;
744  for (unsigned int i=0; i<actHE.size(); ++i) {
745  if (ieta == actHE[i].ieta && depth == actHE[i].depth) {
746  lx = actHE[i].thick;
747 // std::cout<<"actHE[i].thick"<<actHE[i].thick<<std::endl;
748  break;
749  }
750  }
751  }
752  return lx;
753 }
754 
755 //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
static const std::string kSharedResource
Definition: TFileService.h:76
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
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, const std::string &theTrackQuality, bool debug=false)
~HcalRaddamMuon() override
const HcalDDDRecConstants * dddConstants() const
Definition: HcalTopology.h:167
std::vector< double > dzWithBS
std::vector< double > GlobalMuonHits
std::vector< bool > muon_tracker
std::vector< double > MuonHcalDepth3HotEnergyCalo
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:146
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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:579
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
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
std::vector< unsigned int > MuonEHcalDetId
std::vector< double > track_cosmic_momentumIZ
int bunchCrossing() const
Definition: EventBase.h:66
std::vector< double > NPvz
std::vector< double > OuterTrackEta
std::vector< double > MuonHcalDepth1HotEnergyCalo
std::vector< double > MuonHcalDepth1EnergyCalo
std::vector< HcalDDDRecConstants::HcalActiveLength > actHB
std::vector< double > MuonHcalDepth7Energy
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
int zside(DetId const &)
std::vector< double > NPvx
std::string hltlabel_
std::vector< double > innerTrackphi
std::vector< double > TrackerLayer
const edm::InputTag hlTriggerResults_
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
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
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
const edm::InputTag muonsrc_
HLTConfigProvider hltConfig_
int ieta() const
get the cell ieta
Definition: HcalDetId.h:159
std::vector< double > MuonHcalDepth5EnergyCalo
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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.h:161
Definition: DetId.h:18
std::vector< HcalDDDRecConstants::HcalActiveLength > actHE
std::vector< double > innerTrackpt
std::vector< double > track_cosmic_detIDinner
const int verbosity_
std::vector< bool > Trk_match_MuStat
std::vector< double > MuonHcalDepth3EnergyCalo
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 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 &)
std::vector< double > v_RH_h3x3_ene
std::vector< double > track_cosmic_detIDouter
std::vector< double > Tight_TrkerLayers
std::vector< double > chiTracker
std::vector< bool > GlobalTrack
std::vector< double > dxyWithBS
std::vector< double > MuonHcalDepth6HotEnergyCalo
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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:32
HLT enums.
std::vector< double > PValidHits
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::vector< double > track_cosmic_zmomentum
T get() const
Definition: EventSetup.h:68
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
const bool isAOD_
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:84
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
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, int useRaw=0, int depthHE=3, bool debug=false)
std::vector< double > PD0Error
std::vector< int > hltresults
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:301
std::vector< double > MuonHcalDepth6Energy
std::vector< double > PtGlob
std::vector< double > track_cosmic_zposition
std::vector< double > NRefPointY
Definition: Run.h:44
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
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, int useRaw=0, bool debug=false)
std::vector< double > MatchedStat
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)