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