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 
27 
34 
35 #include "CollHandle.h"
36 
37 #include <string>
38 #include <set>
39 #include <fstream>
40 
41 class EBDetId;
42 class EEDetId;
45 
48  typedef EcalRecHit RecHit;
49 
50 public:
53 
56  void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
57  void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
58 
59 protected:
61  void analyze(edm::Event const& e, edm::EventSetup const& c) override;
62 
63  void dqmEndRun(const edm::Run& r, const edm::EventSetup& c) override;
64 
65 private:
67  enum subdet_t { EB, EE };
68 
72  template <class T, class U>
73  void anaDigi(const T& frame, const U& srFlagColl);
74 
78  void anaDigiInit();
79 
84  void analyzeDataVolume(const edm::Event& e, const edm::EventSetup& es);
85 
90  void analyzeEB(const edm::Event& event, const edm::EventSetup& es);
91 
96  void analyzeEE(const edm::Event& event, const edm::EventSetup& es);
97 
102  void analyzeTP(const edm::Event& event, const edm::EventSetup& es);
103 
104  // /** Selective Readout decisions Validation
105  // * @param event EDM event
106  // * @param es event setup
107  // */
108  // void SRFlagValidation(const edm::Event& event, const edm::EventSetup& es);
109 
113  double frame2Energy(const EcalDataFrame& frame) const;
114 
121  template <class T>
122  double frame2EnergyForTp(const T& frame, int offset = 0) const;
123 
124  // double getEcalEventSize(double nReadXtals) const{
125  // return getDccOverhead(EB)*nEbDccs+getDccOverhead(EE)*nEeDccs
126  // + nReadXtals*getBytesPerCrystal()
127  // + (nEeRus+nEbRus)*8;
128  // }
129 
134  double getEbEventSize(double nReadXtals) const;
135 
140  double getEeEventSize(double nReadXtals) const;
141 
145  double getDccOverhead(subdet_t subdet) const {
146  // return (subdet==EB?34:25)*8;
147  return (subdet == EB ? 34 : 52) * 8;
148  }
149 
154  double getBytesPerCrystal() const { return 3 * 8; }
155 
161  double getDccEventSize(int iDcc0, double nReadXtals) const {
162  subdet_t subdet;
163  if (iDcc0 < 9 || iDcc0 >= 45) {
164  subdet = EE;
165  } else {
166  subdet = EB;
167  }
168  // return getDccOverhead(subdet)+nReadXtals*getBytesPerCrystal()
169  // + getRuCount(iDcc0)*8;
170  return getDccOverhead(subdet) + getDccSrDependentPayload(iDcc0, getRuCount(iDcc0), nReadXtals);
171  }
172 
180  double getDccSrDependentPayload(int iDcc0, double nReadRus, double nReadXtals) const {
181  return nReadXtals * getBytesPerCrystal() + nReadRus * 8;
182  }
183 
188  int getRuCount(int iDcc0) const;
189 
194  void readAllCollections(const edm::Event& e);
195 
204  void setTtEtSums(const edm::EventSetup& es, const EBDigiCollection& ebDigis, const EEDigiCollection& eeDigis);
205 
206  // /** Retrieves the logical number of the DCC reading a given crystal channel.
207  // * @param xtarId crystal channel identifier
208  // * @return the DCC logical number starting from 1.
209  // */
210  // unsigned dccNum(const DetId& xtalId) const;
211 
219  std::pair<int, int> dccCh(const DetId& xtalId) const;
220 
224  int iEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 85 : iEta + 84; }
225 
229  int iPhi2cIndex(int iPhi) const {
230  // return iPhi-1;
231  int iPhi0 = iPhi - 11;
232  if (iPhi0 < 0)
233  iPhi0 += 360;
234  return iPhi0;
235  }
236 
240  int iXY2cIndex(int iX) const { return iX - 1; }
241 
244  int cIndex2iXY(int iX0) const { return iX0 + 1; }
245 
248  int cIndex2iEta(int i) const { return (i < 85) ? i - 85 : i - 84; }
249 
252  int cIndex2iPhi(int i) const { return (i + 11) % 360; }
253 
259  int iTtEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 28 : iEta + 27; }
260 
266  int iTtPhi2cIndex(int iPhi) const {
267  return iPhi - 1;
268  //int iPhi0 = iPhi - 3;
269  //if(iPhi0<0) iPhi0 += 72;
270  //return iPhi0;
271  }
272 
275  int cIndex2iTtEta(int i) const { return (i < 27) ? i - 28 : i - 27; }
276 
279  int cIndex2iTtPhi(int i) const { return i + 1; }
280 
282 
287  EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
288 
289  EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
291 
302  static int dccZsFIR(const EcalDataFrame& frame,
303  const std::vector<int>& firWeights,
304  int firstFIRSample,
305  bool* saturated = nullptr);
306 
311  static std::vector<int> getFIRWeights(const std::vector<double>& normalizedWeights);
312 
314 
318 
320  DQMStore::IBooker&, const std::string& name, const std::string& title, int nbins, double xmin, double xmax);
321 
323  const std::string& name,
324  const std::string& title,
325  int nxbins,
326  double xmin,
327  double xmax,
328  int nybins,
329  double ymin,
330  double ymax);
331 
333  DQMStore::IBooker&, const std::string& name, const std::string& title, int nbins, double xmin, double xmax);
334 
336  const std::string& name,
337  const std::string& title,
338  int nbinx,
339  double xmin,
340  double xmax,
341  int nbiny,
342  double ymin,
343  double ymax,
344  const char* option = "");
346 
348 
350  void fill(MonitorElement* me, float x) {
351  if (me)
352  me->Fill(x);
353  }
354  void fill(MonitorElement* me, float x, float yw) {
355  if (me)
356  me->Fill(x, yw);
357  }
358  void fill(MonitorElement* me, float x, float y, float zw) {
359  if (me)
360  me->Fill(x, y, zw);
361  }
362  void fill(MonitorElement* me, float x, float y, float z, float w) {
363  if (me)
364  me->Fill(x, y, z, w);
365  }
367 
368  void initAsciiFile();
369 
373  void updateL1aRate(const edm::Event& event);
374 
379  double getL1aRate() const;
380 
381 private:
384  struct energiesEb_t {
385  double simE;
386  double noZsRecE;
387  double recE;
388  // EBDigiCollection::const_iterator itNoZsFrame; //
389  int simHit;
390  double phi;
391  double eta;
392  bool gain12; //all MGPA samples at gain 12?
393  };
394 
397  struct energiesEe_t {
398  double simE;
399  double noZsRecE;
400  double recE;
401  // EEDigiCollection::const_iterator itNoZsFrame;
402  int simHit;
403  double phi;
404  double eta;
405  bool gain12; //all MGPA samples at gain 12?
406  };
407 
414 
416  static const int kByte_ = 1024;
417 
419  static const unsigned nDccs_ = 54;
420 
422  // = maximum number of RUs read by a DCC
423  static const unsigned nDccChs_ = 68;
424 
425  //Lower bound of DCC ID range
426  static const int minDccId_ = 1;
427 
428  //Upper bound of DCC ID range
429  static const int maxDccId_ = minDccId_ + nDccs_ - 1;
430 
432  static const int nEbDccs = 36;
433 
435  static const int nEeDccs = 18;
436 
438  static const int nEbRus = 36 * 68;
439 
441  static const int nEeRus = 2 * (34 + 32 + 33 + 33 + 32 + 34 + 33 + 34 + 33);
442 
444  static const int nDccRus_[nDccs_];
445 
447  static const int nEndcaps = 2;
448 
450  static const int nEbEta = 170;
451 
453  static const int nEbPhi = 360;
454 
456  static const int nEeX = 100;
457 
459  static const int nEeY = 100;
460 
462  static const int ebTtEdge = 5;
463 
465  static const int scEdge = 5;
466 
468  static const int nOneEeTtEta = 11;
469 
471  static const int nEbTtEta = 34;
472 
474  static const int nTtEta = 2 * nOneEeTtEta + nEbTtEta;
475 
477  static const int nTtPhi = 72;
478 
480  static const int nMaxXtalPerRu = 25;
482  static const double rad2deg;
483 
485  bool verbose_;
486 
489 
492 
496 
500 
502  std::ofstream srpAlgoErrorLog_;
503 
505  std::ofstream srApplicationErrorLog_;
506 
508  std::ofstream zsErrorLog_;
509 
511 
528 
530 
532  int64_t tmax;
533  int64_t tmin;
534  int64_t l1aOfTmin;
535  int64_t l1aOfTmax;
538 
540 
556 
562 
570 
578 
582 
587 
589 
593 
597 
603 
607 
611 
615 
626 
628 
635 
639 
642 
645 
648 
651 
654 
657 
660 
664 
668 
672 
676 
681 
684  std::vector<double> weights_;
685 
688  std::vector<int> firWeights_;
689 
692  int ebZsThr_;
693 
696  int eeZsThr_;
697 
700  bool tpInGeV_;
701 
706 
711 
716  std::vector<bool> logErrForDccs_;
717 
720  int nEb_;
721 
724  int nEe_;
725 
728  int nEeLI_;
729 
732  int nEeHI_;
733 
736  int nEbLI_;
737 
740  int nEbHI_;
741 
745 
749 
753 
757 
761 
765 
767 
772 
774 
778 
781  int ievt_;
782 
788 
792 
796  std::set<std::string> histList_;
797 
800  bool allHists_;
801 
805 
809  std::map<std::string, std::string> availableHistList_;
810 
814 
818 
823  bool registerHist(const std::string& name, const std::string& title);
824 
828  void printAvailableHists();
829 
835  void configFirWeights(const std::vector<double>& weightsForZsFIR);
836 
842 
847 
856  template <class T>
857  void compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf);
858 
863  template <class T>
864  void checkSrApplication(const edm::Event& event, T& srfs);
865 
869  int ruGraphX(const EcalScDetId& id) const { return id.ix() + (id.zside() > 0 ? 20 : -40); }
871 
872  int ruGraphY(const EcalScDetId& id) const { return id.iy(); }
873 
874  int ruGraphX(const EcalTrigTowerDetId& id) const { return id.ieta(); }
875 
876  int ruGraphY(const EcalTrigTowerDetId& id) const { return id.iphi(); }
877 
878  int xtalGraphX(const EEDetId& id) const { return id.ix() + (id.zside() > 0 ? 100 : -200); }
879 
880  int xtalGraphY(const EEDetId& id) const { return id.iy(); }
881 
882  int xtalGraphX(const EBDetId& id) const { return id.ieta(); }
883 
884  int xtalGraphY(const EBDetId& id) const { return id.iphi(); }
885 
887 
889 
892  int dccId(const EcalScDetId& detId) const;
893  int dccId(const EcalTrigTowerDetId& detId) const;
895 
901  void selectFedsForLog();
902 
908  int getCrystalCount(int iDcc, int iDccCh);
909 };
910 
911 #endif //EcalSelectiveReadoutValidation_H not defined
void configFirWeights(const std::vector< double > &weightsForZsFIR)
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.
static const int nEeX
EE crystal grid size along X.
EcalTrigTowerDetId readOutUnitOf(const EBDetId &xtalId) const
int nIncompleteFRO_
Counter of FRO-flagged RU only partial data.
std::ofstream zsErrorLog_
File to log ZS and other errors.
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
T w() const
static const int nEbPhi
number of crystals along Phi in EB
int ruGraphY(const EcalScDetId &id) const
static const unsigned nDccChs_
Number of input channels of a DCC.
static const double rad2deg
Conversion factor from radian to degree.
double getDccSrDependentPayload(int iDcc0, double nReadRus, double nReadXtals) const
int simHit
energy reconstructed from zero-suppressed digi
CollHandle< EcalTrigPrimDigiCollection > tps_
bool collNotFoundWarn_
Switch for collection-not-found warning.
std::pair< int, int > dccCh(const DetId &xtalId) const
void analyzeEB(const edm::Event &event, const edm::EventSetup &es)
edm::ESGetToken< EcalTPGLutIdMap, EcalTPGLutIdMapRcd > lutMapHandle
int simHit
energy reconstructed from zero-suppressed digi
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
double frame2Energy(const EcalDataFrame &frame) const
double frame2EnergyForTp(const T &frame, int offset=0) const
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
edm::ESGetToken< EcalTrigTowerConstituentsMap, IdealGeometryRecord > hTriggerTowerMap
CollHandle< EESrFlagCollection > eeComputedSrFlags_
static const int nTtPhi
Number of Trigger Towers along Phi.
CollHandle< EEDigiCollection > eeDigis_
void checkSrApplication(const edm::Event &event, T &srfs)
int ruGraphX(const EcalTrigTowerDetId &id) const
std::string outputFile_
Output file for histograms.
CollHandle< RecHitCollection > eeRecHits_
int ruGraphX(const EcalScDetId &id) const
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="")
double getDccEventSize(int iDcc0, double nReadXtals) const
void analyzeDataVolume(const edm::Event &e, const edm::EventSetup &es)
edm::ESGetToken< EcalTPGLutGroup, EcalTPGLutGroupRcd > lutGrpHandle
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geoToken
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)
edm::ESGetToken< EcalTPGPhysicsConst, EcalTPGPhysicsConstRcd > physHandle
void updateL1aRate(const edm::Event &event)
int nCompleteZS_
Counter of ZS-flagged RU fully read out.
double getDccOverhead(subdet_t subdet) const
CollHandle< std::vector< PCaloHit > > eeSimHits_
static int dccZsFIR(const EcalDataFrame &frame, const std::vector< int > &firWeights, int firstFIRSample, bool *saturated=nullptr)
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
double getEbEventSize(double nReadXtals) const
static const int nOneEeTtEta
Number of Trigger Towers in an endcap along Eta.
int dccId(const EcalScDetId &detId) const
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.
static const int kByte_
number of bytes in 1 kByte:
bool ebRuActive_[nEbEta/ebTtEdge][nEbPhi/ebTtEdge]
edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > ecalmapping
MonitorElement * bookProfile(DQMStore::IBooker &, const std::string &name, const std::string &title, int nbins, double xmin, double xmax)
CollHandle< EEDigiCollection > eeNoZsDigis_
double recE
energy reconstructed from unsuppressed digi
std::map< std::string, std::string > availableHistList_
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.
int ruGraphY(const EcalTrigTowerDetId &id) const
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.
void fill(MonitorElement *me, float x)
void compareSrfColl(const edm::Event &event, T &srfFromData, T &computedSrf)
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 getEeEventSize(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_