CMS 3D CMS Logo

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