CMS 3D CMS Logo

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