CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalSelectiveReadoutValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalSelectiveReadoutValidation.cc
3  *
4  *
5  */
6 
9 
11 
17 
23 
25 
27 
28 #include <string.h>
30 
31 #if (CMSSW_COMPAT_VERSION>=210)
34 #else
37 #endif
38 
39 #define ML_DEBUG
40 
41 using namespace cms;
42 using namespace edm;
43 using namespace std;
44 
45 const double EcalSelectiveReadoutValidation::rad2deg = 45./atan(1.);
46 
48  //EE- DCCs:
49  // 1 2 3 4 5 6 7 8 9
50  34, 32, 33, 33, 32, 34, 33, 34, 33,
51  //EB- DCCs:
52  // 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
53  68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
54  //EB+ DCCs:
55  // 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
56  68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
57  //EE+ DCCs:
58  // 46 47 48 49 50 51 52 53 54
59  32, 33, 33, 32, 34, 33, 34, 33, 34
60 };
61 
62 //#define DO_TIMING
63 
64 #ifdef DO_TIMING
65 # include <sys/time.h>
66 struct PgTiming{
67  PgTiming(const std::string& mess): mess_(mess), stopped_(false){
68  gettimeofday(&start_, 0);
69  }
70 
71  ~PgTiming(){
72  if(!stopped_) stop();
73  }
74  void stop(){
75  timeval t;
76  gettimeofday(&t, 0);
77  std::cout << "[PgTiming] " << mess_ << " "
78  << ((t.tv_sec-start_.tv_sec)*1.e3
79  + (t.tv_usec-start_.tv_usec)*1.e-3)
80  << " ms.\n";
81  stopped_ = true;
82  }
83  timeval start_;
84  std::string mess_;
85  bool stopped_;
86 };
87 #else //DO_TIMING is not defined
88 struct PgTiming{
89  PgTiming(const std::string& mess){}
90  void stop(){}
91 };
92 #endif //DO_TIMING defined condition
93 
95  collNotFoundWarn_(ps.getUntrackedParameter<bool>("warnIfCollectionNotFound", true)),
96  ebDigis_(ps.getParameter<edm::InputTag>("EbDigiCollection"), false,
97  collNotFoundWarn_),
98  eeDigis_(ps.getParameter<edm::InputTag>("EeDigiCollection"), false,
99  collNotFoundWarn_),
100  ebNoZsDigis_(ps.getParameter<edm::InputTag>("EbUnsuppressedDigiCollection"),
101  false, false/*collNotFoundWarn_*/),
102  eeNoZsDigis_(ps.getParameter<edm::InputTag>("EeUnsuppressedDigiCollection"),
103  false, false/*collNotFoundWarn_*/),
104  ebSrFlags_(ps.getParameter<edm::InputTag>("EbSrFlagCollection"), false,
105  collNotFoundWarn_),
106  eeSrFlags_(ps.getParameter<edm::InputTag>("EeSrFlagCollection"), false,
107  collNotFoundWarn_),
108  ebComputedSrFlags_(ps.getParameter<edm::InputTag>("EbSrFlagFromTTCollection"), false,
109  false/*collNotFoundWarn_*/),
110  eeComputedSrFlags_(ps.getParameter<edm::InputTag>("EeSrFlagFromTTCollection"), false,
111  false/*collNotFoundWarn_*/),
112  ebSimHits_(ps.getParameter<edm::InputTag>("EbSimHitCollection"), false,
113  false/*collNotFoundWarn_*/),
114  eeSimHits_(ps.getParameter<edm::InputTag>("EeSimHitCollection"), false,
115  false/*collNotFoundWarn_*/),
116  tps_(ps.getParameter<edm::InputTag>("TrigPrimCollection"), false,
117  collNotFoundWarn_),
118  ebRecHits_(ps.getParameter<edm::InputTag>("EbRecHitCollection"), false,
119  false/*collNotFoundWarn_*/),
120  eeRecHits_(ps.getParameter<edm::InputTag>("EeRecHitCollection"), false,
121  false/*collNotFoundWarn_*/),
122  fedRaw_(ps.getParameter<edm::InputTag>("FEDRawCollection"), false,
123  false/*collNotFoundWarn_*/),
124  tmax(0),
125  tmin(numeric_limits<int64_t>::max()),
126  l1aOfTmin(0),
127  l1aOfTmax(0),
128  triggerTowerMap_(0),
129  localReco_(ps.getParameter<bool>("LocalReco")),
130  weights_(ps.getParameter<vector<double> >("weights")),
131  tpInGeV_(ps.getParameter<bool>("tpInGeV")),
132  firstFIRSample_(ps.getParameter<int>("ecalDccZs1stSample")),
133  useEventRate_(ps.getParameter<bool>("useEventRate")),
134  logErrForDccs_(nDccs_, false),
135  ievt_(0),
136  allHists_(false),
137  histDir_(ps.getParameter<string>("histDir")),
138  withEeSimHit_(false),
139  withEbSimHit_(false){
140 
141  PgTiming t("EcalSelectiveReadoutValidation ctor");
142 
143 // std::vector<int> excludedFeds =
144 // ps.getParameter<vector<int> >("excludedFeds");
145 
146 // for(size_t i = 0; i < excludedFeds.size(); ++i){
147 // int iDcc = excludedFeds[i] % 600;
148 // if(iDcc < minDccId_ || iDcc > maxDccId_){
149 // throw cms::Exception("config") << "Error in parameter excludedFeds of "
150 // "EcalSelectiveReadoutValidation module. Values must be between "
151 // << 600 + minDccId_
152 // << " and " << 600 + maxDccId_ << "\n";
153 // } else{
154 // logErrForDccs_.at(iDcc-minDccId_) = false;
155 // }
156 // }
157 
158  double ebZsThr = ps.getParameter<double>("ebZsThrADCCount");
159  double eeZsThr = ps.getParameter<double>("eeZsThrADCCount");
160 
161  ebZsThr_ = lround(ebZsThr*4);
162  eeZsThr_ = lround(eeZsThr*4);
163 
164  //File to log SRP algorithem inconsistency
166  = ps.getUntrackedParameter<string>("srpAlgoErrorLogFile","");
168 
169  //File to log SRP decision application inconsistency
171  = ps.getUntrackedParameter<string>("srApplicationErrorLogFile","");
173 
174  //FIR ZS weights
175  configFirWeights(ps.getParameter<vector<double> >("dccWeights"));
176 
177  // DQM ROOT output
178  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
179 
180  if(outputFile_.size() != 0){
181  LogInfo("OutputInfo") << " Ecal Digi Task histograms will be saved to '"
182  << outputFile_.c_str() << "'";
183  } else{
184  LogInfo("OutputInfo") << " Ecal Digi Task histograms will NOT be saved";
185  }
186 
187  // verbosity switch
188  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
189 
190  // get hold of back-end interface
192 
193  if(verbose_){
194  dbe_->setVerbose(1);
195  } else{
196  dbe_->setVerbose(0);
197  }
198 
199  if(verbose_) dbe_->showDirStructure();
200 
201  dbe_->setCurrentFolder(histDir_);
202 
203  vector<string>
204  hists(ps.getUntrackedParameter<vector<string> >("histograms",
205  vector<string>(1, "all")));
206 
207  for(vector<string>::iterator it = hists.begin();
208  it!=hists.end(); ++it) histList_.insert(*it);
209  if(histList_.find("all") != histList_.end()) allHists_ = true;
210 
211  //Data volume
212  meEbFixedPayload_ = bookFloat("ebFixedVol");
213  double ebFixed = getDccOverhead(EB)*nEbDccs;
214  double eeFixed = getDccOverhead(EE)*nEeDccs;
215  meEbFixedPayload_->Fill(ebFixed);
216  meEeFixedPayload_ = bookFloat("eeFixedVol");
217  meEbFixedPayload_->Fill(eeFixed);
218  meFixedPayload_ = bookFloat("fixedVol");
219  meFixedPayload_->Fill(ebFixed+eeFixed);
220 
221  meL1aRate_ = bookFloat("l1aRate_");
222 
223  meDccVol_ = bookProfile("hDccVol", //"EcalDccEventSizeComputed",
224  "ECAL DCC event fragment size;Dcc id; "
225  "<Event size> (kB)", nDccs_, .5, .5+nDccs_);
226 
227  meDccLiVol_ = bookProfile("hDccLiVol",
228  "LI channel payload per DCC;Dcc id; "
229  "<Event size> (kB)", nDccs_, .5, .5+nDccs_);
230 
231  meDccHiVol_ = bookProfile("hDccHiVol",
232  "HI channel payload per DCC;Dcc id; "
233  "<Event size> (kB)", nDccs_, .5, .5+nDccs_);
234 
235  meDccVolFromData_ = bookProfile("hDccVolFromData", //"EcalDccEventSize",
236  "ECAL DCC event fragment size;Dcc id; "
237  "<Event size> (kB)", nDccs_, .5, .5+nDccs_);
238 
239  meVolBLI_ = book1D("hVolBLI",// "EBLowInterestPayload",
240  "ECAL Barrel low interest crystal data payload;"
241  "Event size (kB);Nevts",
242  100, 0., 200.);
243 
244  meVolELI_ = book1D("hVolELI", //"EELowInterestPayload",
245  "Endcap low interest crystal data payload;"
246  "Event size (kB);Nevts",
247  100, 0., 200.);
248 
249  meVolLI_ = book1D("hVolLI", //"EcalLowInterestPayload",
250  "ECAL low interest crystal data payload;"
251  "Event size (kB);Nevts",
252  100, 0., 200.);
253 
254  meVolBHI_ = book1D("hVolBHI", //"EBHighInterestPayload",
255  "Barrel high interest crystal data payload;"
256  "Event size (kB);Nevts",
257  100, 0., 200.);
258 
259  meVolEHI_ = book1D("hVolEHI", //"EEHighInterestPayload",
260  "Endcap high interest crystal data payload;"
261  "Event size (kB);Nevts",
262  100, 0., 200.);
263 
264  meVolHI_ = book1D("hVolHI", //"EcalHighInterestPayload",
265  "ECAL high interest crystal data payload;"
266  "Event size (kB);Nevts",
267  100, 0., 200.);
268 
269  meVolB_ = book1D("hVolB", //"EBEventSize",
270  "Barrel data volume;Event size (kB);Nevts",
271  100, 0., 200.);
272 
273  meVolE_ = book1D("hVolE", //"EEEventSize",
274  "Endcap data volume;Event size (kB);Nevts",
275  100, 0., 200.);
276 
277  meVol_ = book1D("hVol", //"EcalEventSize",
278  "ECAL data volume;Event size (kB);Nevts",
279  100, 0., 200.);
280 
281  meChOcc_ = book2D("h2ChOcc", //"EcalChannelOccupancy",
282  "ECAL crystal channel occupancy after zero suppression;"
283  "iX -200 / iEta / iX + 100;"
284  "iY / iPhi (starting from -10^{o}!);"
285  "Event count",
286  401, -200.5, 200.5,
287  360, .5, 360.5);
288 
289  //TP
290  string tpUnit;
291  if(tpInGeV_) tpUnit = string("GeV"); else tpUnit = string("TP hw unit");
292  string title;
293  title = string("Trigger primitive TT E_{T};E_{T} ")
294  + tpUnit + string(";Event Count");
295  meTp_ = book1D("hTp", //"EcalTriggerPrimitiveEt",
296  title.c_str(),
297  (tpInGeV_?100:40), 0., (tpInGeV_?10.:40.));
298 
299  meTtf_ = book1D("hTtf", //"EcalTriggerTowerFlag",
300  "Trigger primitive TT flag;Flag number;Event count",
301  8, -.5, 7.5);
302 
303  title = string("Trigger tower flag vs TP;E_{T}(TT) (")
304  + tpUnit + string(");Flag number");
305  meTtfVsTp_ = book2D("h2TtfVsTp",
306  title.c_str(),
307  100, 0., (tpInGeV_?10.:40.),
308  8, -.5, 7.5);
309 
310  meTtfVsEtSum_ = book2D("h2TtfVsEtSum",
311  "Trigger tower flag vs #sumE_{T};"
312  "E_{T}(TT) (GeV);"
313  "TTF",
314  100, 0., 10.,
315  8, -.5, 7.5);
316  title = string("Trigger primitive Et (TP) vs #sumE_{T};"
317  "E_{T} (sum) (GeV);"
318  "E_{T} (TP) (") + tpUnit + string (")");
319 
320  meTpVsEtSum_ = book2D("h2TpVsEtSum",
321  title.c_str(),
322  100, 0., 10.,
323  100, 0., (tpInGeV_?10.:40.));
324 
325  title = string("Trigger primitive E_{T};"
326  "iEta;"
327  "iPhi;"
328  "E_{T} (TP) (") + tpUnit + string (")");
329  meTpMap_ = bookProfile2D("h2Tp",
330  title.c_str(),
331  57, -28.5, 28.5,
332  72, .5, 72.5);
333 
334  //SRF
335  meFullRoRu_ = book2D("h2FRORu", //"EcalFullReadoutSRFlagMap",
336  "Full Read-out readout unit;"
337  "iX - 40 / iEta / iX + 20;"
338  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
339  "Event count",
340  80, -39.5, 40.5,
341  72, .5, 72.5);
342 
343  meFullRoCnt_ = book1D("hFROCnt",
344  "Number of Full-readout-flagged readout units;"
345  "FRO RU count;Event count",
346  300, -.5, 299.5);
347 
348  meEbFullRoCnt_ = book1D("hEbFROCnt",
349  "Number of EB Full-readout-flagged readout units;"
350  "FRO RU count;Event count",
351  200, -.5, 199.5);
352 
353  meEeFullRoCnt_ = book1D("hEeFROCnt",
354  "Number of EE Full-readout-flagged readout units;"
355  "FRO RU count;Event count",
356  200, -.5, 199.5);
357 
358  meZs1Ru_ = book2D("h2Zs1Ru", //"EbZeroSupp1SRFlagMap",
359  "Readout unit with ZS-thr-1 flag;"
360  "iX - 40 / iEta / iX + 20;"
361  "iY0 / iPhi0 (iPhi = 1 at phi = 0 rad);"
362  "Event count",
363  80, -39.5, 40.5,
364  72, .5, 72.5);
365 
366  meForcedRu_ = book2D("h2ForcedRu", //"EcalReadoutUnitForcedBitMap",
367  "ECAL readout unit with forced bit of SR flag on;"
368  "iX - 40 / iEta / iX + 20;"
369  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
370  "Event count",
371  80, -39.5, 40.5,
372  72, .5, 72.5);
373 
374  meLiTtf_ = book2D("h2LiTtf", //"EcalLowInterestTriggerTowerFlagMap",
375  "Low interest trigger tower flags;"
376  "iEta;"
377  "iPhi;"
378  "Event count",
379  57, -28.5, 28.5,
380  72, .5, 72.5);
381 
382  meMiTtf_ = book2D("h2MiTtf", //"EcalMidInterestTriggerTowerFlagMap",
383  "Mid interest trigger tower flags;"
384  "iEta;"
385  "iPhi;"
386  "Event count",
387  57, -28.5, 28.5,
388  72, .5, 72.5);
389 
390  meHiTtf_ = book2D("h2HiTtf", //"EcalHighInterestTriggerTowerFlagMap",
391  "High interest trigger tower flags;"
392  "iEta;"
393  "iPhi;"
394  "Event count",
395  57, -28.5, 28.5,
396  72, .5, 72.5);
397 
398  meForcedTtf_ = book2D("h2ForcedTtf", //"EcalTtfForcedBitMap",
399  "Trigger tower flags with forced bit set;"
400  "iEta;"
401  "iPhi;"
402  "Event count",
403  57, -28.5, 28.5,
404  72, .5, 72.5);
405 
406 
407  const float ebMinNoise = -1.;
408  const float ebMaxNoise = 1.;
409 
410  const float eeMinNoise = -1.;
411  const float eeMaxNoise = 1.;
412 
413 #if 0
414  const float ebMinE = 0.;
415  const float ebMaxE = 120.;
416 
417  const float eeMinE = 0.;
418  const float eeMaxE = 120.;
419 #else
420  const float ebMinE = ebMinNoise;
421  const float ebMaxE = ebMaxNoise;
422 
423  const float eeMinE = eeMinNoise;
424  const float eeMaxE = eeMaxNoise;
425 #endif
426 
427 
428  const int evtMax = 500;
429 
430  meEbRecE_ = book1D("hEbRecE",
431  "Crystal reconstructed energy;E (GeV);Event count",
432  100, ebMinE, ebMaxE);
433 
434  meEbEMean_ = bookProfile("hEbEMean",
435  "EE <E_hit>;event #;<E_hit> (GeV)",
436  evtMax, .5, evtMax + .5);
437 
438  meEbNoise_ = book1D("hEbNoise",
439  "Crystal noise "
440  "(rec E of crystal without deposited energy)"
441  ";Rec E (GeV);Event count",
442  100, ebMinNoise, ebMaxNoise);
443 
444  meEbLiZsFir_ = book1D("zsEbLiFIRemu",
445  "Emulated ouput of ZS FIR filter for EB "
446  "low interest crystals;"
447  "ADC count*4;"
448  "Event count",
449  60, -30, 30);
450 
451  meEbHiZsFir_ = book1D("zsEbHiFIRemu",
452  "Emulated ouput of ZS FIR filter for EB "
453  "high interest crystals;"
454  "ADC count*4;"
455  "Event count",
456  60, -30, 30);
457 
458  //TODO: Fill this histogram...
459 // meEbIncompleteRUZsFir_ = book1D("zsEbIncompleteRUFIRemu",
460 // "Emulated ouput of ZS FIR filter for EB "
461 // "incomplete FRO-flagged RU;"
462 // "ADC count*4;"
463 // "Event count",
464 // 60, -30, 30);
465 
466  meEbSimE_ = book1D("hEbSimE", "EB hit crystal simulated energy",
467  100, ebMinE, ebMaxE);
468 
469  meEbRecEHitXtal_ = book1D("hEbRecEHitXtal",
470  "EB rec energy of hit crystals",
471  100, ebMinE, ebMaxE);
472 
473  meEbRecVsSimE_ = book2D("hEbRecVsSimE",
474  "Crystal simulated vs reconstructed energy;"
475  "Esim (GeV);Erec GeV);Event count",
476  100, ebMinE, ebMaxE,
477  100, ebMinE, ebMaxE);
478 
479  meEbNoZsRecVsSimE_ = book2D("hEbNoZsRecVsSimE",
480  "Crystal no-zs simulated vs reconstructed "
481  "energy;"
482  "Esim (GeV);Erec GeV);Event count",
483  100, ebMinE, ebMaxE,
484  100, ebMinE, ebMaxE);
485 
486  meEeRecE_ = book1D("hEeRecE",
487  "EE crystal reconstructed energy;E (GeV);"
488  "Event count",
489  100, eeMinE, eeMaxE);
490 
491  meEeEMean_ = bookProfile("hEeEMean",
492  "<E_{EE hit}>;event;<E_{hit}> (GeV)",
493  evtMax, .5, evtMax + .5);
494 
495 
496  meEeNoise_ = book1D("hEeNoise",
497  "EE crystal noise "
498  "(rec E of crystal without deposited energy);"
499  "E (GeV);Event count",
500  200, eeMinNoise, eeMaxNoise);
501 
502  meEeLiZsFir_ = book1D("zsEeLiFIRemu",
503  "Emulated ouput of ZS FIR filter for EE "
504  "low interest crystals;"
505  "ADC count*4;"
506  "Event count",
507  60, -30, 30);
508 
509  meEeHiZsFir_ = book1D("zsEeHiFIRemu",
510  "Emulated ouput of ZS FIR filter for EE "
511  "high interest crystals;"
512  "ADC count*4;"
513  "Event count",
514  60, -30, 30);
515 
516  //TODO: Fill this histogram...
517 // meEeIncompleteRUZsFir_ = book1D("zsEeIncompleteRUFIRemu",
518 // "Emulated ouput of ZS FIR filter for EE "
519 // "incomplete FRO-flagged RU;"
520 // "ADC count*4;"
521 // "Event count",
522 // 60, -30, 30);
523 
524 
525  meEeSimE_ = book1D("hEeSimE", "EE hit crystal simulated energy",
526  100, eeMinE, eeMaxE);
527 
528  meEeRecEHitXtal_ = book1D("hEeRecEHitXtal",
529  "EE rec energy of hit crystals",
530  100, eeMinE, eeMaxE);
531 
532  meEeRecVsSimE_ = book2D("hEeRecVsSimE",
533  "EE crystal simulated vs reconstructed energy;"
534  "Esim (GeV);Erec GeV);Event count",
535  100, eeMinE, eeMaxE,
536  100, eeMinE, eeMaxE);
537 
538  meEeNoZsRecVsSimE_ = book2D("hEeNoZsRecVsSimE",
539  "EE crystal no-zs simulated vs "
540  "reconstructed "
541  "energy;Esim (GeV);Erec GeV);Event count",
542  100, eeMinE, eeMaxE,
543  100, eeMinE, eeMaxE);
544 
545  meSRFlagsConsistency_ = book2D("hSRAlgoErrorMap",
546  "TTFlags and SR Flags mismatch;"
547  "iX - 40 / iEta / iX + 20;"
548  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
549  "Event count",
550  80, -39.5, 40.5,
551  72, .5, 72.5);
552 
553  //Readout Units histos (interest/Ncrystals)
554  meIncompleteFROMap_ = book2D("hIncompleteFROMap",
555  "Incomplete full-readout-flagged readout units;"
556  "iX - 40 / iEta / iX + 20;"
557  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
558  "Event count",
559  80, -39.5, 40.5,
560  72, .5, 72.5);
561 
562  meIncompleteFROCnt_ = book1D("hIncompleteFROCnt",
563  "Number of incomplete full-readout-flagged "
564  "readout units;"
565  "Number of RUs;Event count;",
566  200, -.5, 199.5);
567 
569  = bookProfile2D("hIncompleteFRORateMap",
570  "Incomplete full-readout-flagged readout units;"
571  "iX - 40 / iEta / iX + 20;"
572  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
573  "Incomplete error rate",
574  80, -39.5, 40.5,
575  72, .5, 72.5);
576 
577 
578  meDroppedFROMap_ = book2D("hDroppedFROMap",
579  "Dropped full-readout-flagged readout units;"
580  "iX - 40 / iEta / iX + 20;"
581  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
582  "Event count",
583  80, -39.5, 40.5,
584  72, .5, 72.5);
585 
586  meDroppedFROCnt_ = book1D("hDroppedFROCnt",
587  "Number of dropped full-readout-flagged "
588  "RU count;RU count;Event count",
589  200, -.5, 199.5);
590 
591  meCompleteZSCnt_ = book1D("hCompleteZsCnt",
592  "Number of zero-suppressed-flagged RU fully "
593  "readout;"
594  "RU count;Event count",
595  200, -.5, 199.5);
596 
597  stringstream buf;
598  buf << "Number of LI EB channels below the " << ebZsThr_/4. << " ADC count ZS threshold;"
599  "Channel count;Event count",
600  meEbZsErrCnt_ = book1D("hEbZsErrCnt",
601  buf.str().c_str(),
602  200, -.5, 199.5);
603 
604  buf.str("");
605  buf << "Number of LI EE channels below the " << eeZsThr_/4. << " ADC count ZS theshold;"
606  "Channel count;Event count",
607  meEeZsErrCnt_ = book1D("hEeZsErrCnt",
608  buf.str().c_str(),
609  200, -.5, 199.5);
610 
611  meZsErrCnt_ = book1D("hZsErrCnt",
612  "Number of LI channels below the ZS threshold;"
613  "Channel count;Event count",
614  200, -.5, 199.5);
615 
616  meEbZsErrType1Cnt_ = book1D("hEbZsErrType1Cnt",
617  "Number of EB channels below the ZS "
618  "threshold in a LI but fully readout RU;"
619  "Channel count;Event count;",
620  200, -.5, 199.5);
621 
622  meEeZsErrType1Cnt_ = book1D("hEeZsErrType1Cnt",
623  "Number EE channels below the ZS threshold"
624  " in a LI but fully readout RU;"
625  "Channel count;Event count",
626  200, -.5, 199.5);
627 
628  meZsErrType1Cnt_ = book1D("hZsErrType1Cnt",
629  "Number of LI channels below the ZS threshold "
630  "in a LI but fully readout RU;"
631  "Channel count;Event count",
632  200, -.5, 199.5);
633 
634 
636  = bookProfile2D("hDroppedFRORateMap",
637  "Dropped full-readout-flagged readout units"
638  "iX - 40 / iEta / iX + 20;"
639  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
640  "Dropping rate",
641  80, -39.5, 40.5,
642  72, .5, 72.5);
643 
644  meCompleteZSMap_ = book2D("hCompleteZSMap",
645  "Complete zero-suppressed-flagged readout units;"
646  "iX - 40 / iEta / iX + 20;"
647  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
648  "Event count",
649  80, -39.5, 40.5,
650  72, .5, 72.5);
651 
653  = bookProfile2D("hCompleteZSRate",
654  "Complete zero-suppressed-flagged readout units;"
655  "iX - 40 / iEta / iX + 20;"
656  "iY / iPhi (iPhi = 1 at phi = 0 rad);"
657  "Completeness rate",
658  80, -39.5, 40.5,
659  72, .5, 72.5);
660 
661  //print list of available histograms (must be called after
662  //the bookXX methods):
664 
665  //check the histList parameter:
666  stringstream s;
667  for(set<string>::iterator it = histList_.begin();
668  it!=histList_.end();
669  ++it){
670  if(*it!=string("all")
671  && availableHistList_.find(*it)==availableHistList_.end()){
672  s << (s.str().size()==0?"":", ") << *it;
673  }
674  }
675  if(s.str().size()!=0){
676  LogWarning("Configuration")
677  << "Parameter 'histList' contains some unknown histogram(s). "
678  "Check spelling. Following name were not found: "
679  << s.str();
680  }
681 }
682 
683 
685  const int32_t bx = event.bunchCrossing();
686  if(bx<1 || bx > 3564) return;//throw cms::Exception("EcalSelectiveReadoutValidation")
687  // << "bx value, " << bx << " is out of range\n";
688 
689  int64_t t = event.bunchCrossing() + (event.orbitNumber()-1)*3564;
690 
691  if(t<tmin){
692  tmin = t;
693  l1aOfTmin = event.id().event();
694  }
695 
696  if(t>tmax){
697  tmax = t;
698  l1aOfTmax = event.id().event();
699  }
700 }
701 
703  LogDebug("EcalSrValid") << __FILE__ << ":" << __LINE__ << ": "
704  << "Tmax = " << tmax << " x 25ns; Tmin = " << tmin
705  << " x 25ns; L1A(Tmax) = " << l1aOfTmax << "; L1A(Tmin) = "
706  << l1aOfTmin << "\n";
707  return (double)(l1aOfTmax - l1aOfTmin) / ((tmax-tmin) * 25e-9);
708 }
709 
711  EventSetup const & es){
712 
713  updateL1aRate(event);
714 
715  {
716  PgTiming t("collection readout");
717 
718  //retrieves event products:
719  readAllCollections(event);
720 
721  }
722 
723  withEeSimHit_ = (eeSimHits_->size()!=0);
724  withEbSimHit_ = (ebSimHits_->size()!=0);
725 
726  if(ievt_<10){
727  edm::LogInfo("EcalSrValid") << "Size of TP collection: " << tps_->size() << "\n"
728  << "Size of EB SRF collection read from data: "
729  << ebSrFlags_->size() << "\n"
730  << "Size of EB SRF collection computed from data TTFs: "
731  << ebComputedSrFlags_->size() << "\n"
732  << "Size of EE SRF collection read from data: "
733  << eeSrFlags_->size() << "\n"
734  << "Size of EE SRF collection computed from data TTFs: "
735  << eeComputedSrFlags_->size() << "\n";
736  }
737 
738  if(ievt_==0){
739  selectFedsForLog(); //note: must be called after readAllCollection
740  }
741 
742  //computes Et sum trigger tower crystals:
744 
745  {
746  PgTiming t("data volume analysis");
747 
748  //Data Volume
749  analyzeDataVolume(event, es);
750  }
751 
752  {
753  PgTiming t("EB analysis");
754  //EB digis
755  //must be called after analyzeDataVolume because it uses
756  //isRuComplete_ array that this method fills
757  analyzeEB(event, es);
758  }
759 
760  {
761  PgTiming t("EE analysis");
762  //EE digis
763  //must be called after analyzeDataVolume because it uses
764  //isRuComplete_ array that this method fills
765  analyzeEE(event, es);
766  }
767 
771 
775 
779 
780  {
781  PgTiming t("TP analysis");
782  //TP
783  analyzeTP(event, es);
784  }
785 
786  //SR Consistency and validation
787  //SRFlagValidation(event,es);
788  if(ebComputedSrFlags_->size()){
790  }
791  if(eeComputedSrFlags_->size()){
793  }
794  nDroppedFRO_ = 0;
795  nIncompleteFRO_ = 0;
796  nCompleteZS_ = 0;
802  ++ievt_;
803 }
804 
805 
807  const edm::EventSetup& es){
808  bool eventError = false;
809  nEeZsErrors_ = 0;
810 
811  {
812  PgTiming t("analyzeEE: init");
813  for(int iZ0=0; iZ0<nEndcaps; ++iZ0){
814  for(int iX0=0; iX0<nEeX; ++iX0){
815  for(int iY0=0; iY0<nEeY; ++iY0){
816  eeEnergies[iZ0][iX0][iY0].noZsRecE = -numeric_limits<double>::max();
817  eeEnergies[iZ0][iX0][iY0].recE = -numeric_limits<double>::max();
818  eeEnergies[iZ0][iX0][iY0].simE = 0; //must be set to zero.
819  eeEnergies[iZ0][iX0][iY0].simHit = 0;
820  eeEnergies[iZ0][iX0][iY0].gain12 = false;
821  }
822  }
823  }
824  }
825 
826  // gets the endcap geometry:
827  edm::ESHandle<CaloGeometry> geoHandle;
828  es.get<MyCaloGeometryRecord>().get(geoHandle);
829  const CaloSubdetectorGeometry *geometry_p
830  = (*geoHandle).getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
831  CaloSubdetectorGeometry const& geometry = *geometry_p;
832 
833  {
834  PgTiming t("analyzeEE: unsupressed digis");
835  //EE unsupressed digis:
836  for (unsigned int digis=0; digis<eeNoZsDigis_->size(); ++digis){
837 
838  EEDataFrame frame = (*eeNoZsDigis_)[digis];
839  int iX0 = iXY2cIndex(frame.id().ix());
840  int iY0 = iXY2cIndex(frame.id().iy());
841  int iZ0 = frame.id().zside()>0?1:0;
842 
843  if(iX0<0 || iX0>=nEeX){
844  edm::LogError("EcalSrValid") << "iX0 (= " << iX0 << ") is out of range ("
845  << "[0," << nEeX -1 << "]\n";
846  }
847  if(iY0<0 || iY0>=nEeY){
848  edm::LogError("EcalSrValid") << "iY0 (= " << iY0 << ") is out of range ("
849  << "[0," << nEeY -1 << "]\n";
850  }
851  // cout << "EE no ZS energy computation..." ;
852  eeEnergies[iZ0][iX0][iY0].noZsRecE = frame2Energy(frame);
853 
854  eeEnergies[iZ0][iX0][iY0].gain12 = true;
855  for(int i = 0; i< frame.size(); ++i){
856  const int gain12Code = 0x1;
857  if(frame[i].gainId()!=gain12Code) eeEnergies[iZ0][iX0][iY0].gain12 = false;
858  }
859 
860  const GlobalPoint xtalPos
861  = geometry.getGeometry(frame.id())->getPosition();
862 
863  eeEnergies[iZ0][iX0][iY0].phi = rad2deg*((double)xtalPos.phi());
864  eeEnergies[iZ0][iX0][iY0].eta = xtalPos.eta();
865  }
866  }
867 
868  {
869  PgTiming t("analyzeEE:rec hits");
870  //EE rec hits:
871  if(!localReco_){
873  = eeRecHits_->begin();
874  it != eeRecHits_->end(); ++it){
875  const RecHit& hit = *it;
876  int iX0 = iXY2cIndex(static_cast<const EEDetId&>(hit.id()).ix());
877  int iY0 = iXY2cIndex(static_cast<const EEDetId&>(hit.id()).iy());
878  int iZ0 = static_cast<const EEDetId&>(hit.id()).zside()>0?1:0;
879 
880  if(iX0<0 || iX0>=nEeX){
881  LogError("EcalSrValid") << "iX0 (= " << iX0 << ") is out of range ("
882  << "[0," << nEeX -1 << "]\n";
883  }
884  if(iY0<0 || iY0>=nEeY){
885  LogError("EcalSrValid") << "iY0 (= " << iY0 << ") is out of range ("
886  << "[0," << nEeY -1 << "]\n";
887  }
888  // cout << "EE no ZS energy computation..." ;
889  eeEnergies[iZ0][iX0][iY0].recE = hit.energy();
890  }
891  }
892  }
893 
894  {
895  PgTiming t("analyzeEE:sim hits");
896  //EE sim hits:
897  for(vector<PCaloHit>::const_iterator it = eeSimHits_->begin();
898  it != eeSimHits_->end(); ++it){
899  const PCaloHit& simHit = *it;
900  EEDetId detId(simHit.id());
901  int iX = detId.ix();
902  int iX0 =iXY2cIndex(iX);
903  int iY = detId.iy();
904  int iY0 = iXY2cIndex(iY);
905  int iZ0 = detId.zside()>0?1:0;
906  eeEnergies[iZ0][iX0][iY0].simE += simHit.energy();
907  ++eeEnergies[iZ0][iX0][iY0].simHit;
908  }
909  }
910 
911  {
912  PgTiming t("analyzeEE: suppressed digis");
913 
914  //EE suppressed digis
916  it != eeDigis_->end(); ++it){
917  const EEDataFrame& frame = *it;
918  int iX0 = iXY2cIndex(static_cast<const EEDetId&>(frame.id()).ix());
919  int iY0 = iXY2cIndex(static_cast<const EEDetId&>(frame.id()).iy());
920  int iZ0 = static_cast<const EEDetId&>(frame.id()).zside()>0?1:0;
921  if(iX0<0 || iX0>=nEeX){
922  LogError("EcalSrValid") << "iX0 (= " << iX0 << ") is out of range ("
923  << "[0," << nEeX -1 << "]\n";
924  }
925  if(iY0<0 || iY0>=nEeY){
926  LogError("EcalSrValid") << "iY0 (= " << iY0 << ") is out of range ("
927  << "[0," << nEeY -1 << "]\n";
928  }
929 
930  if(localReco_){
931  eeEnergies[iZ0][iX0][iY0].recE = frame2Energy(frame);
932  }
933 
934  eeEnergies[iZ0][iX0][iY0].gain12 = true;
935  for(int i = 0; i< frame.size(); ++i){
936  const int gain12Code = 0x1;
937  if(frame[i].gainId()!=gain12Code){
938  eeEnergies[iZ0][iX0][iY0].gain12 = false;
939  }
940  }
941 
942  fill(meChOcc_, xtalGraphX(frame.id()), xtalGraphY(frame.id()));
943 
945  = eeSrFlags_->find(readOutUnitOf(frame.id()));
946 
947  bool highInterest = false;
948 
949 
950  if(srf==eeSrFlags_->end()) continue;
951 
952  if(srf!=eeSrFlags_->end()){
953  highInterest = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK)
955  }
956 
957  if(highInterest){
959  } else{
960  int v = dccZsFIR(frame, firWeights_, firstFIRSample_, 0);
961  fill(meEeLiZsFir_, v);
962  if(v < eeZsThr_){
963  eventError = true;
964  ++nEeZsErrors_;
965  pair<int,int> ru = dccCh(frame.id());
966  if(isRuComplete_[ru.first][ru.second-1]) ++nEeZsErrorsType1_;
967  if(nEeZsErrors_ < 3){
968  srApplicationErrorLog_ << event.id() << ", "
969  << "RU " << frame.id() << ", "
970  << "DCC " << ru.first
971  << " Ch : " << ru.second << ": "
972  << "LI channel under ZS threshold.\n";
973  }
974  if(nEeZsErrors_==3){
975  srApplicationErrorLog_ << event.id() << ": "
976  << "more ZS errors for this event...\n";
977  }
978  }
979  }
980  } //next ZS digi.
981  }
982 
983  {
984  PgTiming t("analyzeEE: energies");
985 
986  for(int iZ0=0; iZ0<nEndcaps; ++iZ0){
987  for(int iX0=0; iX0<nEeX; ++iX0){
988  for(int iY0=0; iY0<nEeY; ++iY0){
989  double recE = eeEnergies[iZ0][iX0][iY0].recE;
990  if(recE==-numeric_limits<double>::max()) continue; //not a crystal or ZS
991  fill(meEeRecE_, eeEnergies[iZ0][iX0][iY0].recE);
992 
993  fill(meEeEMean_, ievt_+1,
994  eeEnergies[iZ0][iX0][iY0].recE);
995 
996  if(withEeSimHit_){
997  if(!eeEnergies[iZ0][iX0][iY0].simHit){//noise only crystal channel
998  fill(meEeNoise_, eeEnergies[iZ0][iX0][iY0].noZsRecE);
999  } else{
1000  fill(meEeSimE_, eeEnergies[iZ0][iX0][iY0].simE);
1001  fill(meEeRecEHitXtal_, eeEnergies[iZ0][iX0][iY0].recE);
1002  }
1003  fill(meEeRecVsSimE_, eeEnergies[iZ0][iX0][iY0].simE,
1004  eeEnergies[iZ0][iX0][iY0].recE);
1005  fill(meEeNoZsRecVsSimE_, eeEnergies[iZ0][iX0][iY0].simE,
1006  eeEnergies[iZ0][iX0][iY0].noZsRecE);
1007  }
1008  }
1009  }
1010  }
1011  }
1012 
1013  {
1014  PgTiming t("analyzeEE: RU");
1015 
1016  nEeFROCnt_ = 0;
1017  char eeSrfMark[2][100][100];
1018  bzero(eeSrfMark, sizeof(eeSrfMark));
1019  //Filling RU histo
1021  it != eeSrFlags_->end(); ++it){
1022  const EESrFlag& srf = *it;
1023  int iX = srf.id().ix();
1024  int iY = srf.id().iy();
1025  int iZ = srf.id().zside(); //-1 for EE-, +1 for EE+
1026  if(iX<1 || iY > 100) throw cms::Exception("EcalSelectiveReadoutValidation")
1027  << "Found an endcap SRF with an invalid det ID: " << srf.id() << ".\n";
1028  ++eeSrfMark[iZ>0?1:0][iX-1][iY-1];
1029  if(eeSrfMark[iZ>0?1:0][iX-1][iY-1] > 1) throw cms::Exception("EcalSelectiveReadoutValidation")
1030  << "Duplicate SRF for supercrystal " << srf.id() << ".\n";
1031  int flag = srf.value() & ~EcalSrFlag::SRF_FORCED_MASK;
1032  if(flag == EcalSrFlag::SRF_ZS1){
1033  fill(meZs1Ru_, ruGraphX(srf.id()), ruGraphY(srf.id()));
1034  }
1035 
1036  if(flag == EcalSrFlag::SRF_FULL){
1037  fill(meFullRoRu_, ruGraphX(srf.id()), ruGraphY(srf.id()));
1038  ++nEeFROCnt_;
1039  }
1040 
1041  if(srf.value() & EcalSrFlag::SRF_FORCED_MASK){
1042  fill(meForcedRu_, ruGraphX(srf.id()), ruGraphY(srf.id()));
1043  }
1044  }
1045  }
1046 
1047  {
1048  PgTiming t("analyzeEE: SR appli error log");
1049 
1050  if(eventError) srApplicationErrorLog_ << event.id()
1051  << ": " << nEeZsErrors_
1052  << " ZS-flagged EE channels under "
1053  "the ZS threshold, whose " << nEeZsErrorsType1_
1054  << " in a complete RU.\n";
1055  }
1056 } //end of analyzeEE
1057 
1058 void
1060  const edm::EventSetup& es){
1061 
1062  bool eventError = false;
1063  nEbZsErrors_ = 0;
1064  vector<pair<int,int> > xtalEtaPhi;
1065 
1066  {
1067  PgTiming t("analyzeEB: init");
1068 
1069  xtalEtaPhi.reserve(nEbPhi*nEbEta);
1070  for(int iEta0=0; iEta0<nEbEta; ++iEta0){
1071  for(int iPhi0=0; iPhi0<nEbPhi; ++iPhi0){
1072  ebEnergies[iEta0][iPhi0].noZsRecE = -numeric_limits<double>::max();
1073  ebEnergies[iEta0][iPhi0].recE = -numeric_limits<double>::max();
1074  ebEnergies[iEta0][iPhi0].simE = 0; //must be zero.
1075  ebEnergies[iEta0][iPhi0].simHit = 0;
1076  ebEnergies[iEta0][iPhi0].gain12 = false;
1077  xtalEtaPhi.push_back(pair<int,int>(iEta0, iPhi0));
1078  }
1079  }
1080  }
1081 
1082  // get the barrel geometry:
1083  edm::ESHandle<CaloGeometry> geoHandle;
1084 
1085  PgTiming t1("analyzeEB: geomRetrieval");
1086  es.get<MyCaloGeometryRecord>().get(geoHandle);
1087  const CaloSubdetectorGeometry *geometry_p
1088  = (*geoHandle).getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
1089  CaloSubdetectorGeometry const& geometry = *geometry_p;
1090  t1.stop();
1091 
1092 
1093  {
1094  PgTiming t("analyzeEB: unsuppressed digi loop");
1095  //EB unsuppressed digis:
1097  it != ebNoZsDigis_->end(); ++it){
1098  const EBDataFrame& frame = *it;
1099  int iEta0 = iEta2cIndex(static_cast<const EBDetId&>(frame.id()).ieta());
1100  int iPhi0 = iPhi2cIndex(static_cast<const EBDetId&>(frame.id()).iphi());
1101  if(iEta0<0 || iEta0>=nEbEta){
1102  stringstream s;
1103  s << "EcalSelectiveReadoutValidation: "
1104  << "iEta0 (= " << iEta0 << ") is out of range ("
1105  << "[0," << nEbEta -1 << "]\n";
1106  throw cms::Exception(s.str());
1107  }
1108  if(iPhi0<0 || iPhi0>=nEbPhi){
1109  stringstream s;
1110  s << "EcalSelectiveReadoutValidation: "
1111  << "iPhi0 (= " << iPhi0 << ") is out of range ("
1112  << "[0," << nEbPhi -1 << "]\n";
1113  throw cms::Exception(s.str());
1114  }
1115 
1116  ebEnergies[iEta0][iPhi0].noZsRecE = frame2Energy(frame);
1117  ebEnergies[iEta0][iPhi0].gain12 = true;
1118  for(int i = 0; i< frame.size(); ++i){
1119  const int gain12Code = 0x1;
1120  if(frame[i].gainId()!=gain12Code) ebEnergies[iEta0][iPhi0].gain12 = false;
1121  }
1122 
1123  const GlobalPoint xtalPos
1124  = geometry.getGeometry(frame.id())->getPosition();
1125 
1126  ebEnergies[iEta0][iPhi0].phi = rad2deg*((double)xtalPos.phi());
1127  ebEnergies[iEta0][iPhi0].eta = xtalPos.eta();
1128  } //next non-zs digi
1129  }
1130 
1131 
1132  {
1133  PgTiming t("analyzeEB: simHit loop");
1134  //EB sim hits
1135  for(vector<PCaloHit>::const_iterator it = ebSimHits_->begin();
1136  it != ebSimHits_->end(); ++it){
1137  const PCaloHit& simHit = *it;
1138  EBDetId detId(simHit.id());
1139  int iEta = detId.ieta();
1140  int iEta0 =iEta2cIndex(iEta);
1141  int iPhi = detId.iphi();
1142  int iPhi0 = iPhi2cIndex(iPhi);
1143  ebEnergies[iEta0][iPhi0].simE += simHit.energy();
1144  ++ebEnergies[iEta0][iPhi0].simHit;
1145  }
1146  }
1147 
1148  bool crystalShot[nEbEta][nEbPhi];
1149  {
1150  PgTiming t("analyzeEB: suppressed digi loop init");
1151 
1152  for(int iEta0=0; iEta0<nEbEta; ++iEta0){
1153  for(int iPhi0=0; iPhi0<nEbPhi; ++iPhi0){
1154  crystalShot[iEta0][iPhi0] = false;
1155  }
1156  }
1157  }
1158 
1159  int nEbDigi = 0;
1160 
1161  {
1162  PgTiming t("analyzeEB: suppressed digi loop");
1163 
1165  it != ebDigis_->end(); ++it){
1166  ++nEbDigi;
1167  const EBDataFrame& frame = *it;
1168  int iEta = static_cast<const EBDetId&>(frame.id()).ieta();
1169  int iPhi = static_cast<const EBDetId&>(frame.id()).iphi();
1170  int iEta0 = iEta2cIndex(iEta);
1171  int iPhi0 = iPhi2cIndex(iPhi);
1172  if(iEta0<0 || iEta0>=nEbEta){
1173  throw (cms::Exception("EcalSelectiveReadoutValidation")
1174  << "iEta0 (= " << iEta0 << ") is out of range ("
1175  << "[0," << nEbEta -1 << "]");
1176  }
1177  if(iPhi0<0 || iPhi0>=nEbPhi){
1178  throw (cms::Exception("EcalSelectiveReadoutValidation")
1179  << "iPhi0 (= " << iPhi0 << ") is out of range ("
1180  << "[0," << nEbPhi -1 << "]");
1181  }
1182  assert(iEta0>=0 && iEta0<nEbEta);
1183  assert(iPhi0>=0 && iPhi0<nEbPhi);
1184  if(!crystalShot[iEta0][iPhi0]){
1185  crystalShot[iEta0][iPhi0] = true;
1186  } else{
1187  cout << "Error: several digi for same crystal!";
1188  abort();
1189  }
1190  if(localReco_){
1191  ebEnergies[iEta0][iPhi0].recE = frame2Energy(frame);
1192  }
1193 
1194  ebEnergies[iEta0][iPhi0].gain12 = true;
1195  for(int i = 0; i< frame.size(); ++i){
1196  const int gain12Code = 0x1;
1197  if(frame[i].gainId()!=gain12Code){
1198  ebEnergies[iEta0][iPhi0].gain12 = false;
1199  }
1200  }
1201 
1202  fill(meChOcc_, xtalGraphX(frame.id()), xtalGraphY(frame.id()));
1204  = ebSrFlags_->find(readOutUnitOf(frame.id()));
1205 
1206  bool highInterest = false;
1207 
1208  // if(srf == ebSrFlags_->end()){
1209  // throw cms::Exception("EcalSelectiveReadoutValidation")
1210  // << __FILE__ << ":" << __LINE__ << ": SR flag not found";
1211  //}
1212 
1213  if(srf != ebSrFlags_->end()){
1214  highInterest = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK)
1216  }
1217 
1218 
1219  if(highInterest){
1221  } else{
1222  int v = dccZsFIR(frame, firWeights_, firstFIRSample_, 0);
1223  fill(meEbLiZsFir_, v);
1224  if(v < ebZsThr_){
1225  eventError = true;
1226  ++nEbZsErrors_;
1227  pair<int,int> ru = dccCh(frame.id());
1228  if(isRuComplete_[ru.first][ru.second-1]) ++nEbZsErrorsType1_;
1229  if(nEbZsErrors_ < 3){
1230  srApplicationErrorLog_ << event.id() << ", "
1231  << "RU " << frame.id() << ", "
1232  << "DCC " << ru.first
1233  << " Ch : " << ru.second << ": "
1234  << "LI channel under ZS threshold.\n";
1235  }
1236  if(nEbZsErrors_==3){
1237  srApplicationErrorLog_ << event.id() << ": "
1238  << "more ZS errors for this event...\n";
1239  }
1240  }
1241  }
1242  } //next EB digi
1243  }
1244 
1245 
1246  {
1247  PgTiming t("analyzeEB: rec hit loop");
1248 
1249  if(!localReco_){
1251  = ebRecHits_->begin();
1252  it != ebRecHits_->end(); ++it){
1253  ++nEbDigi;
1254  const RecHit& hit = *it;
1255  int iEta = static_cast<const EBDetId&>(hit.id()).ieta();
1256  int iPhi = static_cast<const EBDetId&>(hit.id()).iphi();
1257  int iEta0 = iEta2cIndex(iEta);
1258  int iPhi0 = iPhi2cIndex(iPhi);
1259  if(iEta0<0 || iEta0>=nEbEta){
1260  LogError("EcalSrValid") << "iEta0 (= " << iEta0 << ") is out of range ("
1261  << "[0," << nEbEta -1 << "]\n";
1262  }
1263  if(iPhi0<0 || iPhi0>=nEbPhi){
1264  LogError("EcalSrValid") << "iPhi0 (= " << iPhi0 << ") is out of range ("
1265  << "[0," << nEbPhi -1 << "]\n";
1266  }
1267  ebEnergies[iEta0][iPhi0].recE = hit.energy();
1268  }
1269  }
1270  }
1271 
1272 
1273 // {
1274 // PgTiming t("analyzeEB: crystal sorting");
1275 
1276 // //sorts crystal in increasing sim hit energy. ebEnergies[][].simE
1277 // //must be set beforehand:
1278 // sort(xtalEtaPhi.begin(), xtalEtaPhi.end(), Sorter(this));
1279 // cout << "\niEta\tiPhi\tsimE\tnoZsE\tzsE\n";
1280 // }
1281 
1282 
1283  {
1284  PgTiming t("analyzeEB: loop on energies");
1285 
1286  for(unsigned int i=0; i<xtalEtaPhi.size(); ++i){
1287  int iEta0 = xtalEtaPhi[i].first;
1288  int iPhi0= xtalEtaPhi[i].second;
1289  energiesEb_t& energies = ebEnergies[iEta0][iPhi0];
1290 
1291  double recE = energies.recE;
1292  if(recE!=-numeric_limits<double>::max()){//not zero suppressed
1293  fill(meEbRecE_, ebEnergies[iEta0][iPhi0].recE);
1294  fill(meEbEMean_, ievt_+1, recE);
1295  } //not zero suppressed
1296 
1297  if(withEbSimHit_){
1298  if(!energies.simHit){//noise only crystal channel
1299  fill(meEbNoise_, energies.noZsRecE);
1300  } else{
1301  fill(meEbSimE_, energies.simE);
1302  fill(meEbRecEHitXtal_, energies.recE);
1303  }
1304  fill(meEbRecVsSimE_, energies.simE, energies.recE);
1305  fill(meEbNoZsRecVsSimE_, energies.simE, energies.noZsRecE);
1306  }
1307  }
1308  }
1309 
1310  {
1311  PgTiming t("analyzeEB: SRF");
1312  //SRF
1313  nEbFROCnt_ = 0;
1314  char ebSrfMark[2][17][72];
1315  bzero(ebSrfMark, sizeof(ebSrfMark));
1316  // int idbg = 0;
1318  it != ebSrFlags_->end(); ++it){
1319  const EBSrFlag& srf = *it;
1320  int iEtaAbs = srf.id().ietaAbs();
1321  int iPhi = srf.id().iphi();
1322  int iZ = srf.id().zside();
1323 
1324 // cout << "--> " << ++idbg << iEtaAbs << " " << iPhi << " " << iZ
1325 // << " " << srf.id() << "\n";
1326 
1327  if(iEtaAbs < 1 || iEtaAbs > 17
1328  || iPhi < 1 || iPhi > 72) throw cms::Exception("EcalSelectiveReadoutValidation")
1329  << "Found a barrel SRF with an invalid det ID: " << srf.id() << ".\n";
1330  ++ebSrfMark[iZ>0?1:0][iEtaAbs-1][iPhi-1];
1331  if(ebSrfMark[iZ>0?1:0][iEtaAbs-1][iPhi-1] > 1) throw cms::Exception("EcalSelectiveReadoutValidation")
1332  << "Duplicate SRF for RU " << srf.id() << ".\n";
1333  int flag = srf.value() & ~EcalSrFlag::SRF_FORCED_MASK;
1334  if(flag == EcalSrFlag::SRF_ZS1){
1335  fill(meZs1Ru_, ruGraphX(srf.id()), ruGraphY(srf.id()));
1336  }
1337  if(flag == EcalSrFlag::SRF_FULL){
1338  fill(meFullRoRu_, ruGraphX(srf.id()), ruGraphY(srf.id()));
1339  ++nEbFROCnt_;
1340  }
1341  if(srf.value() & EcalSrFlag::SRF_FORCED_MASK){
1342  fill(meForcedRu_, ruGraphX(srf.id()), ruGraphY(srf.id()));
1343  }
1344  }
1345  }
1346 
1347  {
1348  PgTiming t("analyzeEB: logSRerror");
1349 
1350  if(eventError) srApplicationErrorLog_ << event.id()
1351  << ": " << nEbZsErrors_
1352  << " ZS-flagged EB channels under "
1353  "the ZS threshold, whose " << nEbZsErrorsType1_
1354  << " in a complete RU.\n";
1355  }
1356 }
1357 
1359 }
1360 
1362  // endcap mapping
1364  es.get<IdealGeometryRecord>().get(hTriggerTowerMap);
1365  triggerTowerMap_ = hTriggerTowerMap.product();
1366 
1367  //electronics map
1369  es.get< EcalMappingRcd >().get(ecalmapping);
1370  elecMap_ = ecalmapping.product();
1371 
1372  initAsciiFile();
1373 }
1374 
1378  if(outputFile_.size()!=0) dbe_->save(outputFile_);
1379 }
1380 
1381 void
1383  edm::EventSetup const & es){
1384  EcalTPGScale ecalScale;
1385 #if (CMSSW_COMPAT_VERSION>=210)
1386  ecalScale.setEventSetup(es) ;
1387 #endif
1388 
1389  // std::cout << __FILE__ << __LINE__
1390  // << "n TP: " << tps_->size() <<std::endl;
1391 
1393  it != tps_->end(); ++it){
1394  // for(int i = 0; i < it->size(); ++i){
1395  // double v = (*it)[i].raw() & 0xFF;
1396  // if(v>0) std::cout << v << " " << i << std::endl;
1397  //}
1398  // if(it->compressedEt() > 0){
1399  // std::cout << "---------> " << it->id().ieta() << ", "
1400  // << it->id().iphi() << ", "
1401  // << it->compressedEt() << std::endl;
1402  //}
1403 
1404  //const int iTcc = elecMap_->TCCid(it->id());
1405  //const int iTt = elecMap_->iTt(it->id());
1406  double tpEt;
1407  if(tpInGeV_){
1408 #if (CMSSW_COMPAT_VERSION<210)
1409  tpEt = ecalScale.getTPGInGeV(es, *it);
1410 #else
1411  tpEt = ecalScale.getTPGInGeV(it->compressedEt(), it->id()) ;
1412 #endif
1413  } else{
1414  tpEt = it->compressedEt();
1415  }
1416  int iEta = it->id().ieta();
1417  int iEta0 = iTtEta2cIndex(iEta);
1418  int iPhi = it->id().iphi();
1419  int iPhi0 = iTtEta2cIndex(iPhi);
1420  double etSum = ttEtSums[iEta0][iPhi0];
1421  fill(meTp_, tpEt);
1422  fill(meTpVsEtSum_, etSum, tpEt);
1423  fill(meTtf_, it->ttFlag());
1424  if((it->ttFlag() & 0x3) == 0){
1425  fill(meLiTtf_, iEta, iPhi);
1426  }
1427  if((it->ttFlag() & 0x3) == 1){
1428  fill(meMiTtf_, iEta, iPhi);
1429  }
1430  if((it->ttFlag() & 0x3) == 3){
1431  fill(meHiTtf_, iEta, iPhi);
1432  }
1433  if((it->ttFlag() & 0x4)){
1434  fill(meForcedTtf_, iEta, iPhi);
1435  }
1436 
1437  fill(meTtfVsTp_, tpEt, it->ttFlag());
1438  fill(meTtfVsEtSum_, etSum, it->ttFlag());
1439  fill(meTpMap_, iEta, iPhi, tpEt, 1.);
1440  }
1441 }
1442 
1444  const EventSetup& es){
1445 
1446  anaDigiInit();
1447 
1448 
1449  //Complete RU, i.e. RU actually fully readout
1450  for(int iDcc = minDccId_; iDcc <= maxDccId_; ++iDcc){
1451  for(int iCh = 1; iCh < nDccRus_[iDcc-minDccId_]; ++iCh){
1452  isRuComplete_[iDcc-minDccId_][iCh-1]
1453  = (nPerRu_[iDcc-minDccId_][iCh-1]==getCrystalCount(iDcc, iCh));
1454  }
1455  }
1456 
1457 
1458  //Barrel
1459  for (unsigned int digis=0; digis<ebDigis_->size(); ++digis){
1460  EBDataFrame ebdf = (*ebDigis_)[digis];
1461  anaDigi(ebdf, *ebSrFlags_);
1462  }
1463 
1464  // Endcap
1465  for (unsigned int digis=0; digis<eeDigis_->size(); ++digis){
1466  EEDataFrame eedf = (*eeDigis_)[digis];
1467  anaDigi(eedf, *eeSrFlags_);
1468  }
1469 
1470  //histos
1471  for(unsigned iDcc0 = 0; iDcc0 < nDccs_; ++iDcc0){
1472  fill(meDccVol_, iDcc0+1, getDccEventSize(iDcc0, nPerDcc_[iDcc0])/kByte_);
1473  fill(meDccLiVol_, iDcc0+1,
1474  getDccSrDependentPayload(iDcc0, nLiRuPerDcc_[iDcc0],
1475  nLiPerDcc_[iDcc0])/kByte_);
1476  fill(meDccHiVol_, iDcc0+1,
1477  getDccSrDependentPayload(iDcc0, nHiRuPerDcc_[iDcc0],
1478  nHiPerDcc_[iDcc0])/kByte_);
1479  const FEDRawDataCollection& raw = *fedRaw_;
1480  fill(meDccVolFromData_, iDcc0+1,
1481  ((double)raw.FEDData(601+iDcc0).size())/kByte_);
1482  }
1483 
1484 
1485  //low interesest channels:
1486  double a = nEbLI_*getBytesPerCrystal()/kByte_; //getEbEventSize(nEbLI_)/kByte_;
1487  fill(meVolBLI_, a);
1488  double b = nEeLI_*getBytesPerCrystal()/kByte_; //getEeEventSize(nEeLI_)/kByte_;
1489  fill(meVolELI_, b);
1490  fill(meVolLI_, a+b);
1491 
1492  //high interest chanels:
1493  a = nEbHI_*getBytesPerCrystal()/kByte_; //getEbEventSize(nEbHI_)/kByte_;
1494  fill(meVolBHI_, a);
1495  b = nEeHI_*getBytesPerCrystal()/kByte_; //getEeEventSize(nEeHI_)/kByte_;
1496  fill(meVolEHI_, b);
1497  fill(meVolHI_, a+b);
1498 
1499  //any-interest channels:
1500  a = getEbEventSize(nEb_)/kByte_;
1501  fill(meVolB_, a);
1502  b = getEeEventSize(nEe_)/kByte_;
1503  fill(meVolE_, b);
1504  fill(meVol_, a+b);
1505 }
1506 
1507 
1508 template<class T, class U>
1510  const U& srFlagColl){
1511  const DetId& xtalId = frame.id();
1512  typedef typename U::key_type RuDetId;
1513  const RuDetId& ruId = readOutUnitOf(frame.id());
1514  typename U::const_iterator srf = srFlagColl.find(ruId);
1515 
1516  bool highInterest = false;
1517  int flag = 0;
1518 
1519  if(srf != srFlagColl.end()){
1520  // throw cms::Exception("EcalSelectiveReadoutValidation")
1521  // << __FILE__ << ":" << __LINE__ << ": SR flag not found";
1522  // }
1523 
1524  flag = srf->value() & ~EcalSrFlag::SRF_FORCED_MASK;
1525 
1526  highInterest = (flag == EcalSrFlag::SRF_FULL);
1527 
1528  }
1529 
1530  bool barrel = (xtalId.subdetId()==EcalBarrel);
1531 
1532  pair<int,int> ch = dccCh(xtalId);
1533 
1534  if(barrel){
1535  ++nEb_;
1536  if(highInterest){
1537  ++nEbHI_;
1538  } else{//low interest
1539  ++nEbLI_;
1540  }
1541  int iEta0 = iEta2cIndex(static_cast<const EBDetId&>(xtalId).ieta());
1542  int iPhi0 = iPhi2cIndex(static_cast<const EBDetId&>(xtalId).iphi());
1543  if(!ebRuActive_[iEta0/ebTtEdge][iPhi0/ebTtEdge]){
1544  ++nRuPerDcc_[ch.first-minDccId_];
1545  if(highInterest){
1546  // fill(meFullRoRu_, ruGraphX(ruId), ruGraphY(ruId));
1547  ++nHiRuPerDcc_[ch.first-minDccId_];
1548  } else{
1549  ++nLiRuPerDcc_[ch.first-minDccId_];
1550  }
1551 // if(flag & EcalSrFlag::SRF_FORCED_MASK){
1552 // fill(meForcedRu_, ruGraphX(ruId), ruGraphY(ruId));
1553 // }
1554 // if(flag == EcalSrFlag::SRF_ZS1){
1555 // fill(meZs1Ru_, ruGraphX(ruId), ruGraphY(ruId));
1556 // }
1557  ebRuActive_[iEta0/ebTtEdge][iPhi0/ebTtEdge] = true;
1558  }
1559  } else{//endcap
1560  ++nEe_;
1561  if(highInterest){
1562  ++nEeHI_;
1563  } else{//low interest
1564  ++nEeLI_;
1565  }
1566  int iX0 = iXY2cIndex(static_cast<const EEDetId&>(frame.id()).ix());
1567  int iY0 = iXY2cIndex(static_cast<const EEDetId&>(frame.id()).iy());
1568  int iZ0 = static_cast<const EEDetId&>(frame.id()).zside()>0?1:0;
1569 
1570  if(!eeRuActive_[iZ0][iX0/scEdge][iY0/scEdge]){
1571  ++nRuPerDcc_[ch.first-minDccId_];
1572  if(highInterest){
1573  // fill(meFullRoRu_, ruGraphX(ruId), ruGraphY(ruId));
1574  ++nHiRuPerDcc_[ch.first-minDccId_];
1575  } else{
1576  ++nLiRuPerDcc_[ch.first-minDccId_];
1577  }
1578 // if(flag == EcalSrFlag::SRF_ZS1){
1579 // fill(meZs1Ru_, ruGraphX(ruId), ruGraphY(ruId));
1580 // }
1581 // if(srf->value() & EcalSrFlag::SRF_FORCED_MASK){
1582 // fill(meForcedRu_, ruGraphX(ruId), ruGraphY(ruId));
1583 // }
1584  eeRuActive_[iZ0][iX0/scEdge][iY0/scEdge] = true;
1585  }
1586  }
1587 
1588  if(ch.second < 1 || ch.second > 68){
1589  throw cms::Exception("EcalSelectiveReadoutValidation")
1590  << "Error in DCC channel retrieval for crystal with detId "
1591  << xtalId.rawId() << "DCC channel out of allowed range [1..68]\n";
1592  }
1593  ++nPerDcc_[ch.first-minDccId_];
1594  ++nPerRu_[ch.first-minDccId_][ch.second-1];
1595  if(highInterest){
1596  ++nHiPerDcc_[ch.first-minDccId_];
1597  } else{//low interest channel
1598  ++nLiPerDcc_[ch.first-minDccId_];
1599  }
1600 }
1601 
1603  nEb_ = 0;
1604  nEe_ = 0;
1605  nEeLI_ = 0;
1606  nEeHI_ = 0;
1607  nEbLI_ = 0;
1608  nEbHI_ = 0;
1609  bzero(nPerDcc_, sizeof(nPerDcc_));
1610  bzero(nLiPerDcc_, sizeof(nLiPerDcc_));
1611  bzero(nHiPerDcc_, sizeof(nHiPerDcc_));
1612  bzero(nRuPerDcc_, sizeof(nRuPerDcc_));
1613  bzero(ebRuActive_, sizeof(ebRuActive_));
1614  bzero(eeRuActive_, sizeof(eeRuActive_));
1615  bzero(nPerRu_, sizeof(nPerRu_));
1616  bzero(nLiRuPerDcc_, sizeof(nLiRuPerDcc_));
1617  bzero(nHiRuPerDcc_, sizeof(nHiRuPerDcc_));
1618 }
1619 
1621  static bool firstCall = true;
1622  if(firstCall){
1623  stringstream buf;
1624  buf << "Weights:";
1625  for(unsigned i=0; i<weights_.size();++i){
1626  buf << "\t" << weights_[i];
1627  }
1628  edm::LogInfo("EcalSrValid") << buf.str() << "\n";
1629  firstCall = false;
1630  }
1631  double adc2GeV = 0.;
1632 
1633  if(typeid(EBDataFrame)==typeid(frame)){//barrel APD
1634  adc2GeV = .035;
1635  } else if(typeid(EEDataFrame)==typeid(frame)){//endcap VPT
1636  adc2GeV = 0.06;
1637  } else{
1638  assert(false);
1639  }
1640 
1641  double acc = 0;
1642 
1643  const int n = min(frame.size(), (int)weights_.size());
1644 
1645  double gainInv[] = {12., 1., 6., 12.};
1646 
1647  for(int i=0; i < n; ++i){
1648  acc += weights_[i]*frame[i].adc()*gainInv[frame[i].gainId()]*adc2GeV;
1649  }
1650  return acc;
1651 }
1652 
1654  // static int nEemRu[] = {34, 32, 33, 33, 32, 34, 33, 34, 33};
1655  // static int nEepRu[] = {32, 33, 33, 32, 34, 33, 34, 33, 34};
1656  // if(iDcc0<9){//EE-
1657  // return nEemRu[iDcc0];
1658  // } else if(iDcc0>=45){//EE+
1659  // return nEepRu[iDcc0-45];
1660  // } else{//EB
1661  // return 68;
1662  // }
1663  return nRuPerDcc_[iDcc0];
1664 }
1665 
1666 pair<int,int> EcalSelectiveReadoutValidation::dccCh(const DetId& detId) const{
1667  if(detId.det()!=DetId::Ecal){
1668  throw cms::Exception("InvalidParameter")
1669  << "Wrong type of DetId passed to the "
1670  "EcalSelectiveReadoutValidation::dccCh(const DetId&). "
1671  "An ECAL DetId was expected.\n";
1672  }
1673 
1674  DetId xtalId;
1675  switch(detId.subdetId()){
1676  case EcalTriggerTower: //Trigger tower
1677  {
1678  const EcalTrigTowerDetId tt = detId;
1679  //pick up one crystal of the trigger tower: they are however all readout by
1680  //the same DCC channel in the barrel.
1681  //Arithmetic is easier on the "c" indices:
1682  const int iTtPhi0 = iTtPhi2cIndex(tt.iphi());
1683  const int iTtEta0 = iTtEta2cIndex(tt.ieta());
1684  const int oneXtalPhi0 = iTtPhi0 * 5;
1685  const int oneXtalEta0 = (iTtEta0 - nOneEeTtEta) * 5;
1686 
1687  xtalId = EBDetId(cIndex2iEta(oneXtalEta0),
1688  cIndex2iPhi(oneXtalPhi0));
1689  }
1690  break;
1691  case EcalEndcap:
1692  if(detId.rawId() & 0x8000){ //Supercrystal
1693  return elecMap_->getDCCandSC(EcalScDetId(detId));
1694 // throw cms::Exception("InvalidParameter")
1695 // << "Wrong type of DetId passed to the method "
1696 // "EcalSelectiveReadoutValidation::dccCh(const DetId&). "
1697 // "A valid EcalTriggerTower, EcalBarrel or EcalEndcap DetId was expected. "
1698 // "detid = " << xtalId.rawId() << ".\n";
1699  } else { //EE crystal
1700  xtalId = detId;
1701  }
1702  break;
1703  case EcalBarrel: //EB crystal
1704  xtalId = detId;
1705  break;
1706  default:
1707  throw cms::Exception("InvalidParameter")
1708  << "Wrong type of DetId passed to the method "
1709  "EcalSelectiveReadoutValidation::dccCh(const DetId&). "
1710  "A valid EcalTriggerTower, EcalBarrel or EcalEndcap DetId was expected. "
1711  "detid = " << xtalId.rawId() << ".\n";
1712  }
1713 
1714  const EcalElectronicsId& EcalElecId = elecMap_->getElectronicsId(xtalId);
1715 
1716  pair<int,int> result;
1717  result.first = EcalElecId.dccId();
1718 
1719  if(result.first < minDccId_ || result.second > maxDccId_){
1720  throw cms::Exception("OutOfRange")
1721  << "Got an invalid DCC ID, DCCID = " << result.first
1722  << " for DetId 0x" << hex << detId.rawId()
1723  << " and 0x" << xtalId.rawId() << dec << "\n";
1724  }
1725 
1726  result.second = EcalElecId.towerId();
1727 
1728  if(result.second < 1 || result.second > 68){
1729  throw cms::Exception("OutOfRange")
1730  << "Got an invalid DCC channel ID, DCC_CH = " << result.second
1731  << " for DetId 0x" << hex << detId.rawId()
1732  << " and 0x" << xtalId.rawId() << dec << "\n";
1733  }
1734 
1735  return result;
1736 }
1737 
1740 {
1741 
1742  const int scEdge = 5;
1743  EcalScDetId id = EcalScDetId((xtalId.ix()-1)/scEdge+1,
1744  (xtalId.iy()-1)/scEdge+1,
1745  xtalId.zside());
1746  return id;
1747  /*
1748  const EcalElectronicsId& EcalElecId = elecMap_->getElectronicsId(xtalId);
1749  int iDCC= EcalElecId.dccId();
1750  int iDccChan = EcalElecId.towerId();
1751  const vector<EcalScDetId> id = elecMap_->getEcalScDetId(iDCC, iDccChan);
1752 
1753  if(SkipInnerSC_)
1754  {
1755  if( (id.ix()>=9 && id.ix()<=12) && (id.iy()>=9 && id.iy()<=12) )
1756  return EcalScDetId();
1757  else
1758  return id;
1759  }
1760  else
1761  {
1762  if(id.ix()==9 && id.iy()==9)
1763  return EcalScDetId(2,5,xtalId.zside());
1764  else if(id.ix()==9 && id.iy()==12)
1765  return EcalScDetId(1,13,xtalId.zside());
1766  else if(id.ix()==12 && id.iy()==9)
1767  return EcalScDetId(19,5,xtalId.zside());
1768  else if(id.ix()==12 && id.iy()==12)
1769  return EcalScDetId(20,13,xtalId.zside());
1770  else
1771  return id;
1772  }
1773  */
1774 }
1775 
1776 
1779  return triggerTowerMap_->towerOf(xtalId);
1780 }
1781 
1784  // return superCrystalOf(xtalId);
1785  const EcalElectronicsId& EcalElecId = elecMap_->getElectronicsId(xtalId);
1786  int iDCC= EcalElecId.dccId();
1787  int iDccChan = EcalElecId.towerId();
1788  const bool ignoreSingle = true;
1789  const vector<EcalScDetId> id = elecMap_->getEcalScDetId(iDCC, iDccChan, ignoreSingle);
1790  return id.size()>0?id[0]:EcalScDetId();
1791 }
1792 
1793 void
1795  const EBDigiCollection& ebDigis,
1796  const EEDigiCollection& eeDigis){
1797  //ecal geometry:
1798  static const CaloSubdetectorGeometry* eeGeometry = 0;
1799  static const CaloSubdetectorGeometry* ebGeometry = 0;
1800  if(eeGeometry==0 || ebGeometry==0){
1801  edm::ESHandle<CaloGeometry> geoHandle;
1802  es.get<MyCaloGeometryRecord>().get(geoHandle);
1803  eeGeometry
1804  = (*geoHandle).getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
1805  ebGeometry
1806  = (*geoHandle).getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
1807  }
1808 
1809  //init etSum array:
1810  for(int iEta0 = 0; iEta0 < nTtEta; ++iEta0){
1811  for(int iPhi0 = 0; iPhi0 < nTtPhi; ++iPhi0){
1812  ttEtSums[iEta0][iPhi0] = 0.;
1813  }
1814  }
1815 
1817  it != ebDigis_->end(); ++it){
1818  const EBDataFrame& frame = *it;
1819  const EcalTrigTowerDetId& ttId = triggerTowerMap_->towerOf(frame.id());
1820  // LogDebug("TT")
1821  // << ((EBDetId&)frame.id()).ieta()
1822  // << "," << ((EBDetId&)frame.id()).iphi()
1823  // << " -> " << ttId.ieta() << "," << ttId.iphi();
1824  const int iTtEta0 = iTtEta2cIndex(ttId.ieta());
1825  const int iTtPhi0 = iTtPhi2cIndex(ttId.iphi());
1826  double theta = ebGeometry->getGeometry(frame.id())->getPosition().theta();
1827  double e = frame2EnergyForTp(frame);
1828  if((frame2EnergyForTp(frame,-1) < e) && (frame2EnergyForTp(frame, 1) < e)){
1829  ttEtSums[iTtEta0][iTtPhi0] += e*sin(theta);
1830  }
1831  }
1832 
1833  for(EEDigiCollection::const_iterator it = eeDigis.begin();
1834  it != eeDigis.end(); ++it){
1835  const EEDataFrame& frame = *it;
1836  const EcalTrigTowerDetId& ttId = triggerTowerMap_->towerOf(frame.id());
1837  const int iTtEta0 = iTtEta2cIndex(ttId.ieta());
1838  const int iTtPhi0 = iTtPhi2cIndex(ttId.iphi());
1839  // LogDebug("TT") << ": EE xtal->TT "
1840  // << ((EEDetId&)frame.id()).ix()
1841  // << "," << ((EEDetId&)frame.id()).iy()
1842  // << " -> " << ttId.ieta() << "," << ttId.iphi() << "\n";
1843  double theta = eeGeometry->getGeometry(frame.id())->getPosition().theta();
1844  double e = frame2EnergyForTp(frame);
1845  if((frame2EnergyForTp(frame,-1) < e) && (frame2EnergyForTp(frame, 1) < e)){
1846  ttEtSums[iTtEta0][iTtPhi0] += e*sin(theta);
1847  }
1848  }
1849 
1850  //dealing with pseudo-TT in two inner EE eta-ring:
1851  int innerTTEtas[] = {0, 1, 54, 55};
1852  for(unsigned iRing = 0; iRing < sizeof(innerTTEtas)/sizeof(innerTTEtas[0]);
1853  ++iRing){
1854  int iTtEta0 = innerTTEtas[iRing];
1855  //this detector eta-section is divided in only 36 phi bins
1856  //For this eta regions,
1857  //current tower eta numbering scheme is inconsistent. For geometry
1858  //version 133:
1859  //- TT are numbered from 0 to 72 for 36 bins
1860  //- some TT have an even index, some an odd index
1861  //For geometry version 125, there are 72 phi bins.
1862  //The code below should handle both geometry definition.
1863  //If there are 72 input trigger primitives for each inner eta-ring,
1864  //then the average of the trigger primitive of the two pseudo-TT of
1865  //a pair (nEta, nEta+1) is taken as Et of both pseudo TTs.
1866  //If there are only 36 input TTs for each inner eta ring, then half
1867  //of the present primitive of a pseudo TT pair is used as Et of both
1868  //pseudo TTs.
1869 
1870  for(unsigned iTtPhi0 = 0; iTtPhi0 < nTtPhi-1; iTtPhi0 += 2){
1871  double et = .5*(ttEtSums[iTtEta0][iTtPhi0]
1872  +ttEtSums[iTtEta0][iTtPhi0+1]);
1873  //divides the TT into 2 phi bins in order to match with 72 phi-bins SRP
1874  //scheme or average the Et on the two pseudo TTs if the TT is already
1875  //divided into two trigger primitives.
1876  ttEtSums[iTtEta0][iTtPhi0] = et;
1877  ttEtSums[iTtEta0][iTtPhi0+1] = et;
1878  }
1879  }
1880 }
1881 
1882 template<class T>
1884  int offset) const{
1885  //we have to start by 0 in order to handle offset=-1
1886  //(however Fenix FIR has AFAK only 5 taps)
1887  double weights[] = {0., -1/3., -1/3., -1/3., 0., 1.};
1888 
1889  double adc2GeV = 0.;
1890  if(typeid(frame) == typeid(EBDataFrame)){
1891  adc2GeV = 0.035;
1892  } else if(typeid(frame) == typeid(EEDataFrame)){
1893  adc2GeV = 0.060;
1894  } else{ //T is an invalid type!
1895  //TODO: replace message by a cms exception
1896  throw cms::Exception("Severe Error")
1897  << __FILE__ << ":" << __LINE__ << ": "
1898  << "this is a bug. Please report it.\n";
1899  }
1900 
1901  double acc = 0;
1902 
1903  const int n = min<int>(frame.size(), sizeof(weights)/sizeof(weights[0]));
1904 
1905  double gainInv[] = {12., 1., 6., 12};
1906 
1907  for(int i=offset; i < n; ++i){
1908  int iframe = i + offset;
1909  if(iframe>=0 && iframe<frame.size()){
1910  acc += weights[i]*frame[iframe].adc()
1911  *gainInv[frame[iframe].gainId()]*adc2GeV;
1912  //cout << (iframe>offset?"+":"")
1913  // << frame[iframe].adc() << "*" << gainInv[frame[iframe].gainId()]
1914  // << "*" << adc2GeV << "*(" << weights[i] << ")";
1915  }
1916  }
1917  //cout << "\n";
1918  return acc;
1919 }
1920 
1922  if(!registerHist(name, "")) return 0; //this histo is disabled
1923  MonitorElement* result = dbe_->bookFloat(name);
1924  if(result==0){
1925  throw cms::Exception("DQM")
1926  << "Failed to book integer DQM monitor element" << name;
1927  }
1928  return result;
1929 }
1930 
1931 
1933  if(!registerHist(name, title)) return 0; //this histo is disabled
1934  MonitorElement* result = dbe_->book1D(name, title, nbins, xmin, xmax);
1935  if(result==0){
1936  throw cms::Exception("Histo")
1937  << "Failed to book histogram " << name;
1938  }
1939  return result;
1940 }
1941 
1942 MonitorElement* EcalSelectiveReadoutValidation::book2D(const std::string& name, const std::string& title, int nxbins, double xmin, double xmax, int nybins, double ymin, double ymax){
1943  if(!registerHist(name, title)) return 0; //this histo is disabled
1944  MonitorElement* result = dbe_->book2D(name, title, nxbins, xmin, xmax,
1945  nybins, ymin, ymax);
1946  if(result==0){
1947  throw cms::Exception("Histo")
1948  << "Failed to book histogram " << name;
1949  }
1950  return result;
1951 }
1952 
1954  if(!registerHist(name, title)) return 0; //this histo is disabled
1955  MonitorElement* result = dbe_->bookProfile(name, title, nbins, xmin, xmax,
1956  0, 0, 0);
1957  if(result==0){
1958  throw cms::Exception("Histo")
1959  << "Failed to book histogram " << name;
1960  }
1961  return result;
1962 }
1963 
1964 MonitorElement* EcalSelectiveReadoutValidation::bookProfile2D(const std::string& name, const std::string& title, int nbinx, double xmin, double xmax, int nbiny, double ymin, double ymax, const char* option){
1965  if(!registerHist(name, title)) return 0; //this histo is disabled
1967  = dbe_->bookProfile2D(name,
1968  title,
1969  nbinx, xmin, xmax,
1970  nbiny, ymin, ymax,
1971  0, 0, 0,
1972  option);
1973  if(result==0){
1974  throw cms::Exception("Histo")
1975  << "Failed to book histogram " << name;
1976  }
1977  return result;
1978 }
1979 
1981  const std::string& title){
1982  availableHistList_.insert(pair<string, string>(name, title));
1983  return allHists_ || histList_.find(name)!=histList_.end();
1984 }
1985 
1987  ebRecHits_.read(event);
1988  eeRecHits_.read(event);
1989  ebDigis_.read(event);
1990  eeDigis_.read(event);
1991  ebNoZsDigis_.read(event);
1992  eeNoZsDigis_.read(event);
1993  ebSrFlags_.read(event);
1994  eeSrFlags_.read(event);
1995  ebComputedSrFlags_.read(event);
1996  eeComputedSrFlags_.read(event);
1997  ebSimHits_.read(event);
1998  eeSimHits_.read(event);
1999  tps_.read(event);
2000  fedRaw_.read(event);
2001 }
2002 
2004  LogInfo log("HistoList");
2005  log << "Avalailable histograms (DQM monitor elements): \n";
2006  for(map<string, string>::iterator it = availableHistList_.begin();
2007  it != availableHistList_.end();
2008  ++it){
2009  log << it->first << ": " << it->second << "\n";
2010  }
2011  log << "\nTo include an histogram add its name in the vstring parameter "
2012  "'histograms' of the EcalSelectiveReadoutValidation module\n";
2013 }
2014 
2015 double EcalSelectiveReadoutValidation::getEbEventSize(double nReadXtals) const{
2016  double ruHeaderPayload = 0.;
2017  const int firstEbDcc0 = nEeDccs/2;
2018  for(int iDcc0 = firstEbDcc0; iDcc0 < firstEbDcc0 + nEbDccs; ++iDcc0){
2019  ruHeaderPayload += getRuCount(iDcc0)*8.;
2020  }
2021 
2022  return getDccOverhead(EB)*nEbDccs + nReadXtals*getBytesPerCrystal()
2023  + ruHeaderPayload;
2024 }
2025 
2026 double EcalSelectiveReadoutValidation::getEeEventSize(double nReadXtals) const{
2027  double ruHeaderPayload = 0.;
2028  const unsigned firstEbDcc0 = nEeDccs/2;
2029  for(unsigned iDcc0 = 0; iDcc0 < nDccs_; ++iDcc0){
2030  //skip barrel:
2031  if(iDcc0== firstEbDcc0) iDcc0 += nEbDccs;
2032  ruHeaderPayload += getRuCount(iDcc0)*8.;
2033  }
2034  return getDccOverhead(EE)*nEeDccs + nReadXtals*getBytesPerCrystal()
2035  + ruHeaderPayload;
2036 }
2037 
2041  //meEbLiZsFir_, meEbHiZsFir_,
2042  //meEeLiZsFir_, meEeHiZsFir_,
2043  };
2044 
2045  double scale = 1./eventCount;
2046  stringstream buf;
2047  for(unsigned i = 0; i < sizeof(mes)/sizeof(mes[0]); ++i){
2048  if(mes[i] == 0) continue;
2049  TH1* h = mes[i]->getTH1();
2050  if(dynamic_cast<TH2*>(h)){//TH2
2051  h->GetZaxis()->SetTitle("Frequency");
2052  } else{ //assuming TH1
2053  h->GetYaxis()->SetTitle("<Count>");
2054  }
2055  buf << "Normalising " << h->GetName() << ". Factor: " << scale << "\n";
2056  h->Scale(scale);
2057  //Set average bit so histogram can be added correctly. Beware must be done
2058  //after call the TH1::Scale (Scale has no effect if average bit is set)
2059  h->SetBit(TH1::kIsAverage);
2060  }
2061  edm::LogInfo("EcalSrValid") << buf.str();
2062 }
2063 
2064 //This implementation assumes that int is coded on at least 28-bits,
2065 //which in pratice should be always true.
2066 int
2068  const std::vector<int>& firWeights,
2069  int firstFIRSample,
2070  bool* saturated){
2071  const int nFIRTaps = 6;
2072  //FIR filter weights:
2073  const vector<int>& w = firWeights;
2074 
2075  //accumulator used to compute weighted sum of samples
2076  int acc = 0;
2077  bool gain12saturated = false;
2078  const int gain12 = 0x01;
2079  const int lastFIRSample = firstFIRSample + nFIRTaps - 1;
2080  //LogDebug("DccFir") << "DCC FIR operation: ";
2081  int iWeight = 0;
2082  for(int iSample=firstFIRSample-1;
2083  iSample<lastFIRSample; ++iSample, ++iWeight){
2084  if(iSample>=0 && iSample < frame.size()){
2085  EcalMGPASample sample(frame[iSample]);
2086  if(sample.gainId()!=gain12) gain12saturated = true;
2087  LogTrace("DccFir") << (iSample>=firstFIRSample?"+":"") << sample.adc()
2088  << "*(" << w[iWeight] << ")";
2089  acc+=sample.adc()*w[iWeight];
2090  } else{
2091  edm::LogWarning("DccFir") << __FILE__ << ":" << __LINE__ <<
2092  ": Not enough samples in data frame or 'ecalDccZs1stSample' module "
2093  "parameter is not valid...";
2094  }
2095  }
2096  LogTrace("DccFir") << "\n";
2097  //discards the 8 LSBs
2098  //(shift operator cannot be used on negative numbers because
2099  // the result depends on compilator implementation)
2100  acc = (acc>=0)?(acc >> 8):-(-acc >> 8);
2101  //ZS passed if weighted sum acc above ZS threshold or if
2102  //one sample has a lower gain than gain 12 (that is gain 12 output
2103  //is saturated)
2104 
2105  LogTrace("DccFir") << "acc: " << acc << "\n"
2106  << "saturated: " << (gain12saturated?"yes":"no") << "\n";
2107 
2108  if(saturated){
2109  *saturated = gain12saturated;
2110  }
2111 
2112  return gain12saturated?numeric_limits<int>::max():acc;
2113 }
2114 
2115 std::vector<int>
2117  normalizedWeights){
2118  const int nFIRTaps = 6;
2119  vector<int> firWeights(nFIRTaps, 0); //default weight: 0;
2120  const static int maxWeight = 0xEFF; //weights coded on 11+1 signed bits
2121  for(unsigned i=0; i < min((size_t)nFIRTaps,normalizedWeights.size()); ++i){
2122  firWeights[i] = lround(normalizedWeights[i] * (1<<10));
2123  if(abs(firWeights[i])>maxWeight){//overflow
2124  firWeights[i] = firWeights[i]<0?-maxWeight:maxWeight;
2125  }
2126  }
2127  return firWeights;
2128 }
2129 
2130 void
2131 EcalSelectiveReadoutValidation::configFirWeights(const vector<double>& weightsForZsFIR){
2132  bool notNormalized = false;
2133  bool notInt = false;
2134  for(unsigned i=0; i < weightsForZsFIR.size(); ++i){
2135  if(weightsForZsFIR[i] > 1.) notNormalized = true;
2136  if((int)weightsForZsFIR[i]!=weightsForZsFIR[i]) notInt = true;
2137  }
2138  if(notInt && notNormalized){
2139  throw cms::Exception("InvalidParameter")
2140  << "weigtsForZsFIR paramater values are not valid: they "
2141  << "must either be integer and uses the hardware representation "
2142  << "of the weights or less or equal than 1 and used the normalized "
2143  << "representation.";
2144  }
2145  LogInfo log("DccFir");
2146  if(notNormalized){
2147  firWeights_ = vector<int>(weightsForZsFIR.size());
2148  for(unsigned i = 0; i< weightsForZsFIR.size(); ++i){
2149  firWeights_[i] = (int)weightsForZsFIR[i];
2150  }
2151  } else{
2152  firWeights_ = getFIRWeights(weightsForZsFIR);
2153  }
2154 
2155  log << "Input weights for FIR: ";
2156  for(unsigned i = 0; i < weightsForZsFIR.size(); ++i){
2157  log << weightsForZsFIR[i] << "\t";
2158  }
2159 
2160  double s2 = 0.;
2161  log << "\nActual FIR weights: ";
2162  for(unsigned i = 0; i < firWeights_.size(); ++i){
2163  log << firWeights_[i] << "\t";
2164  s2 += firWeights_[i]*firWeights_[i];
2165  }
2166 
2167  s2 = sqrt(s2);
2168  log << "\nNormalized FIR weights after hw representation rounding: ";
2169  for(unsigned i = 0; i < firWeights_.size(); ++i){
2170  log << firWeights_[i] / (double)(1<<10) << "\t";
2171  }
2172 
2173  log <<"\nFirst FIR sample: " << firstFIRSample_;
2174 }
2175 
2177  if(logSrpAlgoErrors_){
2179  if(!srpAlgoErrorLog_.good()){
2180  throw cms::Exception("Output")
2181  << "Failed to open the log file '"
2183  << "' for SRP algorithm result check.\n";
2184  }
2185  }
2186 
2189  if(!srApplicationErrorLog_.good()){
2190  throw cms::Exception("Output")
2191  << "Failed to open the log file '"
2193  << "' for Selective Readout decision application check.\n";
2194  }
2195  }
2196 }
2197 
2198 //Compares two SR flag sorted collections . Both collections
2199 //are sorted by their key (the detid) and following algorithm is based on
2200 //this feature.
2201 template<class T> //T must be either an EBSrFlagCollection or an EESrFlagCollection
2202 void EcalSelectiveReadoutValidation::compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf){
2203  typedef typename T::const_iterator SrFlagCollectionConstIt;
2204  typedef typename T::key_type MyRuDetIdType;
2205  SrFlagCollectionConstIt itSrfFromData = srfFromData.begin();
2206  SrFlagCollectionConstIt itComputedSr = computedSrf.begin();
2207 
2208  {
2209  PgTiming t("collection comparison");
2210  //cout << __FILE__ << ":" << __LINE__ << ": "
2211  // << srfFromData.size() << " " << computedSrf.size() << "\n";
2212  // int i = 0;
2213  while(itSrfFromData != srfFromData.end()
2214  || itComputedSr != computedSrf.end()){
2215  // cout << ++i << "\n";
2216  MyRuDetIdType inconsistentRu = 0;
2217  bool inconsistent = false;
2218  if(itComputedSr == computedSrf.end() ||
2219  (itSrfFromData != srfFromData.end()
2220  && itSrfFromData->id() < itComputedSr->id())){
2221  //computedSrf is missig a detid found in srfFromData
2222  pair<int, int> ch = dccCh(itSrfFromData->id());
2223  srpAlgoErrorLog_ << event.id() << ": " << itSrfFromData->id()
2224  << ", DCC " << ch.first << " ch " << ch.second
2225  << " found in data (SRF:" << itSrfFromData->flagName()
2226  << ") but not in the set of SRFs computed from the data TTF.\n";
2227  inconsistentRu = itSrfFromData->id();
2228  inconsistent = true;
2229  ++itSrfFromData;
2230  } else if(itSrfFromData==srfFromData.end() ||
2231  (itComputedSr != computedSrf.end()
2232  && itComputedSr->id() < itSrfFromData->id())){
2233  //ebSrFlags is missing a detid found in computedSrf
2234  pair<int, int> ch = dccCh(itComputedSr->id());
2235  if(logErrForDccs_[ch.first-minDccId_]){
2236  srpAlgoErrorLog_ << event.id() << ": " << itComputedSr->id()
2237  << ", DCC " << ch.first << " ch " << ch.second
2238  << " not found in data. Computed SRF: "
2239  << itComputedSr->flagName() << ".\n";
2240  inconsistentRu = itComputedSr->id();
2241  inconsistent = true;
2242  }
2243  ++itComputedSr;
2244  } else{
2245  //*itSrfFromData and *itComputedSr has same detid
2246  if(itComputedSr->value()!=itSrfFromData->value()){
2247  //if(!(itSrfFromData->value & EcalSrFlag::SRF_FORCED_MASK)){
2248  pair<int, int> ch = dccCh(itSrfFromData->id());
2249  srpAlgoErrorLog_ << event.id() << ", "
2250  << itSrfFromData->id()
2251  << ", DCC " << ch.first << " ch " << ch.second
2252  << ", SRF inconsistency: "
2253  << "from data: " << itSrfFromData->flagName()
2254  << ", computed from TTF: "
2255  << itComputedSr->flagName()
2256  << "\n";
2257  //}
2258  inconsistentRu = itComputedSr->id();
2259  inconsistent = true;
2260  }
2261  if(itComputedSr != computedSrf.end()) ++itComputedSr;
2262  if(itSrfFromData != srfFromData.end()) ++itSrfFromData;
2263  }
2264 
2265  if(inconsistent) fill(meSRFlagsConsistency_, ruGraphX(inconsistentRu),
2266  ruGraphY(inconsistentRu));
2267  }
2268  }
2269 }
2270 
2271 
2273  return elecMap_->getDCCandSC(detId).first;
2274 }
2275 
2277  if(detId.ietaAbs()>17){
2278  throw cms::Exception("InvalidArgument")
2279  << "Argument of EcalSelectiveReadoutValidation::dccId(const EcalTrigTowerDetId&) "
2280  << "must be a barrel trigger tower Id\n";
2281  }
2282  return dccCh(detId).first;
2283 
2284  // int iDccPhi0 = (detId.iphi()-1)/4; //4 TT along phi covered by a DCC
2285  // int iDccEta0 = detId.zside()<0?0:1;
2286  // const int nDccsInPhi = 18;
2287  // return 1 + iDccEta0 * nDccsInPhi + iDccPhi0;
2288 }
2289 
2290 
2291 
2293  logErrForDccs_ = vector<bool>(nDccs_, false);
2294 
2296  it != ebSrFlags_->end();
2297  ++it){
2298 
2299  //cout << __FILE__ << ":" << __LINE__ << ": "
2300  // << EcalTrigTowerDetId(it->id()) << "\n";
2301 
2302  int iDcc = dccId(it->id()) - minDccId_;
2303  // cout << __FILE__ << ":" << __LINE__ << ": "
2304  // << it->id().rawId() << "-> DCC " << (iDcc+1) << "\n";
2305  logErrForDccs_.at(iDcc) = true;
2306  }
2307 
2309  it != eeSrFlags_->end();
2310  ++it){
2311  int iDcc = dccId(it->id()) - minDccId_;
2312 // cout << __FILE__ << ":" << __LINE__ << ": "
2313 // << it->id().rawId() << "-> DCC " << (iDcc+1) << "\n";
2314  logErrForDccs_.at(iDcc) = true;
2315  }
2316 
2317  stringstream buf;
2318  buf << "List of DCCs found in the first processed event: ";
2319  bool first = true;
2320  for(unsigned iDcc = 0; iDcc < nDccs_; ++iDcc){
2321  if(logErrForDccs_[iDcc]){
2322  buf << (first?"":", ") << (iDcc + minDccId_);
2323  first = false;
2324  }
2325  }
2326  buf << "\nOnly DCCs from this list will be considered for error logging\n";
2327  srpAlgoErrorLog_ << buf.str();
2328  srApplicationErrorLog_<< buf.str();
2329  LogInfo("EcalSrValid") << buf;
2330 }
2331 
2332 
2333 template<class T>
2335  T& srfs){
2336  typedef typename T::const_iterator SrFlagCollectionConstIt;
2337  typedef typename T::key_type MyRuDetIdType;
2338 
2339  for(SrFlagCollectionConstIt itSrf = srfs.begin();
2340  itSrf != srfs.end(); ++itSrf){
2341  int flag = itSrf->value() & ~EcalSrFlag::SRF_FORCED_MASK;
2342  pair<int,int> ru = dccCh(itSrf->id());
2343 
2344  if(flag == EcalSrFlag::SRF_FULL){
2345  if(nPerRu_[ru.first-minDccId_][ru.second-1]==getCrystalCount(ru.first, ru.second)){ //no error
2346  fill(meIncompleteFRORateMap_, ruGraphX(itSrf->id()),
2347  ruGraphY(itSrf->id()), 0);
2349  ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 0);
2350  } else if(nPerRu_[ru.first-minDccId_][ru.second-1]==0) {//tower dropped!
2352  ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 0);
2354  ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 1);
2355  fill(meDroppedFROMap_, ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 1);
2356  ++nDroppedFRO_;
2357  srApplicationErrorLog_ << event.id() << ": Flag of RU "
2358  << itSrf->id() << " (DCC " << ru.first
2359  << " ch " << ru.second << ") is 'Full readout' "
2360  << "while none of its channel was read out\n";
2361  } else{ //tower partially read out
2363  ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 1);
2365  ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 0);
2367  ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 1);
2368  ++nIncompleteFRO_;
2369  srApplicationErrorLog_ << event.id() << ": Flag of RU"
2370  << itSrf->id() << " (DCC " << ru.first
2371  << " ch " << ru.second << ") is 'Full readout' "
2372  << "while only "
2373  << nPerRu_[ru.first-minDccId_][ru.second-1]
2374  << " / " << getCrystalCount(ru.first, ru.second)
2375  << " channels were read out.\n";
2376  }
2377  }
2378 
2379  if(flag == EcalSrFlag::SRF_ZS1 || flag == EcalSrFlag::SRF_ZS2){
2380  if(nPerRu_[ru.first-minDccId_][ru.second-1]
2381  ==getCrystalCount(ru.first, ru.second)){
2382  //ZS readout unit whose every channel was read
2383 
2384  fill(meCompleteZSMap_, ruGraphX(itSrf->id()), ruGraphY(itSrf->id()));
2386  ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 1);
2387  //srApplicationErrorLog_ << event.id() << ": "
2388  // << "All " << nMaxXtalPerRu << " channels of RU "
2389  // << itSrf->id() << " passed the Zero suppression.";
2390  ++nCompleteZS_;
2391  } else{
2393  ruGraphX(itSrf->id()), ruGraphY(itSrf->id()), 0);
2394  }
2395  }
2396  }
2397 }
2398 
2400  if(iDcc < minDccId_ || iDcc > maxDccId_){ //invalid DCC
2401  return 0;
2402  } else if (10 <= iDcc && iDcc <= 45) {//EB
2403  return 25;
2404  } else { //EE
2405  int iDccPhi;
2406  if(iDcc < 10) iDccPhi = iDcc;
2407  else iDccPhi = iDcc - 45;
2408  switch(iDccPhi*100+iDccCh){
2409  case 110:
2410  case 232:
2411  case 312:
2412  case 412:
2413  case 532:
2414  case 610:
2415  case 830:
2416  case 806:
2417  //inner partials at 12, 3, and 9 o'clock
2418  return 20;
2419  case 134:
2420  case 634:
2421  case 827:
2422  case 803:
2423  return 10;
2424  case 330:
2425  case 430:
2426  return 20;
2427  case 203:
2428  case 503:
2429  case 721:
2430  case 921:
2431  return 21;
2432  default:
2433  return 25;
2434  }
2435  }
2436 }
#define LogDebug(id)
void configFirWeights(const std::vector< double > &weightsForZsFIR)
double getDccSrDependentPayload(int iDcc0, double nReadRus, double nReadXtals) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * bookProfile(const std::string &name, const std::string &title, int nbins, double xmin, double xmax)
CollHandle< EBDigiCollection > ebNoZsDigis_
int value() const
Definition: EcalSrFlag.h:44
std::ofstream srApplicationErrorLog_
Output ascii file for unconsistency between Xtals and RU Flags.
int ix() const
Definition: EEDetId.h:76
double getDccOverhead(subdet_t subdet) const
static const int nEeX
EE crystal grid size along X.
key_type id() const
Definition: EBDataFrame.h:31
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
int xtalGraphX(const EEDetId &id) const
double getDccEventSize(int iDcc0, double nReadXtals) const
int nIncompleteFRO_
Counter of FRO-flagged RU only partial data.
void setEventSetup(const edm::EventSetup &evtSetup)
Definition: EcalTPGScale.cc:19
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
int gainId(sample_type sample)
get the gainId (2 bits)
static const int SRF_ZS2
Definition: EcalSrFlag.h:21
static const int nEbPhi
number of crystals along Phi in EB
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
static const int SRF_FORCED_MASK
Definition: EcalSrFlag.h:29
static const double rad2deg
Conversion factor from radian to degree.
energiesEe_t eeEnergies[nEndcaps][nEeX][nEeY]
double energy() const
Definition: PCaloHit.h:29
int simHit
energy reconstructed from zero-suppressed digi
CollHandle< EcalTrigPrimDigiCollection > tps_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void analyzeEB(const edm::Event &event, const edm::EventSetup &es)
std::vector< EcalRecHit >::const_iterator const_iterator
Geom::Theta< T > theta() const
int simHit
energy reconstructed from zero-suppressed digi
void analyze(edm::Event const &e, edm::EventSetup const &c)
Analyzes the event.
void endRun(const edm::Run &r, const edm::EventSetup &c)
Calls at end of run.
int nEeZsErrors_
Counter of EE ZS errors (LI channel below ZS threshold)
CollHandle< FEDRawDataCollection > fedRaw_
int towerId() const
get the tower id
void beginRun(const edm::Run &r, const edm::EventSetup &c)
Calls at begin of run.
void analyzeEE(const edm::Event &event, const edm::EventSetup &es)
const_iterator begin() const
static const int nEeDccs
number of DCCs for EE
double getTPGInGeV(const EcalTriggerPrimitiveDigi &tpDigi)
Definition: EcalTPGScale.cc:24
std::pair< int, int > getDCCandSC(EcalScDetId id) const
int gainId() const
get the gainId (2 bits)
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int size() const
Definition: EcalDataFrame.h:26
bool registerHist(const std::string &name, const std::string &title)
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
int ieta() const
get the tower ieta
void setTtEtSums(const edm::EventSetup &es, const EBDigiCollection &ebDigis, const EEDigiCollection &eeDigis)
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:809
int zside() const
get the z-side of the tower (1/-1)
MonitorElement * book1D(const std::string &name, const std::string &title, int nbins, double xmin, double xmax)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
tuple s2
Definition: indexGen.py:106
void Fill(long long x)
static const int nEbEta
number of crystals along Eta in EB
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
double frame2EnergyForTp(const T &frame, int offset=0) const
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
CollHandle< EESrFlagCollection > eeComputedSrFlags_
static const int nTtPhi
Number of Trigger Towers along Phi.
int xtalGraphY(const EEDetId &id) const
CollHandle< EEDigiCollection > eeDigis_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void checkSrApplication(const edm::Event &event, T &srfs)
std::string outputFile_
Output file for histograms.
CollHandle< RecHitCollection > eeRecHits_
const T & max(const T &a, const T &b)
int ix() const
Definition: EcalScDetId.h:71
int ietaAbs() const
get the absolute value of the tower ieta
void analyzeDataVolume(const edm::Event &e, const edm::EventSetup &es)
float energy() const
Definition: CaloRecHit.h:17
T sqrt(T t)
Definition: SSEVec.h:48
tuple result
Definition: query.py:137
void anaDigi(const T &frame, const U &srFlagColl)
CollHandle< EBSrFlagCollection > ebSrFlags_
int zside() const
Definition: EEDetId.h:70
void updateL1aRate(const edm::Event &event)
static const int SRF_FULL
Definition: EcalSrFlag.h:24
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int nCompleteZS_
Counter of ZS-flagged RU fully read out.
TH1 * getTH1(void) const
CollHandle< std::vector< PCaloHit > > eeSimHits_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
static int dccZsFIR(const EcalDataFrame &frame, const std::vector< int > &firWeights, int firstFIRSample, bool *saturated=0)
int iy() const
Definition: EEDetId.h:82
DQMStore * dbe_
Histogramming interface.
int nEeFROCnt_
Counter of EE FRO-flagged RUs.
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1186
MonitorElement * bookFloat(const std::string &name)
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
unsigned int id() const
Definition: PCaloHit.h:43
unsigned int offset(bool)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool first
Definition: L1TdeRCT.cc:79
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
MonitorElement * book2D(const std::string &name, const std::string &title, int nxbins, double xmin, double xmax, int nybins, double ymin, double ymax)
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
#define LogTrace(id)
int iy() const
Definition: EcalScDetId.h:77
void read(const edm::Event &event)
Definition: CollHandle.h:50
EcalScDetId superCrystalOf(const EEDetId &xtalId) const
static const int SRF_ZS1
Definition: EcalSrFlag.h:18
key_type id() const
Definition: EEDataFrame.h:28
std::vector< EcalScDetId > getEcalScDetId(int DCCid, int DCC_Channel, bool ignoreSingleCrystal=true) const
CollHandle< EESrFlagCollection > eeSrFlags_
static const int nDccRus_[nDccs_]
number of RUs for each DCC
tuple out
Definition: dbtoconf.py:99
static const int nOneEeTtEta
Number of Trigger Towers in an endcap along Eta.
int nEbFROCnt_
Counter of EB FRO-flagged RUs.
static const int nEbDccs
number of DCCs for EB
CollHandle< std::vector< PCaloHit > > ebSimHits_
int nEbZsErrors_
Counter of EB ZS errors (LI channel below ZS threshold)
static const int scEdge
Number of crystals along a supercrystal edge.
double recE
energy reconstructed from unsuppressed digi
static const double tmax[3]
Definition: DetId.h:18
static std::vector< int > getFIRWeights(const std::vector< double > &normalizedWeights)
int iphi() const
get the tower iphi
static const int ebTtEdge
Number of crystals along an EB TT.
EcalSelectiveReadoutValidation(const edm::ParameterSet &ps)
Constructor.
DetId id() const
get the id
Definition: EcalRecHit.h:80
double getEeEventSize(double nReadXtals) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
static const int kByte_
number of bytes in 1 kByte:
const EcalScDetId & id() const
Definition: EESrFlag.h:37
bool ebRuActive_[nEbEta/ebTtEdge][nEbPhi/ebTtEdge]
const T & get() const
Definition: EventSetup.h:55
PgTiming(const std::string &mess)
T const * product() const
Definition: ESHandle.h:62
double b
Definition: hdecay.h:120
int zside() const
Definition: EcalScDetId.h:65
EcalTrigTowerDetId readOutUnitOf(const EBDetId &xtalId) const
CollHandle< EEDigiCollection > eeNoZsDigis_
double recE
energy reconstructed from unsuppressed digi
const EcalTrigTowerDetId & id() const
Definition: EBSrFlag.h:36
int dccId(const EcalScDetId &detId) const
std::map< std::string, std::string > availableHistList_
IdealGeometryRecord MyCaloGeometryRecord
const_iterator end() const
T eta() const
Definition: PV3DBase.h:76
unsigned ttId(const DetId &)
ESHandle< TrackerGeometry > geometry
int ruGraphX(const EcalScDetId &id) const
static const int nTtEta
Number of Trigger Towers along Eta.
double a
Definition: hdecay.h:121
int nDroppedFRO_
Counter of FRO-flagged RU dropped from data.
tuple cout
Definition: gather_cfg.py:121
void fill(MonitorElement *me, float x)
T w() const
int ruGraphY(const EcalScDetId &id) const
volatile std::atomic< bool > shutdown_flag false
void compareSrfColl(const edm::Event &event, T &srfFromData, T &computedSrf)
std::pair< int, int > dccCh(const DetId &xtalId) const
double frame2Energy(const EcalDataFrame &frame) const
std::ofstream srpAlgoErrorLog_
Output ascii file for unconsistency on SR flags.
static const int nEeY
EE crystal grid size along Y.
CollHandle< EBDigiCollection > ebDigis_
double getEbEventSize(double nReadXtals) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
long double T
static const unsigned nDccs_
Total number of DCCs.
static const int nEndcaps
number of endcaps
const EcalTrigTowerConstituentsMap * triggerTowerMap_
void analyzeTP(const edm::Event &event, const edm::EventSetup &es)
const EcalElectronicsMapping * elecMap_
CollHandle< RecHitCollection > ebRecHits_
Definition: Run.h:41
int adc() const
get the ADC sample (12 bits)
bool eeRuActive_[nEndcaps][nEeX/scEdge][nEeY/scEdge]
CollHandle< EBSrFlagCollection > ebComputedSrFlags_
MonitorElement * bookProfile2D(const std::string &name, const std::string &title, int nbinx, double xmin, double xmax, int nbiny, double ymin, double ymax, const char *option="")
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")
Definition: DQMStore.cc:1330