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  // 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 
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 
260  ;
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  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 
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
std::vector< double > cchi2
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * meRecHitsM2Chi2HB
std::vector< PCaloHit > PCaloHitContainer
const edm::EventSetup & c
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hh_
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)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
MonitorElement * meTEprofileHE_Low
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
std::vector< EcalRecHit >::const_iterator const_iterator
MonitorElement * meLog10Chi2profileHB
MonitorElement * meEnConeEtaProfile
double npart
Definition: HydjetWrapper.h:46
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_
MonitorElement * meEnConeEtaProfile_E
const CaloGeometry * geometry_
MonitorElement * meRecHitSimHitHB
MonitorElement * meRecHitSimHitHFS
void Fill(long long x)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
std::vector< double > cphi
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_Geom_
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:322
T sqrt(T t)
Definition: SSEVec.h:19
MonitorElement * meRecHitsM2Chi2HE
MonitorElement * meTEprofileHB
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:70
#define PI
Definition: QcdUeDQM.h:37
MonitorElement * meRecHitSimHitHO
MonitorElement * meRecHitSimHitProfileHB
GlobalPoint getPosition(const DetId &id) const
MonitorElement * meTEprofileHF_Low
edm::EDGetTokenT< EBRecHitCollection > tok_EB_
MonitorElement * meTEprofileHO_High
Log< level::Info, false > LogInfo
MonitorElement * meTEprofileHE
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
edm::EDGetTokenT< EERecHitCollection > tok_EE_
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:177
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< double > ctime
MonitorElement * meEnConeEtaProfile_EH
MonitorElement * meRecHitSimHitProfileHFL
std::vector< double > cz
T eta() const
Definition: PV3DBase.h:73
MonitorElement * meRecHitsEnergyHO
edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > tok_HRNDC_
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 * 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:46
tmp
align.sh
Definition: createJobs.py:716
MonitorElement * meRecHitSimHitHE
HcalRecHitsValidation(edm::ParameterSet const &conf)
MonitorElement * meTEprofileHB_High
std::vector< double > cen
Definition: Run.h:45