CMS 3D CMS Logo

HcalRecHitsValidation.cc
Go to the documentation of this file.
7 
9  : topFolderName_(conf.getParameter<std::string>("TopFolderName")) {
10  // DQM ROOT output
11  outputFile_ = conf.getUntrackedParameter<std::string>("outputFile", "myfile.root");
12 
13  if (!outputFile_.empty()) {
14  edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will be saved to '" << outputFile_.c_str() << "'";
15  } else {
16  edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will NOT be saved";
17  }
18 
19  nevtot = 0;
20 
21  hcalselector_ = conf.getUntrackedParameter<std::string>("hcalselector", "all");
22  ecalselector_ = conf.getUntrackedParameter<std::string>("ecalselector", "yes");
23  sign_ = conf.getUntrackedParameter<std::string>("sign", "*");
24  mc_ = conf.getUntrackedParameter<std::string>("mc", "yes");
25  testNumber_ = conf.getParameter<bool>("TestNumber");
26 
27  // Collections
28  tok_hbhe_ = consumes<HBHERecHitCollection>(conf.getUntrackedParameter<edm::InputTag>("HBHERecHitCollectionLabel"));
29  tok_hf_ = consumes<HFRecHitCollection>(conf.getUntrackedParameter<edm::InputTag>("HFRecHitCollectionLabel"));
30  tok_ho_ = consumes<HORecHitCollection>(conf.getUntrackedParameter<edm::InputTag>("HORecHitCollectionLabel"));
31 
32  // register for data access
33  tok_evt_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
34  edm::InputTag EBRecHitCollectionLabel = conf.getParameter<edm::InputTag>("EBRecHitCollectionLabel");
35  tok_EB_ = consumes<EBRecHitCollection>(EBRecHitCollectionLabel);
36  edm::InputTag EERecHitCollectionLabel = conf.getParameter<edm::InputTag>("EERecHitCollectionLabel");
37  tok_EE_ = consumes<EERecHitCollection>(EERecHitCollectionLabel);
38 
39  tok_hh_ = consumes<edm::PCaloHitContainer>(conf.getUntrackedParameter<edm::InputTag>("SimHitCollectionLabel"));
40 
41  subdet_ = 5;
42  if (hcalselector_ == "noise")
43  subdet_ = 0;
44  if (hcalselector_ == "HB")
45  subdet_ = 1;
46  if (hcalselector_ == "HE")
47  subdet_ = 2;
48  if (hcalselector_ == "HO")
49  subdet_ = 3;
50  if (hcalselector_ == "HF")
51  subdet_ = 4;
52  if (hcalselector_ == "all")
53  subdet_ = 5;
54  if (hcalselector_ == "ZS")
55  subdet_ = 6;
56 
57  iz = 1;
58  if (sign_ == "-")
59  iz = -1;
60  if (sign_ == "*")
61  iz = 0;
62 
63  imc = 1;
64  if (mc_ == "no")
65  imc = 0;
66 }
67 
69 
71  Char_t histo[200];
72 
74 
75  //======================= Now various cases one by one ===================
76 
77  // Histograms drawn for single pion scan
78  if (subdet_ != 0 && imc != 0) { // just not for noise
79  sprintf(histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths");
80  meEnConeEtaProfile = ib.bookProfile(histo, histo, 83, -41.5, 41.5, -100., 2000., " ");
81 
82  sprintf(histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E");
83  meEnConeEtaProfile_E = ib.bookProfile(histo, histo, 83, -41.5, 41.5, -100., 2000., " ");
84 
85  sprintf(histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH");
86  meEnConeEtaProfile_EH = ib.bookProfile(histo, histo, 83, -41.5, 41.5, -100., 2000., " ");
87  }
88 
89  // ************** HB **********************************
90  if (subdet_ == 1 || subdet_ == 5) {
91  sprintf(histo, "HcalRecHitTask_M2Log10Chi2_of_rechits_HB"); // Chi2
92  meRecHitsM2Chi2HB = ib.book1D(histo, histo, 120, -2., 10.);
93 
94  sprintf(histo, "HcalRecHitTask_Log10Chi2_vs_energy_profile_HB");
95  meLog10Chi2profileHB = ib.bookProfile(histo, histo, 300, -5., 295., -2., 9.9, " ");
96 
97  sprintf(histo, "HcalRecHitTask_energy_of_rechits_HB");
98  meRecHitsEnergyHB = ib.book1D(histo, histo, 2010, -10., 2000.);
99 
100  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_HB");
101  meTEprofileHB = ib.bookProfile(histo, histo, 150, -5., 295., -48., 92., " ");
102 
103  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HB");
104  meTEprofileHB_Low = ib.bookProfile(histo, histo, 150, -5., 295., -48., 92., " ");
105 
106  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_High_HB");
107  meTEprofileHB_High = ib.bookProfile(histo, histo, 150, -5., 295., 48., 92., " ");
108 
109  if (imc != 0) {
110  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HB");
111  meRecHitSimHitHB = ib.book2D(histo, histo, 120, 0., 1.2, 300, 0., 150.);
112  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HB");
113  meRecHitSimHitProfileHB = ib.bookProfile(histo, histo, 120, 0., 1.2, 0., 500., " ");
114  }
115  }
116 
117  // ********************** HE ************************************
118  if (subdet_ == 2 || subdet_ == 5) {
119  sprintf(histo, "HcalRecHitTask_M2Log10Chi2_of_rechits_HE"); // Chi2
120  meRecHitsM2Chi2HE = ib.book1D(histo, histo, 120, -2., 10.);
121 
122  sprintf(histo, "HcalRecHitTask_Log10Chi2_vs_energy_profile_HE");
123  meLog10Chi2profileHE = ib.bookProfile(histo, histo, 1000, -5., 995., -2., 9.9, " ");
124 
125  sprintf(histo, "HcalRecHitTask_energy_of_rechits_HE");
126  meRecHitsEnergyHE = ib.book1D(histo, histo, 2010, -10., 2000.);
127 
128  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HE");
129  meTEprofileHE_Low = ib.bookProfile(histo, histo, 80, -5., 75., -48., 92., " ");
130 
131  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_HE");
132  meTEprofileHE = ib.bookProfile(histo, histo, 200, -5., 2995., -48., 92., " ");
133 
134  if (imc != 0) {
135  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HE");
136  meRecHitSimHitHE = ib.book2D(histo, histo, 120, 0., 0.6, 300, 0., 150.);
137  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HE");
138  meRecHitSimHitProfileHE = ib.bookProfile(histo, histo, 120, 0., 0.6, 0., 500., " ");
139  }
140  }
141 
142  // ************** HO ****************************************
143  if (subdet_ == 3 || subdet_ == 5) {
144  sprintf(histo, "HcalRecHitTask_energy_of_rechits_HO");
145  meRecHitsEnergyHO = ib.book1D(histo, histo, 2010, -10., 2000.);
146 
147  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_HO");
148  meTEprofileHO = ib.bookProfile(histo, histo, 60, -5., 55., -48., 92., " ");
149 
150  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_High_HO");
151  meTEprofileHO_High = ib.bookProfile(histo, histo, 100, -5., 995., -48., 92., " ");
152 
153  if (imc != 0) {
154  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HO");
155  meRecHitSimHitHO = ib.book2D(histo, histo, 150, 0., 1.5, 350, 0., 350.);
156  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HO");
157  meRecHitSimHitProfileHO = ib.bookProfile(histo, histo, 150, 0., 1.5, 0., 500., " ");
158  }
159  }
160 
161  // ********************** HF ************************************
162  if (subdet_ == 4 || subdet_ == 5) {
163  sprintf(histo, "HcalRecHitTask_energy_of_rechits_HF");
164  meRecHitsEnergyHF = ib.book1D(histo, histo, 2010, -10., 2000.);
165 
166  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HF");
167  meTEprofileHF_Low = ib.bookProfile(histo, histo, 100, -5., 195., -48., 92., " ");
168 
169  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_HF");
170  meTEprofileHF = ib.bookProfile(histo, histo, 200, -5., 995., -48., 92., " ");
171 
172  if (imc != 0) {
173  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HF");
174  meRecHitSimHitHF = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
175  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HFL");
176  meRecHitSimHitHFL = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
177  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HFS");
178  meRecHitSimHitHFS = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
179  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HF");
180  meRecHitSimHitProfileHF = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
181  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HFL");
182  meRecHitSimHitProfileHFL = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
183  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HFS");
184  meRecHitSimHitProfileHFS = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
185  }
186  }
187 }
188 
190  using namespace edm;
191 
193  c.get<HcalRecNumberingRecord>().get(pHRNDC);
194  const HcalDDDRecConstants *hcons = &(*pHRNDC);
195 
196  // cuts for each subdet_ector mimiking "Scheme B"
197  // double cutHB = 0.9, cutHE = 1.4, cutHO = 1.1, cutHFL = 1.2, cutHFS = 1.8;
198 
199  // energy in HCAL
200  double eHcal = 0.;
201  double eHcalCone = 0.;
202  double eHcalConeHB = 0.;
203  double eHcalConeHE = 0.;
204  double eHcalConeHO = 0.;
205  double eHcalConeHF = 0.;
206  double eHcalConeHFL = 0.;
207  double eHcalConeHFS = 0.;
208 
209  // Total numbet of RecHits in HCAL, in the cone, above 1 GeV theshold
210  int nrechits = 0;
211  int nrechitsCone = 0;
212  int nrechitsThresh = 0;
213 
214  // energy in ECAL
215  double eEcal = 0.;
216  double eEcalB = 0.;
217  double eEcalE = 0.;
218  double eEcalCone = 0.;
219  int numrechitsEcal = 0;
220 
221  // MC info
222  double phi_MC = -999999.; // phi of initial particle from HepMC
223  double eta_MC = -999999.; // eta of initial particle from HepMC
224 
225  // HCAL energy around MC eta-phi at all depths;
226  double partR = 0.3;
227 
228  if (imc != 0) {
230  ev.getByToken(tok_evt_, evtMC); // generator in late 310_preX
231  if (!evtMC.isValid()) {
232  edm::LogInfo("HcalRecHitsValidation") << "no HepMCProduct found";
233  } else {
234  // std::cout << "*** source HepMCProduct found"<< std::endl;
235  }
236 
237  // MC particle with highest pt is taken as a direction reference
238  double maxPt = -99999.;
239  int npart = 0;
240  const HepMC::GenEvent *myGenEvent = evtMC->GetEvent();
241  for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
242  ++p) {
243  double phip = (*p)->momentum().phi();
244  double etap = (*p)->momentum().eta();
245  // phi_MC = phip;
246  // eta_MC = etap;
247  double pt = (*p)->momentum().perp();
248  if (pt > maxPt) {
249  npart++;
250  maxPt = pt;
251  phi_MC = phip;
252  eta_MC = etap;
253  }
254  }
255  // std::cout << "*** Max pT = " << maxPt << std::endl;
256  }
257 
258  // std::cout << "*** 2" << std::endl;
259 
260  c.get<CaloGeometryRecord>().get(geometry);
261 
262  // Fill working vectors of HCAL RecHits quantities (all of these are drawn)
263  fillRecHitsTmp(subdet_, ev);
264 
265  // std::cout << "*** 3" << std::endl;
266 
267  //===========================================================================
268  // IN ALL other CASES : ieta-iphi maps
269  //===========================================================================
270 
271  // ECAL
272  if (ecalselector_ == "yes" && (subdet_ == 1 || subdet_ == 2 || subdet_ == 5)) {
274 
277 
278  if (ev.getByToken(tok_EB_, rhitEB)) {
279  RecHit = rhitEB.product()->begin();
280  RecHitEnd = rhitEB.product()->end();
281 
282  for (; RecHit != RecHitEnd; ++RecHit) {
283  EBDetId EBid = EBDetId(RecHit->id());
284 
285  auto cellGeometry = geometry->getSubdetectorGeometry(EBid)->getGeometry(EBid);
286  double eta = cellGeometry->getPosition().eta();
287  double phi = cellGeometry->getPosition().phi();
288  double en = RecHit->energy();
289  eEcal += en;
290  eEcalB += en;
291 
292  double r = dR(eta_MC, phi_MC, eta, phi);
293  if (r < partR) {
294  eEcalCone += en;
295  numrechitsEcal++;
296  }
297  }
298  }
299 
301 
302  if (ev.getByToken(tok_EE_, rhitEE)) {
303  RecHit = rhitEE.product()->begin();
304  RecHitEnd = rhitEE.product()->end();
305 
306  for (; RecHit != RecHitEnd; ++RecHit) {
307  EEDetId EEid = EEDetId(RecHit->id());
308 
309  auto cellGeometry = geometry->getSubdetectorGeometry(EEid)->getGeometry(EEid);
310  double eta = cellGeometry->getPosition().eta();
311  double phi = cellGeometry->getPosition().phi();
312  double en = RecHit->energy();
313  eEcal += en;
314  eEcalE += en;
315 
316  double r = dR(eta_MC, phi_MC, eta, phi);
317  if (r < partR) {
318  eEcalCone += en;
319  numrechitsEcal++;
320  }
321  }
322  }
323  } // end of ECAL selection
324 
325  // std::cout << "*** 4" << std::endl;
326 
327  //===========================================================================
328  // SUBSYSTEMS,
329  //===========================================================================
330 
331  if ((subdet_ != 6) && (subdet_ != 0)) {
332  // std::cout << "*** 6" << std::endl;
333 
334  double HcalCone = 0.;
335 
336  int ietaMax = 9999;
337  double etaMax = 9999.;
338 
339  // CYCLE over cells ====================================================
340 
341  for (unsigned int i = 0; i < cen.size(); i++) {
342  int sub = csub[i];
343  int depth = cdepth[i];
344  double eta = ceta[i];
345  double phi = cphi[i];
346  double en = cen[i];
347  double t = ctime[i];
348  int ieta = cieta[i];
349  double chi2 = cchi2[i];
350 
351  double chi2_log10 = 9.99; // initial value above histos limits , keep it if chi2 <= 0.
352  if (chi2 > 0.)
353  chi2_log10 = log10(chi2);
354 
355  nrechits++;
356  eHcal += en;
357  if (en > 1.)
358  nrechitsThresh++;
359 
360  double r = dR(eta_MC, phi_MC, eta, phi);
361  if (r < partR) {
362  if (sub == 1)
363  eHcalConeHB += en;
364  if (sub == 2)
365  eHcalConeHE += en;
366  if (sub == 3)
367  eHcalConeHO += en;
368  if (sub == 4) {
369  eHcalConeHF += en;
370  if (depth == 1)
371  eHcalConeHFL += en;
372  else
373  eHcalConeHFS += en;
374  }
375  eHcalCone += en;
376  nrechitsCone++;
377 
378  HcalCone += en;
379 
380  // alternative: ietamax -> closest to MC eta !!!
381  float eta_diff = fabs(eta_MC - eta);
382  if (eta_diff < etaMax) {
383  etaMax = eta_diff;
384  ietaMax = ieta;
385  }
386  }
387 
388  // The energy and overall timing histos are drawn while
389  // the ones split by depth are not
390  if (sub == 1 && (subdet_ == 1 || subdet_ == 5)) {
391  meRecHitsM2Chi2HB->Fill(chi2_log10);
392  meLog10Chi2profileHB->Fill(en, chi2_log10);
393 
394  meRecHitsEnergyHB->Fill(en);
395 
396  meTEprofileHB_Low->Fill(en, t);
397  meTEprofileHB->Fill(en, t);
398  meTEprofileHB_High->Fill(en, t);
399  }
400  if (sub == 2 && (subdet_ == 2 || subdet_ == 5)) {
401  meRecHitsM2Chi2HE->Fill(chi2_log10);
402  meLog10Chi2profileHE->Fill(en, chi2_log10);
403 
404  meRecHitsEnergyHE->Fill(en);
405 
406  meTEprofileHE_Low->Fill(en, t);
407  meTEprofileHE->Fill(en, t);
408  }
409  if (sub == 4 && (subdet_ == 4 || subdet_ == 5)) {
410  meRecHitsEnergyHF->Fill(en);
411 
412  meTEprofileHF_Low->Fill(en, t);
413  meTEprofileHF->Fill(en, t);
414  }
415  if (sub == 3 && (subdet_ == 3 || subdet_ == 5)) {
416  meRecHitsEnergyHO->Fill(en);
417 
418  meTEprofileHO->Fill(en, t);
419  meTEprofileHO_High->Fill(en, t);
420  }
421  }
422 
423  if (imc != 0) {
424  meEnConeEtaProfile->Fill(double(ietaMax), HcalCone); //
425  meEnConeEtaProfile_E->Fill(double(ietaMax), eEcalCone);
426  meEnConeEtaProfile_EH->Fill(double(ietaMax), HcalCone + eEcalCone);
427  }
428 
429  // std::cout << "*** 7" << std::endl;
430  }
431 
432  // SimHits vs. RecHits
433  const CaloGeometry *geo = geometry.product();
434  if (subdet_ > 0 && subdet_ < 6 && imc != 0) { // not noise
435 
437  if (ev.getByToken(tok_hh_, hcalHits)) {
438  const PCaloHitContainer *SimHitResult = hcalHits.product();
439 
440  double enSimHits = 0.;
441  double enSimHitsHB = 0.;
442  double enSimHitsHE = 0.;
443  double enSimHitsHO = 0.;
444  double enSimHitsHF = 0.;
445  double enSimHitsHFL = 0.;
446  double enSimHitsHFS = 0.;
447  // sum of SimHits in the cone
448 
449  for (std::vector<PCaloHit>::const_iterator SimHits = SimHitResult->begin(); SimHits != SimHitResult->end();
450  ++SimHits) {
451  int sub, depth;
452  HcalDetId cell;
453 
454  if (testNumber_)
455  cell = HcalHitRelabeller::relabel(SimHits->id(), hcons);
456  else
457  cell = HcalDetId(SimHits->id());
458 
459  sub = cell.subdet();
460  depth = cell.depth();
461 
462  if (sub != subdet_ && subdet_ != 5)
463  continue; // If we are not looking at all of the subdetectors and the
464  // simhit doesn't come from the specific subdetector of
465  // interest, then we won't do any thing with it
466 
467  const HcalGeometry *cellGeometry =
468  dynamic_cast<const HcalGeometry *>(geo->getSubdetectorGeometry(DetId::Hcal, cell.subdet()));
469  double etaS = cellGeometry->getPosition(cell).eta();
470  double phiS = cellGeometry->getPosition(cell).phi();
471  double en = SimHits->energy();
472 
473  double r = dR(eta_MC, phi_MC, etaS, phiS);
474 
475  if (r < partR) { // just energy in the small cone
476 
477  enSimHits += en;
478  if (sub == static_cast<int>(HcalBarrel))
479  enSimHitsHB += en;
480  if (sub == static_cast<int>(HcalEndcap))
481  enSimHitsHE += en;
482  if (sub == static_cast<int>(HcalOuter))
483  enSimHitsHO += en;
484  if (sub == static_cast<int>(HcalForward)) {
485  enSimHitsHF += en;
486  if (depth == 1)
487  enSimHitsHFL += en;
488  else
489  enSimHitsHFS += en;
490  }
491  }
492  }
493 
494  // Now some histos with SimHits
495 
496  if (subdet_ == 4 || subdet_ == 5) {
497  meRecHitSimHitHF->Fill(enSimHitsHF, eHcalConeHF);
498  meRecHitSimHitProfileHF->Fill(enSimHitsHF, eHcalConeHF);
499 
500  meRecHitSimHitHFL->Fill(enSimHitsHFL, eHcalConeHFL);
501  meRecHitSimHitProfileHFL->Fill(enSimHitsHFL, eHcalConeHFL);
502  meRecHitSimHitHFS->Fill(enSimHitsHFS, eHcalConeHFS);
503  meRecHitSimHitProfileHFS->Fill(enSimHitsHFS, eHcalConeHFS);
504  }
505  if (subdet_ == 1 || subdet_ == 5) {
506  meRecHitSimHitHB->Fill(enSimHitsHB, eHcalConeHB);
507  meRecHitSimHitProfileHB->Fill(enSimHitsHB, eHcalConeHB);
508  }
509  if (subdet_ == 2 || subdet_ == 5) {
510  meRecHitSimHitHE->Fill(enSimHitsHE, eHcalConeHE);
511  meRecHitSimHitProfileHE->Fill(enSimHitsHE, eHcalConeHE);
512  }
513  if (subdet_ == 3 || subdet_ == 5) {
514  meRecHitSimHitHO->Fill(enSimHitsHO, eHcalConeHO);
515  meRecHitSimHitProfileHO->Fill(enSimHitsHO, eHcalConeHO);
516  }
517  }
518  }
519 
520  nevtot++;
521 }
522 
525  using namespace edm;
526 
527  // initialize data vectors
528  csub.clear();
529  cen.clear();
530  ceta.clear();
531  cphi.clear();
532  ctime.clear();
533  cieta.clear();
534  ciphi.clear();
535  cdepth.clear();
536  cz.clear();
537  cchi2.clear();
538 
539  if (subdet_ == 1 || subdet_ == 2 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
540  // HBHE
542  if (ev.getByToken(tok_hbhe_, hbhecoll)) {
543  const CaloGeometry *geo = geometry.product();
544 
545  for (HBHERecHitCollection::const_iterator j = hbhecoll->begin(); j != hbhecoll->end(); j++) {
546  HcalDetId cell(j->id());
547  const HcalGeometry *cellGeometry =
548  dynamic_cast<const HcalGeometry *>(geo->getSubdetectorGeometry(DetId::Hcal, cell.subdet()));
549  double eta = cellGeometry->getPosition(cell).eta();
550  double phi = cellGeometry->getPosition(cell).phi();
551  double zc = cellGeometry->getPosition(cell).z();
552  int sub = cell.subdet();
553  int depth = cell.depth();
554  int inteta = cell.ieta();
555  int intphi = cell.iphi() - 1;
556  double en = j->energy();
557  double t = j->time();
558  double chi2 = j->chi2();
559 
560  if ((iz > 0 && eta > 0.) || (iz < 0 && eta < 0.) || iz == 0) {
561  csub.push_back(sub);
562  cen.push_back(en);
563  ceta.push_back(eta);
564  cphi.push_back(phi);
565  ctime.push_back(t);
566  cieta.push_back(inteta);
567  ciphi.push_back(intphi);
568  cdepth.push_back(depth);
569  cz.push_back(zc);
570  cchi2.push_back(chi2);
571  }
572  }
573  }
574  }
575 
576  if (subdet_ == 4 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
577  // HF
579  if (ev.getByToken(tok_hf_, hfcoll)) {
580  for (HFRecHitCollection::const_iterator j = hfcoll->begin(); j != hfcoll->end(); j++) {
581  HcalDetId cell(j->id());
582  auto cellGeometry = geometry->getSubdetectorGeometry(cell)->getGeometry(cell);
583 
584  double eta = cellGeometry->getPosition().eta();
585  double phi = cellGeometry->getPosition().phi();
586  double zc = cellGeometry->getPosition().z();
587  int sub = cell.subdet();
588  int depth = cell.depth();
589  int inteta = cell.ieta();
590  int intphi = cell.iphi() - 1;
591  double en = j->energy();
592  double t = j->time();
593 
594  if ((iz > 0 && eta > 0.) || (iz < 0 && eta < 0.) || iz == 0) {
595  csub.push_back(sub);
596  cen.push_back(en);
597  ceta.push_back(eta);
598  cphi.push_back(phi);
599  ctime.push_back(t);
600  cieta.push_back(inteta);
601  ciphi.push_back(intphi);
602  cdepth.push_back(depth);
603  cz.push_back(zc);
604  cchi2.push_back(0.);
605  }
606  }
607  }
608  }
609 
610  // HO
611  if (subdet_ == 3 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
613  if (ev.getByToken(tok_ho_, hocoll)) {
614  for (HORecHitCollection::const_iterator j = hocoll->begin(); j != hocoll->end(); j++) {
615  HcalDetId cell(j->id());
616  auto cellGeometry = geometry->getSubdetectorGeometry(cell)->getGeometry(cell);
617 
618  double eta = cellGeometry->getPosition().eta();
619  double phi = cellGeometry->getPosition().phi();
620  double zc = cellGeometry->getPosition().z();
621  int sub = cell.subdet();
622  int depth = cell.depth();
623  int inteta = cell.ieta();
624  int intphi = cell.iphi() - 1;
625  double t = j->time();
626  double en = j->energy();
627 
628  if ((iz > 0 && eta > 0.) || (iz < 0 && eta < 0.) || iz == 0) {
629  csub.push_back(sub);
630  cen.push_back(en);
631  ceta.push_back(eta);
632  cphi.push_back(phi);
633  ctime.push_back(t);
634  cieta.push_back(inteta);
635  ciphi.push_back(intphi);
636  cdepth.push_back(depth);
637  cz.push_back(zc);
638  cchi2.push_back(0.);
639  }
640  }
641  }
642  }
643 }
644 
645 double HcalRecHitsValidation::dR(double eta1, double phi1, double eta2, double phi2) {
646  double PI = 3.1415926535898;
647  double deltaphi = phi1 - phi2;
648  if (phi2 > phi1) {
649  deltaphi = phi2 - phi1;
650  }
651  if (deltaphi > PI) {
652  deltaphi = 2. * PI - deltaphi;
653  }
654  double deltaeta = eta2 - eta1;
655  double tmp = sqrt(deltaeta * deltaeta + deltaphi * deltaphi);
656  return tmp;
657 }
658 
659 double HcalRecHitsValidation::phi12(double phi1, double en1, double phi2, double en2) {
660  // weighted mean value of phi1 and phi2
661 
662  double tmp;
663  double PI = 3.1415926535898;
664  double a1 = phi1;
665  double a2 = phi2;
666 
667  if (a1 > 0.5 * PI && a2 < 0.)
668  a2 += 2 * PI;
669  if (a2 > 0.5 * PI && a1 < 0.)
670  a1 += 2 * PI;
671  tmp = (a1 * en1 + a2 * en2) / (en1 + en2);
672  if (tmp > PI)
673  tmp -= 2. * PI;
674 
675  return tmp;
676 }
677 
678 double HcalRecHitsValidation::dPhiWsign(double phi1, double phi2) {
679  // clockwise phi2 w.r.t phi1 means "+" phi distance
680  // anti-clockwise phi2 w.r.t phi1 means "-" phi distance
681 
682  double PI = 3.1415926535898;
683  double a1 = phi1;
684  double a2 = phi2;
685  double tmp = a2 - a1;
686  if (a1 * a2 < 0.) {
687  if (a1 > 0.5 * PI)
688  tmp += 2. * PI;
689  if (a2 > 0.5 * PI)
690  tmp -= 2. * PI;
691  }
692  return tmp;
693 }
694 
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
std::vector< double > cchi2
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * meRecHitsM2Chi2HB
std::vector< PCaloHit > PCaloHitContainer
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hh_
MonitorElement * meRecHitsEnergyHF
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:146
double phi12(double phi1, double en1, double phi2, double en2)
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
MonitorElement * meTEprofileHE_Low
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
std::vector< EcalRecHit >::const_iterator const_iterator
MonitorElement * meLog10Chi2profileHB
MonitorElement * meEnConeEtaProfile
double npart
Definition: HydjetWrapper.h:49
bool ev
double dPhiWsign(double phi1, double phi2)
MonitorElement * meRecHitSimHitProfileHF
MonitorElement * meRecHitSimHitProfileHFS
MonitorElement * meRecHitsEnergyHB
std::vector< double > ceta
MonitorElement * meRecHitSimHitHF
MonitorElement * meRecHitsEnergyHE
MonitorElement * meRecHitSimHitProfileHE
edm::EDGetTokenT< HORecHitCollection > tok_ho_
void Fill(long long x)
MonitorElement * meEnConeEtaProfile_E
MonitorElement * meRecHitSimHitHB
MonitorElement * meRecHitSimHitHFS
std::vector< double > cphi
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * meRecHitsM2Chi2HE
MonitorElement * meTEprofileHB
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
virtual void fillRecHitsTmp(int subdet_, edm::Event const &ev)
double dR(double eta1, double phi1, double eta2, double phi2)
MonitorElement * meLog10Chi2profileHE
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
bool isValid() const
Definition: HandleBase.h:74
#define PI
Definition: QcdUeDQM.h:36
MonitorElement * meRecHitSimHitHO
MonitorElement * meRecHitSimHitProfileHB
GlobalPoint getPosition(const DetId &id) const
const_iterator end() const
MonitorElement * meTEprofileHF_Low
edm::EDGetTokenT< EBRecHitCollection > tok_EB_
MonitorElement * meTEprofileHO_High
MonitorElement * meTEprofileHE
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
T const * product() const
Definition: Handle.h:74
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
MonitorElement * meTEprofileHF
MonitorElement * meRecHitSimHitProfileHO
void analyze(edm::Event const &ev, edm::EventSetup const &c) override
edm::EDGetTokenT< EERecHitCollection > tok_EE_
std::vector< double > ctime
MonitorElement * meEnConeEtaProfile_EH
MonitorElement * meRecHitSimHitProfileHFL
std::vector< double > cz
T eta() const
Definition: PV3DBase.h:76
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
MonitorElement * meRecHitsEnergyHO
HLT enums.
T get() const
Definition: EventSetup.h:71
MonitorElement * meRecHitSimHitHFL
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * meTEprofileHO
edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
DetId relabel(const uint32_t testId) const
MonitorElement * meTEprofileHB_Low
MonitorElement * meRecHitSimHitHE
HcalRecHitsValidation(edm::ParameterSet const &conf)
MonitorElement * meTEprofileHB_High
std::vector< double > cen
const_iterator begin() const
Definition: Run.h:45
ib
Definition: cuy.py:662