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(2410, -3000., 720000.); //300 fC binning
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
603  CaloSamples tool;
604  iEvent.getByToken(tok, digiCollection);
605  if (!digiCollection.isValid()) return;
606  int isubdet = 0;
607  if (subdet_ == "HB") isubdet = 1;
608  if (subdet_ == "HE") isubdet = 2;
609  if (subdet_ == "HO") isubdet = 3;
610  if (subdet_ == "HF") isubdet = 4;
611 
612  if (isubdet == 1) nevent1++;
613  if (isubdet == 2) nevent2++;
614  if (isubdet == 3) nevent3++;
615  if (isubdet == 4) nevent4++;
616 
617  int indigis = 0;
618  // amplitude for signal cell at diff. depths
619  std::vector<double> v_ampl_c(maxDepth_[isubdet]+1,0);
620 
621  // is set to 1 if "seed" SimHit is found
622  int seedSimHit = 0;
623 
624  int ieta_Sim = 9999;
625  int iphi_Sim = 9999;
626  double emax_Sim = -9999.;
627 
628  // SimHits MC only
629  if (mc_ == "yes") {
631  iEvent.getByToken(tok_mc_, hcalHits);
632  const edm::PCaloHitContainer * simhitResult = hcalHits.product();
633 
634  if (isubdet != 0 && noise_ == 0) { // signal only SimHits
635 
636  for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin(); simhits != simhitResult->end(); ++simhits) {
637 
638  unsigned int id_ = simhits->id();
639  int sub, ieta, iphi;
640  HcalDetId hid;
642  else hid = HcalDetId(id_);
643  sub = hid.subdet();
644  ieta = hid.ieta();
645  iphi = hid.iphi();
646 
647  double en = simhits->energy();
648 
649  if (en > emax_Sim && sub == isubdet) {
650  emax_Sim = en;
651  ieta_Sim = ieta;
652  iphi_Sim = iphi;
653  // to limit "seed" SimHit energy in case of "multi" event
654  if (mode_ == "multi" &&
655  ((sub == 4 && en < 100. && en > 1.)
656  || ((sub != 4) && en < 1. && en > 0.02))) {
657  seedSimHit = 1;
658  break;
659  }
660  }
661 
662  } // end of SimHits cycle
663 
664 
665  // found highest-energy SimHit for single-particle
666  if (mode_ != "multi" && emax_Sim > 0.) seedSimHit = 1;
667  } // end of SimHits
668  }// end of mc_ == "yes"
669 
670  // CYCLE OVER CELLS ========================================================
671  int Ndig = 0;
672 
673  for (digiItr = digiCollection->begin(); digiItr != digiCollection->end(); digiItr++) {
674 
675  HcalDetId cell(digiItr->id());
676  int depth = cell.depth();
677  int iphi = cell.iphi();
678  int ieta = cell.ieta();
679  int sub = cell.subdet();
680 
681  if(depth > maxDepth_[isubdet] && sub == isubdet){
682  edm::LogWarning("HcalDetId") << "HcalDetID presents conflicting information. Depth: " << depth << ", iphi: " << iphi << ", ieta: " << ieta << ". Max depth from geometry is: " << maxDepth_[isubdet] << ". TestNumber = " << testNumber_;
683  continue;
684  }
685 
686  // amplitude for signal cell at diff. depths
687  std::vector<double> v_ampl(maxDepth_[isubdet]+1,0);
688 
689  // Gains, pedestals (once !) and only for "noise" case
690  if (((nevent1 == 1 && isubdet == 1) ||
691  (nevent2 == 1 && isubdet == 2) ||
692  (nevent3 == 1 && isubdet == 3) ||
693  (nevent4 == 1 && isubdet == 4)) && noise_ == 1 && sub == isubdet) {
694 
695  HcalGenericDetId hcalGenDetId(digiItr->id());
696  const HcalPedestal* pedestal = conditions->getPedestal(hcalGenDetId);
697  const HcalGain* gain = conditions->getGain(hcalGenDetId);
698  const HcalGainWidth* gainWidth = conditions->getGainWidth(hcalGenDetId);
699  const HcalPedestalWidth* pedWidth = conditions-> getPedestalWidth(hcalGenDetId);
700 
701  for (int i = 0; i < 4; i++) {
702  fill1D("HcalDigiTask_gain_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, gain->getValue(i));
703  fill1D("HcalDigiTask_gainWidth_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, gainWidth->getValue(i));
704  fill1D("HcalDigiTask_pedestal_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, pedestal->getValue(i));
705  fill1D("HcalDigiTask_pedestal_width_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, pedWidth->getWidth(i));
706  }
707 
708  fill2D("HcalDigiTask_gainMap_Depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi), gain->getValue(0));
709  fill2D("HcalDigiTask_pwidthMap_Depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi), pedWidth->getWidth(0));
710 
711  }// end of event #1
712 
713  if (sub == isubdet) Ndig++; // subdet number of digi
714 
715  // No-noise case, only single subdet selected ===========================
716 
717  if (sub == isubdet && noise_ == 0) {
718 
720 
721  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
722  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
723  HcalCoderDb coder(*channelCoder, *shape);
724  coder.adc2fC(*digiItr, tool);
725 
726  // for dynamic digi time sample analysis
727  int soi = tool.presamples();
728  int lastbin = tool.size() - 1;
729 
730  double noiseADC = (*digiItr)[0].adc();
731  double noisefC = tool[0];
732  // noise evaluations from "pre-samples"
733  fill1D("HcalDigiTask_ADC0_adc_depth" + str(depth) + "_" + subdet_, noiseADC);
734  fill1D("HcalDigiTask_ADC0_fC_depth" + str(depth) + "_" + subdet_, noisefC);
735 
736  // OCCUPANCY maps fill
737  fill2D("HcalDigiTask_ieta_iphi_occupancy_map_depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi));
738 
739  fill1D("HcalDigiTask_depths_"+subdet_,double(depth));
740 
741  // Cycle on time slices
742  // - for each Digi
743  // - for one Digi with max SimHits E in subdet
744 
745 
746  int closen = 0; // =1 if 1) seedSimHit = 1 and 2) the cell is the same
747  if (ieta == ieta_Sim && iphi == iphi_Sim) closen = seedSimHit;
748 
749  for (int ii = 0; ii < tool.size(); ii++) {
750  int capid = (*digiItr)[ii].capid();
751  // single ts amplitude
752  double val = (tool[ii] - calibrations.pedestal(capid));
753 
754  if (val > 100.) {
755  fill1D("HcalDigiTask_ADC0_adc_depth" + str(depth) + "_" + subdet_, noiseADC);
756  strtmp = "HcalDigiTask_all_amplitudes_vs_bin_1D_depth" + str(depth) + "_" + subdet_;
757  fill1D(strtmp, double(ii), val);
758  }
759 
760  if (closen == 1) {
761  strtmp = "HcalDigiTask_signal_amplitude_vs_bin_all_depths_" + subdet_;
762  fill2D(strtmp, double(ii), val);
763  }
764 
765 
766  // all detectors
767  if (ii >= soi && ii <= lastbin) {
768  v_ampl[0] += val;
769  v_ampl[depth] += val;
770 
771  if (closen == 1) {
772  v_ampl_c[0] += val;
773  v_ampl_c[depth] += val;
774  }
775  }
776 
777  }
778  // end of time bucket sample
779 
780  // maps of sum of amplitudes (sum lin.digis(4,5,6,7) - ped) all depths
781  // just 1D of all cells' amplitudes
782  strtmp = "HcalDigiTask_sum_all_amplitudes_" + subdet_;
783  fill1D(strtmp, v_ampl[0]);
784 
785  std::vector<int> v_ampl_sub(v_ampl.begin() + 1, v_ampl.end()); // remove element 0, which is the sum of any depth
786  double ampl_max = *std::max_element(v_ampl_sub.begin(),v_ampl_sub.end());
787  if (ampl_max>10.) indigis++;
788  //KH if (ampl1 > 10. || ampl2 > 10. || ampl3 > 10. || ampl4 > 10.) indigis++;
789 
790  // fraction 5,6 bins if ampl. is big.
791  if (v_ampl[depth] > 30.) {
792  double fbinSOI = tool[soi] - calibrations.pedestal((*digiItr)[soi].capid());
793  double fbinPS = 0;
794 
795  for(int j = soi+1; j <= lastbin; j++) fbinPS += tool[j] - calibrations.pedestal((*digiItr)[j].capid());
796 
797  fbinSOI /= v_ampl[depth];
798  fbinPS /= v_ampl[depth];
799  strtmp = "HcalDigiTask_SOI_frac_" + subdet_;
800  fill1D(strtmp, fbinSOI);
801  strtmp = "HcalDigiTask_postSOI_frac_" + subdet_;
802  fill1D(strtmp, fbinPS);
803  }
804 
805  strtmp = "HcalDigiTask_signal_amplitude_" + subdet_;
806  fill1D(strtmp, v_ampl[0]);
807  strtmp = "HcalDigiTask_signal_amplitude_depth" + str(depth) + "_" + subdet_;
808  fill1D(strtmp, v_ampl[depth]);
809  }
810  } // End of CYCLE OVER CELLS =============================================
811 
812  if (isubdet != 0 && noise_ == 0) { // signal only, once per event
813  strtmp = "HcalDigiTask_number_of_amplitudes_above_10fC_" + subdet_;
814  fill1D(strtmp, indigis);
815 
816  // SimHits once again !!!
817  double eps = 1.e-3;
818  std::vector<double> v_ehits(maxDepth_[isubdet]+1,0);
819 
820  if (mc_ == "yes") {
822  iEvent.getByToken(tok_mc_, hcalHits);
823  const edm::PCaloHitContainer * simhitResult = hcalHits.product();
824  for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin(); simhits != simhitResult->end(); ++simhits) {
825 
826  unsigned int id_ = simhits->id();
827  int sub, depth, ieta, iphi;
828  HcalDetId hid;
830  else hid = HcalDetId(id_);
831  sub = hid.subdet();
832  depth = hid.depth();
833  ieta = hid.ieta();
834  iphi = hid.iphi();
835 
836  if(depth > maxDepth_[isubdet] && sub == isubdet){
837  edm::LogWarning("HcalDetId") << "HcalDetID(SimHit) presents conflicting information. Depth: " << depth << ", iphi: " << iphi << ", ieta: " << ieta << ". Max depth from geometry is: " << maxDepth_[isubdet] << ". TestNumber = " << testNumber_;
838  continue;
839  }
840 
841 
842  // take cell already found to be max energy in a particular subdet
843  if (sub == isubdet && ieta == ieta_Sim && iphi == iphi_Sim) {
844  double en = simhits->energy();
845 
846  v_ehits[0] += en;
847  v_ehits[depth] += en;
848 
849  }
850  } // simhit loop
851 
852  strtmp = "HcalDigiTask_amplitude_vs_simhits_" + subdet_;
853  if (v_ehits[0] > eps) fill2D(strtmp, v_ehits[0], v_ampl_c[0]);
854  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
855  strtmp = "HcalDigiTask_amplitude_vs_simhits_depth" + str(depth) + "_" + subdet_;
856  if (v_ehits[depth] > eps) fill2D(strtmp, v_ehits[depth], v_ampl_c[depth]);
857  }
858 
859  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_" + subdet_;
860  if (v_ehits[0] > eps) fillPf(strtmp, v_ehits[0], v_ampl_c[0]);
861  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
862  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_depth" + str(depth) + "_" + subdet_;
863  if (v_ehits[depth] > eps) fillPf(strtmp, v_ehits[depth], v_ampl_c[depth]);
864  }
865 
866  strtmp = "HcalDigiTask_ratio_amplitude_vs_simhits_" + subdet_;
867  if (v_ehits[0] > eps) fill1D(strtmp, v_ampl_c[0] / v_ehits[0]);
868  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
869  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_depth" + str(depth) + "_" + subdet_;
870  if (v_ehits[depth] > eps) fillPf(strtmp, v_ehits[depth], v_ampl_c[depth]);
871  strtmp = "HcalDigiTask_ratio_amplitude_vs_simhits_depth" + str(depth) + "_" + subdet_;
872  if (v_ehits[depth] > eps) fill1D(strtmp, v_ampl_c[depth] / v_ehits[depth]);
873  }
874 
875 
876  } // end of if(mc_ == "yes")
877 
878  strtmp = "HcalDigiTask_Ndigis_" + subdet_;
879  fill1D(strtmp, double(Ndig));
880 
881  } // end of if( subdet != 0 && noise_ == 0) { // signal only
882 
883 }
884 template<class dataFrameType> void HcalDigisValidation::reco(const edm::Event& iEvent, const edm::EventSetup& iSetup, const edm::EDGetTokenT<HcalDataFrameContainer<dataFrameType> > & tok) {
885 
886 
887  // HistLim =============================================================
888 
889  std::string strtmp;
890 
891  // ======================================================================
892  using namespace edm;
894  //typename HcalDataFrameContainer<dataFrameType>::const_iterator digiItr;
895 
896 
897  // ADC2fC
898  CaloSamples tool;
899  iEvent.getByToken(tok, digiHandle);
900  if (!digiHandle.isValid()) return;
902  int isubdet = 0;
903  if (subdet_ == "HB") isubdet = 1;
904  if (subdet_ == "HE") isubdet = 2;
905  if (subdet_ == "HO") isubdet = 3;
906  if (subdet_ == "HF") isubdet = 4;
907 
908  if (isubdet == 1) nevent1++;
909  if (isubdet == 2) nevent2++;
910  if (isubdet == 3) nevent3++;
911  if (isubdet == 4) nevent4++;
912 
913  int indigis = 0;
914  // amplitude for signal cell at diff. depths
915  std::vector<double> v_ampl_c(maxDepth_[isubdet]+1,0);
916 
917  // is set to 1 if "seed" SimHit is found
918  int seedSimHit = 0;
919 
920  int ieta_Sim = 9999;
921  int iphi_Sim = 9999;
922  double emax_Sim = -9999.;
923 
924  // SimHits MC only
925  if (mc_ == "yes") {
927  iEvent.getByToken(tok_mc_, hcalHits);
928  const edm::PCaloHitContainer * simhitResult = hcalHits.product();
929 
930  if (isubdet != 0 && noise_ == 0) { // signal only SimHits
931 
932  for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin(); simhits != simhitResult->end(); ++simhits) {
933 
934  unsigned int id_ = simhits->id();
935  int sub, ieta, iphi;
936  HcalDetId hid;
938  else hid = HcalDetId(id_);
939  sub = hid.subdet();
940  ieta = hid.ieta();
941  iphi = hid.iphi();
942 
943  double en = simhits->energy();
944 
945  if (en > emax_Sim && sub == isubdet) {
946  emax_Sim = en;
947  ieta_Sim = ieta;
948  iphi_Sim = iphi;
949  // to limit "seed" SimHit energy in case of "multi" event
950  if (mode_ == "multi" &&
951  ((sub == 4 && en < 100. && en > 1.)
952  || ((sub != 4) && en < 1. && en > 0.02))) {
953  seedSimHit = 1;
954  break;
955  }
956  }
957 
958  } // end of SimHits cycle
959 
960 
961  // found highest-energy SimHit for single-particle
962  if (mode_ != "multi" && emax_Sim > 0.) seedSimHit = 1;
963  } // end of SimHits
964  }// end of mc_ == "yes"
965 
966  // CYCLE OVER CELLS ========================================================
967  int Ndig = 0;
968 
969  for (typename HcalDataFrameContainer<dataFrameType>::const_iterator digiItr = digiCollection->begin(); digiItr != digiCollection->end(); digiItr++) {
970 
971  dataFrameType dataFrame = *digiItr;
972 
973  HcalDetId cell(digiItr->id());
974  int depth = cell.depth();
975  int iphi = cell.iphi();
976  int ieta = cell.ieta();
977  int sub = cell.subdet();
978 
979  //Is this in HEP17
980  bool isHEP17 = (iphi>=63)&&(iphi<=66)&&(ieta>0)&&(sub == 2);
981 
982 
983  if(depth > maxDepth_[isubdet] && sub == isubdet){
984  edm::LogWarning("HcalDetId") << "HcalDetID presents conflicting information. Depth: " << depth << ", iphi: " << iphi << ", ieta: " << ieta << ". Max depth from geometry is: " << maxDepth_[isubdet] << ". TestNumber = " << testNumber_;
985  continue;
986  }
987 
988  // amplitude for signal cell at diff. depths
989  std::vector<double> v_ampl(maxDepth_[isubdet]+1,0);
990 
991  // Gains, pedestals (once !) and only for "noise" case
992  if (((nevent1 == 1 && isubdet == 1) ||
993  (nevent2 == 1 && isubdet == 2) ||
994  (nevent3 == 1 && isubdet == 3) ||
995  (nevent4 == 1 && isubdet == 4)) && noise_ == 1 && sub == isubdet) {
996 
997  HcalGenericDetId hcalGenDetId(digiItr->id());
998  const HcalPedestal* pedestal = conditions->getPedestal(hcalGenDetId);
999  const HcalGain* gain = conditions->getGain(hcalGenDetId);
1000  const HcalGainWidth* gainWidth = conditions->getGainWidth(hcalGenDetId);
1001  const HcalPedestalWidth* pedWidth = conditions-> getPedestalWidth(hcalGenDetId);
1002 
1003  for (int i = 0; i < 4; i++) {
1004  fill1D("HcalDigiTask_gain_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, gain->getValue(i));
1005  fill1D("HcalDigiTask_gainWidth_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, gainWidth->getValue(i));
1006  fill1D("HcalDigiTask_pedestal_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, pedestal->getValue(i));
1007  fill1D("HcalDigiTask_pedestal_width_capId" + str(i) + "_Depth" + str(depth) + "_" + subdet_, pedWidth->getWidth(i));
1008  }
1009 
1010  fill2D("HcalDigiTask_gainMap_Depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi), gain->getValue(0));
1011  fill2D("HcalDigiTask_pwidthMap_Depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi), pedWidth->getWidth(0));
1012 
1013  }// end of event #1
1014  //std::cout << "==== End of event noise block in cell cycle" << std::endl;
1015 
1016  if (sub == isubdet) Ndig++; // subdet number of digi
1017 
1018  // No-noise case, only single subdet selected ===========================
1019 
1020  if (sub == isubdet && noise_ == 0) {
1021 
1023 
1024  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
1025  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
1026  HcalCoderDb coder(*channelCoder, *shape);
1027  coder.adc2fC(dataFrame, tool);
1028 
1029  // for dynamic digi time sample analysis
1030  int soi = tool.presamples();
1031  int lastbin = tool.size() - 1;
1032 
1033  double noiseADC = (dataFrame)[0].adc();
1034  double noisefC = tool[0];
1035  // noise evaluations from "pre-samples"
1036  fill1D("HcalDigiTask_ADC0_adc_depth" + str(depth) + "_" + subdet_, noiseADC);
1037  fill1D("HcalDigiTask_ADC0_fC_depth" + str(depth) + "_" + subdet_, noisefC);
1038 
1039  // OCCUPANCY maps fill
1040  fill2D("HcalDigiTask_ieta_iphi_occupancy_map_depth" + str(depth) + "_" + subdet_, double(ieta), double(iphi));
1041 
1042  fill1D("HcalDigiTask_depths_"+subdet_,double(depth));
1043 
1044  // Cycle on time slices
1045  // - for each Digi
1046  // - for one Digi with max SimHits E in subdet
1047 
1048 
1049  int closen = 0; // =1 if 1) seedSimHit = 1 and 2) the cell is the same
1050  if (ieta == ieta_Sim && iphi == iphi_Sim) closen = seedSimHit;
1051 
1052  for (int ii = 0; ii < tool.size(); ii++) {
1053  int capid = (dataFrame)[ii].capid();
1054  // single ts amplitude
1055  double val = (tool[ii] - calibrations.pedestal(capid));
1056 
1057  if (val > 100.) {
1058  fill1D("HcalDigiTask_ADC0_adc_depth" + str(depth) + "_" + subdet_, noiseADC);
1059  if(hep17_){
1060  if(!isHEP17){
1061  strtmp = "HcalDigiTask_all_amplitudes_vs_bin_1D_depth" + str(depth) + "_" + subdet_;
1062  fill1D(strtmp, double(ii), val);
1063  } else {
1064  strtmp = "HcalDigiTask_all_amplitudes_vs_bin_1D_depth" + str(depth) + "_HEP17";
1065  fill1D(strtmp, double(ii), val);
1066  }
1067  } else {
1068  strtmp = "HcalDigiTask_all_amplitudes_vs_bin_1D_depth" + str(depth) + "_" + subdet_;
1069  fill1D(strtmp, double(ii), val);
1070  }
1071  }
1072 
1073  if (closen == 1) {
1074  if(hep17_){
1075  if(!isHEP17){
1076  strtmp = "HcalDigiTask_signal_amplitude_vs_bin_all_depths_" + subdet_;
1077  fill2D(strtmp, double(ii), val);
1078  }else{
1079  strtmp = "HcalDigiTask_signal_amplitude_vs_bin_all_depths_HEP17";
1080  fill2D(strtmp, double(ii), val);
1081  }
1082  } else {
1083  strtmp = "HcalDigiTask_signal_amplitude_vs_bin_all_depths_" + subdet_;
1084  fill2D(strtmp, double(ii), val);
1085  }
1086  }
1087 
1088  // all detectors
1089  if (ii >= soi && ii <= lastbin) {
1090  v_ampl[0] += val;
1091  v_ampl[depth] += val;
1092 
1093  if (closen == 1) {
1094  v_ampl_c[0] += val;
1095  v_ampl_c[depth] += val;
1096  }
1097  }
1098 
1099  }
1100  // end of time bucket sample
1101 
1102  // just 1D of all cells' amplitudes
1103  strtmp = "HcalDigiTask_sum_all_amplitudes_" + subdet_;
1104  fill1D(strtmp, v_ampl[0]);
1105 
1106  std::vector<int> v_ampl_sub(v_ampl.begin() + 1, v_ampl.end()); // remove element 0, which is the sum of any depth
1107  double ampl_max = *std::max_element(v_ampl_sub.begin(),v_ampl_sub.end());
1108  if (ampl_max>10.) indigis++;
1109  //KH if (ampl1 > 10. || ampl2 > 10. || ampl3 > 10. || ampl4 > 10.) indigis++;
1110 
1111  // fraction 5,6 bins if ampl. is big.
1112  //histogram names have not been changed, but it should be understood that bin_5 is soi, and bin_6_7 is latter TS'
1113  if ((v_ampl[depth] > 30. && (subdet_ != "HE" || subdet_ != "HB")) || (v_ampl[depth] > 300.)) { //300 fC cut for QIE-11 HB & HE
1114  double fbinSOI = tool[soi] - calibrations.pedestal((dataFrame)[soi].capid());
1115  double fbinPS = 0;
1116 
1117  for(int j = soi+1; j <= lastbin; j++) fbinPS += tool[j] - calibrations.pedestal((dataFrame)[j].capid());
1118 
1119  fbinSOI /= v_ampl[depth];
1120  fbinPS /= v_ampl[depth];
1121  strtmp = "HcalDigiTask_SOI_frac_" + subdet_;
1122  fill1D(strtmp, fbinSOI);
1123  strtmp = "HcalDigiTask_postSOI_frac_" + subdet_;
1124  fill1D(strtmp, fbinPS);
1125  }
1126 
1127 
1128  if(hep17_){
1129  if(!isHEP17){
1130  strtmp = "HcalDigiTask_signal_amplitude_" + subdet_;
1131  fill1D(strtmp, v_ampl[0]);
1132  strtmp = "HcalDigiTask_signal_amplitude_depth" + str(depth) + "_" + subdet_;
1133  fill1D(strtmp, v_ampl[depth]);
1134  } else {
1135  strtmp = "HcalDigiTask_signal_amplitude_HEP17";
1136  fill1D(strtmp, v_ampl[0]);
1137  strtmp = "HcalDigiTask_signal_amplitude_depth" + str(depth) + "_HEP17";
1138  fill1D(strtmp, v_ampl[depth]);
1139  }
1140  }else{
1141  strtmp = "HcalDigiTask_signal_amplitude_" + subdet_;
1142  fill1D(strtmp, v_ampl[0]);
1143  strtmp = "HcalDigiTask_signal_amplitude_depth" + str(depth) + "_" + subdet_;
1144  fill1D(strtmp, v_ampl[depth]);
1145  }
1146  }
1147  } // End of CYCLE OVER CELLS =============================================
1148 
1149  if (isubdet != 0 && noise_ == 0) { // signal only, once per event
1150  strtmp = "HcalDigiTask_number_of_amplitudes_above_10fC_" + subdet_;
1151  fill1D(strtmp, indigis);
1152 
1153  // SimHits once again !!!
1154  double eps = 1.e-3;
1155  std::vector<double> v_ehits(maxDepth_[isubdet]+1,0);
1156 
1157  if (mc_ == "yes") {
1159  iEvent.getByToken(tok_mc_, hcalHits);
1160  const edm::PCaloHitContainer * simhitResult = hcalHits.product();
1161  for (std::vector<PCaloHit>::const_iterator simhits = simhitResult->begin(); simhits != simhitResult->end(); ++simhits) {
1162 
1163  unsigned int id_ = simhits->id();
1164  int sub, depth, ieta, iphi;
1165  HcalDetId hid;
1167  else hid = HcalDetId(id_);
1168  sub = hid.subdet();
1169  depth = hid.depth();
1170  ieta = hid.ieta();
1171  iphi = hid.iphi();
1172 
1173  if(depth > maxDepth_[isubdet] && sub == isubdet){
1174  edm::LogWarning("HcalDetId") << "HcalDetID(SimHit) presents conflicting information. Depth: " << depth << ", iphi: " << iphi << ", ieta: " << ieta << ". Max depth from geometry is: " << maxDepth_[isubdet] << ". TestNumber = " << testNumber_;
1175  continue;
1176  }
1177 
1178 
1179  // take cell already found to be max energy in a particular subdet
1180  if (sub == isubdet && ieta == ieta_Sim && iphi == iphi_Sim) {
1181  double en = simhits->energy();
1182 
1183  v_ehits[0] += en;
1184  v_ehits[depth] += en;
1185 
1186  }
1187  } // simhit loop
1188 
1189  strtmp = "HcalDigiTask_amplitude_vs_simhits_" + subdet_;
1190  if (v_ehits[0] > eps) fill2D(strtmp, v_ehits[0], v_ampl_c[0]);
1191  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
1192  strtmp = "HcalDigiTask_amplitude_vs_simhits_depth" + str(depth) + "_" + subdet_;
1193  if (v_ehits[depth] > eps) fill2D(strtmp, v_ehits[depth], v_ampl_c[depth]);
1194  }
1195 
1196  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_" + subdet_;
1197  if (v_ehits[0] > eps) fillPf(strtmp, v_ehits[0], v_ampl_c[0]);
1198  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
1199  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_depth" + str(depth) + "_" + subdet_;
1200  if (v_ehits[depth] > eps) fillPf(strtmp, v_ehits[depth], v_ampl_c[depth]);
1201  }
1202 
1203  strtmp = "HcalDigiTask_ratio_amplitude_vs_simhits_" + subdet_;
1204  if (v_ehits[0] > eps) fill1D(strtmp, v_ampl_c[0] / v_ehits[0]);
1205  for (int depth = 1; depth <= maxDepth_[isubdet]; depth++) {
1206  strtmp = "HcalDigiTask_amplitude_vs_simhits_profile_depth" + str(depth) + "_" + subdet_;
1207  if (v_ehits[depth] > eps) fillPf(strtmp, v_ehits[depth], v_ampl_c[depth]);
1208  strtmp = "HcalDigiTask_ratio_amplitude_vs_simhits_depth" + str(depth) + "_" + subdet_;
1209  if (v_ehits[depth] > eps) fill1D(strtmp, v_ampl_c[depth] / v_ehits[depth]);
1210  }
1211 
1212 
1213  } // end of if(mc_ == "yes")
1214 
1215  strtmp = "HcalDigiTask_Ndigis_" + subdet_;
1216  fill1D(strtmp, double(Ndig));
1217 
1218  } // end of if( subdet != 0 && noise_ == 0) { // signal only
1219 
1220 } //HcalDataFrameContainer
1221 
1223  if (!msm_->count(name)) (*msm_)[name] = ib.book1D(name.c_str(), name.c_str(), n, min, max);
1224 }
1225 
1227  if (!msm_->count(name)) (*msm_)[name] = ib.book1D(name.c_str(), name.c_str(), limX.n, limX.min, limX.max);
1228 }
1229 
1231  msm_->find(name)->second->Fill(X, weight);
1232 }
1233 
1235  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);
1236 }
1237 
1238 void HcalDigisValidation::fill2D(std::string name, double X, double Y, double weight) {
1239  msm_->find(name)->second->Fill(X, Y, weight);
1240 }
1241 
1243  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);
1244 }
1245 
1246 void HcalDigisValidation::bookPf(DQMStore::IBooker &ib, std::string name, const HistLim& limX, const HistLim& limY, const char *option) {
1247  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);
1248 }
1249 
1251  msm_->find(name)->second->Fill(X, Y);
1252 }
1253 
1255  if (!msm_->count(name)) return nullptr;
1256  else return msm_->find(name)->second;
1257 }
1258 
1260  std::stringstream out;
1261  out << x;
1262  return out.str();
1263 }
1264 
1265 
1266 //define this as a plug-in
1268 
1269 
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:49
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:146
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
unsigned int getHxSize(const int type) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
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: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)
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.h:166
void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const override
Definition: HcalCoderDb.cc:68
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
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:159
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
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:74
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:161
edm::EDGetTokenT< HFDigiCollection > tok_hf_
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
T const * product() const
Definition: Handle.h:74
void fill1D(std::string name, double X, double weight=1)
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
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
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
T get() const
Definition: EventSetup.h:71
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:45
ib
Definition: cuy.py:662
int firstHFTower(int version) const