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