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  // double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint);
69 
70 private:
71  void beginJob() override;
72  void analyze(const edm::Event&, const edm::EventSetup&) override;
73 
74  // ----------member data ---------------------------
75 
76  //Variables from HcalIsotrackAnalyzer
77 
80  double taECALCone_;
81  double taHCALCone_;
82 
83  const CaloGeometry* geo;
84  // nothing is done with these tags, so I leave it - cowden
85  const bool takeGenTracks_;
87  const double associationConeSize_;
88  const bool allowMissingInputs_;
90  const double calibrationConeSize_;
92  const int MinNTECHitsEndcap;
93  const double energyECALmip;
94  const double energyMinIso;
95  const double energyMaxIso;
96  const double maxPNear;
97 
103 
106 
108  std::vector<edm::InputTag> genecalLabel_;
110 
111  int gen, iso, pix;
112  float genPt[500], genPhi[500], genEta[500];
113  float isoPt[500], isoPhi[500], isoEta[500];
114  float pixPt[500], pixPhi[500], pixEta[500];
115 
116  int NisoTrk;
118  float ptNear;
119  float ptrack, rvert;
120  //float eecal, ehcal;
121 
122  Float_t emEnergy;
123  Float_t targetE;
124 
125  TTree *tTree, *fTree;
126 
127  Float_t xTrkEcal;
128  Float_t yTrkEcal;
129  Float_t zTrkEcal;
130 
131  Float_t xTrkHcal;
132  Float_t yTrkHcal;
133  Float_t zTrkHcal;
134 
135  int Nhits;
136  float eClustBefore; //Calo energy before calibration
137  float eClustAfter; //After calibration
138  float eTrack; //Track energy
139  float etaTrack;
140  float phiTrack;
141  float eECAL; // Energy deposited in ECAL
142  int numHits; //number of rechits
143 
151  int iEta;
152  int iPhi;
153  int iEtaTr;
154  int iPhiTr;
155  float iDr, delR;
156  int dietatr;
157  int diphitr;
158 
159  float iTime;
160  float HTime[100];
161  float e3x3Before;
162  float e3x3After;
163  float e5x5Before;
164  float e5x5After;
167  float PtNearBy;
169 
171 
172  TH1F* nTracks;
173 };
174 
176  : takeGenTracks_(iConfig.getUntrackedParameter<bool>("takeGenTracks")),
177  genhbheLabel_(iConfig.getParameter<edm::InputTag>("genHBHE")),
178  associationConeSize_(iConfig.getParameter<double>("associationConeSize")),
179  allowMissingInputs_(iConfig.getUntrackedParameter<bool>("allowMissingInputs", true)),
180  AxB_(iConfig.getParameter<std::string>("AxB")),
181  calibrationConeSize_(iConfig.getParameter<double>("calibrationConeSize")),
182  MinNTrackHitsBarrel(iConfig.getParameter<int>("MinNTrackHitsBarrel")),
183  MinNTECHitsEndcap(iConfig.getParameter<int>("MinNTECHitsEndcap")),
184  energyECALmip(iConfig.getParameter<double>("energyECALmip")),
185  energyMinIso(iConfig.getParameter<double>("energyMinIso")),
186  energyMaxIso(iConfig.getParameter<double>("energyMaxIso")),
187  maxPNear(iConfig.getParameter<double>("maxPNear")),
188  tok_genTrack_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("genTracksLabel"))),
189  tok_hbhe_(consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"))),
190  tok_ho_(consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"))),
191  tok_track_(consumes<reco::IsolatedPixelTrackCandidateCollection>(
192  iConfig.getParameter<edm::InputTag>("HcalIsolTrackInput"))),
193  tok_track1_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("trackInput"))),
194  tok_recalibCorrs_(esConsumes(edm::ESInputTag("", "recalibrate"))),
195  tok_geom_(esConsumes()) {
196  usesResource(TFileService::kSharedResource);
197 
198  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
202 }
203 
204 // ------------ method called to for each event ------------
206  try {
208 
209  edm::LogVerbatim("ValidIsoTrkCalib") << " Loaded: OK ";
210 
211  } catch (const cms::Exception& e) {
212  edm::LogWarning("ValidIsoTrkCalib") << " Not Found!! ";
213  }
214 
216 
217  const edm::Handle<reco::TrackCollection>& isoProdTracks = iEvent.getHandle(tok_track1_);
218 
220  //edm::Handle<reco::TrackCollection> isoPixelTracks;
221 
222  /*
223  edm::Handle<EcalRecHitCollection> ecal;
224  iEvent.getByLabel(eLabel_,ecal);
225  const EcalRecHitCollection Hitecal = *(ecal.product());
226  */
227 
229  const HBHERecHitCollection Hithbhe = *(hbhe.product());
230 
231  geo = &iSetup.getData(tok_geom_);
232 
233  const HcalGeometry* gHcal = static_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(DetId::Hcal, HcalBarrel));
234  //Note: even though it says HcalBarrel, we actually get the whole Hcal detector geometry!
235 
236  // Lumi_n=iEvent.luminosityBlock();
237  parameters_.useEcal = true;
238  parameters_.useHcal = true;
239  parameters_.useCalo = false;
240  parameters_.useMuon = false;
241  //parameters_.dREcal = taECALCone_;
242  //parameters_.dRHcal = taHCALCone_;
243 #ifdef EDM_ML_DEBUG
244  edm::LogVerbatim("ValidIsoTrkCalib") << "Hello World. TrackCollectionSize: " << isoPixelTracks->size();
245 #endif
246  if (isoPixelTracks->empty())
247  return;
248 
249  for (reco::TrackCollection::const_iterator trit = isoProdTracks->begin(); trit != isoProdTracks->end(); trit++) {
250  reco::IsolatedPixelTrackCandidateCollection::const_iterator isoMatched = isoPixelTracks->begin();
251  //reco::TrackCollection::const_iterator isoMatched=isoPixelTracks->begin();
252  bool matched = false;
253 
254  //for (reco::IsolatedPixelTrackCandidateCollection::const_iterator trit = isoPixelTracks->begin(); trit!=isoPixelTracks->end(); trit++)
255  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator it = isoPixelTracks->begin();
256  it != isoPixelTracks->end();
257  it++)
258  //for (reco::TrackCollection::const_iterator it = isoPixelTracks->begin(); it!=isoPixelTracks->end(); it++)
259  {
260  if (abs((trit->pt() - it->pt()) / it->pt()) < 0.005 && abs(trit->eta() - it->eta()) < 0.01) {
261  isoMatched = it;
262  matched = true;
263  break;
264  }
265  }
266  // CUT
267 
268  if (!matched)
269  continue;
270  if (isoMatched->maxPtPxl() > maxPNear)
271  continue;
272 
273  ptNear = isoMatched->maxPtPxl();
274 #ifdef EDM_ML_DEBUG
275  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.1 isoMatch. ptnear: " << ptNear;
276 #endif
277  // CUT
278  if (trit->hitPattern().numberOfValidHits() < MinNTrackHitsBarrel)
279  continue;
280  if (fabs(trit->eta()) > 1.47 && trit->hitPattern().numberOfValidStripTECHits() < MinNTECHitsEndcap)
281  continue;
282 
283 #ifdef EDM_ML_DEBUG
284  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.2.1 after numofvalidhits HB: "
285  << trit->hitPattern().numberOfValidHits();
286  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.2.2 after numofvalidstrips HE: "
287  << trit->hitPattern().numberOfValidStripTECHits();
288 #endif
289  numVH = trit->hitPattern().numberOfValidHits();
290  numVS = trit->hitPattern().numberOfValidStripTECHits();
291 
292  trackE = sqrt(trit->px() * trit->px() + trit->py() * trit->py() + trit->pz() * trit->pz() + 0.14 * 0.14);
293  trackPt = trit->pt();
294  trackEta = trit->eta();
295  trackPhi = trit->phi();
296 
297  emEnergy = isoMatched->energyIn();
298 
299 #ifdef EDM_ML_DEBUG
300  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.3. Matched :: pt: " << trit->pt() << " wholeEnergy: " << trackE
301  << " emEnergy: " << emEnergy << " eta: " << trackEta << " phi: " << trackPhi;
302  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 0.4. EM energy in cone: " << emEnergy;
303 #endif
305  iEvent,
306  iSetup,
308  parameters_);
309 
310  //float etaecal=info.trkGlobPosAtEcal.eta();
311  //float phiecal=info.trkGlobPosAtEcal.phi();
312  // float etahcal=info.trkGlobPosAtHcal.eta();
313  // float phihcal=info.trkGlobPosAtHcal.phi();
314 
315  xTrkEcal = info.trkGlobPosAtEcal.x();
316  yTrkEcal = info.trkGlobPosAtEcal.y();
317  zTrkEcal = info.trkGlobPosAtEcal.z();
318 
319  xTrkHcal = info.trkGlobPosAtHcal.x();
320  yTrkHcal = info.trkGlobPosAtHcal.y();
321  zTrkHcal = info.trkGlobPosAtHcal.z();
322 
323  if (xTrkEcal == 0 && yTrkEcal == 0 && zTrkEcal == 0) {
324  edm::LogVerbatim("ValidIsoTrkCalib") << "zero point at Ecal";
325  continue;
326  }
327  if (xTrkHcal == 0 && yTrkHcal == 0 && zTrkHcal == 0) {
328  edm::LogVerbatim("ValidIsoTrkCalib") << "zero point at Hcal";
329  continue;
330  }
331 
332  /*GlobalVector trackMomAtEcal = info.trkMomAtEcal;
333  GlobalVector trackMomAtHcal = info.trkMomAtHcal;
334 
335  PxTrkHcal = trackMomAtHcal.x();
336  PyTrkHcal = trackMomAtHcal.y();
337  PzTrkHcal = trackMomAtHcal.z();
338  */
339 
340  GlobalPoint gPointEcal(xTrkEcal, yTrkEcal, zTrkEcal);
341  GlobalPoint gPointHcal(xTrkHcal, yTrkHcal, zTrkHcal);
342 
343  int iphitrue = -10;
344  int ietatrue = 100;
345  const HcalDetId tempId = gHcal->getClosestCell(gPointHcal);
346  ietatrue = tempId.ieta();
347  iphitrue = tempId.iphi();
348 
349  MaxHit_struct MaxHit;
350 
351  MaxHit.hitenergy = -100.;
352 
353  //container for used recHits
354  std::vector<DetId> usedHits;
355  //
356  usedHits.clear();
357 #ifdef EDM_ML_DEBUG
358  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 1. Entrance to HBHECollection";
359 #endif
360  //float dddeta = 1000.;
361  //float dddphi = 1000.;
362  //int iphitrue = 1234;
363  //int ietatrue = 1234;
364 
365  GlobalPoint gPhot;
366 
367  for (HBHERecHitCollection::const_iterator hhit = Hithbhe.begin(); hhit != Hithbhe.end(); hhit++) {
368  //check that this hit was not considered before and push it into usedHits
369  bool hitIsUsed = false;
370  for (uint32_t i = 0; i < usedHits.size(); i++) {
371  if (usedHits[i] == hhit->id())
372  hitIsUsed = true;
373  }
374  if (hitIsUsed)
375  continue;
376  usedHits.push_back(hhit->id());
377  //
378 
379  // rof 16.05.2008 start: include the possibility for recalibration
380  float recal = 1;
381  // rof end
382 
383  GlobalPoint pos = geo->getPosition(hhit->detid());
384  //float phihit = pos.phi();
385  //float etahit = pos.eta();
386 
387  int iphihitm = (hhit->id()).iphi();
388  int ietahitm = (hhit->id()).ieta();
389  int depthhit = (hhit->id()).depth();
390  float enehit = hhit->energy() * recal;
391 
392  if (depthhit != 1)
393  continue;
394 
395 #ifdef EDM_ML_DEBUG
396  float dphi = fabs(info.trkGlobPosAtHcal.phi() - pos.phi());
397  if (dphi > 4. * atan(1.))
398  dphi = 8. * atan(1.) - dphi;
399  float deta = fabs(info.trkGlobPosAtHcal.eta() - pos.eta());
400  float dr = sqrt(dphi * dphi + deta * deta);
401 #endif
402 
403  //double distAtHcal = getDistInPlaneTrackDir(gPointHcal, trackMomAtHcal, pos);
404  double distAtHcal = getDistInPlaneSimple(gPointHcal, pos);
405 
406  if (distAtHcal < associationConeSize_) {
407  for (HBHERecHitCollection::const_iterator hhit2 = Hithbhe.begin(); hhit2 != Hithbhe.end(); hhit2++) {
408  int iphihitm2 = (hhit2->id()).iphi();
409  int ietahitm2 = (hhit2->id()).ieta();
410  int depthhit2 = (hhit2->id()).depth();
411  float enehit2 = hhit2->energy() * recal;
412 
413  if (iphihitm == iphihitm2 && ietahitm == ietahitm2 && depthhit != depthhit2)
414  enehit = enehit + enehit2;
415  }
416 
417 #ifdef EDM_ML_DEBUG
418  edm::LogVerbatim("ValidIsoTrkCalib") << "IN CONE ieta: " << ietahitm << " iphi: " << iphihitm
419  << " depthhit: " << depthhit << " dr: " << dr << " energy: " << enehit;
420 #endif
421  //Find a Hit with Maximum Energy
422 
423  if (enehit > MaxHit.hitenergy) {
424  MaxHit.hitenergy = enehit;
425  MaxHit.ietahitm = (hhit->id()).ieta();
426  MaxHit.iphihitm = (hhit->id()).iphi();
427  MaxHit.dr = distAtHcal;
428  //MaxHit.depthhit = (hhit->id()).depth();
429  MaxHit.depthhit = 1;
430 
431  //gPhot = geo->getPosition(hhit->detid());
432  }
433  }
434  } //end of all HBHE hits cycle
435 
436  usedHits.clear();
437 
438 #ifdef EDM_ML_DEBUG
439  edm::LogVerbatim("ValidIsoTrkCalib") << "Hottest ieta: " << MaxHit.ietahitm << " iphi: " << MaxHit.iphihitm
440  << " dr: " << MaxHit.dr;
441  edm::LogVerbatim("ValidIsoTrkCalib") << "Track ieta: " << ietatrue << " iphi: " << iphitrue;
442  edm::LogVerbatim("ValidIsoTrkCalib") << "Point 3. MaxHit :::En " << MaxHit.hitenergy
443  << " ieta: " << MaxHit.ietahitm << " iphi: " << MaxHit.iphihitm;
444 #endif
445 
446  Bool_t passCuts = kFALSE;
447  if (trackE > energyMinIso && trackE < energyMaxIso && emEnergy < energyECALmip && MaxHit.hitenergy > 0. &&
448  abs(MaxHit.ietahitm) < 29)
449  passCuts = kTRUE;
450 
451 #ifdef EDM_ML_DEBUG
452  edm::LogVerbatim("ValidIsoTrkCalib") << "Pont 0.1.1. trackE:" << trackE << " emEn: " << emEnergy;
453 #endif
454  numHits = 0;
455 
456  eClustBefore = 0.0;
457  eClustAfter = 0.0;
458  eBeforeDepth1 = 0.0;
459  eAfterDepth1 = 0.0;
460  eBeforeDepth2 = 0.0;
461  eAfterDepth2 = 0.0;
462  CentHitFactor = 0.0;
463  e3x3After = 0.0;
464  e3x3Before = 0.0;
465  e5x5After = 0.0;
466  e5x5Before = 0.0;
467 
468  for (HBHERecHitCollection::const_iterator hhit = Hithbhe.begin(); hhit != Hithbhe.end(); hhit++) {
469  //check that this hit was not considered before and push it into usedHits
470  bool hitIsUsed = false;
471  for (uint32_t i = 0; i < usedHits.size(); i++) {
472  if (usedHits[i] == hhit->id())
473  hitIsUsed = true;
474  }
475  if (hitIsUsed)
476  continue;
477  usedHits.push_back(hhit->id());
478 
479  int DIETA = 100;
480  if (MaxHit.ietahitm * (hhit->id()).ieta() > 0) {
481  DIETA = MaxHit.ietahitm - (hhit->id()).ieta();
482  }
483  if (MaxHit.ietahitm * (hhit->id()).ieta() < 0) {
484  DIETA = MaxHit.ietahitm - (hhit->id()).ieta();
485  DIETA = DIETA > 0 ? DIETA - 1 : DIETA + 1;
486  }
487 
488  int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi());
489  DIPHI = DIPHI > 36 ? 72 - DIPHI : DIPHI;
490 
491  int numbercell = 100; //always collect Wide clastor!
492 
493  //if(AxB_=="5x5" || AxB_=="3x3" || AxB_=="7x7"|| AxB_=="Cone")
494 
495  //if(AxB_=="3x3") numbercell = 1;
496  //if(AxB_=="5x5") numbercell = 2;
497  //if(AxB_=="Cone") numbercell = 1000;
498 
499  if (abs(DIETA) <= numbercell &&
500  (abs(DIPHI) <= numbercell || (abs(MaxHit.ietahitm) >= 20 && abs(DIPHI) <= numbercell + 1))) {
501  const GlobalPoint pos2 = geo->getPosition(hhit->detid());
502 
503  if (passCuts && hhit->energy() > 0) {
504  float factor = 0.0;
505  // factor = CalibFactors[hhit->id()];
506  factor = respRecalib->getValues(hhit->id())->getValue();
507 
508 #ifdef EDM_ML_DEBUG
509  edm::LogVerbatim("ValidIsoTrkCalib") << " calib factors: " << factor;
510 #endif
511 
512  if (hhit->id().ieta() == MaxHit.ietahitm && hhit->id().iphi() == MaxHit.iphihitm)
514 
515  if (hhit->id().ieta() == MaxHit.ietahitm && hhit->id().iphi() == MaxHit.iphihitm)
516  iTime = hhit->time();
517 
518  if (AxB_ != "3x3" && AxB_ != "5x5" && AxB_ != "Cone")
519  edm::LogWarning(" AxB ") << " Not supported: " << AxB_;
520 
521  if (abs(DIETA) <= 2 && (abs(DIPHI) <= 2 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 4) &&
522  !((abs(MaxHit.ietahitm) == 21 || abs(MaxHit.ietahitm) == 22) &&
523  abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 2)))) {
524  e5x5Before += hhit->energy();
525  e5x5After += hhit->energy() * factor;
526  }
527 
528  if (abs(DIETA) <= 1 && (abs(DIPHI) <= 1 || ((abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 2) &&
529  !(abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 &&
530  abs(DIPHI) > 1)))) {
531  e3x3Before += hhit->energy();
532  e3x3After += hhit->energy() * factor;
533  }
534 
535  if (AxB_ == "5x5") {
536  if (abs(DIETA) <= 2 && (abs(DIPHI) <= 2 || (abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 4))) {
537  if (abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 3)
538  continue;
539 
540  HTime[numHits] = hhit->time();
541  numHits++;
542 
543  eClustBefore += hhit->energy();
544  eClustAfter += hhit->energy() * factor;
545 
546  if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
547  eBeforeDepth1 += hhit->energy();
548  eAfterDepth1 += hhit->energy() * factor;
549  } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
550  eBeforeDepth2 += hhit->energy();
551  eAfterDepth2 += hhit->energy() * factor;
552  }
553  }
554  } //end of 5x5
555 
556  if (AxB_ == "3x3") {
557  if (abs(DIETA) <= 1 && (abs(DIPHI) <= 1 || (abs(MaxHit.ietahitm) > 20 && abs(DIPHI) <= 2))) {
558  if (abs(MaxHit.ietahitm) == 21 && abs((hhit->id()).ieta()) <= 20 && abs(DIPHI) > 2)
559  continue;
560 
561  HTime[numHits] = hhit->time();
562  numHits++;
563 
564  eClustBefore += hhit->energy();
565  eClustAfter += hhit->energy() * factor;
566 
567  if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
568  eBeforeDepth1 += hhit->energy();
569  eAfterDepth1 += hhit->energy() * factor;
570  } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
571  eBeforeDepth2 += hhit->energy();
572  eAfterDepth2 += hhit->energy() * factor;
573  }
574  }
575  } //end of 3x3
576 
577  if (AxB_ == "Cone" && getDistInPlaneSimple(gPointHcal, pos2) < calibrationConeSize_) {
578  HTime[numHits] = hhit->time();
579  numHits++;
580 
581  eClustBefore += hhit->energy();
582  eClustAfter += hhit->energy() * factor;
583 
584  if ((hhit->id().depth() == 1) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
585  eBeforeDepth1 += hhit->energy();
586  eAfterDepth1 += hhit->energy() * factor;
587  } else if ((hhit->id().depth() == 2) && (abs(hhit->id().ieta()) > 17) && (abs(hhit->id().ieta()) < 29)) {
588  eBeforeDepth2 += hhit->energy();
589  eAfterDepth2 += hhit->energy() * factor;
590  }
591 
592  } //end of Cone
593 
594  } //end of passCuts
595 
596  } //end of DIETA DIPHI
597 
598  } //end of associatedcone HBHE hits cycle
599 
600  int dieta_M_P = 100;
601  int diphi_M_P = 100;
602  if (MaxHit.ietahitm * ietatrue > 0) {
603  dieta_M_P = abs(MaxHit.ietahitm - ietatrue);
604  }
605  if (MaxHit.ietahitm * ietatrue < 0) {
606  dieta_M_P = abs(MaxHit.ietahitm - ietatrue) - 1;
607  }
608  diphi_M_P = abs(MaxHit.iphihitm - iphitrue);
609  diphi_M_P = diphi_M_P > 36 ? 72 - diphi_M_P : diphi_M_P;
610 
611  if (passCuts)
612 
613  {
614  eventNumber = iEvent.id().event();
615  runNumber = iEvent.id().run();
616 
617  eCentHitBefore = MaxHit.hitenergy;
619  eECAL = emEnergy;
622  PtNearBy = ptNear;
623 
624  eTrack = trackE;
625  phiTrack = trackPhi;
626  etaTrack = trackEta;
627 
628  iEta = MaxHit.ietahitm;
629  iPhi = MaxHit.iphihitm;
630 
631  iEtaTr = ietatrue;
632  iPhiTr = iphitrue;
633  iDr = sqrt(diphi_M_P * diphi_M_P + dieta_M_P * dieta_M_P);
634  delR = MaxHit.dr;
635  dietatr = dieta_M_P;
636  diphitr = diphi_M_P;
637 
638  fTree->Fill();
639  }
640 
641  } //end of isoProdTracks cycle
642 
643  /* ------------------ Some stuff for general tracks ---------- ----*/
644 #ifdef EDM_ML_DEBUG
645  edm::LogVerbatim("ValidIsoTrkCalib") << " generalTracks Size: " << generalTracks->size();
646 #endif
647  int n = generalTracks->size();
648  nTracks->Fill(n);
649 
650  if (takeGenTracks_ && iEvent.id().event() % 10 == 1) {
651  gen = generalTracks->size();
652  iso = isoProdTracks->size();
653  pix = isoPixelTracks->size();
654 
655  genPt[0] = -33;
656  genPhi[0] = -33;
657  genEta[0] = -33;
658 
659  isoPt[0] = -33;
660  isoPhi[0] = -33;
661  isoEta[0] = -33;
662 
663  pixPt[0] = -33;
664  pixPhi[0] = -33;
665  pixEta[0] = -33;
666 
667  Int_t gencount = 0, isocount = 0, pixcount = 0;
668  for (reco::TrackCollection::const_iterator gentr = generalTracks->begin(); gentr != generalTracks->end(); gentr++) {
669  genPt[gencount] = gentr->pt();
670  genPhi[gencount] = gentr->phi();
671  genEta[gencount] = gentr->eta();
672  gencount++;
673  }
674 
675  for (reco::TrackCollection::const_iterator isotr = isoProdTracks->begin(); isotr != isoProdTracks->end(); isotr++) {
676  isoPt[isocount] = isotr->pt();
677  isoPhi[isocount] = isotr->phi();
678  isoEta[isocount] = isotr->eta();
679  isocount++;
680  }
681 
682  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator pixtr = isoPixelTracks->begin();
683  pixtr != isoPixelTracks->end();
684  pixtr++) {
685  pixPt[pixcount] = pixtr->pt();
686  pixPhi[pixcount] = pixtr->phi();
687  pixEta[pixcount] = pixtr->eta();
688  pixcount++;
689  }
690  }
691 
692  tTree->Fill();
693 }
694 
695 // ------------ method called once each job just before starting event loop ------------
698 
699  nTracks = fs->make<TH1F>("nTracks", "general;number of general tracks", 11, -0.5, 10.5);
700 
701  tTree = fs->make<TTree>("tTree", "Tree for gen info");
702 
703  fTree = fs->make<TTree>("fTree", "Tree for IsoTrack Calibration");
704 
705  fTree->Branch("eventNumber", &eventNumber, "eventNumber/I");
706  fTree->Branch("runNumber", &runNumber, "runNumber/I");
707 
708  fTree->Branch("eClustBefore", &eClustBefore, "eClustBefore/F");
709  fTree->Branch("eClustAfter", &eClustAfter, "eClustAfter/F");
710  fTree->Branch("eTrack", &eTrack, "eTrack/F");
711  fTree->Branch("etaTrack", &etaTrack, "etaTrack/F");
712  fTree->Branch("phiTrack", &phiTrack, "phiTrack/F");
713 
714  fTree->Branch("numHits", &numHits, "numHits/I");
715  fTree->Branch("eECAL", &eECAL, "eECAL/F");
716  fTree->Branch("PtNearBy", &PtNearBy, "PtNearBy/F");
717  fTree->Branch("numValidTrkHits", &numValidTrkHits, "numValidTrkHits/F");
718  fTree->Branch("numValidTrkStrips", &numValidTrkStrips, "numValidTrkStrips/F");
719 
720  fTree->Branch("eBeforeDepth1", &eBeforeDepth1, "eBeforeDepth1/F");
721  fTree->Branch("eBeforeDepth2", &eBeforeDepth2, "eBeforeDepth2/F");
722  fTree->Branch("eAfterDepth1", &eAfterDepth1, "eAfterDepth1/F");
723  fTree->Branch("eAfterDepth2", &eAfterDepth2, "eAfterDepth2/F");
724 
725  fTree->Branch("e3x3Before", &e3x3Before, "e3x3Before/F");
726  fTree->Branch("e3x3After", &e3x3After, "e3x3After/F");
727  fTree->Branch("e5x5Before", &e5x5Before, "e5x5Before/F");
728  fTree->Branch("e5x5After", &e5x5After, "e5x5After/F");
729 
730  fTree->Branch("eCentHitAfter", &eCentHitAfter, "eCentHitAfter/F");
731  fTree->Branch("eCentHitBefore", &eCentHitBefore, "eCentHitBefore/F");
732  fTree->Branch("iEta", &iEta, "iEta/I");
733  fTree->Branch("iPhi", &iPhi, "iPhi/I");
734 
735  fTree->Branch("iEtaTr", &iEtaTr, "iEtaTr/I");
736  fTree->Branch("iPhiTr", &iPhiTr, "iPhiTr/I");
737  fTree->Branch("dietatr", &dietatr, "dietatr/I");
738  fTree->Branch("diphitr", &diphitr, "diphitr/I");
739  fTree->Branch("iDr", &iDr, "iDr/F");
740  fTree->Branch("delR", &delR, "delR/F");
741 
742  fTree->Branch("iTime", &iTime, "iTime/F");
743  fTree->Branch("HTime", HTime, "HTime[numHits]/F");
744 
745  fTree->Branch("xTrkEcal", &xTrkEcal, "xTrkEcal/F");
746  fTree->Branch("yTrkEcal", &yTrkEcal, "yTrkEcal/F");
747  fTree->Branch("zTrkEcal", &zTrkEcal, "zTrkEcal/F");
748  fTree->Branch("xTrkHcal", &xTrkHcal, "xTrkHcal/F");
749  fTree->Branch("yTrkHcal", &yTrkHcal, "yTrkHcal/F");
750  fTree->Branch("zTrkHcal", &zTrkHcal, "zTrkHcal/F");
751 
752  if (takeGenTracks_) {
753  tTree->Branch("gen", &gen, "gen/I");
754  tTree->Branch("iso", &iso, "iso/I");
755  tTree->Branch("pix", &pix, "pix/I");
756  tTree->Branch("genPt", genPt, "genPt[gen]/F");
757  tTree->Branch("genPhi", genPhi, "genPhi[gen]/F");
758  tTree->Branch("genEta", genEta, "genEta[gen]/F");
759 
760  tTree->Branch("isoPt", isoPt, "isoPt[iso]/F");
761  tTree->Branch("isoPhi", isoPhi, "isoPhi[iso]/F");
762  tTree->Branch("isoEta", isoEta, "isoEta[iso]/F");
763 
764  tTree->Branch("pixPt", pixPt, "pixPt[pix]/F");
765  tTree->Branch("pixPhi", pixPhi, "pixPhi[pix]/F");
766  tTree->Branch("pixEta", pixEta, "pixEta[pix]/F");
767  }
768 }
769 
770 //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)
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_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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:19
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
bool getData(T &iHolder) const
Definition: EventSetup.h:122
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