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