CMS 3D CMS Logo

EcalSelectiveReadoutValidation.h
Go to the documentation of this file.
1 #ifndef EcalSelectiveReadoutValidation_H
2 #define EcalSelectiveReadoutValidation_H
3 
4 /*
5  * \file EcalSelectiveReadoutValidation.h
6  *
7  *
8  */
9 
11 
13 
16 
22 
24 
25 #include <string>
26 #include <set>
27 #include <fstream>
28 
29 class EBDetId;
30 class EEDetId;
33 
35 
37  typedef EcalRecHit RecHit;
38 
39 public:
40 
43 
46  void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
47  void bookHistograms(DQMStore::IBooker &i, edm::Run const&, edm::EventSetup const&) override;
48 
49 protected:
50 
52  void analyze(edm::Event const & e, edm::EventSetup const & c) override;
53 
54  void endRun(const edm::Run& r, const edm::EventSetup& c) override;
55 
56 private:
58  enum subdet_t {EB, EE};
59 
63  template<class T, class U>
64  void anaDigi(const T& frame, const U& srFlagColl);
65 
69  void anaDigiInit();
70 
75  void analyzeDataVolume(const edm::Event& e, const edm::EventSetup& es);
76 
81  void analyzeEB(const edm::Event& event, const edm::EventSetup& es);
82 
87  void analyzeEE(const edm::Event& event, const edm::EventSetup& es);
88 
93  void analyzeTP(const edm::Event& event, const edm::EventSetup& es);
94 
95  // /** Selective Readout decisions Validation
96  // * @param event EDM event
97  // * @param es event setup
98  // */
99  // void SRFlagValidation(const edm::Event& event, const edm::EventSetup& es);
100 
104  double frame2Energy(const EcalDataFrame& frame) const;
105 
112  template<class T>
113  double frame2EnergyForTp(const T& frame, int offset = 0) const;
114 
115  // double getEcalEventSize(double nReadXtals) const{
116  // return getDccOverhead(EB)*nEbDccs+getDccOverhead(EE)*nEeDccs
117  // + nReadXtals*getBytesPerCrystal()
118  // + (nEeRus+nEbRus)*8;
119  // }
120 
125  double getEbEventSize(double nReadXtals) const;
126 
131  double getEeEventSize(double nReadXtals) const;
132 
136  double getDccOverhead(subdet_t subdet) const{
137  // return (subdet==EB?34:25)*8;
138  return (subdet==EB?34:52)*8;
139  }
140 
145  double getBytesPerCrystal() const{
146  return 3*8;
147  }
148 
154  double getDccEventSize(int iDcc0, double nReadXtals) const{
155  subdet_t subdet;
156  if(iDcc0<9 || iDcc0>=45){
157  subdet = EE;
158  } else{
159  subdet = EB;
160  }
161  // return getDccOverhead(subdet)+nReadXtals*getBytesPerCrystal()
162  // + getRuCount(iDcc0)*8;
163  return getDccOverhead(subdet)
164  + getDccSrDependentPayload(iDcc0, getRuCount(iDcc0), nReadXtals);
165  }
166 
174  double getDccSrDependentPayload(int iDcc0, double nReadRus,
175  double nReadXtals) const{
176  return nReadXtals*getBytesPerCrystal() + nReadRus*8;
177  }
178 
183  int getRuCount(int iDcc0) const;
184 
189  void readAllCollections(const edm::Event& e);
190 
199  void setTtEtSums(const edm::EventSetup& es,
200  const EBDigiCollection& ebDigis,
201  const EEDigiCollection& eeDigis);
202 
203  // /** Retrieves the logical number of the DCC reading a given crystal channel.
204  // * @param xtarId crystal channel identifier
205  // * @return the DCC logical number starting from 1.
206  // */
207  // unsigned dccNum(const DetId& xtalId) const;
208 
216  std::pair<int,int> dccCh(const DetId& xtalId) const;
217 
218 
222  int iEta2cIndex(int iEta) const{
223  return (iEta<0)?iEta+85:iEta+84;
224  }
225 
229  int iPhi2cIndex(int iPhi) const{
230  // return iPhi-1;
231  int iPhi0 = iPhi - 11;
232  if(iPhi0<0) iPhi0 += 360;
233  return iPhi0;
234  }
235 
239  int iXY2cIndex(int iX) const{
240  return iX-1;
241  }
242 
245  int cIndex2iXY(int iX0) const{
246  return iX0+1;
247  }
248 
251  int cIndex2iEta(int i) const{
252  return (i<85)?i-85:i-84;
253  }
254 
255 
258  int cIndex2iPhi(int i) const {
259  return (i+11) % 360;
260  }
261 
267  int iTtEta2cIndex(int iEta) const{
268  return (iEta<0)?iEta+28:iEta+27;
269  }
270 
276  int iTtPhi2cIndex(int iPhi) const{
277  return iPhi-1;
278  //int iPhi0 = iPhi - 3;
279  //if(iPhi0<0) iPhi0 += 72;
280  //return iPhi0;
281  }
282 
285  int cIndex2iTtEta(int i) const{
286  return (i<27)?i-28:i-27;
287  }
288 
291  int cIndex2iTtPhi(int i) const{
292  return i + 1;
293  }
294 
296 
301  EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
302 
303  EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
305 
316  static int dccZsFIR(const EcalDataFrame& frame,
317  const std::vector<int>& firWeights,
318  int firstFIRSample,
319  bool* saturated = nullptr);
320 
321 
326  static std::vector<int> getFIRWeights(const std::vector<double>&
327  normalizedWeights);
328 
330 
334 
336  const std::string& title, int nbins,
337  double xmin, double xmax);
338 
340  const std::string& title,
341  int nxbins, double xmin, double xmax,
342  int nybins, double ymin, double ymax);
343 
345  const std::string& title,
346  int nbins, double xmin, double xmax);
347 
349  const std::string& title,
350  int nbinx, double xmin, double xmax,
351  int nbiny, double ymin, double ymax,
352  const char* option = "");
354 
356 
358  void fill(MonitorElement* me, float x){
359  if(me) me->Fill(x);
360  }
361  void fill(MonitorElement* me,float x, float yw){
362  if(me) me->Fill(x, yw);
363  }
364  void fill(MonitorElement* me,float x, float y, float zw){
365  if(me) me->Fill(x, y, zw);
366  }
367  void fill(MonitorElement* me,float x, float y, float z, float w){
368  if(me) me->Fill(x, y, z, w);
369  }
371 
372  void initAsciiFile();
373 
377  void updateL1aRate(const edm::Event& event);
378 
383  double getL1aRate() const;
384 
385 private:
388  struct energiesEb_t{
389  double simE;
390  double noZsRecE;
391  double recE;
392  // EBDigiCollection::const_iterator itNoZsFrame; //
393  int simHit;
394  double phi;
395  double eta;
396  bool gain12; //all MGPA samples at gain 12?
397  };
398 
401  struct energiesEe_t{
402  double simE;
403  double noZsRecE;
404  double recE;
405  // EEDigiCollection::const_iterator itNoZsFrame;
406  int simHit;
407  double phi;
408  double eta;
409  bool gain12; //all MGPA samples at gain 12?
410  };
411 
413  static const int kByte_ = 1024;
414 
416  static const unsigned nDccs_ = 54;
417 
419  // = maximum number of RUs read by a DCC
420  static const unsigned nDccChs_ = 68;
421 
422  //Lower bound of DCC ID range
423  static const int minDccId_ = 1 ;
424 
425  //Upper bound of DCC ID range
426  static const int maxDccId_ = minDccId_ + nDccs_ -1;
427 
429  static const int nEbDccs = 36;
430 
432  static const int nEeDccs = 18;
433 
435  static const int nEbRus = 36*68;
436 
438  static const int nEeRus = 2*(34+32+33+33+32+34+33+34+33);
439 
441  static const int nDccRus_[nDccs_];
442 
444  static const int nEndcaps = 2;
445 
447  static const int nEbEta = 170;
448 
450  static const int nEbPhi = 360;
451 
453  static const int nEeX = 100;
454 
456  static const int nEeY = 100;
457 
459  static const int ebTtEdge = 5;
460 
462  static const int scEdge = 5;
463 
465  static const int nOneEeTtEta = 11;
466 
468  static const int nEbTtEta = 34;
469 
471  static const int nTtEta = 2*nOneEeTtEta + nEbTtEta;
472 
474  static const int nTtPhi = 72;
475 
477  static const int nMaxXtalPerRu = 25;
479  static const double rad2deg;
480 
482  bool verbose_;
483 
486 
489 
493 
497 
499  std::ofstream srpAlgoErrorLog_;
500 
502  std::ofstream srApplicationErrorLog_;
503 
505  std::ofstream zsErrorLog_;
506 
508 
525 
527 
529  int64_t tmax;
530  int64_t tmin;
531  int64_t l1aOfTmin;
532  int64_t l1aOfTmax;
535 
537 
553 
559 
567 
575 
579 
584 
586 
590 
594 
600 
604 
608 
612 
623 
625 
632 
636 
639 
642 
645 
648 
651 
654 
657 
661 
665 
666 
670 
674 
679 
682  std::vector<double> weights_;
683 
686  std::vector<int> firWeights_;
687 
690  int ebZsThr_;
691 
694  int eeZsThr_;
695 
698  bool tpInGeV_;
699 
704 
709 
714  std::vector<bool> logErrForDccs_;
715 
718  int nEb_;
719 
722  int nEe_;
723 
726  int nEeLI_;
727 
730  int nEeHI_;
731 
734  int nEbLI_;
735 
738  int nEbHI_;
739 
743 
747 
751 
752 
756 
760 
764 
765 
767 
769  bool ebRuActive_[nEbEta/ebTtEdge][nEbPhi/ebTtEdge];
770  bool eeRuActive_[nEndcaps][nEeX/scEdge][nEeY/scEdge];
772 
774 
778 
781  int ievt_;
782 
788 
793 
799 
803 
807  std::set<std::string> histList_;
808 
811  bool allHists_;
812 
816 
820  std::map<std::string, std::string> availableHistList_;
821 
822 
826 
830 
835  bool registerHist(const std::string& name, const std::string& title);
836 
840  void printAvailableHists();
841 
847  void configFirWeights(const std::vector<double>& weightsForZsFIR);
848 
854 
859 
868  template<class T>
869  void compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf);
870 
875  template<class T>
876  void checkSrApplication(const edm::Event& event, T& srfs);
877 
878 
882  int ruGraphX(const EcalScDetId& id) const{
884  return id.ix() + (id.zside()>0?20:-40);
885  }
886 
887  int ruGraphY(const EcalScDetId& id) const{
888  return id.iy();
889  }
890 
891  int ruGraphX(const EcalTrigTowerDetId& id) const{
892  return id.ieta();
893  }
894 
895  int ruGraphY(const EcalTrigTowerDetId& id) const{
896  return id.iphi();
897  }
898 
899  int xtalGraphX(const EEDetId& id) const{
900  return id.ix() + (id.zside()>0?100:-200);
901  }
902 
903  int xtalGraphY(const EEDetId& id) const{
904  return id.iy();
905  }
906 
907  int xtalGraphX(const EBDetId& id) const{
908  return id.ieta();
909  }
910 
911  int xtalGraphY(const EBDetId& id) const{
912  return id.iphi();
913  }
914 
916 
918 
921  int dccId(const EcalScDetId& detId) const;
922  int dccId(const EcalTrigTowerDetId& detId) const;
924 
930  void selectFedsForLog();
931 
937  int getCrystalCount(int iDcc, int iDccCh);
938 
939 };
940 
941 #endif //EcalSelectiveReadoutValidation_H not defined
942 
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
void fill(MonitorElement *me, float x, float y, float zw)
CollHandle< EBDigiCollection > ebNoZsDigis_
static const int nMaxXtalPerRu
Number of crystals per Readout Unit excepted partial SCs.
std::ofstream srApplicationErrorLog_
Output ascii file for unconsistency between Xtals and RU Flags.
double getDccOverhead(subdet_t subdet) const
static const int nEeX
EE crystal grid size along X.
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
std::ofstream zsErrorLog_
File to log ZS and other errors.
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
static const int nEbPhi
number of crystals along Phi in EB
MonitorElement * bookFloat(DQMStore::IBooker &, const std::string &name)
int xtalGraphY(const EBDetId &id) const
static const unsigned nDccChs_
Number of input channels of a DCC.
static const double rad2deg
Conversion factor from radian to degree.
energiesEe_t eeEnergies[nEndcaps][nEeX][nEeY]
int simHit
energy reconstructed from zero-suppressed digi
CollHandle< EcalTrigPrimDigiCollection > tps_
bool collNotFoundWarn_
Switch for collection-not-found warning.
void analyzeEB(const edm::Event &event, const edm::EventSetup &es)
int simHit
energy reconstructed from zero-suppressed digi
int ruGraphX(const EcalTrigTowerDetId &id) const
int nEeZsErrors_
Counter of EE ZS errors (LI channel below ZS threshold)
CollHandle< FEDRawDataCollection > fedRaw_
void analyzeEE(const edm::Event &event, const edm::EventSetup &es)
static const int nEeDccs
number of DCCs for EE
void fill(MonitorElement *me, float x, float y, float z, float w)
bool registerHist(const std::string &name, const std::string &title)
void setTtEtSums(const edm::EventSetup &es, const EBDigiCollection &ebDigis, const EEDigiCollection &eeDigis)
void Fill(long long x)
static const int nEbEta
number of crystals along Eta in EB
double frame2EnergyForTp(const T &frame, int offset=0) const
CollHandle< EESrFlagCollection > eeComputedSrFlags_
static const int nTtPhi
Number of Trigger Towers along Phi.
int xtalGraphY(const EEDetId &id) const
CollHandle< EEDigiCollection > eeDigis_
void checkSrApplication(const edm::Event &event, T &srfs)
std::string outputFile_
Output file for histograms.
CollHandle< RecHitCollection > eeRecHits_
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 * 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)
void analyze(edm::Event const &e, edm::EventSetup const &c) override
Analyzes the event.
CollHandle< EBSrFlagCollection > ebSrFlags_
void anaDigi(const T &frame, const U &srFlagColl)
void updateL1aRate(const edm::Event &event)
int nCompleteZS_
Counter of ZS-flagged RU fully read out.
CollHandle< std::vector< PCaloHit > > eeSimHits_
static int dccZsFIR(const EcalDataFrame &frame, const std::vector< int > &firWeights, int firstFIRSample, bool *saturated=0)
int nEeFROCnt_
Counter of EE FRO-flagged RUs.
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)
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.
double recE
energy reconstructed from unsuppressed digi
Definition: DetId.h:18
static const int nEeRus
number of RUs for EE
static std::vector< int > getFIRWeights(const std::vector< double > &normalizedWeights)
static const int ebTtEdge
Number of crystals along an EB TT.
EcalSelectiveReadoutValidation(const edm::ParameterSet &ps)
Constructor.
double getEeEventSize(double nReadXtals) const
static const int kByte_
number of bytes in 1 kByte:
bool ebRuActive_[nEbEta/ebTtEdge][nEbPhi/ebTtEdge]
int xtalGraphX(const EBDetId &id) const
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_
int ruGraphX(const EcalScDetId &id) const
void fill(MonitorElement *me, float x, float yw)
subdet_t
distinguishes barral and endcap of ECAL.
static const int nTtEta
Number of Trigger Towers along Eta.
static const int nEbTtEta
Number of Trigger Towers in barrel along Eta.
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:75
int nDroppedFRO_
Counter of FRO-flagged RU dropped from data.
int ruGraphY(const EcalTrigTowerDetId &id) const
void fill(MonitorElement *me, float x)
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
long double T
static const int nEbRus
number of RUs for EB
static const unsigned nDccs_
Total number of DCCs.
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 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: event.py:1
Definition: Run.h:43
bool eeRuActive_[nEndcaps][nEeX/scEdge][nEeY/scEdge]
CollHandle< EBSrFlagCollection > ebComputedSrFlags_