CMS 3D CMS Logo

IsolatedTracksHcalScale.cc
Go to the documentation of this file.
1 // system include files
2 #include <cmath>
3 #include <string>
4 #include <map>
5 #include <vector>
6 
7 
8 // root objects
9 #include "TROOT.h"
10 #include "TSystem.h"
11 #include "TFile.h"
12 #include "TH1F.h"
13 #include "TH2F.h"
14 #include "TProfile.h"
15 #include "TDirectory.h"
16 #include "TTree.h"
17 
18 #include <Math/GenVector/VectorUtil.h>
19 
30 
32 
37 
38 // muons and tracks
43 // Vertices
47 // Calorimeters
56 
57 // Jets in the event
61 
69 
70 // TFile Service
73 
81 
87 
88 // SimHit
94 
95 // track associator
100 
101 class IsolatedTracksHcalScale : public edm::one::EDAnalyzer<edm::one::SharedResources> {
102 
103 public:
106 
107  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
108 
109 private:
110  void beginJob() override ;
111  void analyze(const edm::Event&, const edm::EventSetup&) override;
112  void endJob() override ;
113 
114  void clearTreeVectors();
115 
116 private:
117 
118  bool doMC_;
123  double tMinE_, tMaxE_;
124 
126 
133 
139 
141 
142  TTree* tree_;
143 
145  std::vector<double> *t_trackP, *t_trackPt, *t_trackEta, *t_trackPhi;
146  std::vector<double> *t_trackHcalEta, *t_trackHcalPhi, *t_eHCALDR;
147  std::vector<double> *t_hCone, *t_conehmaxNearP, *t_eMipDR, *t_eECALDR;
148  std::vector<double> *t_e11x11_20Sig, *t_e15x15_20Sig;
149  std::vector<double> *t_eMipDR_1, *t_eECALDR_1, *t_eMipDR_2, *t_eECALDR_2;
150  std::vector<double> *t_hConeHB, *t_eHCALDRHB;
153  std::vector<double> *t_hsimInfoTotal, *t_hsim;
156  std::vector<int> *t_nSimHits;
157 };
158 
160  doMC_(iConfig.getUntrackedParameter<bool>("DoMC",false)),
161  myverbose_(iConfig.getUntrackedParameter<int>("Verbosity",5)),
162  theTrackQuality_(iConfig.getUntrackedParameter<std::string>("TrackQuality","highPurity")),
163  a_mipR_(iConfig.getUntrackedParameter<double>("ConeRadiusMIP",14.0)),
164  a_coneR_(iConfig.getUntrackedParameter<double>("ConeRadius",34.98)),
165  tMinE_(iConfig.getUntrackedParameter<double>("TimeMinCutECAL",-500.)),
166  tMaxE_(iConfig.getUntrackedParameter<double>("TimeMaxCutECAL",500.)),
168 
169  usesResource(TFileService::kSharedResource);
170 
171  //now do what ever initialization is needed
173  selectionParameters_.minPt = iConfig.getUntrackedParameter<double>("MinTrackPt", 10.0);
175  selectionParameters_.maxDxyPV = iConfig.getUntrackedParameter<double>("MaxDxyPV", 0.2);
176  selectionParameters_.maxDzPV = iConfig.getUntrackedParameter<double>("MaxDzPV", 5.0);
177  selectionParameters_.maxChi2 = iConfig.getUntrackedParameter<double>("MaxChi2", 5.0);
178  selectionParameters_.maxDpOverP = iConfig.getUntrackedParameter<double>("MaxDpOverP", 0.1);
179  selectionParameters_.minOuterHit = iConfig.getUntrackedParameter<int>("MinOuterHit", 4);
180  selectionParameters_.minLayerCrossed = iConfig.getUntrackedParameter<int>("MinLayerCrossed", 8);
181  selectionParameters_.maxInMiss = iConfig.getUntrackedParameter<int>("MaxInMiss", 0);
182  selectionParameters_.maxOutMiss = iConfig.getUntrackedParameter<int>("MaxOutMiss", 0);
183  a_charIsoR_ = a_coneR_ + 28.9;
184  a_neutIsoR_ = a_charIsoR_*0.726;
185 
186  tok_genTrack_ = consumes<reco::TrackCollection>(edm::InputTag("generalTracks"));
187  tok_recVtx_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
188  tok_bs_ = consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"));
189  tok_EB_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEB"));
190  tok_EE_ = consumes<EcalRecHitCollection>(edm::InputTag("ecalRecHit","EcalRecHitsEE"));
191  tok_hbhe_ = consumes<HBHERecHitCollection>(edm::InputTag("hbhereco"));
192  tok_simTk_ = consumes<edm::SimTrackContainer>(edm::InputTag("g4SimHits"));
193  tok_simVtx_ = consumes<edm::SimVertexContainer>(edm::InputTag("g4SimHits"));
194  tok_caloEB_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "EcalHitsEB"));
195  tok_caloEE_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "EcalHitsEE"));
196  tok_caloHH_ = consumes<edm::PCaloHitContainer>(edm::InputTag("g4SimHits", "HcalHits"));
197 
198  if (myverbose_>=0) {
199  edm::LogVerbatim("IsoTrack") <<"Parameters read from config file \n"
200  <<" doMC " << doMC_
201  <<"\t myverbose " << myverbose_
202  <<"\t minPt " << selectionParameters_.minPt
203  <<"\t theTrackQuality " << theTrackQuality_
204  <<"\t minQuality " << selectionParameters_.minQuality
205  <<"\t maxDxyPV " << selectionParameters_.maxDxyPV
206  <<"\t maxDzPV " << selectionParameters_.maxDzPV
207  <<"\t maxChi2 " << selectionParameters_.maxChi2
208  <<"\t maxDpOverP " << selectionParameters_.maxDpOverP
209  <<"\t minOuterHit " << selectionParameters_.minOuterHit
210  <<"\t minLayerCrossed " << selectionParameters_.minLayerCrossed
211  <<"\t maxInMiss " << selectionParameters_.maxInMiss
212  <<"\t maxOutMiss " << selectionParameters_.maxOutMiss
213  <<"\t a_coneR " << a_coneR_
214  <<"\t a_charIsoR " << a_charIsoR_
215  <<"\t a_neutIsoR " << a_neutIsoR_
216  <<"\t a_mipR " << a_mipR_
217  <<"\t time Range (" << tMinE_
218  << ":" << tMaxE_ << ")";
219  }
220 }
221 
223 
225  desc.addUntracked<bool>("doMC", false);
226  desc.addUntracked<int>("Verbosity", 0);
227  desc.addUntracked<std::string>("TrackQuality", "highPurity");
228  desc.addUntracked<double>("MinTrackPt", 10.0);
229  desc.addUntracked<double>("MaxDxyPV", 0.02);
230  desc.addUntracked<double>("MaxDzPV", 0.02);
231  desc.addUntracked<double>("MaxChi2", 5.0);
232  desc.addUntracked<double>("MaxDpOverP", 0.1);
233  desc.addUntracked<int>("MinOuterHit", 4);
234  desc.addUntracked<int>("MinLayerCrossed", 8);
235  desc.addUntracked<int>("MaxInMiss", 0);
236  desc.addUntracked<int>("MaxOutMiss", 0);
237  desc.addUntracked<double>("ConeRadius", 34.98);
238  desc.addUntracked<double>("ConeRadiusMIP", 14.0);
239  desc.addUntracked<double>("TimeMinCutECAL", -500.0);
240  desc.addUntracked<double>("TimeMaxCutECAL", 500.0);
241  descriptions.add("isolatedTracksHcalScale",desc);
242 }
243 
245 
247  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
248  const MagneticField *bField = bFieldH.product();
249 
250  // get handles to calogeometry and calotopology
252  iSetup.get<CaloGeometryRecord>().get(pG);
253  const CaloGeometry* geo = pG.product();
254 
255  edm::ESHandle<CaloTopology> theCaloTopology;
256  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
257  const CaloTopology *caloTopology = theCaloTopology.product();
258 
259  // Retrieve the good/bad ECAL channels from the DB
261  iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
262  const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
263 
265 
266  ++nEventProc_;
267 
268  t_RunNo = iEvent.id().run();
269  t_EvtNo = iEvent.id().event();
270  t_Lumi = iEvent.luminosityBlock();
271  t_Bunch = iEvent.bunchCrossing();
272  if (myverbose_>0)
273  edm::LogVerbatim("IsoTrack") << nEventProc_ << " Run " << t_RunNo
274  << " Event " << t_EvtNo << " Lumi " << t_Lumi
275  << " Bunch " << t_Bunch;
276 
278  iEvent.getByToken(tok_genTrack_, trkCollection);
279 
281  iEvent.getByToken(tok_recVtx_,recVtxs);
282 
283  // Get the beamspot
284  edm::Handle<reco::BeamSpot> beamSpotH;
285  iEvent.getByToken(tok_bs_, beamSpotH);
286 
287  math::XYZPoint leadPV(0,0,0);
288  if (!recVtxs->empty() && !((*recVtxs)[0].isFake())) {
289  leadPV = math::XYZPoint( (*recVtxs)[0].x(),(*recVtxs)[0].y(), (*recVtxs)[0].z() );
290  } else if (beamSpotH.isValid()) {
291  leadPV = beamSpotH->position();
292  }
293 
294  if (myverbose_>0) {
295  edm::LogVerbatim("IsoTrack") << "Primary Vertex " << leadPV;
296  if (beamSpotH.isValid()) edm::LogVerbatim("IsoTrack") << "Beam Spot "
297  << beamSpotH->position();
298  }
299 
300  std::vector<spr::propagatedTrackDirection> trkCaloDirections;
301  spr::propagateCALO(trkCollection, geo, bField, theTrackQuality_, trkCaloDirections, (myverbose_>2));
302  std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
303 
304  edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
305  edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
306  iEvent.getByToken(tok_EB_,barrelRecHitsHandle);
307  iEvent.getByToken(tok_EE_,endcapRecHitsHandle);
308 
310  iEvent.getByToken(tok_hbhe_, hbhe);
311  const HBHERecHitCollection Hithbhe = *(hbhe.product());
312 
313  //get Handles to SimTracks and SimHits
315  edm::SimTrackContainer::const_iterator simTrkItr;
317 
318  //get Handles to PCaloHitContainers of eb/ee/hbhe
322 
323  //associates tracker rechits/simhits to a track
324  std::unique_ptr<TrackerHitAssociator> associate;
325 
326  if (doMC_) {
327  iEvent.getByToken(tok_simTk_,SimTk);
328  iEvent.getByToken(tok_simVtx_,SimVtx);
329  iEvent.getByToken(tok_caloEB_, pcaloeb);
330  iEvent.getByToken(tok_caloEE_, pcaloee);
331  iEvent.getByToken(tok_caloHH_, pcalohh);
332  associate.reset(new TrackerHitAssociator(iEvent, trackerHitAssociatorConfig_));
333  }
334 
335  unsigned int nTracks=0;
336  for (trkDetItr = trkCaloDirections.begin(),nTracks=0; trkDetItr != trkCaloDirections.end(); trkDetItr++,nTracks++){
337  const reco::Track* pTrack = &(*(trkDetItr->trkItr));
338  if (spr::goodTrack(pTrack,leadPV,selectionParameters_,(myverbose_>2)) && trkDetItr->okECAL && trkDetItr->okHCAL) {
339  int nRH_eMipDR=0, nRH_eDR=0, nNearTRKs=0, nRecHitsCone=-99;
340  double distFromHotCell=-99.0, distFromHotCell2=-99.0;
341  int ietaHotCell=-99, iphiHotCell=-99;
342  int ietaHotCell2=-99, iphiHotCell2=-99;
343  GlobalPoint gposHotCell(0.,0.,0.), gposHotCell2(0.,0.,0.);
344  std::vector<DetId> coneRecHitDetIds, coneRecHitDetIds2;
345  std::pair<double, bool> e11x11_20SigP, e15x15_20SigP;
346  double hCone = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL,
347  trkDetItr->pointECAL,
348  a_coneR_, trkDetItr->directionHCAL,
349  nRecHitsCone, coneRecHitDetIds,
350  distFromHotCell, ietaHotCell, iphiHotCell,
351  gposHotCell, -1);
352  double hConeHB = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL,
353  trkDetItr->pointECAL,
354  a_coneR_, trkDetItr->directionHCAL,
355  nRecHitsCone, coneRecHitDetIds,
356  distFromHotCell, ietaHotCell,
357  iphiHotCell, gposHotCell,
358  (int)(HcalBarrel));
359  double eHCALDR = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL,
360  trkDetItr->pointECAL, a_charIsoR_,
361  trkDetItr->directionHCAL, nRecHitsCone,
362  coneRecHitDetIds2, distFromHotCell2,
363  ietaHotCell2, iphiHotCell2, gposHotCell2,
364  -1);
365  double eHCALDRHB = spr::eCone_hcal(geo, hbhe, trkDetItr->pointHCAL,
366  trkDetItr->pointECAL, a_charIsoR_,
367  trkDetItr->directionHCAL, nRecHitsCone,
368  coneRecHitDetIds2, distFromHotCell2,
369  ietaHotCell2, iphiHotCell2,
370  gposHotCell2, (int)(HcalBarrel));
371 
372  double conehmaxNearP = spr::chargeIsolationCone(nTracks, trkCaloDirections, a_charIsoR_, nNearTRKs, (myverbose_>3));
373 
374  double eMipDR = spr::eCone_ecal(geo, barrelRecHitsHandle,
375  endcapRecHitsHandle,trkDetItr->pointHCAL,
376  trkDetItr->pointECAL, a_mipR_,
377  trkDetItr->directionECAL, nRH_eMipDR);
378  double eECALDR = spr::eCone_ecal(geo, barrelRecHitsHandle,
379  endcapRecHitsHandle,trkDetItr->pointHCAL,
380  trkDetItr->pointECAL, a_neutIsoR_,
381  trkDetItr->directionECAL, nRH_eDR);
382  double eMipDR_1= spr::eCone_ecal(geo, barrelRecHitsHandle,
383  endcapRecHitsHandle,trkDetItr->pointHCAL,
384  trkDetItr->pointECAL, a_mipR_,
385  trkDetItr->directionECAL, nRH_eMipDR,
386  0.030, 0.150);
387  double eECALDR_1=spr::eCone_ecal(geo, barrelRecHitsHandle,
388  endcapRecHitsHandle,trkDetItr->pointHCAL,
389  trkDetItr->pointECAL, a_neutIsoR_,
390  trkDetItr->directionECAL, nRH_eDR,
391  0.030, 0.150);
392  double eMipDR_2= spr::eCone_ecal(geo, barrelRecHitsHandle,
393  endcapRecHitsHandle,trkDetItr->pointHCAL,
394  trkDetItr->pointECAL, a_mipR_,
395  trkDetItr->directionECAL, nRH_eMipDR,
396  0.060, 0.300);
397  double eECALDR_2=spr::eCone_ecal(geo, barrelRecHitsHandle,
398  endcapRecHitsHandle,trkDetItr->pointHCAL,
399  trkDetItr->pointECAL, a_neutIsoR_,
400  trkDetItr->directionECAL, nRH_eDR,
401  0.060, 0.300);
402 
403  HcalDetId closestCell = (HcalDetId)(trkDetItr->detIdHCAL);
404 
406  iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
407 
408  e11x11_20SigP = spr::eECALmatrix(trkDetItr->detIdECAL,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),5,5, 0.060, 0.300, tMinE_,tMaxE_);
409  e15x15_20SigP = spr::eECALmatrix(trkDetItr->detIdECAL,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),7,7, 0.060, 0.300, tMinE_,tMaxE_);
410 
411  // Fill the tree Branches here
412  t_trackP ->push_back( pTrack->p() );
413  t_trackPt ->push_back( pTrack->pt() );
414  t_trackEta ->push_back( pTrack->momentum().eta() );
415  t_trackPhi ->push_back( pTrack->momentum().phi() );
416  t_trackHcalEta ->push_back( closestCell.ieta() );
417  t_trackHcalPhi ->push_back( closestCell.iphi() );
418  t_hCone ->push_back( hCone);
419  t_conehmaxNearP ->push_back( conehmaxNearP);
420  t_eMipDR ->push_back( eMipDR);
421  t_eECALDR ->push_back( eECALDR);
422  t_eHCALDR ->push_back( eHCALDR);
423  t_e11x11_20Sig ->push_back( e11x11_20SigP.first );
424  t_e15x15_20Sig ->push_back( e15x15_20SigP.first );
425  t_eMipDR_1 ->push_back( eMipDR_1);
426  t_eECALDR_1 ->push_back( eECALDR_1);
427  t_eMipDR_2 ->push_back( eMipDR_2);
428  t_eECALDR_2 ->push_back( eECALDR_2);
429  t_hConeHB ->push_back( hConeHB);
430  t_eHCALDRHB ->push_back( eHCALDRHB);
431 
432  if (myverbose_ > 0) {
433  edm::LogVerbatim("IsoTrack") << "Track p " << pTrack->p() << " pt "
434  << pTrack->pt() << " eta "
435  << pTrack->momentum().eta() << " phi "
436  << pTrack->momentum().phi()
437  << " ieta/iphi (" << closestCell.ieta()
438  << ", " << closestCell.iphi()
439  << ") Energy in cone " << hCone
440  << " Charge Isolation " << conehmaxNearP
441  << " eMIP (" << eMipDR << ", " << eMipDR_1
442  << ", " << eMipDR_2 << ")"
443  << " Neutral isolation (ECAL) ("
444  << eECALDR-eMipDR << ", "
445  << eECALDR_1-eMipDR_1 << ", "
446  << eECALDR_2-eMipDR_2 << ") (ECAL NxN) "
447  << e15x15_20SigP.first-e11x11_20SigP.first
448  << " (HCAL) " << eHCALDR-hCone;
449  }
450 
451  if (doMC_) {
452  int nSimHits = -999;
453  double hsim;
454  std::map<std::string, double> hsimInfo;
455  std::vector<int> multiplicity;
456  hsim = spr::eCone_hcal(geo, pcalohh, trkDetItr->pointHCAL,
457  trkDetItr->pointECAL, a_coneR_,
458  trkDetItr->directionHCAL, nSimHits);
459  hsimInfo = spr::eHCALSimInfoCone(iEvent, pcalohh, SimTk, SimVtx,
460  pTrack, *associate, geo,
461  trkDetItr->pointHCAL,
462  trkDetItr->pointECAL, a_coneR_,
463  trkDetItr->directionHCAL,
464  multiplicity);
465 
466  t_hsimInfoMatched ->push_back(hsimInfo["eMatched" ]);
467  t_hsimInfoRest ->push_back(hsimInfo["eRest" ]);
468  t_hsimInfoPhoton ->push_back(hsimInfo["eGamma" ]);
469  t_hsimInfoNeutHad ->push_back(hsimInfo["eNeutralHad"]);
470  t_hsimInfoCharHad ->push_back(hsimInfo["eChargedHad"]);
471  t_hsimInfoPdgMatched->push_back(hsimInfo["pdgMatched" ]);
472  t_hsimInfoTotal ->push_back(hsimInfo["eTotal" ]);
473 
474  t_hsimInfoNMatched ->push_back(multiplicity.at(0));
475  t_hsimInfoNTotal ->push_back(multiplicity.at(1));
476  t_hsimInfoNNeutHad ->push_back(multiplicity.at(2));
477  t_hsimInfoNCharHad ->push_back(multiplicity.at(3));
478  t_hsimInfoNPhoton ->push_back(multiplicity.at(4));
479  t_hsimInfoNRest ->push_back(multiplicity.at(5));
480 
481  t_hsim ->push_back(hsim );
482  t_nSimHits ->push_back(nSimHits );
483 
484  if (myverbose_ > 0) {
485  edm::LogVerbatim("IsoTrack") << "Matched (E) " << hsimInfo["eMatched"]
486  << " (N) " << multiplicity.at(0)
487  << " Rest (E) " << hsimInfo["eRest"]
488  << " (N) " << multiplicity.at(1)
489  << " Gamma (E) " << hsimInfo["eGamma"]
490  << " (N) " << multiplicity.at(2)
491  << " Neutral Had (E) "
492  << hsimInfo["eNeutralHad"] << " (N) "
493  << multiplicity.at(3)
494  << " Charged Had (E) "
495  << hsimInfo["eChargedHad"] << " (N) "
496  << multiplicity.at(4) << " Total (E) "
497  << hsimInfo["eTotal"] << " (N) "
498  << multiplicity.at(5) << " PDG "
499  << hsimInfo["pdgMatched"] << " Total E "
500  << hsim << " NHit " << nSimHits;
501  }
502  }
503  }
504  }
505 
506  tree_->Fill();
507 }
508 
510 
511  nEventProc_=0;
513 
515  tree_ = fs->make<TTree>("tree", "tree");
516  tree_->SetAutoSave(10000);
517 
518  tree_->Branch("t_RunNo" ,&t_RunNo ,"t_RunNo/I");
519  tree_->Branch("t_Lumi" ,&t_Lumi ,"t_Lumi/I");
520  tree_->Branch("t_Bunch" ,&t_Bunch ,"t_Bunch/I");
521 
522  t_trackP = new std::vector<double>();
523  t_trackPt = new std::vector<double>();
524  t_trackEta = new std::vector<double>();
525  t_trackPhi = new std::vector<double>();
526  t_trackHcalEta = new std::vector<double>();
527  t_trackHcalPhi = new std::vector<double>();
528  t_hCone = new std::vector<double>();
529  t_conehmaxNearP = new std::vector<double>();
530  t_eMipDR = new std::vector<double>();
531  t_eECALDR = new std::vector<double>();
532  t_eHCALDR = new std::vector<double>();
533  t_e11x11_20Sig = new std::vector<double>();
534  t_e15x15_20Sig = new std::vector<double>();
535  t_eMipDR_1 = new std::vector<double>();
536  t_eECALDR_1 = new std::vector<double>();
537  t_eMipDR_2 = new std::vector<double>();
538  t_eECALDR_2 = new std::vector<double>();
539  t_hConeHB = new std::vector<double>();
540  t_eHCALDRHB = new std::vector<double>();
541 
542  tree_->Branch("t_trackP", "std::vector<double>", &t_trackP);
543  tree_->Branch("t_trackPt", "std::vector<double>", &t_trackPt);
544  tree_->Branch("t_trackEta", "std::vector<double>", &t_trackEta);
545  tree_->Branch("t_trackPhi", "std::vector<double>", &t_trackPhi);
546  tree_->Branch("t_trackHcalEta", "std::vector<double>", &t_trackHcalEta);
547  tree_->Branch("t_trackHcalPhi", "std::vector<double>", &t_trackHcalPhi);
548  tree_->Branch("t_hCone", "std::vector<double>", &t_hCone);
549  tree_->Branch("t_conehmaxNearP", "std::vector<double>", &t_conehmaxNearP);
550  tree_->Branch("t_eMipDR", "std::vector<double>", &t_eMipDR);
551  tree_->Branch("t_eECALDR", "std::vector<double>", &t_eECALDR);
552  tree_->Branch("t_eHCALDR", "std::vector<double>", &t_eHCALDR);
553  tree_->Branch("t_e11x11_20Sig", "std::vector<double>", &t_e11x11_20Sig);
554  tree_->Branch("t_e15x15_20Sig", "std::vector<double>", &t_e15x15_20Sig);
555  tree_->Branch("t_eMipDR_1", "std::vector<double>", &t_eMipDR_1);
556  tree_->Branch("t_eECALDR_1", "std::vector<double>", &t_eECALDR_1);
557  tree_->Branch("t_eMipDR_2", "std::vector<double>", &t_eMipDR_2);
558  tree_->Branch("t_eECALDR_2", "std::vector<double>", &t_eECALDR_2);
559  tree_->Branch("t_hConeHB", "std::vector<double>", &t_hConeHB);
560  tree_->Branch("t_eHCALDRHB", "std::vector<double>", &t_eHCALDRHB);
561 
562  if (doMC_) {
563  t_hsimInfoMatched = new std::vector<double>();
564  t_hsimInfoRest = new std::vector<double>();
565  t_hsimInfoPhoton = new std::vector<double>();
566  t_hsimInfoNeutHad = new std::vector<double>();
567  t_hsimInfoCharHad = new std::vector<double>();
568  t_hsimInfoPdgMatched = new std::vector<double>();
569  t_hsimInfoTotal = new std::vector<double>();
570  t_hsimInfoNMatched = new std::vector<int>();
571  t_hsimInfoNTotal = new std::vector<int>();
572  t_hsimInfoNNeutHad = new std::vector<int>();
573  t_hsimInfoNCharHad = new std::vector<int>();
574  t_hsimInfoNPhoton = new std::vector<int>();
575  t_hsimInfoNRest = new std::vector<int>();
576  t_hsim = new std::vector<double>();
577  t_nSimHits = new std::vector<int>();
578 
579  tree_->Branch("t_hsimInfoMatched", "std::vector<double>", &t_hsimInfoMatched);
580  tree_->Branch("t_hsimInfoRest", "std::vector<double>", &t_hsimInfoRest);
581  tree_->Branch("t_hsimInfoPhoton", "std::vector<double>", &t_hsimInfoPhoton);
582  tree_->Branch("t_hsimInfoNeutHad", "std::vector<double>", &t_hsimInfoNeutHad);
583  tree_->Branch("t_hsimInfoCharHad", "std::vector<double>", &t_hsimInfoCharHad);
584  tree_->Branch("t_hsimInfoPdgMatched", "std::vector<double>", &t_hsimInfoPdgMatched);
585  tree_->Branch("t_hsimInfoTotal", "std::vector<double>", &t_hsimInfoTotal);
586  tree_->Branch("t_hsimInfoNMatched", "std::vector<int>", &t_hsimInfoNMatched);
587  tree_->Branch("t_hsimInfoNTotal", "std::vector<int>", &t_hsimInfoNTotal);
588  tree_->Branch("t_hsimInfoNNeutHad", "std::vector<int>", &t_hsimInfoNNeutHad);
589  tree_->Branch("t_hsimInfoNCharHad", "std::vector<int>", &t_hsimInfoNCharHad);
590  tree_->Branch("t_hsimInfoNPhoton", "std::vector<int>", &t_hsimInfoNPhoton);
591  tree_->Branch("t_hsimInfoNRest", "std::vector<int>", &t_hsimInfoNRest);
592  tree_->Branch("t_hsim", "std::vector<double>", &t_hsim);
593  tree_->Branch("t_nSimHits", "std::vector<int>", &t_nSimHits);
594  }
595 }
596 
598  edm::LogVerbatim("IsoTrack") << "Number of Events Processed " << nEventProc_;
599 }
600 
602 
603  t_trackP ->clear();
604  t_trackPt ->clear();
605  t_trackEta ->clear();
606  t_trackPhi ->clear();
607  t_trackHcalEta ->clear();
608  t_trackHcalPhi ->clear();
609  t_hCone ->clear();
610  t_conehmaxNearP ->clear();
611  t_eMipDR ->clear();
612  t_eECALDR ->clear();
613  t_eHCALDR ->clear();
614  t_e11x11_20Sig ->clear();
615  t_e15x15_20Sig ->clear();
616  t_eMipDR_1 ->clear();
617  t_eECALDR_1 ->clear();
618  t_eMipDR_2 ->clear();
619  t_eECALDR_2 ->clear();
620  t_hConeHB ->clear();
621  t_eHCALDRHB ->clear();
622 
623  if (doMC_) {
624  t_hsimInfoMatched ->clear();
625  t_hsimInfoRest ->clear();
626  t_hsimInfoPhoton ->clear();
627  t_hsimInfoNeutHad ->clear();
628  t_hsimInfoCharHad ->clear();
629  t_hsimInfoPdgMatched ->clear();
630  t_hsimInfoTotal ->clear();
631  t_hsimInfoNMatched ->clear();
632  t_hsimInfoNTotal ->clear();
633  t_hsimInfoNNeutHad ->clear();
634  t_hsimInfoNCharHad ->clear();
635  t_hsimInfoNPhoton ->clear();
636  t_hsimInfoNRest ->clear();
637  t_hsim ->clear();
638  t_nSimHits ->clear();
639  }
640 }
641 
642 
643 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
static const std::string kSharedResource
Definition: TFileService.h:76
double p() const
momentum vector magnitude
Definition: TrackBase.h:615
double eCone_hcal(const CaloGeometry *geo, edm::Handle< T > &hits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double hbThr=-100, double heThr=-100, double hfThr=-100, double hoThr=-100, double tMin=-500, double tMax=500, int detOnly=-1, int useRaw=0, bool debug=false)
std::vector< double > * t_hsimInfoMatched
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > * t_eHCALDR
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, const std::string &theTrackQuality, bool debug=false)
const unsigned int nTracks(const reco::Vertex &sv)
std::vector< int > * t_hsimInfoNRest
std::vector< double > * t_hCone
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
IsolatedTracksHcalScale(const edm::ParameterSet &)
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
std::vector< int > * t_hsimInfoNTotal
std::vector< int > * t_hsimInfoNCharHad
edm::EDGetTokenT< edm::PCaloHitContainer > tok_caloEE_
TrackerHitAssociator::Config trackerHitAssociatorConfig_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< int > * t_hsimInfoNMatched
TrackQuality
track quality
Definition: TrackBase.h:151
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
std::vector< double > * t_hsim
int bunchCrossing() const
Definition: EventBase.h:66
std::vector< double > * t_hsimInfoNeutHad
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< double > * t_eMipDR_2
std::vector< int > * t_hsimInfoNPhoton
double chargeIsolationCone(unsigned int trkIndex, std::vector< spr::propagatedTrackDirection > &trkDirs, double dR, int &nNearTRKs, bool debug=false)
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:675
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
std::vector< double > * t_e11x11_20Sig
std::vector< int > * t_hsimInfoNNeutHad
bool goodTrack(const reco::Track *pTrack, math::XYZPoint leadPV, trackSelectionParameters parameters, bool debug=false)
edm::EDGetTokenT< edm::PCaloHitContainer > tok_caloEB_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
spr::trackSelectionParameters selectionParameters_
double pt() const
track transverse momentum
Definition: TrackBase.h:621
edm::EDGetTokenT< reco::VertexCollection > tok_recVtx_
std::vector< double > * t_trackEta
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
std::vector< double > * t_eECALDR_2
edm::EDGetTokenT< edm::SimTrackContainer > tok_simTk_
std::vector< double > * t_eECALDR
double eCone_ecal(const CaloGeometry *geo, edm::Handle< T > &barrelhits, edm::Handle< T > &endcaphits, const GlobalPoint &hpoint1, const GlobalPoint &point1, double dR, const GlobalVector &trackMom, int &nRecHits, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)
bool isValid() const
Definition: HandleBase.h:74
std::vector< double > * t_eMipDR_1
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:103
std::vector< double > * t_trackPt
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
T const * product() const
Definition: Handle.h:81
std::vector< double > * t_trackHcalEta
std::vector< double > * t_trackP
std::vector< double > * t_eECALDR_1
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:59
std::vector< double > * t_trackHcalPhi
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< double > * t_hsimInfoPhoton
std::vector< double > * t_hsimInfoTotal
edm::EventID id() const
Definition: EventBase.h:60
edm::EDGetTokenT< edm::PCaloHitContainer > tok_caloHH_
std::vector< double > * t_hsimInfoCharHad
reco::TrackBase::TrackQuality minQuality
edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
std::vector< double > * t_trackPhi
const Point & position() const
position
Definition: BeamSpot.h:62
std::vector< double > * t_eHCALDRHB
std::vector< double > * t_hsimInfoPdgMatched
edm::EDGetTokenT< reco::BeamSpot > tok_bs_
edm::EDGetTokenT< edm::SimVertexContainer > tok_simVtx_
T const * product() const
Definition: ESHandle.h:86
std::vector< double > * t_hConeHB
std::vector< double > * t_hsimInfoRest
std::vector< double > * t_conehmaxNearP
std::vector< double > * t_e15x15_20Sig
std::vector< double > * t_eMipDR
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)