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  sprintf (histo, "HcalRecHitTask_energy_of_rechits_HB" ) ;
88  meRecHitsEnergyHB = ib.book1D(histo, histo, 2010 , -10. , 2000.);
89 
90  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_HB" ) ;
91  meTEprofileHB = ib.bookProfile(histo, histo, 150, -5., 295., -48., 92., " ");
92 
93  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HB" ) ;
94  meTEprofileHB_Low = ib.bookProfile(histo, histo, 150, -5., 295., -48., 92., " ");
95 
96  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_High_HB" ) ;
97  meTEprofileHB_High = ib.bookProfile(histo, histo, 150, -5., 295., 48., 92., " ");
98 
99  if(imc != 0) {
100  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_HB");
101  meRecHitSimHitHB = ib.book2D(histo, histo, 120, 0., 1.2, 300, 0., 150.);
102  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HB");
103  meRecHitSimHitProfileHB = ib.bookProfile(histo, histo, 120, 0., 1.2, 0., 500., " ");
104  }
105 
106  }
107 
108  // ********************** HE ************************************
109  if ( subdet_ == 2 || subdet_ == 5 ){
110 
111  sprintf (histo, "HcalRecHitTask_energy_of_rechits_HE" ) ;
112  meRecHitsEnergyHE = ib.book1D(histo, histo, 2010, -10., 2000.);
113 
114  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HE" ) ;
115  meTEprofileHE_Low = ib.bookProfile(histo, histo, 80, -5., 75., -48., 92., " ");
116 
117  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_HE" ) ;
118  meTEprofileHE = ib.bookProfile(histo, histo, 200, -5., 2995., -48., 92., " ");
119 
120  if(imc != 0) {
121  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_HE");
122  meRecHitSimHitHE = ib.book2D(histo, histo, 120, 0., 0.6, 300, 0., 150.);
123  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HE");
124  meRecHitSimHitProfileHE = ib.bookProfile(histo, histo, 120, 0., 0.6, 0., 500., " ");
125  }
126 
127  }
128 
129  // ************** HO ****************************************
130  if ( subdet_ == 3 || subdet_ == 5 ){
131 
132  sprintf (histo, "HcalRecHitTask_energy_of_rechits_HO" ) ;
133  meRecHitsEnergyHO = ib.book1D(histo, histo, 2010 , -10. , 2000.);
134 
135  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_HO" ) ;
136  meTEprofileHO = ib.bookProfile(histo, histo, 60, -5., 55., -48., 92., " ");
137 
138  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_High_HO" ) ;
139  meTEprofileHO_High = ib.bookProfile(histo, histo, 100, -5., 995., -48., 92., " ");
140 
141  if(imc != 0) {
142  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_HO");
143  meRecHitSimHitHO = ib.book2D(histo, histo, 150, 0., 1.5, 350, 0., 350.);
144  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HO");
145  meRecHitSimHitProfileHO = ib.bookProfile(histo, histo, 150, 0., 1.5, 0., 500., " ");
146  }
147 
148  }
149 
150  // ********************** HF ************************************
151  if ( subdet_ == 4 || subdet_ == 5 ){
152 
153  sprintf (histo, "HcalRecHitTask_energy_of_rechits_HF" ) ;
154  meRecHitsEnergyHF = ib.book1D(histo, histo, 2010 , -10. , 2000.);
155 
156  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_Low_HF" ) ;
157  meTEprofileHF_Low = ib.bookProfile(histo, histo, 100, -5., 195., -48., 92., " ");
158 
159  sprintf (histo, "HcalRecHitTask_timing_vs_energy_profile_HF" ) ;
160  meTEprofileHF = ib.bookProfile(histo, histo, 200, -5., 995., -48., 92., " ");
161 
162  if(imc != 0) {
163  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_HF");
164  meRecHitSimHitHF = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
165  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_HFL");
166  meRecHitSimHitHFL = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
167  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_HFS");
168  meRecHitSimHitHFS = ib.book2D(histo, histo, 50, 0., 50., 150, 0., 150.);
169  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HF");
170  meRecHitSimHitProfileHF = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
171  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HFL");
172  meRecHitSimHitProfileHFL = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
173  sprintf (histo, "HcalRecHitTask_energy_rechits_vs_simhits_profile_HFS");
174  meRecHitSimHitProfileHFS = ib.bookProfile(histo, histo, 50, 0., 50., 0., 500., " ");
175  }
176 
177  }
178 
179 }
180 
182 
183  using namespace edm;
184 
186  c.get<HcalRecNumberingRecord>().get( pHRNDC );
187  const HcalDDDRecConstants* hcons = &(*pHRNDC);
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 
224  ev.getByToken(tok_evt_,evtMC); // generator in late 310_preX
225  if (!evtMC.isValid()) {
226  edm::LogInfo("HcalRecHitsValidation") << "no HepMCProduct found";
227  } else {
228  // std::cout << "*** source HepMCProduct found"<< std::endl;
229  }
230 
231  // MC particle with highest pt is taken as a direction reference
232  double maxPt = -99999.;
233  int npart = 0;
234  const HepMC::GenEvent * myGenEvent = evtMC->GetEvent();
235  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin(); p != myGenEvent->particles_end(); ++p ) {
236  double phip = (*p)->momentum().phi();
237  double etap = (*p)->momentum().eta();
238  // phi_MC = phip;
239  // eta_MC = etap;
240  double pt = (*p)->momentum().perp();
241  if(pt > maxPt) { npart++; maxPt = pt; phi_MC = phip; eta_MC = etap; }
242  }
243  // std::cout << "*** Max pT = " << maxPt << std::endl;
244 
245  }
246 
247  // std::cout << "*** 2" << std::endl;
248 
249  c.get<CaloGeometryRecord>().get (geometry);
250 
251  // Fill working vectors of HCAL RecHits quantities (all of these are drawn)
252  fillRecHitsTmp(subdet_, ev);
253 
254  // std::cout << "*** 3" << std::endl;
255 
256  //===========================================================================
257  // IN ALL other CASES : ieta-iphi maps
258  //===========================================================================
259 
260  // ECAL
261  if(ecalselector_ == "yes" && (subdet_ == 1 || subdet_ == 2 || subdet_ == 5)) {
263 
266 
267 
268  if ( ev.getByToken(tok_EB_, rhitEB) ) {
269 
270  RecHit = rhitEB.product()->begin();
271  RecHitEnd = rhitEB.product()->end();
272 
273  for (; RecHit != RecHitEnd ; ++RecHit) {
274  EBDetId EBid = EBDetId(RecHit->id());
275 
276  auto cellGeometry = geometry->getSubdetectorGeometry(EBid)->getGeometry (EBid) ;
277  double eta = cellGeometry->getPosition ().eta () ;
278  double phi = cellGeometry->getPosition ().phi () ;
279  double en = RecHit->energy();
280  eEcal += en;
281  eEcalB += en;
282 
283  double r = dR(eta_MC, phi_MC, eta, phi);
284  if( r < partR) {
285  eEcalCone += en;
286  numrechitsEcal++;
287  }
288  }
289 
290  }
291 
293 
294  if ( ev.getByToken(tok_EE_, rhitEE) ) {
295 
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 
319  // std::cout << "*** 4" << std::endl;
320 
321 
322  //===========================================================================
323  // SUBSYSTEMS,
324  //===========================================================================
325 
326  if ((subdet_ != 6) && (subdet_ != 0)) {
327 
328  // std::cout << "*** 6" << std::endl;
329 
330 
331  double HcalCone = 0.;
332 
333  int ietaMax = 9999;
334  double etaMax = 9999.;
335 
336 
337  // CYCLE over cells ====================================================
338 
339  for (unsigned int i = 0; i < cen.size(); i++) {
340  int sub = csub[i];
341  int depth = cdepth[i];
342  double eta = ceta[i];
343  double phi = cphi[i];
344  double en = cen[i];
345  double t = ctime[i];
346  int ieta = cieta[i];
347 
348  nrechits++;
349  eHcal += en;
350  if(en > 1. ) nrechitsThresh++;
351 
352  double r = dR(eta_MC, phi_MC, eta, phi);
353  if( r < partR ){
354  if(sub == 1) eHcalConeHB += en;
355  if(sub == 2) eHcalConeHE += en;
356  if(sub == 3) eHcalConeHO += en;
357  if(sub == 4) {
358  eHcalConeHF += en;
359  if (depth == 1) eHcalConeHFL += en;
360  else eHcalConeHFS += en;
361  }
362  eHcalCone += en;
363  nrechitsCone++;
364 
365  HcalCone += en;
366 
367  // alternative: ietamax -> closest to MC eta !!!
368  float eta_diff = fabs(eta_MC - eta);
369  if(eta_diff < etaMax) {
370  etaMax = eta_diff;
371  ietaMax = ieta;
372  }
373  }
374 
375  //The energy and overall timing histos are drawn while
376  //the ones split by depth are not
377  if(sub == 1 && (subdet_ == 1 || subdet_ == 5)) {
378  meRecHitsEnergyHB->Fill(en);
379 
380  meTEprofileHB_Low->Fill(en, t);
381  meTEprofileHB->Fill(en, t);
382  meTEprofileHB_High->Fill(en, t);
383 
384  }
385  if(sub == 2 && (subdet_ == 2 || subdet_ == 5)) {
386  meRecHitsEnergyHE->Fill(en);
387 
388  meTEprofileHE_Low->Fill(en, t);
389  meTEprofileHE->Fill(en, t);
390 
391  }
392  if(sub == 4 && (subdet_ == 4 || subdet_ == 5)) {
393  meRecHitsEnergyHF->Fill(en);
394 
395  meTEprofileHF_Low->Fill(en, t);
396  meTEprofileHF->Fill(en, t);
397 
398  }
399  if(sub == 3 && (subdet_ == 3 || subdet_ == 5)) {
400  meRecHitsEnergyHO->Fill(en);
401 
402  meTEprofileHO->Fill(en, t);
403  meTEprofileHO_High->Fill(en, t);
404  }
405  }
406 
407  if(imc != 0) {
408  meEnConeEtaProfile ->Fill(double(ietaMax), HcalCone); //
409  meEnConeEtaProfile_E ->Fill(double(ietaMax), eEcalCone);
410  meEnConeEtaProfile_EH ->Fill(double(ietaMax), HcalCone+eEcalCone);
411  }
412 
413  // std::cout << "*** 7" << std::endl;
414 
415 
416  }
417 
418  //SimHits vs. RecHits
419  const CaloGeometry* geo = geometry.product();
420  if(subdet_ > 0 && subdet_ < 6 && imc !=0) { // not noise
421 
423  if ( ev.getByToken(tok_hh_,hcalHits) ) {
424  const PCaloHitContainer * SimHitResult = hcalHits.product () ;
425 
426  double enSimHits = 0.;
427  double enSimHitsHB = 0.;
428  double enSimHitsHE = 0.;
429  double enSimHitsHO = 0.;
430  double enSimHitsHF = 0.;
431  double enSimHitsHFL = 0.;
432  double enSimHitsHFS = 0.;
433  // sum of SimHits in the cone
434 
435  for (std::vector<PCaloHit>::const_iterator SimHits = SimHitResult->begin () ; SimHits != SimHitResult->end(); ++SimHits) {
436 
437  int sub, depth;
438  HcalDetId cell;
439 
440  if (testNumber_) cell = HcalHitRelabeller::relabel(SimHits->id(),hcons);
441  else cell = HcalDetId(SimHits->id());
442 
443  sub = cell.subdet();
444  depth = cell.depth();
445 
446  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
447 
448  const HcalGeometry* cellGeometry =
449  dynamic_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(DetId::Hcal,cell.subdet()));
450  double etaS = cellGeometry->getPosition(cell).eta () ;
451  double phiS = cellGeometry->getPosition(cell).phi () ;
452  double en = SimHits->energy();
453 
454  double r = dR(eta_MC, phi_MC, etaS, phiS);
455 
456  if ( r < partR ){ // just energy in the small cone
457 
458  enSimHits += en;
459  if(sub == static_cast<int>(HcalBarrel)) enSimHitsHB += en;
460  if(sub == static_cast<int>(HcalEndcap)) enSimHitsHE += en;
461  if(sub == static_cast<int>(HcalOuter)) enSimHitsHO += en;
462  if(sub == static_cast<int>(HcalForward)) {
463  enSimHitsHF += en;
464  if(depth == 1) enSimHitsHFL += en;
465  else enSimHitsHFS += en;
466  }
467  }
468  }
469 
470  // Now some histos with SimHits
471 
472  if(subdet_ == 4 || subdet_ == 5) {
473  meRecHitSimHitHF->Fill( enSimHitsHF, eHcalConeHF );
474  meRecHitSimHitProfileHF->Fill( enSimHitsHF, eHcalConeHF);
475 
476  meRecHitSimHitHFL->Fill( enSimHitsHFL, eHcalConeHFL );
477  meRecHitSimHitProfileHFL->Fill( enSimHitsHFL, eHcalConeHFL);
478  meRecHitSimHitHFS->Fill( enSimHitsHFS, eHcalConeHFS );
479  meRecHitSimHitProfileHFS->Fill( enSimHitsHFS, eHcalConeHFS);
480  }
481  if(subdet_ == 1 || subdet_ == 5) {
482  meRecHitSimHitHB->Fill( enSimHitsHB,eHcalConeHB );
483  meRecHitSimHitProfileHB->Fill( enSimHitsHB,eHcalConeHB);
484  }
485  if(subdet_ == 2 || subdet_ == 5) {
486  meRecHitSimHitHE->Fill( enSimHitsHE,eHcalConeHE );
487  meRecHitSimHitProfileHE->Fill( enSimHitsHE,eHcalConeHE);
488  }
489  if(subdet_ == 3 || subdet_ == 5) {
490  meRecHitSimHitHO->Fill( enSimHitsHO,eHcalConeHO );
491  meRecHitSimHitProfileHO->Fill( enSimHitsHO,eHcalConeHO);
492  }
493 
494  }
495  }
496 
497  nevtot++;
498 }
499 
500 
503 
504  using namespace edm;
505 
506  // initialize data vectors
507  csub.clear();
508  cen.clear();
509  ceta.clear();
510  cphi.clear();
511  ctime.clear();
512  cieta.clear();
513  ciphi.clear();
514  cdepth.clear();
515  cz.clear();
516 
517  if( subdet_ == 1 || subdet_ == 2 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
518 
519  //HBHE
521  if ( ev.getByToken(tok_hbhe_, hbhecoll) ) {
522  const CaloGeometry* geo = geometry.product();
523 
524  for (HBHERecHitCollection::const_iterator j=hbhecoll->begin(); j != hbhecoll->end(); j++) {
525 
526  HcalDetId cell(j->id());
527  const HcalGeometry* cellGeometry =
528  dynamic_cast<const HcalGeometry*>(geo->getSubdetectorGeometry(DetId::Hcal,cell.subdet()));
529  double eta = cellGeometry->getPosition(cell).eta () ;
530  double phi = cellGeometry->getPosition(cell).phi () ;
531  double zc = cellGeometry->getPosition(cell).z ();
532  int sub = cell.subdet();
533  int depth = cell.depth();
534  int inteta = cell.ieta();
535  int intphi = cell.iphi()-1;
536  double en = j->energy();
537  double t = j->time();
538 
539  if((iz > 0 && eta > 0.) || (iz < 0 && eta <0.) || iz == 0) {
540 
541  csub.push_back(sub);
542  cen.push_back(en);
543  ceta.push_back(eta);
544  cphi.push_back(phi);
545  ctime.push_back(t);
546  cieta.push_back(inteta);
547  ciphi.push_back(intphi);
548  cdepth.push_back(depth);
549  cz.push_back(zc);
550  }
551  }
552  }
553 
554  }
555 
556  if( subdet_ == 4 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
557 
558  //HF
560  if ( ev.getByToken(tok_hf_, hfcoll) ) {
561 
562  for (HFRecHitCollection::const_iterator j = hfcoll->begin(); j != hfcoll->end(); j++) {
563 
564  HcalDetId cell(j->id());
565  auto cellGeometry = geometry->getSubdetectorGeometry(cell)->getGeometry (cell) ;
566 
567  double eta = cellGeometry->getPosition().eta () ;
568  double phi = cellGeometry->getPosition().phi () ;
569  double zc = cellGeometry->getPosition().z ();
570  int sub = cell.subdet();
571  int depth = cell.depth();
572  int inteta = cell.ieta();
573  int intphi = cell.iphi()-1;
574  double en = j->energy();
575  double t = j->time();
576 
577  if((iz > 0 && eta > 0.) || (iz < 0 && eta <0.) || iz == 0) {
578 
579  csub.push_back(sub);
580  cen.push_back(en);
581  ceta.push_back(eta);
582  cphi.push_back(phi);
583  ctime.push_back(t);
584  cieta.push_back(inteta);
585  ciphi.push_back(intphi);
586  cdepth.push_back(depth);
587  cz.push_back(zc);
588  }
589  }
590  }
591  }
592 
593  //HO
594  if( subdet_ == 3 || subdet_ == 5 || subdet_ == 6 || subdet_ == 0) {
595 
597  if ( ev.getByToken(tok_ho_, hocoll) ) {
598 
599  for (HORecHitCollection::const_iterator j = hocoll->begin(); j != hocoll->end(); j++) {
600 
601  HcalDetId cell(j->id());
602  auto cellGeometry = geometry->getSubdetectorGeometry(cell)->getGeometry (cell) ;
603 
604  double eta = cellGeometry->getPosition().eta () ;
605  double phi = cellGeometry->getPosition().phi () ;
606  double zc = cellGeometry->getPosition().z ();
607  int sub = cell.subdet();
608  int depth = cell.depth();
609  int inteta = cell.ieta();
610  int intphi = cell.iphi()-1;
611  double t = j->time();
612  double en = j->energy();
613 
614  if((iz > 0 && eta > 0.) || (iz < 0 && eta <0.) || iz == 0) {
615  csub.push_back(sub);
616  cen.push_back(en);
617  ceta.push_back(eta);
618  cphi.push_back(phi);
619  ctime.push_back(t);
620  cieta.push_back(inteta);
621  ciphi.push_back(intphi);
622  cdepth.push_back(depth);
623  cz.push_back(zc);
624  }
625  }
626  }
627  }
628 }
629 
630 double HcalRecHitsValidation::dR(double eta1, double phi1, double eta2, double phi2) {
631  double PI = 3.1415926535898;
632  double deltaphi= phi1 - phi2;
633  if( phi2 > phi1 ) { deltaphi= phi2 - phi1;}
634  if(deltaphi > PI) { deltaphi = 2.*PI - deltaphi;}
635  double deltaeta = eta2 - eta1;
636  double tmp = sqrt(deltaeta* deltaeta + deltaphi*deltaphi);
637  return tmp;
638 }
639 
640 double HcalRecHitsValidation::phi12(double phi1, double en1, double phi2, double en2) {
641  // weighted mean value of phi1 and phi2
642 
643  double tmp;
644  double PI = 3.1415926535898;
645  double a1 = phi1; double a2 = phi2;
646 
647  if( a1 > 0.5*PI && a2 < 0.) a2 += 2*PI;
648  if( a2 > 0.5*PI && a1 < 0.) a1 += 2*PI;
649  tmp = (a1 * en1 + a2 * en2)/(en1 + en2);
650  if(tmp > PI) tmp -= 2.*PI;
651 
652  return tmp;
653 
654 }
655 
656 double HcalRecHitsValidation::dPhiWsign(double phi1, double phi2) {
657  // clockwise phi2 w.r.t phi1 means "+" phi distance
658  // anti-clockwise phi2 w.r.t phi1 means "-" phi distance
659 
660  double PI = 3.1415926535898;
661  double a1 = phi1; double a2 = phi2;
662  double tmp = a2 - a1;
663  if( a1*a2 < 0.) {
664  if(a1 > 0.5 * PI) tmp += 2.*PI;
665  if(a2 > 0.5 * PI) tmp -= 2.*PI;
666  }
667  return tmp;
668 
669 }
670 
671 
673 
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
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PCaloHit > PCaloHitContainer
edm::EDGetTokenT< edm::PCaloHitContainer > tok_hh_
MonitorElement * meRecHitsEnergyHF
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:142
double phi12(double phi1, double en1, double phi2, double en2)
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
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 * 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
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * meTEprofileHB
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
virtual void fillRecHitsTmp(int subdet_, edm::Event const &ev)
double dR(double eta1, double phi1, double eta2, double phi2)
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
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
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:63
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:661