CMS 3D CMS Logo

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