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 
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  if (isSLHC_) {
161  tok_hbhe_= consumes<HBHERecHitCollection>(edm::InputTag("reducedHcalRecHits","hbheUpgradeReco"));
162  } else {
163  tok_hbhe_= consumes<HBHERecHitCollection>(edm::InputTag("reducedHcalRecHits", "hbhereco"));
164  }
165  } else {
166  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEB"));
167  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEE"));
168  if (isSLHC_) {
169  tok_hbhe_= consumes<HBHERecHitCollection>(edm::InputTag("hbheUpgradeReco"));
170  } else {
171  tok_hbhe_= consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"));
172  }
173  }
174  tok_muon_ = consumes<reco::MuonCollection>(muonsrc_);
175 }
176 
178  // do anything here that needs to be done at desctruction time
179  // (e.g. close files, deallocate resources etc.)
180 }
181 
182 
183 
184 //
185 // member functions
186 //
187 
188 // ------------ method called for each event ------------
190 
191  clearVectors();
192  RunNumber = iEvent.id().run();
193  EventNumber = iEvent.id().event();
194  LumiNumber = iEvent.id().luminosityBlock();
195  BXNumber = iEvent.bunchCrossing();
196 
198  iEvent.getByToken(tok_hcal_,calosimhits);
199 
201  iEvent.getByToken(tok_trigRes_,_Triggers);
202 
203  if ((verbosity_%10)>1) std::cout << "size of all triggers "
204  << all_triggers.size() << std::endl;
205  int Ntriggers = all_triggers.size();
206 
207  if ((verbosity_%10)>1) std::cout << "size of HLT MENU: "
208  << _Triggers->size() << std::endl;
209 
210  if (_Triggers.isValid()) {
211  const edm::TriggerNames &triggerNames_ = iEvent.triggerNames(*_Triggers);
212 
213  std::vector<int> index;
214  for (int i=0;i < Ntriggers;i++) {
215  index.push_back(triggerNames_.triggerIndex(all_triggers[i]));
216  int triggerSize =int( _Triggers->size());
217  if ((verbosity_%10)>2) std::cout << "outside loop " << index[i]
218  << "\ntriggerSize " << triggerSize
219  << std::endl;
220  if (index[i] < triggerSize) {
221  hltresults.push_back(_Triggers->accept(index[i])) ;
222  if ((verbosity_%10)>2) std::cout << "trigger_info " << triggerSize
223  << " triggerSize " << index[i]
224  << " trigger_index " << hltresults.at(i)
225  << " hltresult " << std::endl;
226  } else {
227  edm::LogInfo("TriggerBlock") << "Requested HLT path \"" << "\" does not exist";
228  }
229  }
230  }
231 
232  // get handles to calogeometry and calotopology
234  iSetup.get<CaloGeometryRecord>().get(pG);
235  const CaloGeometry* geo = pG.product();
236 
238  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
239  const MagneticField* bField = bFieldH.product();
240 
242  iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
243  const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
244 
246  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
247 
248  edm::ESHandle<CaloTopology> theCaloTopology;
249  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
250  const CaloTopology *caloTopology = theCaloTopology.product();
251 
253  iSetup.get<HcalRecNumberingRecord>().get(htopo);
254  const HcalTopology* theHBHETopology = htopo.product();
255 
257  iEvent.getByToken(tok_bs_,bmspot);
258 
260  iEvent.getByToken(tok_recVtx_,vtx);
261 
262  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
263  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
264  iEvent.getByToken(tok_EB_,barrelRecHitsHandle);
265  iEvent.getByToken(tok_EE_,endcapRecHitsHandle);
266 
268  iEvent.getByToken(tok_hbhe_,hbhe);
269 
271  iEvent.getByToken(tok_muon_,_Muon);
272  const reco::Vertex& vertex = (*(vtx)->begin());
273 
274  math::XYZPoint bspot;
275  bspot= (bmspot.isValid()) ? bmspot->position() : math::XYZPoint(0,0,0);
276 
277  if (_Muon.isValid()) {
278  for (reco::MuonCollection::const_iterator RecMuon = _Muon->begin(); RecMuon!= _Muon->end(); ++RecMuon) {
279  muon_is_good.push_back(RecMuon->isPFMuon());
280  muon_global.push_back(RecMuon->isGlobalMuon());
281  muon_tracker.push_back(RecMuon->isTrackerMuon());
282  PtGlob.push_back((RecMuon)->pt());
283  EtaGlob.push_back(RecMuon->eta());
284  PhiGlob.push_back(RecMuon->phi());
285  Energy.push_back(RecMuon->energy());
286  Pmuon.push_back(RecMuon->p());
287  // if (RecMuon->isPFMuon()) goodEvent = true;
288  // acessing tracker hits info
289  if (RecMuon->track().isNonnull()) {
290  TrackerLayer.push_back(RecMuon->track()->hitPattern().trackerLayersWithMeasurement());
291  } else {
292  TrackerLayer.push_back(-1);
293  }
294  if (RecMuon->innerTrack().isNonnull()) {
295  innerTrack.push_back(true);
296  NumPixelLayers.push_back(RecMuon->innerTrack()->hitPattern().pixelLayersWithMeasurement());
297  chiTracker.push_back(RecMuon->innerTrack()->normalizedChi2());
298  DxyTracker.push_back(fabs(RecMuon->innerTrack()->dxy((vertex).position())));
299  DzTracker.push_back(fabs(RecMuon->innerTrack()->dz((vertex).position())));
300  innerTrackpt.push_back(RecMuon->innerTrack()->pt());
301  innerTracketa.push_back(RecMuon->innerTrack()->eta());
302  innerTrackphi.push_back(RecMuon->innerTrack()->phi());
303  Tight_PixelHits.push_back(RecMuon->innerTrack()->hitPattern().numberOfValidPixelHits());
304  } else {
305  innerTrack.push_back(false);
306  NumPixelLayers.push_back(0);
307  chiTracker.push_back(0);
308  DxyTracker.push_back(0);
309  DzTracker.push_back(0);
310  innerTrackpt.push_back(0);
311  innerTracketa.push_back(0);
312  innerTrackphi.push_back(0);
313  Tight_PixelHits.push_back(0);
314  }
315  // outer track info
316 
317  if (RecMuon->outerTrack().isNonnull()) {
318  OuterTrack.push_back(true);
319  OuterTrackPt.push_back(RecMuon->outerTrack()->pt());
320  OuterTrackEta.push_back(RecMuon->outerTrack()->eta());
321  OuterTrackPhi.push_back(RecMuon->outerTrack()->phi());
322  OuterTrackChi.push_back(RecMuon->outerTrack()->normalizedChi2());
323  OuterTrackHits.push_back(RecMuon->outerTrack()->numberOfValidHits());
324  OuterTrackRHits.push_back(RecMuon->outerTrack()->recHitsSize());
325  } else {
326  OuterTrack.push_back(false);
327  OuterTrackPt.push_back(0);
328  OuterTrackEta.push_back(0);
329  OuterTrackPhi.push_back(0);
330  OuterTrackChi.push_back(0);
331  OuterTrackHits.push_back(0);
332  OuterTrackRHits.push_back(0);
333  }
334  // Tight Muon cuts
335  if (RecMuon->globalTrack().isNonnull()) {
336  GlobalTrack.push_back(true);
337  chiGlobal.push_back(RecMuon->globalTrack()->normalizedChi2());
338  GlobalMuonHits.push_back(RecMuon->globalTrack()->hitPattern().numberOfValidMuonHits());
339  MatchedStat.push_back(RecMuon->numberOfMatchedStations());
340  GlobalTrckPt.push_back(RecMuon->globalTrack()->pt());
341  GlobalTrckEta.push_back(RecMuon->globalTrack()->eta());
342  GlobalTrckPhi.push_back(RecMuon->globalTrack()->phi());
343  Tight_TransImpara.push_back(fabs(RecMuon->muonBestTrack()->dxy(vertex.position())));
344  Tight_LongPara.push_back(fabs(RecMuon->muonBestTrack()->dz(vertex.position())));
345  } else {
346  GlobalTrack.push_back(false);
347  chiGlobal.push_back(0);
348  GlobalMuonHits.push_back(0);
349  MatchedStat.push_back(0);
350  GlobalTrckPt.push_back(0);
351  GlobalTrckEta.push_back(0);
352  GlobalTrckPhi.push_back(0);
353  Tight_TransImpara.push_back(0);
354  Tight_LongPara.push_back(0);
355  }
356 
357  IsolationR04.push_back(((RecMuon->pfIsolationR04().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR04().sumNeutralHadronEt + RecMuon->pfIsolationR04().sumPhotonEt - (0.5 *RecMuon->pfIsolationR04().sumPUPt))) / RecMuon->pt()) );
358 
359  IsolationR03.push_back(((RecMuon->pfIsolationR03().sumChargedHadronPt + std::max(0.,RecMuon->pfIsolationR03().sumNeutralHadronEt + RecMuon->pfIsolationR03().sumPhotonEt - (0.5 * RecMuon->pfIsolationR03().sumPUPt))) / RecMuon->pt()));
360 
361  MuonEcalEnergy.push_back(RecMuon->calEnergy().emS9);
362  MuonHcalEnergy.push_back(RecMuon->calEnergy().hadS9);
363  MuonHOEnergy.push_back(RecMuon->calEnergy().hoS9);
364 
365  double eEcal(0),eHcal(0),activeL(0),eHcalDepth[7],eHcalDepthHot[7],eHcalDepthCalo[7],eHcalDepthHotCalo[7];
366  unsigned int isHot = 0;
367  unsigned int isHotCalo = 0;
368 
369  for (int i=0; i<7; ++i) eHcalDepth[i]=eHcalDepthHot[i]=eHcalDepthCalo[i]=eHcalDepthHotCalo[i]=-10000 ;
370 
371  if (RecMuon->innerTrack().isNonnull()) {
372  const reco::Track* pTrack = (RecMuon->innerTrack()).get();
373  spr::propagatedTrackID trackID = spr::propagateCALO(pTrack, geo, bField, (((verbosity_/100)%10>0)));
374 
375  MuonEcalDetId.push_back((trackID.detIdECAL)());
376  MuonHcalDetId.push_back((trackID.detIdHCAL)());
377  MuonEHcalDetId.push_back((trackID.detIdEHCAL)());
378 
379  if(trackID.okECAL){
380  const DetId isoCell(trackID.detIdECAL);
381  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);
382 
383  eEcal = e3x3.first;
384  //std::cout<<"eEcal"<<eEcal<<std::endl;
385  }
386 
387  if (trackID.okHCAL) {
388  const DetId closestCell(trackID.detIdHCAL);
389  eHcal = spr::eHCALmatrix(theHBHETopology, closestCell, hbhe,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.);
390 
391  //std::cout<<"eHcal"<<eHcal<<std::endl;
392  std::vector<std::pair<double,int> > ehdepth;
393  spr::energyHCALCell((HcalDetId) closestCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, (((verbosity_/1000)%10)>0));
394  for (unsigned int i=0; i<ehdepth.size(); ++i) {
395  eHcalDepth[ehdepth[i].second-1] = ehdepth[i].first;
396  //std::cout<<eHcalDepth[ehdepth[i].second-1]<<std::endl;
397  }
398 
399  eHcal = spr::eHCALmatrix(theHBHETopology, closestCell, calosimhits,0,0, false, true, -100.0, -100.0, -100.0, -100.0, -500.,500.);
400 
401  //std::cout<<"eHcal"<<eHcal<<std::endl;
402  const DetId closestCellCalo(trackID.detIdHCAL);
403  std::vector<std::pair<double,int> > ehdepthCalo;
404  spr::energyHCALCell((HcalDetId) closestCellCalo, calosimhits, ehdepthCalo, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, (((verbosity_/1000)%10)>0));
405  for (unsigned int i=0; i<ehdepthCalo.size(); ++i) {
406  eHcalDepthCalo[ehdepthCalo[i].second-1] = ehdepthCalo[i].first;
407  //std::cout<<eHcalDepth[ehdepth[i].second-1]<<std::endl;
408  }
409 
410  HcalDetId hcid0(closestCell.rawId());
411  activeL = activeLength(trackID.detIdHCAL);
412 
413  std::cout<<activeL<<std::endl;
414  HcalDetId hotCell, hotCellCalo;
415  h3x3 = spr::eHCALmatrix(geo,theHBHETopology, closestCell, hbhe, 1,1, hotCell, false, false);
416  h3x3Calo = spr::eHCALmatrix(geo,theHBHETopology, closestCellCalo, calosimhits, 1,1, hotCellCalo, false, false);
417 
418  isHot = matchId(closestCell,hotCell);
419  isHotCalo = matchId(closestCellCalo,hotCellCalo);
420 
421  // std::cout<<"hcal 3X3 < "<<h3x3<<">" << " ClosestCell <" << (HcalDetId)(closestCell) << "> hotCell id < " << hotCell << "> isHot" << isHot << std::endl;
422  if (hotCell != HcalDetId()) {
423  std::vector<std::pair<double,int> > ehdepth;
424  // spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, false);//(((verbosity_/1000)%10)>0 ));
425  spr::energyHCALCell(hotCell, hbhe, ehdepth, maxDepth_, -100.0, -100.0, -100.0, -100.0, -500.0, 500.0, false);
426  for (unsigned int i=0; i<ehdepth.size(); ++i) {
427  eHcalDepthHot[ehdepth[i].second-1] = ehdepth[i].first;
428  // std::cout<<eHcalDepthHot[ehdepth[i].second-1]<<std::endl;
429  }
430  }
431 
432  if (hotCellCalo != HcalDetId()) {
433  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, 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 
637 // ------------ method called when starting to processes a luminosity block ------------
639 
640 // ------------ method called when ending the processing of a luminosity block ------------
642 
643 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
645  //The following says we do not know what parameters are allowed so do no validation
646  // Please change this to state exactly what you do use, even if it is no parameters
648  desc.setUnknown();
649  descriptions.addDefault(desc);
650 }
651 
654  EventNumber = -99999;
655  RunNumber = -99999;
656  LumiNumber = -99999;
657  BXNumber = -99999;
658  energy_hb.clear();
659  time_hb.clear();
660  muon_is_good.clear();
661  muon_global.clear();
662  muon_tracker.clear();
663  PtGlob.clear();
664  EtaGlob.clear();
665  PhiGlob.clear();
666  Energy.clear();
667  Pmuon.clear();
668  TrackerLayer.clear();
669  innerTrack.clear();
670  NumPixelLayers.clear();
671  chiTracker.clear();
672  DxyTracker.clear();
673  DzTracker.clear();
674  innerTrackpt.clear();
675  innerTracketa.clear();
676  innerTrackphi.clear();
677  Tight_PixelHits.clear();
678  OuterTrack.clear();
679  OuterTrackPt.clear();
680  OuterTrackEta.clear();
681  OuterTrackPhi.clear();
682  OuterTrackHits.clear();
683  OuterTrackRHits.clear();
684  OuterTrackChi.clear();
685  GlobalTrack.clear();
686  chiGlobal.clear();
687  GlobalMuonHits.clear();
688  MatchedStat.clear();
689  GlobalTrckPt.clear();
690  GlobalTrckEta.clear();
691  GlobalTrckPhi.clear();
692  Tight_TransImpara.clear();
693  Tight_LongPara.clear();
694 
695  IsolationR04.clear();
696  IsolationR03.clear();
697  MuonEcalEnergy.clear();
698  MuonHcalEnergy.clear();
699  MuonHOEnergy.clear();
700  MuonEcalDetId.clear();
701  MuonHcalDetId.clear();
702  MuonEHcalDetId.clear();
703  MuonEcal3x3Energy.clear();
704  MuonHcal1x1Energy.clear();
705  MuonHcalDepth1Energy.clear();
706  MuonHcalDepth2Energy.clear();
707  MuonHcalDepth3Energy.clear();
708  MuonHcalDepth4Energy.clear();
709  MuonHcalDepth5Energy.clear();
710  MuonHcalDepth6Energy.clear();
711  MuonHcalDepth7Energy.clear();
712 
713  MuonHcalDepth1HotEnergy.clear();
714  MuonHcalDepth2HotEnergy.clear();
715  MuonHcalDepth3HotEnergy.clear();
716  MuonHcalDepth4HotEnergy.clear();
717  MuonHcalDepth5HotEnergy.clear();
718  MuonHcalDepth6HotEnergy.clear();
719  MuonHcalDepth7HotEnergy.clear();
720  MuonHcalHot.clear();
721  MuonHcalActiveLength.clear();
722  hltresults.clear();
723 }
724 
725 int HcalRaddamMuon::matchId(const HcalDetId& id1, const HcalDetId& id2) {
726 
727  HcalDetId kd1(id1.subdet(),id1.ieta(),id1.iphi(),1);
728  HcalDetId kd2(id2.subdet(),id2.ieta(),id2.iphi(),1);
729  int match = ((kd1 == kd2) ? 1 : 0);
730  return match;
731 }
732 
734  HcalDetId id(id_);
735  int ieta = id.ietaAbs();
736  int depth= id.depth();
737  double lx(0);
738  if (id.subdet() == HcalBarrel) {
739  // std::cout<<"actHB.size()"<<actHB.size()<<std::endl;
740  for (unsigned int i=0; i<actHB.size(); ++i) {
741  if (ieta == actHB[i].ieta && depth == actHB[i].depth) {
742  lx = actHB[i].thick;
743  break;
744  }
745  }
746  } else {
747  // std::cout<<"actHE.size()"<<actHE.size()<<std::endl;
748  for (unsigned int i=0; i<actHE.size(); ++i) {
749  if (ieta == actHE[i].ieta && depth == actHE[i].depth) {
750  lx = actHE[i].thick;
751 // std::cout<<"actHE[i].thick"<<actHE[i].thick<<std::endl;
752  break;
753  }
754  }
755  }
756  return lx;
757 }
758 
759 //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
tuple t
Definition: tree.py:139
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:220
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:45
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:464
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
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:106
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
double eHCALmatrix(const HcalTopology *topology, const DetId &det, edm::Handle< T > &hits, int ieta, int iphi, bool includeHO=false, bool algoNew=true, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, bool debug=false)
void energyHCALCell(HcalDetId detId, edm::Handle< T > &hits, std::vector< std::pair< double, int > > &energyCell, int maxDepth=1, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, bool debug=false)
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:51
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
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.h:53
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: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< double > NTrkMomentum
tuple cout
Definition: gather_cfg.py:121
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)