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 
36  typedef EcalRecHit RecHit;
37 
38 public:
41 
44  void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
45  void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
46 
47 protected:
49  void analyze(edm::Event const& e, edm::EventSetup const& c) override;
50 
51  void dqmEndRun(const edm::Run& r, const edm::EventSetup& c) override;
52 
53 private:
55  enum subdet_t { EB, EE };
56 
60  template <class T, class U>
61  void anaDigi(const T& frame, const U& srFlagColl);
62 
66  void anaDigiInit();
67 
72  void analyzeDataVolume(const edm::Event& e, const edm::EventSetup& es);
73 
78  void analyzeEB(const edm::Event& event, const edm::EventSetup& es);
79 
84  void analyzeEE(const edm::Event& event, const edm::EventSetup& es);
85 
90  void analyzeTP(const edm::Event& event, const edm::EventSetup& es);
91 
92  // /** Selective Readout decisions Validation
93  // * @param event EDM event
94  // * @param es event setup
95  // */
96  // void SRFlagValidation(const edm::Event& event, const edm::EventSetup& es);
97 
101  double frame2Energy(const EcalDataFrame& frame) const;
102 
109  template <class T>
110  double frame2EnergyForTp(const T& frame, int offset = 0) const;
111 
112  // double getEcalEventSize(double nReadXtals) const{
113  // return getDccOverhead(EB)*nEbDccs+getDccOverhead(EE)*nEeDccs
114  // + nReadXtals*getBytesPerCrystal()
115  // + (nEeRus+nEbRus)*8;
116  // }
117 
122  double getEbEventSize(double nReadXtals) const;
123 
128  double getEeEventSize(double nReadXtals) const;
129 
133  double getDccOverhead(subdet_t subdet) const {
134  // return (subdet==EB?34:25)*8;
135  return (subdet == EB ? 34 : 52) * 8;
136  }
137 
142  double getBytesPerCrystal() const { return 3 * 8; }
143 
149  double getDccEventSize(int iDcc0, double nReadXtals) const {
150  subdet_t subdet;
151  if (iDcc0 < 9 || iDcc0 >= 45) {
152  subdet = EE;
153  } else {
154  subdet = EB;
155  }
156  // return getDccOverhead(subdet)+nReadXtals*getBytesPerCrystal()
157  // + getRuCount(iDcc0)*8;
158  return getDccOverhead(subdet) + getDccSrDependentPayload(iDcc0, getRuCount(iDcc0), nReadXtals);
159  }
160 
168  double getDccSrDependentPayload(int iDcc0, double nReadRus, double nReadXtals) const {
169  return nReadXtals * getBytesPerCrystal() + nReadRus * 8;
170  }
171 
176  int getRuCount(int iDcc0) const;
177 
182  void readAllCollections(const edm::Event& e);
183 
192  void setTtEtSums(const edm::EventSetup& es, const EBDigiCollection& ebDigis, const EEDigiCollection& eeDigis);
193 
194  // /** Retrieves the logical number of the DCC reading a given crystal channel.
195  // * @param xtarId crystal channel identifier
196  // * @return the DCC logical number starting from 1.
197  // */
198  // unsigned dccNum(const DetId& xtalId) const;
199 
207  std::pair<int, int> dccCh(const DetId& xtalId) const;
208 
212  int iEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 85 : iEta + 84; }
213 
217  int iPhi2cIndex(int iPhi) const {
218  // return iPhi-1;
219  int iPhi0 = iPhi - 11;
220  if (iPhi0 < 0)
221  iPhi0 += 360;
222  return iPhi0;
223  }
224 
228  int iXY2cIndex(int iX) const { return iX - 1; }
229 
232  int cIndex2iXY(int iX0) const { return iX0 + 1; }
233 
236  int cIndex2iEta(int i) const { return (i < 85) ? i - 85 : i - 84; }
237 
240  int cIndex2iPhi(int i) const { return (i + 11) % 360; }
241 
247  int iTtEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 28 : iEta + 27; }
248 
254  int iTtPhi2cIndex(int iPhi) const {
255  return iPhi - 1;
256  //int iPhi0 = iPhi - 3;
257  //if(iPhi0<0) iPhi0 += 72;
258  //return iPhi0;
259  }
260 
263  int cIndex2iTtEta(int i) const { return (i < 27) ? i - 28 : i - 27; }
264 
267  int cIndex2iTtPhi(int i) const { return i + 1; }
268 
270 
275  EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
276 
277  EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
279 
290  static int dccZsFIR(const EcalDataFrame& frame,
291  const std::vector<int>& firWeights,
292  int firstFIRSample,
293  bool* saturated = nullptr);
294 
299  static std::vector<int> getFIRWeights(const std::vector<double>& normalizedWeights);
300 
302 
306 
308  DQMStore::IBooker&, const std::string& name, const std::string& title, int nbins, double xmin, double xmax);
309 
311  const std::string& name,
312  const std::string& title,
313  int nxbins,
314  double xmin,
315  double xmax,
316  int nybins,
317  double ymin,
318  double ymax);
319 
321  DQMStore::IBooker&, const std::string& name, const std::string& title, int nbins, double xmin, double xmax);
322 
324  const std::string& name,
325  const std::string& title,
326  int nbinx,
327  double xmin,
328  double xmax,
329  int nbiny,
330  double ymin,
331  double ymax,
332  const char* option = "");
334 
336 
338  void fill(MonitorElement* me, float x) {
339  if (me)
340  me->Fill(x);
341  }
342  void fill(MonitorElement* me, float x, float yw) {
343  if (me)
344  me->Fill(x, yw);
345  }
346  void fill(MonitorElement* me, float x, float y, float zw) {
347  if (me)
348  me->Fill(x, y, zw);
349  }
350  void fill(MonitorElement* me, float x, float y, float z, float w) {
351  if (me)
352  me->Fill(x, y, z, w);
353  }
355 
356  void initAsciiFile();
357 
361  void updateL1aRate(const edm::Event& event);
362 
367  double getL1aRate() const;
368 
369 private:
372  struct energiesEb_t {
373  double simE;
374  double noZsRecE;
375  double recE;
376  // EBDigiCollection::const_iterator itNoZsFrame; //
377  int simHit;
378  double phi;
379  double eta;
380  bool gain12; //all MGPA samples at gain 12?
381  };
382 
385  struct energiesEe_t {
386  double simE;
387  double noZsRecE;
388  double recE;
389  // EEDigiCollection::const_iterator itNoZsFrame;
390  int simHit;
391  double phi;
392  double eta;
393  bool gain12; //all MGPA samples at gain 12?
394  };
395 
397  static const int kByte_ = 1024;
398 
400  static const unsigned nDccs_ = 54;
401 
403  // = maximum number of RUs read by a DCC
404  static const unsigned nDccChs_ = 68;
405 
406  //Lower bound of DCC ID range
407  static const int minDccId_ = 1;
408 
409  //Upper bound of DCC ID range
410  static const int maxDccId_ = minDccId_ + nDccs_ - 1;
411 
413  static const int nEbDccs = 36;
414 
416  static const int nEeDccs = 18;
417 
419  static const int nEbRus = 36 * 68;
420 
422  static const int nEeRus = 2 * (34 + 32 + 33 + 33 + 32 + 34 + 33 + 34 + 33);
423 
425  static const int nDccRus_[nDccs_];
426 
428  static const int nEndcaps = 2;
429 
431  static const int nEbEta = 170;
432 
434  static const int nEbPhi = 360;
435 
437  static const int nEeX = 100;
438 
440  static const int nEeY = 100;
441 
443  static const int ebTtEdge = 5;
444 
446  static const int scEdge = 5;
447 
449  static const int nOneEeTtEta = 11;
450 
452  static const int nEbTtEta = 34;
453 
455  static const int nTtEta = 2 * nOneEeTtEta + nEbTtEta;
456 
458  static const int nTtPhi = 72;
459 
461  static const int nMaxXtalPerRu = 25;
463  static const double rad2deg;
464 
466  bool verbose_;
467 
470 
473 
477 
481 
483  std::ofstream srpAlgoErrorLog_;
484 
486  std::ofstream srApplicationErrorLog_;
487 
489  std::ofstream zsErrorLog_;
490 
492 
509 
511 
513  int64_t tmax;
514  int64_t tmin;
515  int64_t l1aOfTmin;
516  int64_t l1aOfTmax;
519 
521 
537 
543 
551 
559 
563 
568 
570 
574 
578 
584 
588 
592 
596 
607 
609 
616 
620 
623 
626 
629 
632 
635 
638 
641 
645 
649 
653 
657 
662 
665  std::vector<double> weights_;
666 
669  std::vector<int> firWeights_;
670 
673  int ebZsThr_;
674 
677  int eeZsThr_;
678 
681  bool tpInGeV_;
682 
687 
692 
697  std::vector<bool> logErrForDccs_;
698 
701  int nEb_;
702 
705  int nEe_;
706 
709  int nEeLI_;
710 
713  int nEeHI_;
714 
717  int nEbLI_;
718 
721  int nEbHI_;
722 
726 
730 
734 
738 
742 
746 
748 
750  bool ebRuActive_[nEbEta / ebTtEdge][nEbPhi / ebTtEdge];
751  bool eeRuActive_[nEndcaps][nEeX / scEdge][nEeY / scEdge];
753 
755 
759 
762  int ievt_;
763 
769 
774 
780 
784 
788  std::set<std::string> histList_;
789 
792  bool allHists_;
793 
797 
801  std::map<std::string, std::string> availableHistList_;
802 
806 
810 
815  bool registerHist(const std::string& name, const std::string& title);
816 
820  void printAvailableHists();
821 
827  void configFirWeights(const std::vector<double>& weightsForZsFIR);
828 
834 
839 
848  template <class T>
849  void compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf);
850 
855  template <class T>
856  void checkSrApplication(const edm::Event& event, T& srfs);
857 
861  int ruGraphX(const EcalScDetId& id) const { return id.ix() + (id.zside() > 0 ? 20 : -40); }
863 
864  int ruGraphY(const EcalScDetId& id) const { return id.iy(); }
865 
866  int ruGraphX(const EcalTrigTowerDetId& id) const { return id.ieta(); }
867 
868  int ruGraphY(const EcalTrigTowerDetId& id) const { return id.iphi(); }
869 
870  int xtalGraphX(const EEDetId& id) const { return id.ix() + (id.zside() > 0 ? 100 : -200); }
871 
872  int xtalGraphY(const EEDetId& id) const { return id.iy(); }
873 
874  int xtalGraphX(const EBDetId& id) const { return id.ieta(); }
875 
876  int xtalGraphY(const EBDetId& id) const { return id.iphi(); }
877 
879 
881 
884  int dccId(const EcalScDetId& detId) const;
885  int dccId(const EcalTrigTowerDetId& detId) const;
887 
893  void selectFedsForLog();
894 
900  int getCrystalCount(int iDcc, int iDccCh);
901 };
902 
903 #endif //EcalSelectiveReadoutValidation_H not defined
void configFirWeights(const std::vector< double > &weightsForZsFIR)
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
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 dqmEndRun(const edm::Run &r, const edm::EventSetup &c) override
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)
static const int nEbEta
number of crystals along Eta in EB
void Fill(long long x)
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 * 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="")
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 * book2D(DQMStore::IBooker &, const std::string &name, const std::string &title, int nxbins, double xmin, double xmax, int nybins, double ymin, double ymax)
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:17
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.
MonitorElement * book1D(DQMStore::IBooker &, const std::string &name, const std::string &title, int nbins, double xmin, double xmax)
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
MonitorElement * bookProfile(DQMStore::IBooker &, const std::string &name, const std::string &title, int nbins, double xmin, double xmax)
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 * bookFloat(DQMStore::IBooker &, const std::string &name)
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:45
bool eeRuActive_[nEndcaps][nEeX/scEdge][nEeY/scEdge]
CollHandle< EBSrFlagCollection > ebComputedSrFlags_