CMS 3D CMS Logo

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