CMS 3D CMS Logo

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