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