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&);
60 
61  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
62 
63 private:
64  virtual void beginJob() ;
65  virtual void analyze(const edm::Event&, const edm::EventSetup& );
66  virtual void endJob() ;
67  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
68  virtual void endRun(edm::Run const&, edm::EventSetup const&);
69  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
70  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
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  //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_,(((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  std::vector<std::pair<double,int> > ehdepthCalo;
396  spr::energyHCALCell((HcalDetId) closestCellCalo, calosimhits, ehdepthCalo, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, (((verbosity_/1000)%10)>0));
397  for (unsigned int i=0; i<ehdepthCalo.size(); ++i) {
398  eHcalDepthCalo[ehdepthCalo[i].second-1] = ehdepthCalo[i].first;
399  //std::cout<<eHcalDepth[ehdepth[i].second-1]<<std::endl;
400  }
401 
402  HcalDetId hcid0(closestCell.rawId());
403  activeL = activeLength(trackID.detIdHCAL);
404 
405  std::cout<<activeL<<std::endl;
406  HcalDetId hotCell, hotCellCalo;
407  h3x3 = spr::eHCALmatrix(geo,theHBHETopology, closestCell, hbhe, 1,1, hotCell, false, useRaw_, false);
408  h3x3Calo = spr::eHCALmatrix(geo,theHBHETopology, closestCellCalo, calosimhits, 1,1, hotCellCalo, false, useRaw_, false);
409 
410  isHot = matchId(closestCell,hotCell);
411  isHotCalo = matchId(closestCellCalo,hotCellCalo);
412 
413  // std::cout<<"hcal 3X3 < "<<h3x3<<">" << " ClosestCell <" << (HcalDetId)(closestCell) << "> hotCell id < " << hotCell << "> isHot" << isHot << std::endl;
414  if (hotCell != HcalDetId()) {
415  std::vector<std::pair<double,int> > ehdepth;
416  // spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, false);//(((verbosity_/1000)%10)>0 ));
417  spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, false);
418  for (unsigned int i=0; i<ehdepth.size(); ++i) {
419  eHcalDepthHot[ehdepth[i].second-1] = ehdepth[i].first;
420  // std::cout<<eHcalDepthHot[ehdepth[i].second-1]<<std::endl;
421  }
422  }
423 
424  if (hotCellCalo != HcalDetId()) {
425  std::vector<std::pair<double,int> > ehdepthCalo;
426 
427  spr::energyHCALCell(hotCellCalo, calosimhits, ehdepthCalo, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, useRaw_, false);
428  for (unsigned int i=0; i<ehdepthCalo.size(); ++i) {
429  eHcalDepthHotCalo[ehdepthCalo[i].second-1] = ehdepthCalo[i].first;
430  // std::cout<<eHcalDepthHot[ehdepth[i].second-1]<<std::endl;
431  }
432  }
433  }
434  } else {
435  MuonEcalDetId.push_back(0);
436  MuonHcalDetId.push_back(0);
437  MuonEHcalDetId.push_back(0);
438  }
439 
440  MuonEcal3x3Energy.push_back(eEcal);
441  MuonHcal1x1Energy.push_back(eHcal);
442  MuonHcalDepth1Energy.push_back(eHcalDepth[0]);
443  MuonHcalDepth2Energy.push_back(eHcalDepth[1]);
444  MuonHcalDepth3Energy.push_back(eHcalDepth[2]);
445  MuonHcalDepth4Energy.push_back(eHcalDepth[3]);
446  MuonHcalDepth5Energy.push_back(eHcalDepth[4]);
447  MuonHcalDepth6Energy.push_back(eHcalDepth[5]);
448  MuonHcalDepth7Energy.push_back(eHcalDepth[6]);
449  MuonHcalDepth1HotEnergy.push_back(eHcalDepthHot[0]);
450  MuonHcalDepth2HotEnergy.push_back(eHcalDepthHot[1]);
451  MuonHcalDepth3HotEnergy.push_back(eHcalDepthHot[2]);
452  MuonHcalDepth4HotEnergy.push_back(eHcalDepthHot[3]);
453  MuonHcalDepth5HotEnergy.push_back(eHcalDepthHot[4]);
454  MuonHcalDepth6HotEnergy.push_back(eHcalDepthHot[5]);
455  MuonHcalDepth7HotEnergy.push_back(eHcalDepthHot[6]);
456  MuonHcalHot.push_back(isHot);
457 
458  //
459  MuonHcalDepth1EnergyCalo.push_back(eHcalDepthCalo[0]);
460  MuonHcalDepth2EnergyCalo.push_back(eHcalDepthCalo[1]);
461  MuonHcalDepth3EnergyCalo.push_back(eHcalDepthCalo[2]);
462  MuonHcalDepth4EnergyCalo.push_back(eHcalDepthCalo[3]);
463  MuonHcalDepth5EnergyCalo.push_back(eHcalDepthCalo[4]);
464  MuonHcalDepth6EnergyCalo.push_back(eHcalDepthCalo[5]);
465  MuonHcalDepth7EnergyCalo.push_back(eHcalDepthCalo[6]);
466  MuonHcalDepth1HotEnergyCalo.push_back(eHcalDepthHotCalo[0]);
467  MuonHcalDepth2HotEnergyCalo.push_back(eHcalDepthHotCalo[1]);
468  MuonHcalDepth3HotEnergyCalo.push_back(eHcalDepthHotCalo[2]);
469  MuonHcalDepth4HotEnergyCalo.push_back(eHcalDepthHotCalo[3]);
470  MuonHcalDepth5HotEnergyCalo.push_back(eHcalDepthHotCalo[4]);
471  MuonHcalDepth6HotEnergyCalo.push_back(eHcalDepthHotCalo[5]);
472  MuonHcalDepth7HotEnergyCalo.push_back(eHcalDepthHotCalo[6]);
473  MuonHcalHotCalo.push_back(isHotCalo);
474 
475  //
476  MuonHcalActiveLength.push_back(activeL);
477  }
478  }
479  TREE->Fill();
480 }
481 
482 // ------------ method called once each job just before starting event loop ------------
484 
485  TREE = fs->make<TTree>("TREE", "TREE");
486  TREE->Branch("Event_No",&EventNumber);
487  TREE->Branch("Run_No",&RunNumber);
488  TREE->Branch("LumiNumber",&LumiNumber);
489  TREE->Branch("BXNumber",&BXNumber);
490  TREE->Branch("pt_of_muon",&PtGlob);
491  TREE->Branch("eta_of_muon",&EtaGlob);
492  TREE->Branch("phi_of_muon",&PhiGlob);
493  TREE->Branch("energy_of_muon",&Energy);
494  TREE->Branch("p_of_muon",&Pmuon);
495  TREE->Branch("PF_Muon",&muon_is_good);
496  TREE->Branch("Global_Muon",&muon_global);
497  TREE->Branch("Tracker_muon",&muon_tracker);
498 
499 
500  TREE->Branch("hcal_3into3",&MuonHcalEnergy);
501  TREE->Branch("hcal_1x1",&MuonHcal1x1Energy);
502  TREE->Branch("hcal_detID",&MuonHcalDetId);
503  TREE->Branch("hcal_edepth1",&MuonHcalDepth1Energy);
504  TREE->Branch("hcal_edepth2",&MuonHcalDepth2Energy);
505  TREE->Branch("hcal_edepth3",&MuonHcalDepth3Energy);
506  TREE->Branch("hcal_edepth4",&MuonHcalDepth4Energy);
507  TREE->Branch("hcal_edepthHot1",&MuonHcalDepth1HotEnergy);
508  TREE->Branch("hcal_edepthHot2",&MuonHcalDepth2HotEnergy);
509  TREE->Branch("hcal_edepthHot3",&MuonHcalDepth3HotEnergy);
510  TREE->Branch("hcal_edepthHot4",&MuonHcalDepth4HotEnergy);
511 
512  TREE->Branch("hcal_edepth1PSim",&MuonHcalDepth1EnergyCalo);
513  TREE->Branch("hcal_edepth2PSim",&MuonHcalDepth2EnergyCalo);
514  TREE->Branch("hcal_edepth3PSim",&MuonHcalDepth3EnergyCalo);
515  TREE->Branch("hcal_edepth4PSim",&MuonHcalDepth4EnergyCalo);
516  TREE->Branch("hcal_edepthHot1PSim",&MuonHcalDepth1HotEnergyCalo);
517  TREE->Branch("hcal_edepthHot2PSim",&MuonHcalDepth2HotEnergyCalo);
518  TREE->Branch("hcal_edepthHot3PSim",&MuonHcalDepth3HotEnergyCalo);
519  TREE->Branch("hcal_edepthHot4PSim",&MuonHcalDepth4HotEnergyCalo);
520 
521  if (maxDepth_ > 4) {
522  TREE->Branch("hcal_edepth5PSim",&MuonHcalDepth5EnergyCalo);
523  TREE->Branch("hcal_edepthHot5PSim",&MuonHcalDepth5HotEnergyCalo);
524  if (maxDepth_ > 5) {
525  TREE->Branch("hcal_edepth6PSim",&MuonHcalDepth6EnergyCalo);
526  TREE->Branch("hcal_edepthHot6PSim",&MuonHcalDepth6HotEnergyCalo);
527  if (maxDepth_ > 6) {
528  TREE->Branch("hcal_edepth7PSim",&MuonHcalDepth7EnergyCalo);
529  TREE->Branch("hcal_edepthHot7PSim",&MuonHcalDepth7HotEnergyCalo);
530  }
531  }
532  }
533 
534  TREE->Branch("TrackerLayer",&TrackerLayer);
535  TREE->Branch("innerTrack",&innerTrack);
536  TREE->Branch("innerTrackpt",&innerTrackpt);
537  TREE->Branch("innerTracketa",&innerTracketa);
538  TREE->Branch("innerTrackphi",&innerTrackphi);
539  TREE->Branch("MatchedStat",&MatchedStat);
540  TREE->Branch("GlobalTrckPt",&GlobalTrckPt);
541  TREE->Branch("GlobalTrckEta",&GlobalTrckEta);
542  TREE->Branch("GlobalTrckPhi",&GlobalTrckPhi);
543  TREE->Branch("NumPixelLayers",&NumPixelLayers);
544  TREE->Branch("chiTracker",&chiTracker);
545  TREE->Branch("DxyTracker",&DxyTracker);
546  TREE->Branch("DzTracker",&DzTracker);
547  TREE->Branch("OuterTrack",&OuterTrack);
548  TREE->Branch("OuterTrackPt",&OuterTrackPt);
549  TREE->Branch("OuterTrackEta",&OuterTrackEta);
550  TREE->Branch("OuterTrackPhi",&OuterTrackPhi);
551  TREE->Branch("OuterTrackHits",&OuterTrackHits);
552  TREE->Branch("OuterTrackRHits",&OuterTrackRHits);
553  TREE->Branch("OuterTrackChi",&OuterTrackChi);
554  TREE->Branch("GlobalTrack",&GlobalTrack);
555  TREE->Branch("GlobTrack_Chi",&chiGlobal);
556  TREE->Branch("Global_Muon_Hits",&GlobalMuonHits);
557  TREE->Branch("MatchedStations",&MatchedStat);
558  TREE->Branch("Global_Track_Pt",&GlobalTrckPt);
559  TREE->Branch("Global_Track_Eta",&GlobalTrckEta);
560  TREE->Branch("Global_Track_Phi",&GlobalTrckPhi);
562  TREE->Branch("Tight_LongitudinalImpactparameter",&Tight_LongPara);
563  TREE->Branch("Tight_TransImpactparameter",&Tight_TransImpara);
564  TREE->Branch("InnerTrackPixelHits",&Tight_PixelHits);
565  TREE->Branch("IsolationR04",&IsolationR04);
566  TREE->Branch("IsolationR03",&IsolationR03);
567 
568  TREE->Branch("hcal_cellHot",&MuonHcalHot);
569  TREE->Branch("hcal_cellHotPSim",&MuonHcalHotCalo);
570 
571  TREE->Branch("ecal_3into3",&MuonEcalEnergy);
572  TREE->Branch("ecal_3x3",&MuonEcal3x3Energy);
573  TREE->Branch("ecal_detID",&MuonEcalDetId);
574  TREE->Branch("ehcal_detID",&MuonEHcalDetId);
575  TREE->Branch("tracker_3into3",&MuonHOEnergy);
576  TREE->Branch("activeLength",&MuonHcalActiveLength);
577 
578 
580  TREE->Branch("hltresults",&hltresults);
581  TREE->Branch("all_triggers",&all_triggers);
582  TREE->Branch("rechit_energy",&energy_hb);
583  TREE->Branch("rechit_time",&time_hb);
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 HcalRaddamMuon::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
591 
593  iSetup.get<HcalRecNumberingRecord>().get(pHRNDC);
594  const HcalDDDRecConstants & hdc = (*pHRNDC);
595  actHB.clear();
596  actHE.clear();
597  actHB = hdc.getThickActive(0);
598  actHE = hdc.getThickActive(1);
599 
600  bool changed = true;
601  all_triggers.clear();
602  if (hltConfig_.init(iRun, iSetup,"HLT" , changed)) {
603  // if init returns TRUE, initialisation has succeeded!
604  edm::LogInfo("TriggerBlock") << "HLT config with process name "
605  << "HLT" << " successfully extracted";
606  std::string string_search[5]={"HLT_IsoMu_","HLT_L1SingleMu_","HLT_L2Mu","HLT_Mu","HLT_RelIso1p0Mu"};
607  unsigned int ntriggers = hltConfig_.size();
608  for(unsigned int t=0;t<ntriggers;++t){
610  for (unsigned int ik=0; ik<5; ++ik) {
611  if (hltname.find(string_search[ik])!=std::string::npos ){
612  all_triggers.push_back(hltname);
613  break;
614  }
615  }
616  }//loop over ntriggers
617  // std::cout<<"all triggers size in begin run"<<all_triggers.size()<<std::endl;
618  } else {
619  edm::LogError("TriggerBlock") << "Error! HLT config extraction with process name "
620  << "HLT"<< " failed";
621  }
622 
623 }//firstmethod
624 
625 
626 // ------------ method called when ending the processing of a run ------------
628 
629 // ------------ method called when starting to processes a luminosity block ------------
631 
632 // ------------ method called when ending the processing of a luminosity block ------------
634 
635 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
637  //The following says we do not know what parameters are allowed so do no validation
638  // Please change this to state exactly what you do use, even if it is no parameters
640  desc.setUnknown();
641  descriptions.addDefault(desc);
642 }
643 
646  EventNumber = -99999;
647  RunNumber = -99999;
648  LumiNumber = -99999;
649  BXNumber = -99999;
650  energy_hb.clear();
651  time_hb.clear();
652  muon_is_good.clear();
653  muon_global.clear();
654  muon_tracker.clear();
655  PtGlob.clear();
656  EtaGlob.clear();
657  PhiGlob.clear();
658  Energy.clear();
659  Pmuon.clear();
660  TrackerLayer.clear();
661  innerTrack.clear();
662  NumPixelLayers.clear();
663  chiTracker.clear();
664  DxyTracker.clear();
665  DzTracker.clear();
666  innerTrackpt.clear();
667  innerTracketa.clear();
668  innerTrackphi.clear();
669  Tight_PixelHits.clear();
670  OuterTrack.clear();
671  OuterTrackPt.clear();
672  OuterTrackEta.clear();
673  OuterTrackPhi.clear();
674  OuterTrackHits.clear();
675  OuterTrackRHits.clear();
676  OuterTrackChi.clear();
677  GlobalTrack.clear();
678  chiGlobal.clear();
679  GlobalMuonHits.clear();
680  MatchedStat.clear();
681  GlobalTrckPt.clear();
682  GlobalTrckEta.clear();
683  GlobalTrckPhi.clear();
684  Tight_TransImpara.clear();
685  Tight_LongPara.clear();
686 
687  IsolationR04.clear();
688  IsolationR03.clear();
689  MuonEcalEnergy.clear();
690  MuonHcalEnergy.clear();
691  MuonHOEnergy.clear();
692  MuonEcalDetId.clear();
693  MuonHcalDetId.clear();
694  MuonEHcalDetId.clear();
695  MuonEcal3x3Energy.clear();
696  MuonHcal1x1Energy.clear();
697  MuonHcalDepth1Energy.clear();
698  MuonHcalDepth2Energy.clear();
699  MuonHcalDepth3Energy.clear();
700  MuonHcalDepth4Energy.clear();
701  MuonHcalDepth5Energy.clear();
702  MuonHcalDepth6Energy.clear();
703  MuonHcalDepth7Energy.clear();
704 
705  MuonHcalDepth1HotEnergy.clear();
706  MuonHcalDepth2HotEnergy.clear();
707  MuonHcalDepth3HotEnergy.clear();
708  MuonHcalDepth4HotEnergy.clear();
709  MuonHcalDepth5HotEnergy.clear();
710  MuonHcalDepth6HotEnergy.clear();
711  MuonHcalDepth7HotEnergy.clear();
712  MuonHcalHot.clear();
713  MuonHcalActiveLength.clear();
714  hltresults.clear();
715 }
716 
717 int HcalRaddamMuon::matchId(const HcalDetId& id1, const HcalDetId& id2) {
718 
719  HcalDetId kd1(id1.subdet(),id1.ieta(),id1.iphi(),1);
720  HcalDetId kd2(id2.subdet(),id2.ieta(),id2.iphi(),1);
721  int match = ((kd1 == kd2) ? 1 : 0);
722  return match;
723 }
724 
726  HcalDetId id(id_);
727  int ieta = id.ietaAbs();
728  int depth= id.depth();
729  double lx(0);
730  if (id.subdet() == HcalBarrel) {
731  // std::cout<<"actHB.size()"<<actHB.size()<<std::endl;
732  for (unsigned int i=0; i<actHB.size(); ++i) {
733  if (ieta == actHB[i].ieta && depth == actHB[i].depth) {
734  lx = actHB[i].thick;
735  break;
736  }
737  }
738  } else {
739  // std::cout<<"actHE.size()"<<actHE.size()<<std::endl;
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 // std::cout<<"actHE[i].thick"<<actHE[i].thick<<std::endl;
744  break;
745  }
746  }
747  }
748  return lx;
749 }
750 
751 //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
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:460
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
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
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
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< double > MuonHcalDepth3HotEnergy
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.
HLTConfigProvider hltConfig_
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
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
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
std::vector< double > track_cosmic_yposition
std::vector< double > track_cosmic_positionIX
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool isValid() const
Definition: HandleBase.h:74
void energyHCALCell(HcalDetId detId, edm::Handle< T > &hits, std::vector< std::pair< double, int > > &energyCell, int maxDepth=1, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, bool useRaw=false, bool debug=false)
std::vector< double > track_cosmic_momentumOY
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
std::vector< double > DxyTracker
std::vector< bool > innerTrack
std::vector< std::string > all_triggers
std::vector< double > MuonHcalDepth7EnergyCalo
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:103
Definition: DetId.h:18
std::vector< HcalDDDRecConstants::HcalActiveLength > actHE
std::vector< double > innerTrackpt
std::vector< double > track_cosmic_detIDinner
virtual void endRun(edm::Run const &, edm::EventSetup const &)
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
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
virtual void endJob()
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
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
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_
virtual void beginJob()
std::vector< double > PD0Error
std::vector< int > hltresults
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:239
std::vector< double > MuonHcalDepth6Energy
std::vector< double > PtGlob
std::vector< double > track_cosmic_zposition
std::vector< double > NRefPointY
Definition: Run.h:42
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)