CMS 3D CMS Logo

HcalDigisValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalDigisValidation
4 // Class: HcalDigisValidation
5 //
13 //
14 // Original Author: Ali Fahim,22 R-013,+41227672649,
15 // Created: Wed Mar 23 11:42:34 CET 2011
16 //
17 //
18 
25 
27 
28  using namespace std;
29 
30  subdet_ = iConfig.getUntrackedParameter<std::string > ("subdetector", "all");
31  outputFile_ = iConfig.getUntrackedParameter<std::string > ("outputFile", "");
32 // inputLabel_ = iConfig.getParameter<std::string > ("digiLabel");
33  inputTag_ = iConfig.getParameter<edm::InputTag > ("digiTag");
34  QIE10inputTag_ = iConfig.getParameter<edm::InputTag > ("QIE10digiTag");
35  QIE11inputTag_ = iConfig.getParameter<edm::InputTag > ("QIE11digiTag");
36  emulTPsTag_ = iConfig.getParameter<edm::InputTag > ("emulTPs");
37  dataTPsTag_ = iConfig.getParameter<edm::InputTag > ("dataTPs");
38  mc_ = iConfig.getUntrackedParameter<std::string > ("mc", "no");
39  mode_ = iConfig.getUntrackedParameter<std::string > ("mode", "multi");
40  dirName_ = iConfig.getUntrackedParameter<std::string > ("dirName", "HcalDigisV/HcalDigiTask");
41  testNumber_= iConfig.getParameter<bool>("TestNumber");
42  hep17_ = iConfig.getParameter<bool>("hep17");
43 
44  // register for data access
45  if (iConfig.exists("simHits"))
46  {
47  tok_mc_ = consumes<edm::PCaloHitContainer>(iConfig.getUntrackedParameter<edm::InputTag>("simHits"));
48  }
49  tok_hbhe_ = consumes< HBHEDigiCollection >(inputTag_);
50  tok_ho_ = consumes< HODigiCollection >(inputTag_);
51  tok_hf_ = consumes< HFDigiCollection >(inputTag_);
52  tok_emulTPs_ = consumes<HcalTrigPrimDigiCollection>(emulTPsTag_);
53  if(dataTPsTag_==edm::InputTag("")) skipDataTPs = true;
54  else {
55  skipDataTPs = false;
56  tok_dataTPs_ = consumes<HcalTrigPrimDigiCollection>(dataTPsTag_);
57  }
58 
59  tok_qie10_hf_ = consumes< QIE10DigiCollection >(QIE10inputTag_);
60  tok_qie11_hbhe_ = consumes< QIE11DigiCollection >(QIE11inputTag_);
61 
62  nevent1 = 0;
63  nevent2 = 0;
64  nevent3 = 0;
65  nevent4 = 0;
66  nevtot = 0;
67 
68  msm_ = new std::map<std::string, MonitorElement*>();
69 
70  if (!outputFile_.empty()) edm::LogInfo("OutputInfo") << " Hcal Digi Task histograms will be saved to '" << outputFile_.c_str() << "'";
71  else edm::LogInfo("OutputInfo") << " Hcal Digi Task histograms will NOT be saved";
72 
73 }
74 
75 
77  delete msm_;
78 }
79 
80 
82 
84  es.get<HcalRecNumberingRecord>().get( pHRNDC );
85  hcons = &(*pHRNDC);
86 
88 
89  maxDepth_[1] = hcons->getMaxDepth(0); // HB
90  maxDepth_[2] = hcons->getMaxDepth(1); // HE
91  maxDepth_[3] = hcons->getMaxDepth(3); // HO
92  maxDepth_[4] = hcons->getMaxDepth(2); // HF
93  maxDepth_[0] = (maxDepth_[1] > maxDepth_[2] ? maxDepth_[1] : maxDepth_[2]);
94  maxDepth_[0] = (maxDepth_[0] > maxDepth_[3] ? maxDepth_[0] : maxDepth_[3]);
95  maxDepth_[0] = (maxDepth_[0] > maxDepth_[4] ? maxDepth_[0] : maxDepth_[4]); // any of HB/HE/HO/HF
96 
97  es.get<CaloGeometryRecord>().get(geometry);
98  const CaloGeometry* geo = geometry.product();
103 
104  nChannels_[1] = gHB->getHxSize(1);
105  nChannels_[2] = gHE->getHxSize(2);
106  nChannels_[3] = gHO->getHxSize(3);
107  nChannels_[4] = gHF->getHxSize(4);
108 
109  nChannels_[0] = nChannels_[1] + nChannels_[2] + nChannels_[3] + nChannels_[4];
110 
111 }
112 
114 {
115 
117 
118  // book
119  book1D(ib,"nevtot", 1, 0, 1);
120  int bnoise = 0;
121  int bmc = 0;
122  if (subdet_ == "noise") bnoise = 1;
123  if (mc_ == "yes") bmc = 1;
124  if (subdet_ == "noise" || subdet_ == "all") {
125  booking(ib,"HB", bnoise, bmc);
126  booking(ib,"HO", bnoise, bmc);
127  booking(ib,"HF", bnoise, bmc);
128  booking(ib,"HE", bnoise, bmc);
129  } else {
130  booking(ib,subdet_, 0, bmc);
131  }
132 
133  if(skipDataTPs) return;
134 
135  HistLim tp_hl_et(260, -10, 250);
136  HistLim tp_hl_ntp(640, -20, 3180);
137  HistLim tp_hl_ntp_sub(404, -20, 2000);
138  HistLim tp_hl_ieta(85, -42.5, 42.5);
139  HistLim tp_hl_iphi(74,-0.5,73.5);
140 
141 
142  book1D(ib,"HcalDigiTask_tp_et", tp_hl_et);
143  book1D(ib,"HcalDigiTask_tp_et_v0", tp_hl_et);
144  book1D(ib,"HcalDigiTask_tp_et_v1", tp_hl_et);
145  book1D(ib,"HcalDigiTask_tp_et_HB", tp_hl_et);
146  book1D(ib,"HcalDigiTask_tp_et_HE", tp_hl_et);
147  book1D(ib,"HcalDigiTask_tp_et_HF", tp_hl_et);
148  book1D(ib,"HcalDigiTask_tp_et_HF_v0", tp_hl_et);
149  book1D(ib,"HcalDigiTask_tp_et_HF_v1", tp_hl_et);
150  book1D(ib,"HcalDigiTask_tp_ntp", tp_hl_ntp);
151  book1D(ib,"HcalDigiTask_tp_ntp_v0", tp_hl_ntp);
152  book1D(ib,"HcalDigiTask_tp_ntp_v1", tp_hl_ntp);
153  book1D(ib,"HcalDigiTask_tp_ntp_HB", tp_hl_ntp_sub);
154  book1D(ib,"HcalDigiTask_tp_ntp_HE", tp_hl_ntp_sub);
155  book1D(ib,"HcalDigiTask_tp_ntp_HF", tp_hl_ntp_sub);
156  book1D(ib,"HcalDigiTask_tp_ntp_HF_v0", tp_hl_ntp_sub);
157  book1D(ib,"HcalDigiTask_tp_ntp_HF_v1", tp_hl_ntp_sub);
158  book1D(ib,"HcalDigiTask_tp_ntp_ieta", tp_hl_ieta);
159  book1D(ib,"HcalDigiTask_tp_ntp_ieta_v0", tp_hl_ieta);
160  book1D(ib,"HcalDigiTask_tp_ntp_ieta_v1", tp_hl_ieta);
161  book1D(ib,"HcalDigiTask_tp_ntp_iphi", tp_hl_iphi);
162  book1D(ib,"HcalDigiTask_tp_ntp_iphi_v0", tp_hl_iphi);
163  book1D(ib,"HcalDigiTask_tp_ntp_iphi_v1", tp_hl_iphi);
164  book1D(ib,"HcalDigiTask_tp_ntp_10_ieta", tp_hl_ieta);
165  book1D(ib,"HcalDigiTask_tp_ntp_10_ieta_v0", tp_hl_ieta);
166  book1D(ib,"HcalDigiTask_tp_ntp_10_ieta_v1", tp_hl_ieta);
167  book2D(ib,"HcalDigiTask_tp_et_ieta", tp_hl_ieta, tp_hl_et);
168  book2D(ib,"HcalDigiTask_tp_et_ieta_v0", tp_hl_ieta, tp_hl_et);
169  book2D(ib,"HcalDigiTask_tp_et_ieta_v1", tp_hl_ieta, tp_hl_et);
170  book2D(ib,"HcalDigiTask_tp_ieta_iphi", tp_hl_ieta, tp_hl_iphi);
171  book2D(ib,"HcalDigiTask_tp_ieta_iphi_v0", tp_hl_ieta, tp_hl_iphi);
172  book2D(ib,"HcalDigiTask_tp_ieta_iphi_v1", tp_hl_ieta, tp_hl_iphi);
173  bookPf(ib,"HcalDigiTask_tp_ave_et_ieta", tp_hl_ieta, tp_hl_et, " ");
174  bookPf(ib,"HcalDigiTask_tp_ave_et_ieta_v0", tp_hl_ieta, tp_hl_et, " ");
175  bookPf(ib,"HcalDigiTask_tp_ave_et_ieta_v1", tp_hl_ieta, tp_hl_et, " ");
176 
177 }
178 
179 void HcalDigisValidation::booking(DQMStore::IBooker &ib, const std::string bsubdet, int bnoise, int bmc) {
180 
181  // Adjust/Optimize binning (JR Dittmann, 16-JUL-2015)
182 
183  HistLim Ndigis(2600, 0., 2600.);
184  HistLim ndigis(520, -20., 1020.);
185  HistLim sime(200, 0., 1.0);
186 
187  HistLim digiAmp(360, -100., 7100.);
188  HistLim digiAmpWide(360, -10000., 710000.);
189  HistLim ratio(2000, -100., 3900.);
190  HistLim sumAmp(100, -500., 1500.);
191 
192  HistLim nbin(11, -0.5, 10.5);
193 
194  HistLim pedestal(80, -1.0, 15.);
195  HistLim pedestalfC(400, -10., 30.);
196 
197  HistLim frac(80, -0.20, 1.40);
198 
199  HistLim pedLim(80, 0., 8.);
200  HistLim pedWidthLim(100, 0., 2.);
201 
202  HistLim gainLim(120, 0., 0.6);
203  HistLim gainWidthLim(160, 0., 0.32);
204 
205  HistLim ietaLim(85, -42.5, 42.5);
206  HistLim iphiLim(74, -0.5, 73.5);
207 
208  HistLim depthLim(15,-0.5,14.5);
209 
210  if (bsubdet == "HB") {
211  Ndigis = HistLim( ((int)(nChannels_[1]/100) + 1)*100, 0., (float)((int)(nChannels_[1]/100) + 1)*100);
212  } else if (bsubdet == "HE") {
213  sime = HistLim(200, 0., 1.0);
214  Ndigis = HistLim( ((int)(nChannels_[2]/100) + 1)*100, 0., (float)((int)(nChannels_[2]/100) + 1)*100);
215  } else if (bsubdet == "HF") {
216  sime = HistLim(100, 0., 100.);
217  pedLim = HistLim(100, 0., 20.);
218  pedWidthLim = HistLim(100, 0., 5.);
219  frac = HistLim(400, -4.00, 4.00);
220  Ndigis = HistLim( ((int)(nChannels_[4]/100) + 1)*100, 0., (float)((int)(nChannels_[4]/100) + 1)*100);
221  } else if (bsubdet == "HO") {
222  sime = HistLim(200, 0., 1.0);
223  gainLim = HistLim(160, 0., 1.6);
224  Ndigis = HistLim( ((int)(nChannels_[3]/100) + 1)*100, 0., (float)((int)(nChannels_[3]/100) + 1)*100);
225  }
226 
227  int isubdet=0;
228  if (bsubdet=="HB") isubdet=1;
229  else if (bsubdet=="HE") isubdet=2;
230  else if (bsubdet=="HO") isubdet=3;
231  else if (bsubdet=="HF") isubdet=4;
232  else edm::LogWarning("HcalDigisValidation") << "HcalDigisValidation Warning: not HB/HE/HF/HO " << bsubdet << std::endl;
233 
234  Char_t histo[100];
235  const char * sub = bsubdet.c_str();
236  if (bnoise == 0) {
237  // number of digis in each subdetector
238  sprintf(histo, "HcalDigiTask_Ndigis_%s", sub);
239  book1D(ib, histo, Ndigis);
240 
241  // maps of occupancies
242  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
243  sprintf(histo, "HcalDigiTask_ieta_iphi_occupancy_map_depth%d_%s", depth, sub);
244  book2D(ib, histo, ietaLim, iphiLim);
245  }
246 
247  //Depths
248  sprintf(histo, "HcalDigiTask_depths_%s",sub);
249  book1D(ib,histo, depthLim);
250 
251  // occupancies vs ieta
252  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
253  sprintf(histo, "HcalDigiTask_occupancy_vs_ieta_depth%d_%s", depth, sub);
254  book1D(ib, histo, ietaLim);
255  }
256 
257 
258  // just 1D of all cells' amplitudes
259  sprintf(histo, "HcalDigiTask_sum_all_amplitudes_%s", sub);
260  book1D(ib, histo, sumAmp);
261 
262  sprintf(histo, "HcalDigiTask_number_of_amplitudes_above_10fC_%s", sub);
263  book1D(ib, histo, ndigis);
264 
265  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
266  sprintf(histo, "HcalDigiTask_ADC0_adc_depth%d_%s", depth, sub);
267  book1D(ib, histo, pedestal);
268  }
269 
270  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
271  sprintf(histo, "HcalDigiTask_ADC0_fC_depth%d_%s", depth, sub);
272  book1D(ib, histo, pedestalfC);
273  }
274 
275  sprintf(histo, "HcalDigiTask_signal_amplitude_%s", sub);
276  book1D(ib, histo, digiAmp);
277 
278  if(hep17_ && bsubdet=="HE"){
279  sprintf(histo, "HcalDigiTask_signal_amplitude_HEP17");
280  book1D(ib, histo, digiAmpWide);
281  }
282  //
283  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
284  sprintf(histo, "HcalDigiTask_signal_amplitude_depth%d_%s", depth, sub);
285  book1D(ib, histo, digiAmp);
286  if(hep17_ && bsubdet=="HE"){
287  sprintf(histo, "HcalDigiTask_signal_amplitude_depth%d_HEP17", depth);
288  book1D(ib, histo, digiAmpWide);
289  }
290  }
291 
292  sprintf(histo, "HcalDigiTask_signal_amplitude_vs_bin_all_depths_%s", sub);
293  book2D(ib, histo, nbin, digiAmp);
294  if(hep17_ && bsubdet=="HE"){
295  sprintf(histo, "HcalDigiTask_signal_amplitude_vs_bin_all_depths_HEP17");
296  book2D(ib, histo, nbin, digiAmpWide);
297  }
298 
299  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
300  sprintf(histo, "HcalDigiTask_all_amplitudes_vs_bin_1D_depth%d_%s", depth, sub);
301  book1D(ib, histo, nbin);
302  if(hep17_ && bsubdet=="HE"){
303  sprintf(histo, "HcalDigiTask_all_amplitudes_vs_bin_1D_depth%d_HEP17", depth);
304  book1D(ib, histo, nbin);
305  }
306  }
307 
308  sprintf(histo, "HcalDigiTask_SOI_frac_%s", sub);
309  book1D(ib, histo, frac);
310  sprintf(histo, "HcalDigiTask_postSOI_frac_%s", sub);
311  book1D(ib, histo, frac);
312 
313  if (bmc == 1) {
314  sprintf(histo, "HcalDigiTask_amplitude_vs_simhits_%s", sub);
315  book2D(ib, histo, sime, digiAmp);
316  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
317  sprintf(histo, "HcalDigiTask_amplitude_vs_simhits_depth%d_%s", depth, sub);
318  book2D(ib, histo, sime, digiAmp);
319  }
320 
321  sprintf(histo, "HcalDigiTask_amplitude_vs_simhits_profile_%s", sub);
322  bookPf(ib, histo, sime, digiAmp);
323  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
324  sprintf(histo, "HcalDigiTask_amplitude_vs_simhits_profile_depth%d_%s", depth, sub);
325  bookPf(ib, histo, sime, digiAmp);
326  }
327 
328  sprintf(histo, "HcalDigiTask_ratio_amplitude_vs_simhits_%s", sub);
329  book1D(ib, histo, ratio);
330  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
331  sprintf(histo, "HcalDigiTask_ratio_amplitude_vs_simhits_depth%d_%s", depth, sub);
332  book1D(ib, histo, ratio);
333  }
334  }//mc only
335 
336  } else { // noise only
337 
338  // EVENT "1" distributions of all cells properties
339 
340  //KH
341  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
342  sprintf(histo, "HcalDigiTask_gain_capId0_Depth%d_%s", depth, sub);
343  book1D(ib, histo, gainLim);
344  sprintf(histo, "HcalDigiTask_gain_capId1_Depth%d_%s", depth, sub);
345  book1D(ib, histo, gainLim);
346  sprintf(histo, "HcalDigiTask_gain_capId2_Depth%d_%s", depth, sub);
347  book1D(ib, histo, gainLim);
348  sprintf(histo, "HcalDigiTask_gain_capId3_Depth%d_%s", depth, sub);
349  book1D(ib, histo, gainLim);
350 
351  sprintf(histo, "HcalDigiTask_gainWidth_capId0_Depth%d_%s", depth, sub);
352  book1D(ib, histo, gainWidthLim);
353  sprintf(histo, "HcalDigiTask_gainWidth_capId1_Depth%d_%s", depth, sub);
354  book1D(ib, histo, gainWidthLim);
355  sprintf(histo, "HcalDigiTask_gainWidth_capId2_Depth%d_%s", depth, sub);
356  book1D(ib, histo, gainWidthLim);
357  sprintf(histo, "HcalDigiTask_gainWidth_capId3_Depth%d_%s", depth, sub);
358  book1D(ib, histo, gainWidthLim);
359 
360  sprintf(histo, "HcalDigiTask_pedestal_capId0_Depth%d_%s", depth, sub);
361  book1D(ib, histo, pedLim);
362  sprintf(histo, "HcalDigiTask_pedestal_capId1_Depth%d_%s", depth, sub);
363  book1D(ib, histo, pedLim);
364  sprintf(histo, "HcalDigiTask_pedestal_capId2_Depth%d_%s", depth, sub);
365  book1D(ib, histo, pedLim);
366  sprintf(histo, "HcalDigiTask_pedestal_capId3_Depth%d_%s", depth, sub);
367  book1D(ib, histo, pedLim);
368 
369  sprintf(histo, "HcalDigiTask_pedestal_width_capId0_Depth%d_%s", depth, sub);
370  book1D(ib, histo, pedWidthLim);
371  sprintf(histo, "HcalDigiTask_pedestal_width_capId1_Depth%d_%s", depth, sub);
372  book1D(ib, histo, pedWidthLim);
373  sprintf(histo, "HcalDigiTask_pedestal_width_capId2_Depth%d_%s", depth, sub);
374  book1D(ib, histo, pedWidthLim);
375  sprintf(histo, "HcalDigiTask_pedestal_width_capId3_Depth%d_%s", depth, sub);
376  book1D(ib, histo, pedWidthLim);
377 
378  }
379 
380  //KH
381  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
382  sprintf(histo, "HcalDigiTask_gainMap_Depth%d_%s", depth, sub);
383  book2D(ib, histo, ietaLim, iphiLim);
384  sprintf(histo, "HcalDigiTask_pwidthMap_Depth%d_%s", depth, sub);
385  book2D(ib, histo, ietaLim, iphiLim);
386  }
387 
388  } //end of noise-only
389 }//book
390 
392  using namespace edm;
393  using namespace std;
394 
395  iSetup.get<HcalDbRecord > ().get(conditions);
396 
397  //TP Code
399  iSetup.get<CaloTPGRecord>().get(decoder);
400 
402  iSetup.get<CaloGeometryRecord>().get(tp_geometry);
403 
404  iSetup.get<HcalRecNumberingRecord>().get(htopo);
405 
406  //Get all handles
408  iEvent.getByToken(tok_emulTPs_, emulTPs);
409 
411  if(!skipDataTPs) iEvent.getByToken(tok_dataTPs_, dataTPs);
412  //iEvent.getByLabel("hcalDigis", dataTPs);
413 
414  //~TP Code
415 
416  if (subdet_ != "all") {
417  noise_ = 0;
418  if (subdet_ == "HB"){
419  reco<HBHEDataFrame > (iEvent, iSetup, tok_hbhe_);
420  reco<QIE11DataFrame>(iEvent, iSetup, tok_qie11_hbhe_);
421  }
422  if (subdet_ == "HE"){
423  reco<HBHEDataFrame > (iEvent, iSetup, tok_hbhe_);
424  reco<QIE11DataFrame>(iEvent, iSetup, tok_qie11_hbhe_);
425  }
426  if (subdet_ == "HO") reco<HODataFrame > (iEvent, iSetup, tok_ho_);
427  if (subdet_ == "HF"){
428  reco<HFDataFrame > (iEvent, iSetup, tok_hf_);
429  reco<QIE10DataFrame>(iEvent, iSetup, tok_qie10_hf_);
430  }
431 
432  if (subdet_ == "noise") {
433  noise_ = 1;
434  subdet_ = "HB";
435  reco<HBHEDataFrame > (iEvent, iSetup, tok_hbhe_);
436  reco<QIE11DataFrame>(iEvent, iSetup, tok_qie11_hbhe_);
437  subdet_ = "HE";
438  reco<HBHEDataFrame > (iEvent, iSetup, tok_hbhe_);
439  reco<QIE11DataFrame>(iEvent, iSetup, tok_qie11_hbhe_);
440  subdet_ = "HO";
441  reco<HODataFrame > (iEvent, iSetup, tok_ho_);
442  subdet_ = "HF";
443  reco<HFDataFrame > (iEvent, iSetup, tok_hf_);
444  reco<QIE10DataFrame>(iEvent, iSetup, tok_qie10_hf_);
445  subdet_ = "noise";
446  }
447  }// all subdetectors
448  else {
449  noise_ = 0;
450 
451  subdet_ = "HB";
452  reco<HBHEDataFrame > (iEvent, iSetup, tok_hbhe_);
453  reco<QIE11DataFrame>(iEvent, iSetup, tok_qie11_hbhe_);
454  subdet_ = "HE";
455  reco<HBHEDataFrame > (iEvent, iSetup, tok_hbhe_);
456  reco<QIE11DataFrame>(iEvent, iSetup, tok_qie11_hbhe_);
457  subdet_ = "HO";
458  reco<HODataFrame > (iEvent, iSetup, tok_ho_);
459  subdet_ = "HF";
460  reco<HFDataFrame > (iEvent, iSetup, tok_hf_);
461  reco<QIE10DataFrame>(iEvent, iSetup, tok_qie10_hf_);
462  subdet_ = "all";
463  }
464 
465  fill1D("nevtot", 0);
466  nevtot++;
467 
468  //TP Code
469  //Counters
470  int c = 0, cv0 = 0, cv1 = 0, chb = 0, che = 0, chf = 0, chfv0 = 0, chfv1 = 0;
471 
472  if(skipDataTPs) return;
473 
474  for (HcalTrigPrimDigiCollection::const_iterator itr = dataTPs->begin(); itr != dataTPs->end(); ++itr) {
475  int ieta = itr->id().ieta();
476  int iphi = itr->id().iphi();
477 
478  HcalSubdetector subdet = (HcalSubdetector) 0;
479 
480 
481  if ( abs(ieta) <= 16 )
482  subdet = HcalSubdetector::HcalBarrel ;
483  else if ( abs(ieta) < tp_geometry->firstHFTower(itr->id().version()) )
484  subdet = HcalSubdetector::HcalEndcap ;
485  else if ( abs(ieta) <= 42 )
487 
488  //Right now, the only case where version matters is in HF
489  //If the subdetector is not HF, set version to -1
490  int tpVersion = (subdet == HcalSubdetector::HcalForward ? itr->id().version() : -1);
491 
492  float en = decoder->hcaletValue(itr->id(), itr->t0());
493 
494  if (en < 0.00001) continue;
495 
496  //Plot the variables
497  //Retain classic behavior (include all tps)
498  //Additional plots that only include HF 3x2 or HF 1x1
499 
500  //Classic
501  fill1D("HcalDigiTask_tp_et",en);
502  fill2D("HcalDigiTask_tp_et_ieta",ieta,en);
503  fill2D("HcalDigiTask_tp_ieta_iphi",ieta,iphi);
504  fillPf("HcalDigiTask_tp_ave_et_ieta",ieta,en);
505  fill1D("HcalDigiTask_tp_ntp_ieta",ieta);
506  fill1D("HcalDigiTask_tp_ntp_iphi",iphi);
507  if ( en > 10. ) fill1D("HcalDigiTask_tp_ntp_10_ieta",ieta);
508 
509  //3x2 Trig Primitives (tpVersion == 0)
510  if( subdet != HcalSubdetector::HcalForward || tpVersion==0){
511  fill1D("HcalDigiTask_tp_et_v0",en);
512  fill2D("HcalDigiTask_tp_et_ieta_v0",ieta,en);
513  fill2D("HcalDigiTask_tp_ieta_iphi_v0",ieta,iphi);
514  fillPf("HcalDigiTask_tp_ave_et_ieta_v0",ieta,en);
515  fill1D("HcalDigiTask_tp_ntp_ieta_v0",ieta);
516  fill1D("HcalDigiTask_tp_ntp_iphi_v0",iphi);
517  if ( en > 10. ) fill1D("HcalDigiTask_tp_ntp_10_ieta_v0",ieta);
518  }
519 
520  //1x1 Trig Primitives (tpVersion == 1)
521  if( subdet != HcalSubdetector::HcalForward || tpVersion==1){
522  fill1D("HcalDigiTask_tp_et_v1",en);
523  fill2D("HcalDigiTask_tp_et_ieta_v1",ieta,en);
524  fill2D("HcalDigiTask_tp_ieta_iphi_v1",ieta,iphi);
525  fillPf("HcalDigiTask_tp_ave_et_ieta_v1",ieta,en);
526  fill1D("HcalDigiTask_tp_ntp_ieta_v1",ieta);
527  fill1D("HcalDigiTask_tp_ntp_iphi_v1",iphi);
528  if ( en > 10. ) fill1D("HcalDigiTask_tp_ntp_10_ieta_v1",ieta);
529  }
530 
531  ++c;
532  if ( subdet == HcalSubdetector::HcalBarrel ) {
533  fill1D("HcalDigiTask_tp_et_HB",en);
534  ++chb;
535  ++cv0;
536  ++cv1;
537  }
538  if ( subdet == HcalSubdetector::HcalEndcap ) {
539  fill1D("HcalDigiTask_tp_et_HE",en);
540  ++che;
541  ++cv0;
542  ++cv1;
543  }
544  if ( subdet == HcalSubdetector::HcalForward ) {
545  fill1D("HcalDigiTask_tp_et_HF",en);
546  ++chf;
547 
548  if(tpVersion == 0){
549  fill1D("HcalDigiTask_tp_et_HF_v0",en);
550  ++chfv0;
551  ++cv0;
552  }
553 
554  if(tpVersion == 1){
555  fill1D("HcalDigiTask_tp_et_HF_v1",en);
556  ++chfv1;
557  ++cv1;
558  }
559 
560  }
561 
562  }//end data TP collection
563 
564  fill1D("HcalDigiTask_tp_ntp",c);
565  fill1D("HcalDigiTask_tp_ntp_v0",cv0);
566  fill1D("HcalDigiTask_tp_ntp_v1",cv1);
567  fill1D("HcalDigiTask_tp_ntp_HB",chb);
568  fill1D("HcalDigiTask_tp_ntp_HE",che);
569  fill1D("HcalDigiTask_tp_ntp_HF",chf);
570  fill1D("HcalDigiTask_tp_ntp_HF_v0",chfv0);
571  fill1D("HcalDigiTask_tp_ntp_HF_v1",chfv1);
572 
573  //~TP Code
574 }
575 
576 template<class Digi> void HcalDigisValidation::reco(const edm::Event& iEvent, const edm::EventSetup& iSetup, const edm::EDGetTokenT<edm::SortedCollection<Digi> > & tok) {
577 
578 
579  // HistLim =============================================================
580 
581  std::string strtmp;
582 
583  // ======================================================================
584  using namespace edm;
587 
588  // ADC2fC
590  CaloSamples tool;
591  iEvent.getByToken(tok, digiCollection);
592  if (!digiCollection.isValid()) return;
593  int isubdet = 0;
594  if (subdet_ == "HB") isubdet = 1;
595  if (subdet_ == "HE") isubdet = 2;
596  if (subdet_ == "HO") isubdet = 3;
597  if (subdet_ == "HF") isubdet = 4;
598 
599  if (isubdet == 1) nevent1++;
600  if (isubdet == 2) nevent2++;
601  if (isubdet == 3) nevent3++;
602  if (isubdet == 4) nevent4++;
603 
604  int indigis = 0;
605  // amplitude for signal cell at diff. depths
606  std::vector<double> v_ampl_c(maxDepth_[isubdet]+1,0);
607 
608  // is set to 1 if "seed" SimHit is found
609  int seedSimHit = 0;
610 
611  int ieta_Sim = 9999;
612  int iphi_Sim = 9999;
613  double emax_Sim = -9999.;
614 
615 
616  // SimHits MC only
617  if (mc_ == "yes") {
619  iEvent.getByToken(tok_mc_, hcalHits);
620  const edm::PCaloHitContainer * simhitResult = hcalHits.product();
621 
622  if (isubdet != 0 && noise_ == 0) { // signal only SimHits
623 
624  for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin(); simhits != simhitResult->end(); ++simhits) {
625 
626  unsigned int id_ = simhits->id();
627  int sub, ieta, iphi;
628  HcalDetId hid;
630  else hid = HcalDetId(id_);
631  sub = hid.subdet();
632  ieta = hid.ieta();
633  iphi = hid.iphi();
634 
635  double en = simhits->energy();
636 
637  if (en > emax_Sim && sub == isubdet) {
638  emax_Sim = en;
639  ieta_Sim = ieta;
640  iphi_Sim = iphi;
641  // to limit "seed" SimHit energy in case of "multi" event
642  if (mode_ == "multi" &&
643  ((sub == 4 && en < 100. && en > 1.)
644  || ((sub != 4) && en < 1. && en > 0.02))) {
645  seedSimHit = 1;
646  break;
647  }
648  }
649 
650  } // end of SimHits cycle
651 
652 
653  // found highest-energy SimHit for single-particle
654  if (mode_ != "multi" && emax_Sim > 0.) seedSimHit = 1;
655  } // end of SimHits
656  }// end of mc_ == "yes"
657 
658  // CYCLE OVER CELLS ========================================================
659  int Ndig = 0;
660 
661  for (digiItr = digiCollection->begin(); digiItr != digiCollection->end(); digiItr++) {
662 
663  HcalDetId cell(digiItr->id());
664  int depth = cell.depth();
665  int iphi = cell.iphi();
666  int ieta = cell.ieta();
667  int sub = cell.subdet();
668 
669  if(depth > maxDepth_[isubdet] && sub == isubdet){
670  edm::LogWarning("HcalDetId") << "HcalDetID presents conflicting information. Depth: " << depth << ", iphi: " << iphi << ", ieta: " << ieta << ". Max depth from geometry is: " << maxDepth_[isubdet] << ". TestNumber = " << testNumber_;
671  continue;
672  }
673 
674  // amplitude for signal cell at diff. depths
675  std::vector<double> v_ampl(maxDepth_[isubdet]+1,0);
676 
677  // Gains, pedestals (once !) and only for "noise" case
678  if (((nevent1 == 1 && isubdet == 1) ||
679  (nevent2 == 1 && isubdet == 2) ||
680  (nevent3 == 1 && isubdet == 3) ||
681  (nevent4 == 1 && isubdet == 4)) && noise_ == 1 && sub == isubdet) {
682 
683  HcalGenericDetId hcalGenDetId(digiItr->id());
684  const HcalPedestal* pedestal = conditions->getPedestal(hcalGenDetId);
685  const HcalGain* gain = conditions->getGain(hcalGenDetId);
686  const HcalGainWidth* gainWidth = conditions->getGainWidth(hcalGenDetId);
687  const HcalPedestalWidth* pedWidth = conditions-> getPedestalWidth(hcalGenDetId);
688 
689  for (int i = 0; i < 4; i++) {
690  fill1D("HcalDigiTask_gain_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, gain->getValue(i));
691  fill1D("HcalDigiTask_gainWidth_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, gainWidth->getValue(i));
692  fill1D("HcalDigiTask_pedestal_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, pedestal->getValue(i));
693  fill1D("HcalDigiTask_pedestal_width_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, pedWidth->getWidth(i));
694  }
695 
696  fill2D("HcalDigiTask_gainMap_Depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi), gain->getValue(0));
697  fill2D("HcalDigiTask_pwidthMap_Depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi), pedWidth->getWidth(0));
698 
699  }// end of event #1
700 
701  if (sub == isubdet) Ndig++; // subdet number of digi
702 
703  // No-noise case, only single subdet selected ===========================
704 
705  if (sub == isubdet && noise_ == 0) {
706 
707  HcalCalibrations calibrations = conditions->getHcalCalibrations(cell);
708 
709  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
710  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
711  HcalCoderDb coder(*channelCoder, *shape);
712  coder.adc2fC(*digiItr, tool);
713 
714  double noiseADC = (*digiItr)[0].adc();
715  double noisefC = tool[0];
716  // noise evaluations from "pre-samples"
717  fill1D("HcalDigiTask_ADC0_adc_depth" + str(depth) + "_" + subdet_, noiseADC);
718  fill1D("HcalDigiTask_ADC0_fC_depth" + str(depth) + "_" + subdet_, noisefC);
719 
720 
721  // OCCUPANCY maps fill
722  fill2D("HcalDigiTask_ieta_iphi_occupancy_map_depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi));
723 
724  fill1D("HcalDigiTask_depths_"+subdet_,double(depth));
725 
726  // Cycle on time slices
727  // - for each Digi
728  // - for one Digi with max SimHits E in subdet
729 
730 
731  int closen = 0; // =1 if 1) seedSimHit = 1 and 2) the cell is the same
732  if (ieta == ieta_Sim && iphi == iphi_Sim) closen = seedSimHit;
733 
734  for (int ii = 0; ii < tool.size(); ii++) {
735  int capid = (*digiItr)[ii].capid();
736  // single ts amplitude
737  double val = (tool[ii] - calibrations.pedestal(capid));
738 
739  if (val > 100.) {
740  fill1D("HcalDigiTask_ADC0_adc_depth" + str(depth) + "_" + subdet_, noiseADC);
741  strtmp = "HcalDigiTask_all_amplitudes_vs_bin_1D_depth" + str(depth) + "_" + subdet_;
742  fill1D(strtmp, double(ii), val);
743  }
744 
745  if (closen == 1) {
746  strtmp = "HcalDigiTask_signal_amplitude_vs_bin_all_depths_" + subdet_;
747  fill2D(strtmp, double(ii), val);
748  }
749 
750 
751  // HB/HE/HO
752  if (isubdet != 4 && ii >= 4 && ii <= 7) {
753  v_ampl[0] += val;
754  v_ampl[depth] += val;
755 
756  if (closen == 1) {
757  v_ampl_c[0] += val;
758  v_ampl_c[depth] += val;
759  }
760  }
761 
762  // HF
763  if (isubdet == 4 && ii >= 2 && ii <= 4) {
764  v_ampl[0] += val;
765  v_ampl[depth] += val;
766  if (closen == 1) {
767  v_ampl_c[0] += val;
768  v_ampl_c[depth] += val;
769  }
770  }
771  }
772  // end of time bucket sample
773 
774  // maps of sum of amplitudes (sum lin.digis(4,5,6,7) - ped) all depths
775  // just 1D of all cells' amplitudes
776  strtmp = "HcalDigiTask_sum_all_amplitudes_" + subdet_;
777  fill1D(strtmp, v_ampl[0]);
778 
779  std::vector<int> v_ampl_sub(v_ampl.begin() + 1, v_ampl.end()); // remove element 0, which is the sum of any depth
780  double ampl_max = *std::max_element(v_ampl_sub.begin(),v_ampl_sub.end());
781  if (ampl_max>10.) indigis++;
782  //KH if (ampl1 > 10. || ampl2 > 10. || ampl3 > 10. || ampl4 > 10.) indigis++;
783 
784  // fraction 5,6 bins if ampl. is big.
785  if (v_ampl[1] > 30. && depth == 1) {
786  int soi = tool.presamples();
787  int lastbin = tool.size() - 1;
788 
789  double fbinSOI = tool[soi] - calibrations.pedestal((*digiItr)[soi].capid());
790  double fbinPS = 0;
791 
792  for(int j = soi+1; j <= lastbin; j++) fbinPS += tool[j] - calibrations.pedestal((*digiItr)[j].capid());
793 
794  fbinSOI /= v_ampl[1];
795  fbinPS /= v_ampl[1];
796  strtmp = "HcalDigiTask_SOI_frac_" + subdet_;
797  fill1D(strtmp, fbinSOI);
798  strtmp = "HcalDigiTask_postSOI_frac_" + subdet_;
799  fill1D(strtmp, fbinPS);
800  }
801 
802  strtmp = "HcalDigiTask_signal_amplitude_" + subdet_;
803  fill1D(strtmp, v_ampl[0]);
804  strtmp = "HcalDigiTask_signal_amplitude_depth" + str(depth) + "_" + subdet_;
805  fill1D(strtmp, v_ampl[depth]);
806  }
807  } // End of CYCLE OVER CELLS =============================================
808 
809  if (isubdet != 0 && noise_ == 0) { // signal only, once per event
810  strtmp = "HcalDigiTask_number_of_amplitudes_above_10fC_" + subdet_;
811  fill1D(strtmp, indigis);
812 
813  // SimHits once again !!!
814  double eps = 1.e-3;
815  std::vector<double> v_ehits(maxDepth_[isubdet]+1,0);
816 
817  if (mc_ == "yes") {
819  iEvent.getByToken(tok_mc_, hcalHits);
820  const edm::PCaloHitContainer * simhitResult = hcalHits.product();
821  for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin(); simhits != simhitResult->end(); ++simhits) {
822 
823  unsigned int id_ = simhits->id();
824  int sub, depth, ieta, iphi;
825  HcalDetId hid;
827  else hid = HcalDetId(id_);
828  sub = hid.subdet();
829  depth = hid.depth();
830  ieta = hid.ieta();
831  iphi = hid.iphi();
832 
833  if(depth > maxDepth_[isubdet] && sub == isubdet){
834  edm::LogWarning("HcalDetId") << "HcalDetID(SimHit) presents conflicting information. Depth: " << depth << ", iphi: " << iphi << ", ieta: " << ieta << ". Max depth from geometry is: " << maxDepth_[isubdet] << ". TestNumber = " << testNumber_;
835  continue;
836  }
837 
838 
839  // take cell already found to be max energy in a particular subdet
840  if (sub == isubdet && ieta == ieta_Sim && iphi == iphi_Sim) {
841  double en = simhits->energy();
842 
843  v_ehits[0] += en;
844  v_ehits[depth] += en;
845 
846  }
847  } // simhit loop
848 
849  strtmp = "HcalDigiTask_amplitude_vs_simhits_" + subdet_;
850  if (v_ehits[0] > eps) fill2D(strtmp, v_ehits[0], v_ampl_c[0]);
851  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
852  strtmp = "HcalDigiTask_amplitude_vs_simhits_depth" + str(depth) + "_" + subdet_;
853  if (v_ehits[depth] > eps) fill2D(strtmp, v_ehits[depth], v_ampl_c[depth]);
854  }
855 
856  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_" + subdet_;
857  if (v_ehits[0] > eps) fillPf(strtmp, v_ehits[0], v_ampl_c[0]);
858  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
859  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_depth" + str(depth) + "_" + subdet_;
860  if (v_ehits[depth] > eps) fillPf(strtmp, v_ehits[depth], v_ampl_c[depth]);
861  }
862 
863  strtmp = "HcalDigiTask_ratio_amplitude_vs_simhits_" + subdet_;
864  if (v_ehits[0] > eps) fill1D(strtmp, v_ampl_c[0] / v_ehits[0]);
865  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
866  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_depth" + str(depth) + "_" + subdet_;
867  if (v_ehits[depth] > eps) fillPf(strtmp, v_ehits[depth], v_ampl_c[depth]);
868  strtmp = "HcalDigiTask_ratio_amplitude_vs_simhits_depth" + str(depth) + "_" + subdet_;
869  if (v_ehits[depth] > eps) fill1D(strtmp, v_ampl_c[depth] / v_ehits[depth]);
870  }
871 
872 
873  } // end of if(mc_ == "yes")
874 
875  strtmp = "HcalDigiTask_Ndigis_" + subdet_;
876  fill1D(strtmp, double(Ndig));
877 
878  } // end of if( subdet != 0 && noise_ == 0) { // signal only
879 
880 }
881 template<class dataFrameType> void HcalDigisValidation::reco(const edm::Event& iEvent, const edm::EventSetup& iSetup, const edm::EDGetTokenT<HcalDataFrameContainer<dataFrameType> > & tok) {
882 
883 
884  // HistLim =============================================================
885 
886  std::string strtmp;
887 
888  // ======================================================================
889  using namespace edm;
891  //typename HcalDataFrameContainer<dataFrameType>::const_iterator digiItr;
892 
893 
894  // ADC2fC
896  CaloSamples tool;
897  iEvent.getByToken(tok, digiHandle);
898  if (!digiHandle.isValid()) return;
900  int isubdet = 0;
901  if (subdet_ == "HB") isubdet = 1;
902  if (subdet_ == "HE") isubdet = 2;
903  if (subdet_ == "HO") isubdet = 3;
904  if (subdet_ == "HF") isubdet = 4;
905 
906  if (isubdet == 1) nevent1++;
907  if (isubdet == 2) nevent2++;
908  if (isubdet == 3) nevent3++;
909  if (isubdet == 4) nevent4++;
910 
911  int indigis = 0;
912  // amplitude for signal cell at diff. depths
913  std::vector<double> v_ampl_c(maxDepth_[isubdet]+1,0);
914 
915  // is set to 1 if "seed" SimHit is found
916  int seedSimHit = 0;
917 
918  int ieta_Sim = 9999;
919  int iphi_Sim = 9999;
920  double emax_Sim = -9999.;
921 
922 
923  // SimHits MC only
924  if (mc_ == "yes") {
926  iEvent.getByToken(tok_mc_, hcalHits);
927  const edm::PCaloHitContainer * simhitResult = hcalHits.product();
928 
929  if (isubdet != 0 && noise_ == 0) { // signal only SimHits
930 
931  for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin(); simhits != simhitResult->end(); ++simhits) {
932 
933  unsigned int id_ = simhits->id();
934  int sub, ieta, iphi;
935  HcalDetId hid;
937  else hid = HcalDetId(id_);
938  sub = hid.subdet();
939  ieta = hid.ieta();
940  iphi = hid.iphi();
941 
942  double en = simhits->energy();
943 
944  if (en > emax_Sim && sub == isubdet) {
945  emax_Sim = en;
946  ieta_Sim = ieta;
947  iphi_Sim = iphi;
948  // to limit "seed" SimHit energy in case of "multi" event
949  if (mode_ == "multi" &&
950  ((sub == 4 && en < 100. && en > 1.)
951  || ((sub != 4) && en < 1. && en > 0.02))) {
952  seedSimHit = 1;
953  break;
954  }
955  }
956 
957  } // end of SimHits cycle
958 
959 
960  // found highest-energy SimHit for single-particle
961  if (mode_ != "multi" && emax_Sim > 0.) seedSimHit = 1;
962  } // end of SimHits
963  }// end of mc_ == "yes"
964 
965  // CYCLE OVER CELLS ========================================================
966  int Ndig = 0;
967 
968  for (typename HcalDataFrameContainer<dataFrameType>::const_iterator digiItr = digiCollection->begin(); digiItr != digiCollection->end(); digiItr++) {
969 
970  dataFrameType dataFrame = *digiItr;
971 
972  HcalDetId cell(digiItr->id());
973  int depth = cell.depth();
974  int iphi = cell.iphi();
975  int ieta = cell.ieta();
976  int sub = cell.subdet();
977 
978  //Is this in HEP17
979  bool isHEP17 = (iphi>=63)&&(iphi<=66)&&(ieta>0)&&(sub == 2);
980 
981 
982  if(depth > maxDepth_[isubdet] && sub == isubdet){
983  edm::LogWarning("HcalDetId") << "HcalDetID presents conflicting information. Depth: " << depth << ", iphi: " << iphi << ", ieta: " << ieta << ". Max depth from geometry is: " << maxDepth_[isubdet] << ". TestNumber = " << testNumber_;
984  continue;
985  }
986 
987  // amplitude for signal cell at diff. depths
988  std::vector<double> v_ampl(maxDepth_[isubdet]+1,0);
989 
990  // Gains, pedestals (once !) and only for "noise" case
991  if (((nevent1 == 1 && isubdet == 1) ||
992  (nevent2 == 1 && isubdet == 2) ||
993  (nevent3 == 1 && isubdet == 3) ||
994  (nevent4 == 1 && isubdet == 4)) && noise_ == 1 && sub == isubdet) {
995 
996  HcalGenericDetId hcalGenDetId(digiItr->id());
997  const HcalPedestal* pedestal = conditions->getPedestal(hcalGenDetId);
998  const HcalGain* gain = conditions->getGain(hcalGenDetId);
999  const HcalGainWidth* gainWidth = conditions->getGainWidth(hcalGenDetId);
1000  const HcalPedestalWidth* pedWidth = conditions-> getPedestalWidth(hcalGenDetId);
1001 
1002  for (int i = 0; i < 4; i++) {
1003  fill1D("HcalDigiTask_gain_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, gain->getValue(i));
1004  fill1D("HcalDigiTask_gainWidth_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, gainWidth->getValue(i));
1005  fill1D("HcalDigiTask_pedestal_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, pedestal->getValue(i));
1006  fill1D("HcalDigiTask_pedestal_width_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, pedWidth->getWidth(i));
1007  }
1008 
1009  fill2D("HcalDigiTask_gainMap_Depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi), gain->getValue(0));
1010  fill2D("HcalDigiTask_pwidthMap_Depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi), pedWidth->getWidth(0));
1011 
1012  }// end of event #1
1013  //std::cout << "==== End of event noise block in cell cycle" << std::endl;
1014 
1015  if (sub == isubdet) Ndig++; // subdet number of digi
1016 
1017  // No-noise case, only single subdet selected ===========================
1018 
1019  if (sub == isubdet && noise_ == 0) {
1020 
1021  HcalCalibrations calibrations = conditions->getHcalCalibrations(cell);
1022 
1023  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
1024  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
1025  HcalCoderDb coder(*channelCoder, *shape);
1026  coder.adc2fC(dataFrame, tool);
1027 
1028  double noiseADC = (dataFrame)[0].adc();
1029  double noisefC = tool[0];
1030  // noise evaluations from "pre-samples"
1031  fill1D("HcalDigiTask_ADC0_adc_depth" + str(depth) + "_" + subdet_, noiseADC);
1032  fill1D("HcalDigiTask_ADC0_fC_depth" + str(depth) + "_" + subdet_, noisefC);
1033 
1034 
1035  // OCCUPANCY maps fill
1036  fill2D("HcalDigiTask_ieta_iphi_occupancy_map_depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi));
1037 
1038  fill1D("HcalDigiTask_depths_"+subdet_,double(depth));
1039 
1040  // Cycle on time slices
1041  // - for each Digi
1042  // - for one Digi with max SimHits E in subdet
1043 
1044 
1045  int closen = 0; // =1 if 1) seedSimHit = 1 and 2) the cell is the same
1046  if (ieta == ieta_Sim && iphi == iphi_Sim) closen = seedSimHit;
1047 
1048  for (int ii = 0; ii < tool.size(); ii++) {
1049  int capid = (dataFrame)[ii].capid();
1050  // single ts amplitude
1051  double val = (tool[ii] - calibrations.pedestal(capid));
1052 
1053  if (val > 100.) {
1054  fill1D("HcalDigiTask_ADC0_adc_depth" + str(depth) + "_" + subdet_, noiseADC);
1055  if(hep17_){
1056  if(!isHEP17){
1057  strtmp = "HcalDigiTask_all_amplitudes_vs_bin_1D_depth" + str(depth) + "_" + subdet_;
1058  fill1D(strtmp, double(ii), val);
1059  } else {
1060  strtmp = "HcalDigiTask_all_amplitudes_vs_bin_1D_depth" + str(depth) + "_HEP17";
1061  fill1D(strtmp, double(ii), val);
1062  }
1063  } else {
1064  strtmp = "HcalDigiTask_all_amplitudes_vs_bin_1D_depth" + str(depth) + "_" + subdet_;
1065  fill1D(strtmp, double(ii), val);
1066  }
1067  }
1068 
1069  if (closen == 1) {
1070  if(hep17_){
1071  if(!isHEP17){
1072  strtmp = "HcalDigiTask_signal_amplitude_vs_bin_all_depths_" + subdet_;
1073  fill2D(strtmp, double(ii), val);
1074  }else{
1075  strtmp = "HcalDigiTask_signal_amplitude_vs_bin_all_depths_HEP17";
1076  fill2D(strtmp, double(ii), val);
1077  }
1078  } else {
1079  strtmp = "HcalDigiTask_signal_amplitude_vs_bin_all_depths_" + subdet_;
1080  fill2D(strtmp, double(ii), val);
1081  }
1082  }
1083 
1084 
1085  // HB/HE/HO
1086  if (isubdet != 4 && ii >= 4 && ii <= 7) {
1087  v_ampl[0] += val;
1088  v_ampl[depth] += val;
1089 
1090  if (closen == 1) {
1091  v_ampl_c[0] += val;
1092  v_ampl_c[depth] += val;
1093  }
1094  }
1095 
1096  // HF
1097  if (isubdet == 4 && ii >= 2 && ii <= 4) {
1098  v_ampl[0] += val;
1099  v_ampl[depth] += val;
1100  if (closen == 1) {
1101  v_ampl_c[0] += val;
1102  v_ampl_c[depth] += val;
1103  }
1104  }
1105  }
1106  // end of time bucket sample
1107 
1108  // just 1D of all cells' amplitudes
1109  strtmp = "HcalDigiTask_sum_all_amplitudes_" + subdet_;
1110  fill1D(strtmp, v_ampl[0]);
1111 
1112  std::vector<int> v_ampl_sub(v_ampl.begin() + 1, v_ampl.end()); // remove element 0, which is the sum of any depth
1113  double ampl_max = *std::max_element(v_ampl_sub.begin(),v_ampl_sub.end());
1114  if (ampl_max>10.) indigis++;
1115  //KH if (ampl1 > 10. || ampl2 > 10. || ampl3 > 10. || ampl4 > 10.) indigis++;
1116 
1117  // fraction 5,6 bins if ampl. is big.
1118  //histogram names have not been changed, but it should be understood that bin_5 is soi, and bin_6_7 is latter TS'
1119  if (v_ampl[1] > 30. && depth == 1) {
1120  int soi = tool.presamples();
1121  int lastbin = tool.size() - 1;
1122 
1123  double fbinSOI = tool[soi] - calibrations.pedestal((dataFrame)[soi].capid());
1124  double fbinPS = 0;
1125 
1126  for(int j = soi+1; j <= lastbin; j++) fbinPS += tool[j] - calibrations.pedestal((dataFrame)[j].capid());
1127 
1128 
1129  fbinSOI /= v_ampl[1];
1130  fbinPS /= v_ampl[1];
1131  strtmp = "HcalDigiTask_SOI_frac_" + subdet_;
1132  fill1D(strtmp, fbinSOI);
1133  strtmp = "HcalDigiTask_postSOI_frac_" + subdet_;
1134  fill1D(strtmp, fbinPS);
1135  }
1136 
1137 
1138  if(hep17_){
1139  if(!isHEP17){
1140  strtmp = "HcalDigiTask_signal_amplitude_" + subdet_;
1141  fill1D(strtmp, v_ampl[0]);
1142  strtmp = "HcalDigiTask_signal_amplitude_depth" + str(depth) + "_" + subdet_;
1143  fill1D(strtmp, v_ampl[depth]);
1144  } else {
1145  strtmp = "HcalDigiTask_signal_amplitude_HEP17";
1146  fill1D(strtmp, v_ampl[0]);
1147  strtmp = "HcalDigiTask_signal_amplitude_depth" + str(depth) + "_HEP17";
1148  fill1D(strtmp, v_ampl[depth]);
1149  }
1150  }else{
1151  strtmp = "HcalDigiTask_signal_amplitude_" + subdet_;
1152  fill1D(strtmp, v_ampl[0]);
1153  strtmp = "HcalDigiTask_signal_amplitude_depth" + str(depth) + "_" + subdet_;
1154  fill1D(strtmp, v_ampl[depth]);
1155  }
1156  }
1157  } // End of CYCLE OVER CELLS =============================================
1158 
1159  if (isubdet != 0 && noise_ == 0) { // signal only, once per event
1160  strtmp = "HcalDigiTask_number_of_amplitudes_above_10fC_" + subdet_;
1161  fill1D(strtmp, indigis);
1162 
1163  // SimHits once again !!!
1164  double eps = 1.e-3;
1165  std::vector<double> v_ehits(maxDepth_[isubdet]+1,0);
1166 
1167  if (mc_ == "yes") {
1169  iEvent.getByToken(tok_mc_, hcalHits);
1170  const edm::PCaloHitContainer * simhitResult = hcalHits.product();
1171  for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin(); simhits != simhitResult->end(); ++simhits) {
1172 
1173  unsigned int id_ = simhits->id();
1174  int sub, depth, ieta, iphi;
1175  HcalDetId hid;
1177  else hid = HcalDetId(id_);
1178  sub = hid.subdet();
1179  depth = hid.depth();
1180  ieta = hid.ieta();
1181  iphi = hid.iphi();
1182 
1183  if(depth > maxDepth_[isubdet] && sub == isubdet){
1184  edm::LogWarning("HcalDetId") << "HcalDetID(SimHit) presents conflicting information. Depth: " << depth << ", iphi: " << iphi << ", ieta: " << ieta << ". Max depth from geometry is: " << maxDepth_[isubdet] << ". TestNumber = " << testNumber_;
1185  continue;
1186  }
1187 
1188 
1189  // take cell already found to be max energy in a particular subdet
1190  if (sub == isubdet && ieta == ieta_Sim && iphi == iphi_Sim) {
1191  double en = simhits->energy();
1192 
1193  v_ehits[0] += en;
1194  v_ehits[depth] += en;
1195 
1196  }
1197  } // simhit loop
1198 
1199  strtmp = "HcalDigiTask_amplitude_vs_simhits_" + subdet_;
1200  if (v_ehits[0] > eps) fill2D(strtmp, v_ehits[0], v_ampl_c[0]);
1201  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
1202  strtmp = "HcalDigiTask_amplitude_vs_simhits_depth" + str(depth) + "_" + subdet_;
1203  if (v_ehits[depth] > eps) fill2D(strtmp, v_ehits[depth], v_ampl_c[depth]);
1204  }
1205 
1206  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_" + subdet_;
1207  if (v_ehits[0] > eps) fillPf(strtmp, v_ehits[0], v_ampl_c[0]);
1208  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
1209  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_depth" + str(depth) + "_" + subdet_;
1210  if (v_ehits[depth] > eps) fillPf(strtmp, v_ehits[depth], v_ampl_c[depth]);
1211  }
1212 
1213  strtmp = "HcalDigiTask_ratio_amplitude_vs_simhits_" + subdet_;
1214  if (v_ehits[0] > eps) fill1D(strtmp, v_ampl_c[0] / v_ehits[0]);
1215  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
1216  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_depth" + str(depth) + "_" + subdet_;
1217  if (v_ehits[depth] > eps) fillPf(strtmp, v_ehits[depth], v_ampl_c[depth]);
1218  strtmp = "HcalDigiTask_ratio_amplitude_vs_simhits_depth" + str(depth) + "_" + subdet_;
1219  if (v_ehits[depth] > eps) fill1D(strtmp, v_ampl_c[depth] / v_ehits[depth]);
1220  }
1221 
1222 
1223  } // end of if(mc_ == "yes")
1224 
1225  strtmp = "HcalDigiTask_Ndigis_" + subdet_;
1226  fill1D(strtmp, double(Ndig));
1227 
1228  } // end of if( subdet != 0 && noise_ == 0) { // signal only
1229 
1230 } //HcalDataFrameContainer
1231 
1233  if (!msm_->count(name)) (*msm_)[name] = ib.book1D(name.c_str(), name.c_str(), n, min, max);
1234 }
1235 
1237  if (!msm_->count(name)) (*msm_)[name] = ib.book1D(name.c_str(), name.c_str(), limX.n, limX.min, limX.max);
1238 }
1239 
1241  msm_->find(name)->second->Fill(X, weight);
1242 }
1243 
1245  if (!msm_->count(name)) (*msm_)[name] = ib.book2D(name.c_str(), name.c_str(), limX.n, limX.min, limX.max, limY.n, limY.min, limY.max);
1246 }
1247 
1248 void HcalDigisValidation::fill2D(std::string name, double X, double Y, double weight) {
1249  msm_->find(name)->second->Fill(X, Y, weight);
1250 }
1251 
1253  if (!msm_->count(name)) (*msm_)[name] = ib.bookProfile(name.c_str(), name.c_str(), limX.n, limX.min, limX.max, limY.n, limY.min, limY.max);
1254 }
1255 
1256 void HcalDigisValidation::bookPf(DQMStore::IBooker &ib, std::string name, const HistLim& limX, const HistLim& limY, const char *option) {
1257  if (!msm_->count(name)) (*msm_)[name] = ib.bookProfile(name.c_str(), name.c_str(), limX.n, limX.min, limX.max, limY.n, limY.min, limY.max, option);
1258 }
1259 
1261  msm_->find(name)->second->Fill(X, Y);
1262 }
1263 
1265  if (!msm_->count(name)) return nullptr;
1266  else return msm_->find(name)->second;
1267 }
1268 
1270  std::stringstream out;
1271  out << x;
1272  return out.str();
1273 }
1274 
1275 
1276 //define this as a plug-in
1278 
1279 
int adc(sample_type sample)
get the ADC sample (12 bits)
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
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
const HcalGainWidth * getGainWidth(const HcalGenericDetId &fId) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< PCaloHit > PCaloHitContainer
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
unsigned int getHxSize(const int type) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const HcalTopology * htopology
std::vector< HcalTriggerPrimitiveDigi >::const_iterator const_iterator
bool exists(std::string const &parameterName) const
checks if a parameter exists
#define X(str)
Definition: MuonsGrabber.cc:48
int presamples() const
access presample information
Definition: CaloSamples.h:36
Definition: weight.py:1
void reco(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::EDGetTokenT< edm::SortedCollection< Digi > > &tok)
double pedestal(int fCapId) const
get pedestal for capid=0..3
const_iterator begin() const
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:22
virtual void analyze(const edm::Event &, const edm::EventSetup &)
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGainWidth.h:21
edm::EDGetTokenT< QIE11DigiCollection > tok_qie11_hbhe_
edm::EDGetTokenT< QIE10DigiCollection > tok_qie10_hf_
std::map< std::string, MonitorElement * > * msm_
int depth() const
get the tower depth
Definition: HcalDetId.cc:129
void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const override
Definition: HcalCoderDb.cc:68
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
MonitorElement * monitor(std::string name)
void fillPf(std::string name, double X, double Y)
void fill2D(std::string name, double X, double Y, double weight=1)
edm::ESHandle< HcalTopology > htopo
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
HcalSubdetector
Definition: HcalAssistant.h:31
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalDigisValidation(const edm::ParameterSet &)
void bookPf(DQMStore::IBooker &ib, std::string name, const HistLim &limX, const HistLim &limY)
T min(T a, T b)
Definition: MathUtil.h:58
bool isValid() const
Definition: HandleBase.h:74
const HcalDDDRecConstants * hcons
ii
Definition: cuy.py:588
virtual void dqmBeginRun(const edm::Run &run, const edm::EventSetup &c)
edm::InputTag QIE10inputTag_
void book2D(DQMStore::IBooker &ib, std::string name, const HistLim &limX, const HistLim &limY)
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:124
edm::EDGetTokenT< HFDigiCollection > tok_hf_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
T const * product() const
Definition: Handle.h:81
void fill1D(std::string name, double X, double weight=1)
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
int size() const
get the size
Definition: CaloSamples.h:24
edm::EDGetTokenT< edm::PCaloHitContainer > tok_mc_
edm::EDGetTokenT< HODigiCollection > tok_ho_
int getMaxDepth(const int &type) const
const T & get() const
Definition: EventSetup.h:55
void booking(DQMStore::IBooker &ib, std::string subdetopt, int bnoise, int bmc)
const HcalGain * getGain(const HcalGenericDetId &fId) const
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
edm::EDGetTokenT< HcalTrigPrimDigiCollection > tok_emulTPs_
edm::InputTag QIE11inputTag_
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
std::string str(int x)
const_iterator end() const
HLT enums.
edm::EDGetTokenT< HcalTrigPrimDigiCollection > tok_dataTPs_
edm::ESHandle< HcalDbService > conditions
virtual double hcaletValue(const int &ieta, const int &iphi, const int &version, const int &compressedValue) const =0
void book1D(DQMStore::IBooker &ib, std::string name, int n, double min, double max)
DetId relabel(const uint32_t testId) const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
const_iterator begin() const
Definition: Run.h:43
ib
Definition: cuy.py:660
int firstHFTower(int version) const