CMS 3D CMS Logo

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