test
CMS 3D CMS Logo

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