CMS 3D CMS Logo

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