CMS 3D CMS Logo

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