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