CMS 3D CMS Logo

ValidIsoTrkCalib.cc
Go to the documentation of this file.
1 //
2 // Package: ValidIsoTrkCalib
3 // Class: ValidIsoTrkCalib
4 //
5 
6 /*
7  Description: Validation for Isolated tracks Calibration
8 
9  Implementation:
10 See the twiki page for details:
11 https://twiki.cern.ch/twiki/bin/view/CMS/ValidIsoTrkCalib
12 
13 */
14 
15 //
16 // Original Author: Andrey Pozdnyakov
17 // Created: Tue Nov 4 01:16:05 CET 2008
18 //
19 
20 // system include files
21 
22 #include <memory>
23 
24 // user include files
32 
41 
51 
53 
54 #include "TROOT.h"
55 #include "TFile.h"
56 #include "TTree.h"
57 #include "TH1F.h"
58 
59 #include <fstream>
60 #include <map>
61 
62 //#define EDM_ML_DEBUG
63 
64 class ValidIsoTrkCalib : public edm::one::EDAnalyzer<edm::one::SharedResources> {
65 public:
66  explicit ValidIsoTrkCalib(const edm::ParameterSet&);
67 
68 private:
69  void beginJob() override;
70  void analyze(const edm::Event&, const edm::EventSetup&) override;
71 
72  // ----------member data ---------------------------
73 
74  //Variables from HcalIsotrackAnalyzer
75 
78  double taECALCone_;
79  double taHCALCone_;
80 
81  const CaloGeometry* geo;
82  // nothing is done with these tags, so I leave it - cowden
83  const bool takeGenTracks_;
85  const double associationConeSize_;
86  const bool allowMissingInputs_;
88  const double calibrationConeSize_;
90  const int MinNTECHitsEndcap;
91  const double energyECALmip;
92  const double energyMinIso;
93  const double energyMaxIso;
94  const double maxPNear;
95 
101 
104 
106  std::vector<edm::InputTag> genecalLabel_;
108 
109  int gen, iso, pix;
110  float genPt[500], genPhi[500], genEta[500];
111  float isoPt[500], isoPhi[500], isoEta[500];
112  float pixPt[500], pixPhi[500], pixEta[500];
113 
114  int NisoTrk;
116  float ptNear;
117  float ptrack, rvert;
118  //float eecal, ehcal;
119 
120  Float_t emEnergy;
121  Float_t targetE;
122 
123  TTree *tTree, *fTree;
124 
125  Float_t xTrkEcal;
126  Float_t yTrkEcal;
127  Float_t zTrkEcal;
128 
129  Float_t xTrkHcal;
130  Float_t yTrkHcal;
131  Float_t zTrkHcal;
132 
133  int Nhits;
134  float eClustBefore; //Calo energy before calibration
135  float eClustAfter; //After calibration
136  float eTrack; //Track energy
137  float etaTrack;
138  float phiTrack;
139  float eECAL; // Energy deposited in ECAL
140  int numHits; //number of rechits
141 
149  int iEta;
150  int iPhi;
151  int iEtaTr;
152  int iPhiTr;
153  float iDr, delR;
154  int dietatr;
155  int diphitr;
156 
157  float iTime;
158  float HTime[100];
159  float e3x3Before;
160  float e3x3After;
161  float e5x5Before;
162  float e5x5After;
165  float PtNearBy;
167 
169 
170  TH1F* nTracks;
171 };
172 
174  : takeGenTracks_(iConfig.getUntrackedParameter<bool>("takeGenTracks")),
175  genhbheLabel_(iConfig.getParameter<edm::InputTag>("genHBHE")),
176  associationConeSize_(iConfig.getParameter<double>("associationConeSize")),
177  allowMissingInputs_(iConfig.getUntrackedParameter<bool>("allowMissingInputs", true)),
178  AxB_(iConfig.getParameter<std::string>("AxB")),
179  calibrationConeSize_(iConfig.getParameter<double>("calibrationConeSize")),
180  MinNTrackHitsBarrel(iConfig.getParameter<int>("MinNTrackHitsBarrel")),
181  MinNTECHitsEndcap(iConfig.getParameter<int>("MinNTECHitsEndcap")),
182  energyECALmip(iConfig.getParameter<double>("energyECALmip")),
183  energyMinIso(iConfig.getParameter<double>("energyMinIso")),
184  energyMaxIso(iConfig.getParameter<double>("energyMaxIso")),
185  maxPNear(iConfig.getParameter<double>("maxPNear")),
186  tok_genTrack_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("genTracksLabel"))),
187  tok_hbhe_(consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"))),
188  tok_ho_(consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"))),
189  tok_track_(consumes<reco::IsolatedPixelTrackCandidateCollection>(
190  iConfig.getParameter<edm::InputTag>("HcalIsolTrackInput"))),
191  tok_track1_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trackInput"))),
192  tok_recalibCorrs_(esConsumes(edm::ESInputTag("", "recalibrate"))),
193  tok_geom_(esConsumes()) {
194  usesResource(TFileService::kSharedResource);
195 
196  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
200 }
201 
202 // ------------ method called to for each event ------------
204  try {
206 
207  edm::LogVerbatim("ValidIsoTrkCalib") << " Loaded: OK ";
208 
209  } catch (const cms::Exception& e) {
210  edm::LogWarning("ValidIsoTrkCalib") << " Not Found!! ";
211  }
212 
214 
215  const edm::Handle<reco::TrackCollection>& isoProdTracks = iEvent.getHandle(tok_track1_);
216 
218 
220  const HBHERecHitCollection Hithbhe = *(hbhe.product());
221 
222  geo = &iSetup.getData(tok_geom_);
223 
224  const HcalGeometry* gHcal = static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
225  //Note: even though it says HcalBarrel, we actually get the whole Hcal detector geometry!
226 
227  parameters_.useEcal = true;
228  parameters_.useHcal = true;
229  parameters_.useCalo = false;
230  parameters_.useMuon = false;
231 #ifdef EDM_ML_DEBUG
232  edm::LogVerbatim("ValidIsoTrkCalib") << "Hello World. TrackCollectionSize: " << isoPixelTracks->size();
233 #endif
234  if (isoPixelTracks->empty())
235  return;
236 
237  for (reco::TrackCollection::const_iterator trit = isoProdTracks->begin(); trit != isoProdTracks->end(); trit++) {
238  reco::IsolatedPixelTrackCandidateCollection::const_iterator isoMatched = isoPixelTracks->begin();
239  bool matched = false;
240 
241  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator it = isoPixelTracks->begin();
242  it != isoPixelTracks->end();
243  it++) {
244  if (abs((trit->pt() - it->pt()) / it->pt()) < 0.005 && abs(trit->eta() - it->eta()) < 0.01) {
245  isoMatched = it;
246  matched = true;
247  break;
248  }
249  }
250  // CUT
251 
252  if (!matched)
253  continue;
254  if (isoMatched->maxPtPxl() > maxPNear)
255  continue;
256 
257  ptNear = isoMatched->maxPtPxl();
258 #ifdef EDM_ML_DEBUG
259  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.1 isoMatch. ptnear: " << ptNear;
260 #endif
261  // CUT
262  if (trit->hitPattern().numberOfValidHits() < MinNTrackHitsBarrel)
263  continue;
264  if (fabs(trit->eta()) > 1.47 && trit->hitPattern().numberOfValidStripTECHits() < MinNTECHitsEndcap)
265  continue;
266 
267 #ifdef EDM_ML_DEBUG
268  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.2.1 after numofvalidhits HB: "
269  << trit->hitPattern().numberOfValidHits();
270  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.2.2 after numofvalidstrips HE: "
271  << trit->hitPattern().numberOfValidStripTECHits();
272 #endif
273  numVH = trit->hitPattern().numberOfValidHits();
274  numVS = trit->hitPattern().numberOfValidStripTECHits();
275 
276  trackE = sqrt(trit->px() * trit->px() + trit->py() * trit->py() + trit->pz() * trit->pz() + 0.14 * 0.14);
277  trackPt = trit->pt();
278  trackEta = trit->eta();
279  trackPhi = trit->phi();
280 
281  emEnergy = isoMatched->energyIn();
282 
283 #ifdef EDM_ML_DEBUG
284  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.3. Matched :: pt: " << trit->pt() << " wholeEnergy: " << trackE
285  << " emEnergy: " << emEnergy << " eta: " << trackEta << " phi: " << trackPhi;
286  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.4. EM energy in cone: " << emEnergy;
287 #endif
289  iEvent,
290  iSetup,
292  parameters_);
293 
294  xTrkEcal = info.trkGlobPosAtEcal.x();
295  yTrkEcal = info.trkGlobPosAtEcal.y();
296  zTrkEcal = info.trkGlobPosAtEcal.z();
297 
298  xTrkHcal = info.trkGlobPosAtHcal.x();
299  yTrkHcal = info.trkGlobPosAtHcal.y();
300  zTrkHcal = info.trkGlobPosAtHcal.z();
301 
302  if (xTrkEcal == 0 && yTrkEcal == 0 && zTrkEcal == 0) {
303  edm::LogVerbatim("ValidIsoTrkCalib") << "zero point at Ecal";
304  continue;
305  }
306  if (xTrkHcal == 0 && yTrkHcal == 0 && zTrkHcal == 0) {
307  edm::LogVerbatim("ValidIsoTrkCalib") << "zero point at Hcal";
308  continue;
309  }
310 
311  GlobalPoint gPointEcal(xTrkEcal, yTrkEcal, zTrkEcal);
312  GlobalPoint gPointHcal(xTrkHcal, yTrkHcal, zTrkHcal);
313 
314  int iphitrue = -10;
315  int ietatrue = 100;
316  const HcalDetId tempId = gHcal->getClosestCell(gPointHcal);
317  ietatrue = tempId.ieta();
318  iphitrue = tempId.iphi();
319 
320  MaxHit_struct MaxHit;
321 
322  MaxHit.hitenergy = -100.;
323 
324  //container for used recHits
325  std::vector<DetId> usedHits;
326  usedHits.clear();
327 #ifdef EDM_ML_DEBUG
328  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 1. Entrance to HBHECollection";
329 #endif
330 
331  GlobalPoint gPhot;
332 
333  for (HBHERecHitCollection::const_iterator hhit = Hithbhe.begin(); hhit != Hithbhe.end(); hhit++) {
334  //check that this hit was not considered before and push it into usedHits
335  bool hitIsUsed = false;
336  for (uint32_t i = 0; i < usedHits.size(); i++) {
337  if (usedHits[i] == hhit->id())
338  hitIsUsed = true;
339  }
340  if (hitIsUsed)
341  continue;
342  usedHits.push_back(hhit->id());
343  //
344 
345  // rof 16.05.2008 start: include the possibility for recalibration
346  float recal = 1;
347  // rof end
348 
349  GlobalPoint pos = geo->getPosition(hhit->detid());
350 
351  int iphihitm = (hhit->id()).iphi();
352  int ietahitm = (hhit->id()).ieta();
353  int depthhit = (hhit->id()).depth();
354  float enehit = hhit->energy() * recal;
355 
356  if (depthhit != 1)
357  continue;
358 
359 #ifdef EDM_ML_DEBUG
360  float dphi = fabs(info.trkGlobPosAtHcal.phi() - pos.phi());
361  if (dphi > 4. * atan(1.))
362  dphi = 8. * atan(1.) - dphi;
363  float deta = fabs(info.trkGlobPosAtHcal.eta() - pos.eta());
364  float dr = sqrt(dphi * dphi + deta * deta);
365 #endif
366 
367  double distAtHcal = getDistInPlaneSimple(gPointHcal, pos);
368 
369  if (distAtHcal < associationConeSize_) {
370  for (HBHERecHitCollection::const_iterator hhit2 = Hithbhe.begin(); hhit2 != Hithbhe.end(); hhit2++) {
371  int iphihitm2 = (hhit2->id()).iphi();
372  int ietahitm2 = (hhit2->id()).ieta();
373  int depthhit2 = (hhit2->id()).depth();
374  float enehit2 = hhit2->energy() * recal;
375 
376  if (iphihitm == iphihitm2 && ietahitm == ietahitm2 && depthhit != depthhit2)
377  enehit = enehit + enehit2;
378  }
379 
380 #ifdef EDM_ML_DEBUG
381  edm::LogVerbatim("ValidIsoTrkCalib") << "IN CONE ieta: " << ietahitm << " iphi: " << iphihitm
382  << " depthhit: " << depthhit << " dr: " << dr << " energy: " << enehit;
383 #endif
384  //Find a Hit with Maximum Energy
385 
386  if (enehit > MaxHit.hitenergy) {
387  MaxHit.hitenergy = enehit;
388  MaxHit.ietahitm = (hhit->id()).ieta();
389  MaxHit.iphihitm = (hhit->id()).iphi();
390  MaxHit.dr = distAtHcal;
391  MaxHit.depthhit = 1;
392  }
393  }
394  } //end of all HBHE hits cycle
395 
396  usedHits.clear();
397 
398 #ifdef EDM_ML_DEBUG
399  edm::LogVerbatim("ValidIsoTrkCalib") << "Hottest ieta: " << MaxHit.ietahitm << " iphi: " << MaxHit.iphihitm
400  << " dr: " << MaxHit.dr;
401  edm::LogVerbatim("ValidIsoTrkCalib") << "Track ieta: " << ietatrue << " iphi: " << iphitrue;
402  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 3. MaxHit :::En " << MaxHit.hitenergy
403  << " ieta: " << MaxHit.ietahitm << " iphi: " << MaxHit.iphihitm;
404 #endif
405 
406  Bool_t passCuts = kFALSE;
407  if (trackE > energyMinIso && trackE < energyMaxIso && emEnergy < energyECALmip && MaxHit.hitenergy > 0. &&
408  abs(MaxHit.ietahitm) < 29)
409  passCuts = kTRUE;
410 
411 #ifdef EDM_ML_DEBUG
412  edm::LogVerbatim("ValidIsoTrkCalib") << "Pont 0.1.1. trackE:" << trackE << " emEn: " << emEnergy;
413 #endif
414  numHits = 0;
415 
416  eClustBefore = 0.0;
417  eClustAfter = 0.0;
418  eBeforeDepth1 = 0.0;
419  eAfterDepth1 = 0.0;
420  eBeforeDepth2 = 0.0;
421  eAfterDepth2 = 0.0;
422  CentHitFactor = 0.0;
423  e3x3After = 0.0;
424  e3x3Before = 0.0;
425  e5x5After = 0.0;
426  e5x5Before = 0.0;
427 
428  for (HBHERecHitCollection::const_iterator hhit = Hithbhe.begin(); hhit != Hithbhe.end(); hhit++) {
429  //check that this hit was not considered before and push it into usedHits
430  bool hitIsUsed = false;
431  for (uint32_t i = 0; i < usedHits.size(); i++) {
432  if (usedHits[i] == hhit->id())
433  hitIsUsed = true;
434  }
435  if (hitIsUsed)
436  continue;
437  usedHits.push_back(hhit->id());
438 
439  int DIETA = 100;
440  if (MaxHit.ietahitm * (hhit->id()).ieta() > 0) {
441  DIETA = MaxHit.ietahitm - (hhit->id()).ieta();
442  }
443  if (MaxHit.ietahitm * (hhit->id()).ieta() < 0) {
444  DIETA = MaxHit.ietahitm - (hhit->id()).ieta();
445  DIETA = DIETA > 0 ? DIETA - 1 : DIETA + 1;
446  }
447 
448  int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi());
449  DIPHI = DIPHI > 36 ? 72 - DIPHI : DIPHI;
450 
451  int numbercell = 100; //always collect Wide clastor!
452 
453  if (abs(DIETA) <= numbercell &&
454  (abs(DIPHI) <= numbercell || (abs(MaxHit.ietahitm) >= 20 && abs(DIPHI) <= numbercell + 1))) {
455  const GlobalPoint pos2 = geo->getPosition(hhit->detid());
456 
457  if (passCuts && hhit->energy() > 0) {
458  float factor = respRecalib->getValues(hhit->id())->getValue();
459 
460 #ifdef EDM_ML_DEBUG
461  edm::LogVerbatim("ValidIsoTrkCalib") << " calib factors: " << factor;
462 #endif
463 
464  if (hhit->id().ieta() == MaxHit.ietahitm && hhit->id().iphi() == MaxHit.iphihitm)
466 
467  if (hhit->id().ieta() == MaxHit.ietahitm && hhit->id().iphi() == MaxHit.iphihitm)
468  iTime = hhit->time();
469 
470  if (AxB_ != "3x3" && AxB_ != "5x5" && AxB_ != "Cone")
471  edm::LogWarning(" AxB ") << " Not supported: " << AxB_;
472 
473  if (abs(DIETA) <= 2 && (abs(DIPHI) <= 2 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 4) &&
474  !((abs(MaxHit.ietahitm) == 21 || abs(MaxHit.ietahitm) == 22) &&
475  abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 2)))) {
476  e5x5Before += hhit->energy();
477  e5x5After += hhit->energy() * factor;
478  }
479 
480  if (abs(DIETA) <= 1 && (abs(DIPHI) <= 1 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 2) &&
481  !(abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 &&
482  abs(DIPHI) > 1)))) {
483  e3x3Before += hhit->energy();
484  e3x3After += hhit->energy() * factor;
485  }
486 
487  if (AxB_ == "5x5") {
488  if (abs(DIETA) <= 2 && (abs(DIPHI) <= 2 || (abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 4))) {
489  if (abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 3)
490  continue;
491 
492  HTime[numHits] = hhit->time();
493  numHits++;
494 
495  eClustBefore += hhit->energy();
496  eClustAfter += hhit->energy() * factor;
497 
498  if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
499  eBeforeDepth1 += hhit->energy();
500  eAfterDepth1 += hhit->energy() * factor;
501  } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
502  eBeforeDepth2 += hhit->energy();
503  eAfterDepth2 += hhit->energy() * factor;
504  }
505  }
506  } //end of 5x5
507 
508  if (AxB_ == "3x3") {
509  if (abs(DIETA) <= 1 && (abs(DIPHI) <= 1 || (abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 2))) {
510  if (abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 2)
511  continue;
512 
513  HTime[numHits] = hhit->time();
514  numHits++;
515 
516  eClustBefore += hhit->energy();
517  eClustAfter += hhit->energy() * factor;
518 
519  if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
520  eBeforeDepth1 += hhit->energy();
521  eAfterDepth1 += hhit->energy() * factor;
522  } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
523  eBeforeDepth2 += hhit->energy();
524  eAfterDepth2 += hhit->energy() * factor;
525  }
526  }
527  } //end of 3x3
528 
529  if (AxB_ == "Cone" && getDistInPlaneSimple(gPointHcal, pos2) < calibrationConeSize_) {
530  HTime[numHits] = hhit->time();
531  numHits++;
532 
533  eClustBefore += hhit->energy();
534  eClustAfter += hhit->energy() * factor;
535 
536  if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
537  eBeforeDepth1 += hhit->energy();
538  eAfterDepth1 += hhit->energy() * factor;
539  } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
540  eBeforeDepth2 += hhit->energy();
541  eAfterDepth2 += hhit->energy() * factor;
542  }
543 
544  } //end of Cone
545 
546  } //end of passCuts
547 
548  } //end of DIETA DIPHI
549 
550  } //end of associatedcone HBHE hits cycle
551 
552  int dieta_M_P = 100;
553  int diphi_M_P = 100;
554  if (MaxHit.ietahitm * ietatrue > 0) {
555  dieta_M_P = abs(MaxHit.ietahitm - ietatrue);
556  }
557  if (MaxHit.ietahitm * ietatrue < 0) {
558  dieta_M_P = abs(MaxHit.ietahitm - ietatrue) - 1;
559  }
560  diphi_M_P = abs(MaxHit.iphihitm - iphitrue);
561  diphi_M_P = diphi_M_P > 36 ? 72 - diphi_M_P : diphi_M_P;
562 
563  if (passCuts)
564 
565  {
566  eventNumber = iEvent.id().event();
567  runNumber = iEvent.id().run();
568 
569  eCentHitBefore = MaxHit.hitenergy;
571  eECAL = emEnergy;
574  PtNearBy = ptNear;
575 
576  eTrack = trackE;
577  phiTrack = trackPhi;
578  etaTrack = trackEta;
579 
580  iEta = MaxHit.ietahitm;
581  iPhi = MaxHit.iphihitm;
582 
583  iEtaTr = ietatrue;
584  iPhiTr = iphitrue;
585  iDr = sqrt(diphi_M_P * diphi_M_P + dieta_M_P * dieta_M_P);
586  delR = MaxHit.dr;
587  dietatr = dieta_M_P;
588  diphitr = diphi_M_P;
589 
590  fTree->Fill();
591  }
592 
593  } //end of isoProdTracks cycle
594 
595  /* ------------------ Some stuff for general tracks ---------- ----*/
596 #ifdef EDM_ML_DEBUG
597  edm::LogVerbatim("ValidIsoTrkCalib") << " generalTracks Size: " << generalTracks->size();
598 #endif
599  int n = generalTracks->size();
600  nTracks->Fill(n);
601 
602  if (takeGenTracks_ && iEvent.id().event() % 10 == 1) {
603  gen = generalTracks->size();
604  iso = isoProdTracks->size();
605  pix = isoPixelTracks->size();
606 
607  genPt[0] = -33;
608  genPhi[0] = -33;
609  genEta[0] = -33;
610 
611  isoPt[0] = -33;
612  isoPhi[0] = -33;
613  isoEta[0] = -33;
614 
615  pixPt[0] = -33;
616  pixPhi[0] = -33;
617  pixEta[0] = -33;
618 
619  Int_t gencount = 0, isocount = 0, pixcount = 0;
620  for (reco::TrackCollection::const_iterator gentr = generalTracks->begin(); gentr != generalTracks->end(); gentr++) {
621  genPt[gencount] = gentr->pt();
622  genPhi[gencount] = gentr->phi();
623  genEta[gencount] = gentr->eta();
624  gencount++;
625  }
626 
627  for (reco::TrackCollection::const_iterator isotr = isoProdTracks->begin(); isotr != isoProdTracks->end(); isotr++) {
628  isoPt[isocount] = isotr->pt();
629  isoPhi[isocount] = isotr->phi();
630  isoEta[isocount] = isotr->eta();
631  isocount++;
632  }
633 
634  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator pixtr = isoPixelTracks->begin();
635  pixtr != isoPixelTracks->end();
636  pixtr++) {
637  pixPt[pixcount] = pixtr->pt();
638  pixPhi[pixcount] = pixtr->phi();
639  pixEta[pixcount] = pixtr->eta();
640  pixcount++;
641  }
642  }
643 
644  tTree->Fill();
645 }
646 
647 // ------------ method called once each job just before starting event loop ------------
650 
651  nTracks = fs->make<TH1F>("nTracks", "general;number of general tracks", 11, -0.5, 10.5);
652 
653  tTree = fs->make<TTree>("tTree", "Tree for gen info");
654 
655  fTree = fs->make<TTree>("fTree", "Tree for IsoTrack Calibration");
656 
657  fTree->Branch("eventNumber", &eventNumber, "eventNumber/I");
658  fTree->Branch("runNumber", &runNumber, "runNumber/I");
659 
660  fTree->Branch("eClustBefore", &eClustBefore, "eClustBefore/F");
661  fTree->Branch("eClustAfter", &eClustAfter, "eClustAfter/F");
662  fTree->Branch("eTrack", &eTrack, "eTrack/F");
663  fTree->Branch("etaTrack", &etaTrack, "etaTrack/F");
664  fTree->Branch("phiTrack", &phiTrack, "phiTrack/F");
665 
666  fTree->Branch("numHits", &numHits, "numHits/I");
667  fTree->Branch("eECAL", &eECAL, "eECAL/F");
668  fTree->Branch("PtNearBy", &PtNearBy, "PtNearBy/F");
669  fTree->Branch("numValidTrkHits", &numValidTrkHits, "numValidTrkHits/F");
670  fTree->Branch("numValidTrkStrips", &numValidTrkStrips, "numValidTrkStrips/F");
671 
672  fTree->Branch("eBeforeDepth1", &eBeforeDepth1, "eBeforeDepth1/F");
673  fTree->Branch("eBeforeDepth2", &eBeforeDepth2, "eBeforeDepth2/F");
674  fTree->Branch("eAfterDepth1", &eAfterDepth1, "eAfterDepth1/F");
675  fTree->Branch("eAfterDepth2", &eAfterDepth2, "eAfterDepth2/F");
676 
677  fTree->Branch("e3x3Before", &e3x3Before, "e3x3Before/F");
678  fTree->Branch("e3x3After", &e3x3After, "e3x3After/F");
679  fTree->Branch("e5x5Before", &e5x5Before, "e5x5Before/F");
680  fTree->Branch("e5x5After", &e5x5After, "e5x5After/F");
681 
682  fTree->Branch("eCentHitAfter", &eCentHitAfter, "eCentHitAfter/F");
683  fTree->Branch("eCentHitBefore", &eCentHitBefore, "eCentHitBefore/F");
684  fTree->Branch("iEta", &iEta, "iEta/I");
685  fTree->Branch("iPhi", &iPhi, "iPhi/I");
686 
687  fTree->Branch("iEtaTr", &iEtaTr, "iEtaTr/I");
688  fTree->Branch("iPhiTr", &iPhiTr, "iPhiTr/I");
689  fTree->Branch("dietatr", &dietatr, "dietatr/I");
690  fTree->Branch("diphitr", &diphitr, "diphitr/I");
691  fTree->Branch("iDr", &iDr, "iDr/F");
692  fTree->Branch("delR", &delR, "delR/F");
693 
694  fTree->Branch("iTime", &iTime, "iTime/F");
695  fTree->Branch("HTime", HTime, "HTime[numHits]/F");
696 
697  fTree->Branch("xTrkEcal", &xTrkEcal, "xTrkEcal/F");
698  fTree->Branch("yTrkEcal", &yTrkEcal, "yTrkEcal/F");
699  fTree->Branch("zTrkEcal", &zTrkEcal, "zTrkEcal/F");
700  fTree->Branch("xTrkHcal", &xTrkHcal, "xTrkHcal/F");
701  fTree->Branch("yTrkHcal", &yTrkHcal, "yTrkHcal/F");
702  fTree->Branch("zTrkHcal", &zTrkHcal, "zTrkHcal/F");
703 
704  if (takeGenTracks_) {
705  tTree->Branch("gen", &gen, "gen/I");
706  tTree->Branch("iso", &iso, "iso/I");
707  tTree->Branch("pix", &pix, "pix/I");
708  tTree->Branch("genPt", genPt, "genPt[gen]/F");
709  tTree->Branch("genPhi", genPhi, "genPhi[gen]/F");
710  tTree->Branch("genEta", genEta, "genEta[gen]/F");
711 
712  tTree->Branch("isoPt", isoPt, "isoPt[iso]/F");
713  tTree->Branch("isoPhi", isoPhi, "isoPhi[iso]/F");
714  tTree->Branch("isoEta", isoEta, "isoEta[iso]/F");
715 
716  tTree->Branch("pixPt", pixPt, "pixPt[pix]/F");
717  tTree->Branch("pixPhi", pixPhi, "pixPhi[pix]/F");
718  tTree->Branch("pixEta", pixEta, "pixEta[pix]/F");
719  }
720 }
721 
722 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
Log< level::Info, true > LogVerbatim
const edm::EDGetTokenT< HORecHitCollection > tok_ho_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static const TGPicture * info(bool iBackgroundIsBlack)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const bool takeGenTracks_
void analyze(const edm::Event &, const edm::EventSetup &) override
DetId getClosestCell(const GlobalPoint &r) const override
const edm::EDGetTokenT< reco::TrackCollection > tok_track1_
void useDefaultPropagator()
use the default propagator
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< T >::const_iterator const_iterator
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
const double calibrationConeSize_
TrackAssociatorParameters parameters_
const edm::ESGetToken< HcalRespCorrs, HcalRespCorrsRcd > tok_recalibCorrs_
const bool allowMissingInputs_
const Item * getValues(DetId fId, bool throwOnFail=true) const
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
int iEvent
Definition: GenABIO.cc:224
const double energyMinIso
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
const CaloGeometry * geo
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
T sqrt(T t)
Definition: SSEVec.h:23
void beginJob() override
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bFieldToken
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackDetectorAssociator trackAssociator_
std::vector< IsolatedPixelTrackCandidate > IsolatedPixelTrackCandidateCollection
collectin of IsolatedPixelTrackCandidate objects
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const_iterator begin() const
const double energyECALmip
const HcalRespCorrs * respRecalib
const int MinNTrackHitsBarrel
ValidIsoTrkCalib(const edm::ParameterSet &)
const double energyMaxIso
std::string outputFileName_
std::vector< edm::InputTag > genecalLabel_
const_iterator end() const
const edm::EDGetTokenT< reco::TrackCollection > tok_genTrack_
const edm::EDGetTokenT< reco::IsolatedPixelTrackCandidateCollection > tok_track_
const edm::InputTag genhbheLabel_
static FreeTrajectoryState getFreeTrajectoryState(const MagneticField *, const reco::Track &)
get FreeTrajectoryState from different track representations
const int MinNTECHitsEndcap
fixed size matrix
HLT enums.
const std::string AxB_
edm::InputTag genhoLabel_
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint)
Definition: ConeDefinition.h:9
const edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Log< level::Warning, false > LogWarning
const double associationConeSize_
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
const double maxPNear