CMS 3D CMS Logo

HcalRecHitsValidation.cc
Go to the documentation of this file.
5 
7  : topFolderName_(conf.getParameter<std::string>("TopFolderName")) {
8  // DQM ROOT output
9  outputFile_ = conf.getUntrackedParameter<std::string>("outputFile", "myfile.root");
10 
11  if (!outputFile_.empty()) {
12  edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will be saved to '" << outputFile_.c_str() << "'";
13  } else {
14  edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will NOT be saved";
15  }
16 
17  nevtot = 0;
18 
19  hcalselector_ = conf.getUntrackedParameter<std::string>("hcalselector", "all");
20  ecalselector_ = conf.getUntrackedParameter<std::string>("ecalselector", "yes");
21  sign_ = conf.getUntrackedParameter<std::string>("sign", "*");
22  mc_ = conf.getUntrackedParameter<std::string>("mc", "yes");
23  testNumber_ = conf.getParameter<bool>("TestNumber");
24 
25  // Collections
26  tok_hbhe_ = consumes<HBHERecHitCollection>(conf.getUntrackedParameter<edm::InputTag>("HBHERecHitCollectionLabel"));
27  tok_hf_ = consumes<HFRecHitCollection>(conf.getUntrackedParameter<edm::InputTag>("HFRecHitCollectionLabel"));
28  tok_ho_ = consumes<HORecHitCollection>(conf.getUntrackedParameter<edm::InputTag>("HORecHitCollectionLabel"));
29 
30  // register for data access
31  tok_evt_ = consumes<edm::HepMCProduct>(edm::InputTag("generatorSmeared"));
32  edm::InputTag EBRecHitCollectionLabel = conf.getParameter<edm::InputTag>("EBRecHitCollectionLabel");
33  tok_EB_ = consumes<EBRecHitCollection>(EBRecHitCollectionLabel);
34  edm::InputTag EERecHitCollectionLabel = conf.getParameter<edm::InputTag>("EERecHitCollectionLabel");
35  tok_EE_ = consumes<EERecHitCollection>(EERecHitCollectionLabel);
36 
37  tok_hh_ = consumes<edm::PCaloHitContainer>(conf.getUntrackedParameter<edm::InputTag>("SimHitCollectionLabel"));
38 
39  tok_HRNDC_ = esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord>();
40  tok_Geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
41 
42  subdet_ = 5;
43  if (hcalselector_ == "noise")
44  subdet_ = 0;
45  if (hcalselector_ == "HB")
46  subdet_ = 1;
47  if (hcalselector_ == "HE")
48  subdet_ = 2;
49  if (hcalselector_ == "HO")
50  subdet_ = 3;
51  if (hcalselector_ == "HF")
52  subdet_ = 4;
53  if (hcalselector_ == "all")
54  subdet_ = 5;
55  if (hcalselector_ == "ZS")
56  subdet_ = 6;
57 
58  iz = 1;
59  if (sign_ == "-")
60  iz = -1;
61  if (sign_ == "*")
62  iz = 0;
63 
64  imc = 1;
65  if (mc_ == "no")
66  imc = 0;
67 }
68 
70 
72  Char_t histo[200];
73 
74  ib.setCurrentFolder(topFolderName_);
75 
76  //======================= Now various cases one by one ===================
77 
78  // Histograms drawn for single pion scan
79  if (subdet_ != 0 && imc != 0) { // just not for noise
80  sprintf(histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths");
81  meEnConeEtaProfile = ib.bookProfile(histo, histo, 83, -41.5, 41.5, -100., 2000., " ");
82 
83  sprintf(histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E");
84  meEnConeEtaProfile_E = ib.bookProfile(histo, histo, 83, -41.5, 41.5, -100., 2000., " ");
85 
86  sprintf(histo, "HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH");
87  meEnConeEtaProfile_EH = ib.bookProfile(histo, histo, 83, -41.5, 41.5, -100., 2000., " ");
88  }
89 
90  // ************** HB **********************************
91  if (subdet_ == 1 || subdet_ == 5) {
92  sprintf(histo, "HcalRecHitTask_M2Log10Chi2_of_rechits_HB"); // Chi2
93  meRecHitsM2Chi2HB = ib.book1D(histo, histo, 120, -2., 10.);
94 
95  sprintf(histo, "HcalRecHitTask_Log10Chi2_vs_energy_profile_HB");
96  meLog10Chi2profileHB = ib.bookProfile(histo, histo, 300, -5., 295., -2., 9.9, " ");
97 
98  sprintf(histo, "HcalRecHitTask_energy_of_rechits_HB");
99  meRecHitsEnergyHB = ib.book1D(histo, histo, 2010, -10., 2000.);
100 
101  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_HB");
102  meTEprofileHB = ib.bookProfile(histo, histo, 150, -5., 295., -48., 92., " ");
103 
104  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HB");
105  meTEprofileHB_Low = ib.bookProfile(histo, histo, 150, -5., 295., -48., 92., " ");
106 
107  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_High_HB");
108  meTEprofileHB_High = ib.bookProfile(histo, histo, 150, -5., 295., 48., 92., " ");
109 
110  if (imc != 0) {
111  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HB");
112  meRecHitSimHitHB = ib.book2D(histo, histo, 120, 0., 1.2, 300, 0., 150.);
113  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HB");
114  meRecHitSimHitProfileHB = ib.bookProfile(histo, histo, 120, 0., 1.2, 0., 500., " ");
115  }
116  }
117 
118  // ********************** HE ************************************
119  if (subdet_ == 2 || subdet_ == 5) {
120  sprintf(histo, "HcalRecHitTask_M2Log10Chi2_of_rechits_HE"); // Chi2
121  meRecHitsM2Chi2HE = ib.book1D(histo, histo, 120, -2., 10.);
122 
123  sprintf(histo, "HcalRecHitTask_Log10Chi2_vs_energy_profile_HE");
124  meLog10Chi2profileHE = ib.bookProfile(histo, histo, 1000, -5., 995., -2., 9.9, " ");
125 
126  sprintf(histo, "HcalRecHitTask_energy_of_rechits_HE");
127  meRecHitsEnergyHE = ib.book1D(histo, histo, 2010, -10., 2000.);
128 
129  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HE");
130  meTEprofileHE_Low = ib.bookProfile(histo, histo, 80, -5., 75., -48., 92., " ");
131 
132  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_HE");
133  meTEprofileHE = ib.bookProfile(histo, histo, 200, -5., 2995., -48., 92., " ");
134 
135  if (imc != 0) {
136  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HE");
137  meRecHitSimHitHE = ib.book2D(histo, histo, 120, 0., 0.6, 300, 0., 150.);
138  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HE");
139  meRecHitSimHitProfileHE = ib.bookProfile(histo, histo, 120, 0., 0.6, 0., 500., " ");
140  }
141  }
142 
143  // ************** HO ****************************************
144  if (subdet_ == 3 || subdet_ == 5) {
145  sprintf(histo, "HcalRecHitTask_energy_of_rechits_HO");
146  meRecHitsEnergyHO = ib.book1D(histo, histo, 2010, -10., 2000.);
147 
148  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_HO");
149  meTEprofileHO = ib.bookProfile(histo, histo, 60, -5., 55., -48., 92., " ");
150 
151  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_High_HO");
152  meTEprofileHO_High = ib.bookProfile(histo, histo, 100, -5., 995., -48., 92., " ");
153 
154  if (imc != 0) {
155  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HO");
156  meRecHitSimHitHO = ib.book2D(histo, histo, 150, 0., 1.5, 350, 0., 350.);
157  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HO");
158  meRecHitSimHitProfileHO = ib.bookProfile(histo, histo, 150, 0., 1.5, 0., 500., " ");
159  }
160  }
161 
162  // ********************** HF ************************************
163  if (subdet_ == 4 || subdet_ == 5) {
164  sprintf(histo, "HcalRecHitTask_energy_of_rechits_HF");
165  meRecHitsEnergyHF = ib.book1D(histo, histo, 2010, -10., 2000.);
166 
167  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HF");
168  meTEprofileHF_Low = ib.bookProfile(histo, histo, 100, -5., 195., -48., 92., " ");
169 
170  sprintf(histo, "HcalRecHitTask_timing_vs_energy_profile_HF");
171  meTEprofileHF = ib.bookProfile(histo, histo, 200, -5., 995., -48., 92., " ");
172 
173  if (imc != 0) {
174  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HF");
175  meRecHitSimHitHF = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
176  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HFL");
177  meRecHitSimHitHFL = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
178  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_HFS");
179  meRecHitSimHitHFS = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
180  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HF");
181  meRecHitSimHitProfileHF = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
182  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HFL");
183  meRecHitSimHitProfileHFL = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
184  sprintf(histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HFS");
185  meRecHitSimHitProfileHFS = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
186  }
187  }
188 }
189 
191  using namespace edm;
192 
193  const HcalDDDRecConstants *hcons = &c.getData(tok_HRNDC_);
194 
195  // cuts for each subdet_ector mimiking "Scheme B"
196  // double cutHB = 0.9, cutHE = 1.4, cutHO = 1.1, cutHFL = 1.2, cutHFS = 1.8;
197 
198  // energy in HCAL
199  double eHcal = 0.;
200  double eHcalCone = 0.;
201  double eHcalConeHB = 0.;
202  double eHcalConeHE = 0.;
203  double eHcalConeHO = 0.;
204  double eHcalConeHF = 0.;
205  double eHcalConeHFL = 0.;
206  double eHcalConeHFS = 0.;
207 
208  // Total numbet of RecHits in HCAL, in the cone, above 1 GeV theshold
209  int nrechits = 0;
210  int nrechitsCone = 0;
211  int nrechitsThresh = 0;
212 
213  // energy in ECAL
214  double eEcal = 0.;
215  double eEcalB = 0.;
216  double eEcalE = 0.;
217  double eEcalCone = 0.;
218  int numrechitsEcal = 0;
219 
220  // MC info
221  double phi_MC = -999999.; // phi of initial particle from HepMC
222  double eta_MC = -999999.; // eta of initial particle from HepMC
223 
224  // HCAL energy around MC eta-phi at all depths;
225  double partR = 0.3;
226 
227  if (imc != 0) {
229  ev.getByToken(tok_evt_, evtMC); // generator in late 310_preX
230  if (!evtMC.isValid()) {
231  edm::LogInfo("HcalRecHitsValidation") << "no HepMCProduct found";
232  } else {
233  // std::cout << "*** source HepMCProduct found"<< std::endl;
234  }
235 
236  // MC particle with highest pt is taken as a direction reference
237  double maxPt = -99999.;
238  int npart = 0;
239  const HepMC::GenEvent *myGenEvent = evtMC->GetEvent();
240  for (HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end();
241  ++p) {
242  double phip = (*p)->momentum().phi();
243  double etap = (*p)->momentum().eta();
244  // phi_MC = phip;
245  // eta_MC = etap;
246  double pt = (*p)->momentum().perp();
247  if (pt > maxPt) {
248  npart++;
249  maxPt = pt;
250  phi_MC = phip;
251  eta_MC = etap;
252  }
253  }
254  // std::cout << "*** Max pT = " << maxPt << std::endl;
255  }
256 
257  // std::cout << "*** 2" << std::endl;
258 
259  geometry_ = &c.getData(tok_Geom_);
260  ;
261 
262  // Fill working vectors of HCAL RecHits quantities (all of these are drawn)
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  if (subdet_ > 0 && subdet_ < 6 && imc != 0) { // not noise
434 
436  if (ev.getByToken(tok_hh_, hcalHits)) {
437  const PCaloHitContainer *SimHitResult = hcalHits.product();
438 
439  double enSimHits = 0.;
440  double enSimHitsHB = 0.;
441  double enSimHitsHE = 0.;
442  double enSimHitsHO = 0.;
443  double enSimHitsHF = 0.;
444  double enSimHitsHFL = 0.;
445  double enSimHitsHFS = 0.;
446  // sum of SimHits in the cone
447 
448  for (std::vector<PCaloHit>::const_iterator SimHits = SimHitResult->begin(); SimHits != SimHitResult->end();
449  ++SimHits) {
450  int sub, depth;
451  HcalDetId cell;
452 
453  if (testNumber_)
454  cell = HcalHitRelabeller::relabel(SimHits->id(), hcons);
455  else
456  cell = HcalDetId(SimHits->id());
457 
458  sub = cell.subdet();
459  depth = cell.depth();
460 
461  if (sub != subdet_ && subdet_ != 5)
462  continue; // If we are not looking at all of the subdetectors and the
463  // simhit doesn't come from the specific subdetector of
464  // interest, then we won't do any thing with it
465 
466  const HcalGeometry *cellGeometry =
467  dynamic_cast<const HcalGeometry *>(geometry_->getSubdetectorGeometry(DetId::Hcal, cell.subdet()));
468  double etaS = cellGeometry->getPosition(cell).eta();
469  double phiS = cellGeometry->getPosition(cell).phi();
470  double en = SimHits->energy();
471 
472  double r = dR(eta_MC, phi_MC, etaS, phiS);
473 
474  if (r < partR) { // just energy in the small cone
475 
476  enSimHits += en;
477  if (sub == static_cast<int>(HcalBarrel))
478  enSimHitsHB += en;
479  if (sub == static_cast<int>(HcalEndcap))
480  enSimHitsHE += en;
481  if (sub == static_cast<int>(HcalOuter))
482  enSimHitsHO += en;
483  if (sub == static_cast<int>(HcalForward)) {
484  enSimHitsHF += en;
485  if (depth == 1)
486  enSimHitsHFL += en;
487  else
488  enSimHitsHFS += en;
489  }
490  }
491  }
492 
493  // Now some histos with SimHits
494 
495  if (subdet_ == 4 || subdet_ == 5) {
496  meRecHitSimHitHF->Fill(enSimHitsHF, eHcalConeHF);
497  meRecHitSimHitProfileHF->Fill(enSimHitsHF, eHcalConeHF);
498 
499  meRecHitSimHitHFL->Fill(enSimHitsHFL, eHcalConeHFL);
500  meRecHitSimHitProfileHFL->Fill(enSimHitsHFL, eHcalConeHFL);
501  meRecHitSimHitHFS->Fill(enSimHitsHFS, eHcalConeHFS);
502  meRecHitSimHitProfileHFS->Fill(enSimHitsHFS, eHcalConeHFS);
503  }
504  if (subdet_ == 1 || subdet_ == 5) {
505  meRecHitSimHitHB->Fill(enSimHitsHB, eHcalConeHB);
506  meRecHitSimHitProfileHB->Fill(enSimHitsHB, eHcalConeHB);
507  }
508  if (subdet_ == 2 || subdet_ == 5) {
509  meRecHitSimHitHE->Fill(enSimHitsHE, eHcalConeHE);
510  meRecHitSimHitProfileHE->Fill(enSimHitsHE, eHcalConeHE);
511  }
512  if (subdet_ == 3 || subdet_ == 5) {
513  meRecHitSimHitHO->Fill(enSimHitsHO, eHcalConeHO);
514  meRecHitSimHitProfileHO->Fill(enSimHitsHO, eHcalConeHO);
515  }
516  }
517  }
518 
519  nevtot++;
520 }
521 
524  using namespace edm;
525 
526  // initialize data vectors
527  csub.clear();
528  cen.clear();
529  ceta.clear();
530  cphi.clear();
531  ctime.clear();
532  cieta.clear();
533  ciphi.clear();
534  cdepth.clear();
535  cz.clear();
536  cchi2.clear();
537 
538  if (subdet_ == 1 || subdet_ == 2 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
539  // HBHE
541  if (ev.getByToken(tok_hbhe_, hbhecoll)) {
542  for (HBHERecHitCollection::const_iterator j = hbhecoll->begin(); j != hbhecoll->end(); j++) {
543  HcalDetId cell(j->id());
544  const HcalGeometry *cellGeometry =
545  dynamic_cast<const HcalGeometry *>(geometry_->getSubdetectorGeometry(DetId::Hcal, cell.subdet()));
546  double eta = cellGeometry->getPosition(cell).eta();
547  double phi = cellGeometry->getPosition(cell).phi();
548  double zc = cellGeometry->getPosition(cell).z();
549  int sub = cell.subdet();
550  int depth = cell.depth();
551  int inteta = cell.ieta();
552  int intphi = cell.iphi() - 1;
553  double en = j->energy();
554  double t = j->time();
555  double chi2 = j->chi2();
556 
557  if ((iz > 0 && eta > 0.) || (iz < 0 && eta < 0.) || iz == 0) {
558  csub.push_back(sub);
559  cen.push_back(en);
560  ceta.push_back(eta);
561  cphi.push_back(phi);
562  ctime.push_back(t);
563  cieta.push_back(inteta);
564  ciphi.push_back(intphi);
565  cdepth.push_back(depth);
566  cz.push_back(zc);
567  cchi2.push_back(chi2);
568  }
569  }
570  }
571  }
572 
573  if (subdet_ == 4 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
574  // HF
576  if (ev.getByToken(tok_hf_, hfcoll)) {
577  for (HFRecHitCollection::const_iterator j = hfcoll->begin(); j != hfcoll->end(); j++) {
578  HcalDetId cell(j->id());
579  auto cellGeometry = geometry_->getSubdetectorGeometry(cell)->getGeometry(cell);
580 
581  double eta = cellGeometry->getPosition().eta();
582  double phi = cellGeometry->getPosition().phi();
583  double zc = cellGeometry->getPosition().z();
584  int sub = cell.subdet();
585  int depth = cell.depth();
586  int inteta = cell.ieta();
587  int intphi = cell.iphi() - 1;
588  double en = j->energy();
589  double t = j->time();
590 
591  if ((iz > 0 && eta > 0.) || (iz < 0 && eta < 0.) || iz == 0) {
592  csub.push_back(sub);
593  cen.push_back(en);
594  ceta.push_back(eta);
595  cphi.push_back(phi);
596  ctime.push_back(t);
597  cieta.push_back(inteta);
598  ciphi.push_back(intphi);
599  cdepth.push_back(depth);
600  cz.push_back(zc);
601  cchi2.push_back(0.);
602  }
603  }
604  }
605  }
606 
607  // HO
608  if (subdet_ == 3 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
610  if (ev.getByToken(tok_ho_, hocoll)) {
611  for (HORecHitCollection::const_iterator j = hocoll->begin(); j != hocoll->end(); j++) {
612  HcalDetId cell(j->id());
613  auto cellGeometry = geometry_->getSubdetectorGeometry(cell)->getGeometry(cell);
614 
615  double eta = cellGeometry->getPosition().eta();
616  double phi = cellGeometry->getPosition().phi();
617  double zc = cellGeometry->getPosition().z();
618  int sub = cell.subdet();
619  int depth = cell.depth();
620  int inteta = cell.ieta();
621  int intphi = cell.iphi() - 1;
622  double t = j->time();
623  double en = j->energy();
624 
625  if ((iz > 0 && eta > 0.) || (iz < 0 && eta < 0.) || iz == 0) {
626  csub.push_back(sub);
627  cen.push_back(en);
628  ceta.push_back(eta);
629  cphi.push_back(phi);
630  ctime.push_back(t);
631  cieta.push_back(inteta);
632  ciphi.push_back(intphi);
633  cdepth.push_back(depth);
634  cz.push_back(zc);
635  cchi2.push_back(0.);
636  }
637  }
638  }
639  }
640 }
641 
642 double HcalRecHitsValidation::dR(double eta1, double phi1, double eta2, double phi2) {
643  double PI = 3.1415926535898;
644  double deltaphi = phi1 - phi2;
645  if (phi2 > phi1) {
646  deltaphi = phi2 - phi1;
647  }
648  if (deltaphi > PI) {
649  deltaphi = 2. * PI - deltaphi;
650  }
651  double deltaeta = eta2 - eta1;
652  double tmp = sqrt(deltaeta * deltaeta + deltaphi * deltaphi);
653  return tmp;
654 }
655 
656 double HcalRecHitsValidation::phi12(double phi1, double en1, double phi2, double en2) {
657  // weighted mean value of phi1 and phi2
658 
659  double tmp;
660  double PI = 3.1415926535898;
661  double a1 = phi1;
662  double a2 = phi2;
663 
664  if (a1 > 0.5 * PI && a2 < 0.)
665  a2 += 2 * PI;
666  if (a2 > 0.5 * PI && a1 < 0.)
667  a1 += 2 * PI;
668  tmp = (a1 * en1 + a2 * en2) / (en1 + en2);
669  if (tmp > PI)
670  tmp -= 2. * PI;
671 
672  return tmp;
673 }
674 
675 double HcalRecHitsValidation::dPhiWsign(double phi1, double phi2) {
676  // clockwise phi2 w.r.t phi1 means "+" phi distance
677  // anti-clockwise phi2 w.r.t phi1 means "-" phi distance
678 
679  double PI = 3.1415926535898;
680  double a1 = phi1;
681  double a2 = phi2;
682  double tmp = a2 - a1;
683  if (a1 * a2 < 0.) {
684  if (a1 > 0.5 * PI)
685  tmp += 2. * PI;
686  if (a2 > 0.5 * PI)
687  tmp -= 2. * PI;
688  }
689  return tmp;
690 }
691 
PI
Definition: PayloadInspector.h:21
HcalRecHitsValidation::fillRecHitsTmp
virtual void fillRecHitsTmp(int subdet_, edm::Event const &ev)
Definition: HcalRecHitsValidation.cc:523
HcalRecHitsValidation::geometry_
const CaloGeometry * geometry_
Definition: HcalRecHitsValidation.h:153
HcalRecHitsValidation::meRecHitSimHitHE
MonitorElement * meRecHitSimHitHE
Definition: HcalRecHitsValidation.h:129
mps_fire.i
i
Definition: mps_fire.py:428
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
HcalRecHitsValidation::imc
int imc
Definition: HcalRecHitsValidation.h:97
edm::Handle::product
T const * product() const
Definition: Handle.h:70
HcalRecHitsValidation::meTEprofileHE_Low
MonitorElement * meTEprofileHE_Low
Definition: HcalRecHitsValidation.h:118
HcalRecHitsValidation::tok_Geom_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_Geom_
Definition: HcalRecHitsValidation.h:90
HcalRecHitsValidation.h
HcalRecHitsValidation::meRecHitsM2Chi2HB
MonitorElement * meRecHitsM2Chi2HB
Definition: HcalRecHitsValidation.h:147
PI
#define PI
Definition: QcdUeDQM.h:37
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::Run
Definition: Run.h:45
HcalRecHitsValidation::dPhiWsign
double dPhiWsign(double phi1, double phi2)
Definition: HcalRecHitsValidation.cc:675
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
HcalRecHitsValidation::tok_hh_
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hh_
Definition: HcalRecHitsValidation.h:84
HcalRecHitsValidation::analyze
void analyze(edm::Event const &ev, edm::EventSetup const &c) override
Definition: HcalRecHitsValidation.cc:190
DetId::Hcal
Definition: DetId.h:28
HcalRecHitsValidation::tok_evt_
edm::EDGetTokenT< edm::HepMCProduct > tok_evt_
Definition: HcalRecHitsValidation.h:81
HcalRecHitsValidation::meTEprofileHF
MonitorElement * meTEprofileHF
Definition: HcalRecHitsValidation.h:125
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:278
HcalRecHitsValidation::cdepth
std::vector< int > cdepth
Definition: HcalRecHitsValidation.h:159
HcalRecHitsValidation::meRecHitsEnergyHB
MonitorElement * meRecHitsEnergyHB
Definition: HcalRecHitsValidation.h:109
HcalRecHitsValidation::ceta
std::vector< double > ceta
Definition: HcalRecHitsValidation.h:161
L1TrackerEtMissProducer_cfi.maxPt
maxPt
Definition: L1TrackerEtMissProducer_cfi.py:14
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
HcalRecHitsValidation::meTEprofileHB_Low
MonitorElement * meTEprofileHB_Low
Definition: HcalRecHitsValidation.h:114
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
HcalRecHitParam_cfi.EERecHitCollectionLabel
EERecHitCollectionLabel
Definition: HcalRecHitParam_cfi.py:13
HcalBarrel
Definition: HcalAssistant.h:33
HcalRecHitsValidation::~HcalRecHitsValidation
~HcalRecHitsValidation() override
Definition: HcalRecHitsValidation.cc:69
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
HcalRecHitsValidation::meTEprofileHB_High
MonitorElement * meTEprofileHB_High
Definition: HcalRecHitsValidation.h:116
edm::Handle< edm::HepMCProduct >
HcalRecHitsValidation::ctime
std::vector< double > ctime
Definition: HcalRecHitsValidation.h:163
HcalRecHitsValidation::cen
std::vector< double > cen
Definition: HcalRecHitsValidation.h:160
HcalRecHitsValidation::cchi2
std::vector< double > cchi2
Definition: HcalRecHitsValidation.h:167
HcalRecHitsValidation::meRecHitsEnergyHO
MonitorElement * meRecHitsEnergyHO
Definition: HcalRecHitsValidation.h:111
npart
double npart
Definition: HydjetWrapper.h:46
HcalGeometry.h
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
HcalRecHitsValidation::cz
std::vector< double > cz
Definition: HcalRecHitsValidation.h:164
testProducerWithPsetDescEmpty_cfi.a2
a2
Definition: testProducerWithPsetDescEmpty_cfi.py:35
HcalRecHitsValidation::iz
int iz
Definition: HcalRecHitsValidation.h:96
HcalRecHitsValidation::meRecHitSimHitProfileHF
MonitorElement * meRecHitSimHitProfileHF
Definition: HcalRecHitsValidation.h:138
HcalRecHitsValidation::cphi
std::vector< double > cphi
Definition: HcalRecHitsValidation.h:162
HcalRecHitsValidation::tok_hf_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
Definition: HcalRecHitsValidation.h:86
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HcalRecHitsValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HcalRecHitsValidation.cc:71
HcalRecHitsValidation::meRecHitSimHitProfileHFL
MonitorElement * meRecHitSimHitProfileHFL
Definition: HcalRecHitsValidation.h:139
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
PVValHelper::eta
Definition: PVValidationHelpers.h:70
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
HLT_FULL_cff.eta2
eta2
Definition: HLT_FULL_cff.py:9551
HcalRecHitsValidation::meLog10Chi2profileHE
MonitorElement * meLog10Chi2profileHE
Definition: HcalRecHitsValidation.h:151
HcalRecHitsValidation::meEnConeEtaProfile_EH
MonitorElement * meEnConeEtaProfile_EH
Definition: HcalRecHitsValidation.h:106
HcalRecHitsValidation::meRecHitSimHitHFS
MonitorElement * meRecHitSimHitHFS
Definition: HcalRecHitsValidation.h:133
HcalRecHitsValidation::sign_
std::string sign_
Definition: HcalRecHitsValidation.h:76
HcalRecHitsValidation::meRecHitSimHitProfileHO
MonitorElement * meRecHitSimHitProfileHO
Definition: HcalRecHitsValidation.h:137
HcalOuter
Definition: HcalAssistant.h:35
HcalRecHitsValidation::topFolderName_
std::string topFolderName_
Definition: HcalRecHitsValidation.h:71
HcalRecHitsValidation::subdet_
int subdet_
Definition: HcalRecHitsValidation.h:93
HcalRecHitsValidation::meRecHitSimHitProfileHB
MonitorElement * meRecHitSimHitProfileHB
Definition: HcalRecHitsValidation.h:135
HcalRecHitsValidation::csub
std::vector< int > csub
Definition: HcalRecHitsValidation.h:156
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
EEDetId
Definition: EEDetId.h:14
HcalRecHitsValidation::meTEprofileHF_Low
MonitorElement * meTEprofileHF_Low
Definition: HcalRecHitsValidation.h:124
HcalRecHitsValidation::outputFile_
std::string outputFile_
Definition: HcalRecHitsValidation.h:73
HLT_FULL_cff.eta1
eta1
Definition: HLT_FULL_cff.py:9550
HcalRecHitsValidation::meTEprofileHO_High
MonitorElement * meTEprofileHO_High
Definition: HcalRecHitsValidation.h:122
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalRecHitsValidation::meRecHitsEnergyHF
MonitorElement * meRecHitsEnergyHF
Definition: HcalRecHitsValidation.h:112
HcalRecHitsValidation::meLog10Chi2profileHB
MonitorElement * meLog10Chi2profileHB
Definition: HcalRecHitsValidation.h:150
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HcalRecHitsValidation::meRecHitsM2Chi2HE
MonitorElement * meRecHitsM2Chi2HE
Definition: HcalRecHitsValidation.h:148
HcalGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Definition: HcalGeometry.cc:179
HcalRecHitsValidation::tok_HRNDC_
edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_HRNDC_
Definition: HcalRecHitsValidation.h:89
HcalRecHitsValidation::testNumber_
bool testNumber_
Definition: HcalRecHitsValidation.h:78
HcalRecHitsValidation::meRecHitSimHitHFL
MonitorElement * meRecHitSimHitHFL
Definition: HcalRecHitsValidation.h:132
HcalRecHitsValidation::meTEprofileHE
MonitorElement * meTEprofileHE
Definition: HcalRecHitsValidation.h:119
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
HcalHitRelabeller.h
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
HcalRecHitsValidation::hcalselector_
std::string hcalselector_
Definition: HcalRecHitsValidation.h:74
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
HcalRecHitsValidation::meTEprofileHB
MonitorElement * meTEprofileHB
Definition: HcalRecHitsValidation.h:115
HcalDetId
Definition: HcalDetId.h:12
HcalRecHitsValidation::tok_hbhe_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: HcalRecHitsValidation.h:85
HcalRecHitsValidation::ciphi
std::vector< int > ciphi
Definition: HcalRecHitsValidation.h:158
HcalRecHitsValidation::meRecHitsEnergyHE
MonitorElement * meRecHitsEnergyHE
Definition: HcalRecHitsValidation.h:110
HcalRecHitsValidation::meRecHitSimHitProfileHE
MonitorElement * meRecHitSimHitProfileHE
Definition: HcalRecHitsValidation.h:136
cuy.ib
ib
Definition: cuy.py:661
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
edm::EventSetup
Definition: EventSetup.h:58
HcalSubdetector.h
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
HcalRecHitsValidation::HcalRecHitsValidation
HcalRecHitsValidation(edm::ParameterSet const &conf)
Definition: HcalRecHitsValidation.cc:6
HcalRecHitsValidation::meRecHitSimHitHF
MonitorElement * meRecHitSimHitHF
Definition: HcalRecHitsValidation.h:131
HcalRecHitsValidation::cieta
std::vector< int > cieta
Definition: HcalRecHitsValidation.h:157
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalRecHitsValidation::meEnConeEtaProfile
MonitorElement * meEnConeEtaProfile
Definition: HcalRecHitsValidation.h:104
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HcalForward
Definition: HcalAssistant.h:36
DDAxes::phi
HcalHitRelabeller::relabel
DetId relabel(const uint32_t testId) const
Definition: HcalHitRelabeller.cc:49
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
HcalRecHitsValidation
Definition: HcalRecHitsValidation.h:57
HcalRecHitsValidation::nevtot
int nevtot
Definition: HcalRecHitsValidation.h:170
HcalRecHitParam_cfi.EBRecHitCollectionLabel
EBRecHitCollectionLabel
Definition: HcalRecHitParam_cfi.py:12
HcalRecHitsValidation::meTEprofileHO
MonitorElement * meTEprofileHO
Definition: HcalRecHitsValidation.h:121
HcalRecHitsValidation::tok_EE_
edm::EDGetTokenT< EERecHitCollection > tok_EE_
Definition: HcalRecHitsValidation.h:83
HcalEndcap
Definition: HcalAssistant.h:34
HcalRecHitsValidation::dR
double dR(double eta1, double phi1, double eta2, double phi2)
Definition: HcalRecHitsValidation.cc:642
HcalRecHitsValidation::mc_
std::string mc_
Definition: HcalRecHitsValidation.h:77
ev
bool ev
Definition: Hydjet2Hadronizer.cc:97
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalRecHitsValidation::ecalselector_
std::string ecalselector_
Definition: HcalRecHitsValidation.h:75
HcalRecHitsValidation::meEnConeEtaProfile_E
MonitorElement * meEnConeEtaProfile_E
Definition: HcalRecHitsValidation.h:105
dqm::implementation::IBooker
Definition: DQMStore.h:43
HcalRecHitsValidation::meRecHitSimHitHO
MonitorElement * meRecHitSimHitHO
Definition: HcalRecHitsValidation.h:130
HcalDDDRecConstants
Definition: HcalDDDRecConstants.h:23
HcalRecHitsValidation::meRecHitSimHitHB
MonitorElement * meRecHitSimHitHB
Definition: HcalRecHitsValidation.h:128
HcalRecHitsValidation::phi12
double phi12(double phi1, double en1, double phi2, double en2)
Definition: HcalRecHitsValidation.cc:656
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HcalRecHitsValidation::meRecHitSimHitProfileHFS
MonitorElement * meRecHitSimHitProfileHFS
Definition: HcalRecHitsValidation.h:140
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HcalGeometry
Definition: HcalGeometry.h:17
edm::InputTag
Definition: InputTag.h:15
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
HcalRecHitsValidation::tok_ho_
edm::EDGetTokenT< HORecHitCollection > tok_ho_
Definition: HcalRecHitsValidation.h:87
HcalRecHitsValidation::tok_EB_
edm::EDGetTokenT< EBRecHitCollection > tok_EB_
Definition: HcalRecHitsValidation.h:82