CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
13 
17 
18 
22 
24 //#include "DataFormats/EcalDetId/interface/EEDetId.h"
25 //#include "DataFormats/EcalDetId/interface/EBDetId.h"
29 
31 
32 #include <string>
33 #include <set>
34 #include <utility>
35 #include <fstream>
36 #include <inttypes.h>
39 
40 class DQMStore;
41 class MonitorElement;
42 class EBDetId;
43 class EEDetId;
44 class EcalTPParameters;
46 
48 
49  //typedef EcalUncalibratedRecHitCollection RecHitCollection;
50  //typedef EcalUncalibratedRecHit RecHit;
52  typedef EcalRecHit RecHit;
53 
54 public:
55 
58 
61 
62 protected:
63 
65  void analyze(edm::Event const & e, edm::EventSetup const & c);
66 
68  void beginRun(const edm::Run& r, const edm::EventSetup& c);
69 
71  void endRun(const edm::Run& r, const edm::EventSetup& c);
72 
73 private:
75  enum subdet_t {EB, EE};
76 
80  template<class T, class U>
81  void anaDigi(const T& frame, const U& srFlagColl);
82 
86  void anaDigiInit();
87 
92  void analyzeDataVolume(const edm::Event& e, const edm::EventSetup& es);
93 
98  void analyzeEB(const edm::Event& event, const edm::EventSetup& es);
99 
104  void analyzeEE(const edm::Event& event, const edm::EventSetup& es);
105 
110  void analyzeTP(const edm::Event& event, const edm::EventSetup& es);
111 
112  // /** Selective Readout decisions Validation
113  // * @param event EDM event
114  // * @param es event setup
115  // */
116  // void SRFlagValidation(const edm::Event& event, const edm::EventSetup& es);
117 
123  void SRFlagValidation(const edm::Event& event, const edm::EventSetup& es);
124 
128  double frame2Energy(const EcalDataFrame& frame) const;
129 
136  template<class T>
137  double frame2EnergyForTp(const T& frame, int offset = 0) const;
138 
139  // double getEcalEventSize(double nReadXtals) const{
140  // return getDccOverhead(EB)*nEbDccs+getDccOverhead(EE)*nEeDccs
141  // + nReadXtals*getBytesPerCrystal()
142  // + (nEeRus+nEbRus)*8;
143  // }
144 
149  double getEbEventSize(double nReadXtals) const;
150 
155  double getEeEventSize(double nReadXtals) const;
156 
160  double getDccOverhead(subdet_t subdet) const{
161  // return (subdet==EB?34:25)*8;
162  return (subdet==EB?34:52)*8;
163  }
164 
169  double getBytesPerCrystal() const{
170  return 3*8;
171  }
172 
178  double getDccEventSize(int iDcc0, double nReadXtals) const{
179  subdet_t subdet;
180  if(iDcc0<9 || iDcc0>=45){
181  subdet = EE;
182  } else{
183  subdet = EB;
184  }
185  // return getDccOverhead(subdet)+nReadXtals*getBytesPerCrystal()
186  // + getRuCount(iDcc0)*8;
187  return getDccOverhead(subdet)
188  + getDccSrDependentPayload(iDcc0, getRuCount(iDcc0), nReadXtals);
189  }
190 
198  double getDccSrDependentPayload(int iDcc0, double nReadRus,
199  double nReadXtals) const{
200  return nReadXtals*getBytesPerCrystal() + nReadRus*8;
201  }
202 
207  int getRuCount(int iDcc0) const;
208 
213  void readAllCollections(const edm::Event& e);
214 
223  void setTtEtSums(const edm::EventSetup& es,
224  const EBDigiCollection& ebDigis,
225  const EEDigiCollection& eeDigis);
226 
227  // /** Retrieves the logical number of the DCC reading a given crystal channel.
228  // * @param xtarId crystal channel identifier
229  // * @return the DCC logical number starting from 1.
230  // */
231  // unsigned dccNum(const DetId& xtalId) const;
232 
240  std::pair<int,int> dccCh(const DetId& xtalId) const;
241 
242 
246  int iEta2cIndex(int iEta) const{
247  return (iEta<0)?iEta+85:iEta+84;
248  }
249 
253  int iPhi2cIndex(int iPhi) const{
254  // return iPhi-1;
255  int iPhi0 = iPhi - 11;
256  if(iPhi0<0) iPhi0 += 360;
257  return iPhi0;
258  }
259 
263  int iXY2cIndex(int iX) const{
264  return iX-1;
265  }
266 
269  int cIndex2iXY(int iX0) const{
270  return iX0+1;
271  }
272 
275  int cIndex2iEta(int i) const{
276  return (i<85)?i-85:i-84;
277  }
278 
279 
282  int cIndex2iPhi(int i) const {
283  return (i+11) % 360;
284  }
285 
291  int iTtEta2cIndex(int iEta) const{
292  return (iEta<0)?iEta+28:iEta+27;
293  }
294 
300  int iTtPhi2cIndex(int iPhi) const{
301  return iPhi-1;
302  //int iPhi0 = iPhi - 3;
303  //if(iPhi0<0) iPhi0 += 72;
304  //return iPhi0;
305  }
306 
309  int cIndex2iTtEta(int i) const{
310  return (i<27)?i-28:i-27;
311  }
312 
315  int cIndex2iTtPhi(int i) const{
316  return i + 1;
317  }
318 
323  EcalScDetId superCrystalOf(const EEDetId& xtalId) const;
324 
326 
331  EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
332 
333  EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
335 
346  static int dccZsFIR(const EcalDataFrame& frame,
347  const std::vector<int>& firWeights,
348  int firstFIRSample,
349  bool* saturated = 0);
350 
351 
356  static std::vector<int> getFIRWeights(const std::vector<double>&
357  normalizedWeights);
358 
360 
364 
366  const std::string& title, int nbins,
367  double xmin, double xmax);
368 
370  const std::string& title,
371  int nxbins, double xmin, double xmax,
372  int nybins, double ymin, double ymax);
373 
375  const std::string& title,
376  int nbins, double xmin, double xmax);
377 
379  const std::string& title,
380  int nbinx, double xmin, double xmax,
381  int nbiny, double ymin, double ymax,
382  const char* option = "");
384 
386 
388  void fill(MonitorElement* me, float x){
389  if(me) me->Fill(x);
390  }
391  void fill(MonitorElement* me,float x, float yw){
392  if(me) me->Fill(x, yw);
393  }
394  void fill(MonitorElement* me,float x, float y, float zw){
395  if(me) me->Fill(x, y, zw);
396  }
397  void fill(MonitorElement* me,float x, float y, float z, float w){
398  if(me) me->Fill(x, y, z, w);
399  }
401 
402  void initAsciiFile();
403 
407  void updateL1aRate(const edm::Event& event);
408 
413  double getL1aRate() const;
414 
415 private:
418  struct energiesEb_t{
419  double simE;
420  double noZsRecE;
421  double recE;
422  // EBDigiCollection::const_iterator itNoZsFrame; //
423  int simHit;
424  double phi;
425  double eta;
426  bool gain12; //all MGPA samples at gain 12?
427  };
428 
431  struct energiesEe_t{
432  double simE;
433  double noZsRecE;
434  double recE;
435  // EEDigiCollection::const_iterator itNoZsFrame;
436  int simHit;
437  double phi;
438  double eta;
439  bool gain12; //all MGPA samples at gain 12?
440  };
441 
443  static const int kByte_ = 1024;
444 
446  static const unsigned nDccs_ = 54;
447 
449  // = maximum number of RUs read by a DCC
450  static const unsigned nDccChs_ = 68;
451 
452  //Lower bound of DCC ID range
453  static const int minDccId_ = 1 ;
454 
455  //Upper bound of DCC ID range
456  static const int maxDccId_ = minDccId_ + nDccs_ -1;
457 
459  static const int nEbDccs = 36;
460 
462  static const int nEeDccs = 18;
463 
465  static const int nEbRus = 36*68;
466 
468  static const int nEeRus = 2*(34+32+33+33+32+34+33+34+33);
469 
471  static const int nDccRus_[nDccs_];
472 
474  static const int nEndcaps = 2;
475 
477  static const int nEbEta = 170;
478 
480  static const int nEbPhi = 360;
481 
483  static const int nEeX = 100;
484 
486  static const int nEeY = 100;
487 
489  static const int ebTtEdge = 5;
490 
492  static const int scEdge = 5;
493 
495  static const int nOneEeTtEta = 11;
496 
498  static const int nEbTtEta = 34;
499 
501  static const int nTtEta = 2*nOneEeTtEta + nEbTtEta;
502 
504  static const int nTtPhi = 72;
505 
507  static const int nMaxXtalPerRu = 25;
509  static const double rad2deg;
510 
512  bool verbose_;
513 
516 
519 
522 
526 
530 
532  std::ofstream srpAlgoErrorLog_;
533 
535  std::ofstream srApplicationErrorLog_;
536 
538  std::ofstream zsErrorLog_;
539 
541 
558 
560 
562  int64_t tmax;
563  int64_t tmin;
564  int64_t l1aOfTmin;
565  int64_t l1aOfTmax;
568 
570 
586 
592 
600 
608 
612 
617 
619 
623 
627 
633 
637 
641 
645 
656 
658 
665 
669 
672 
675 
678 
681 
684 
687 
690 
694 
698 
699 
703 
707  const EcalTPParameters* tpParam_;
708 
712 
717 
720  std::vector<double> weights_;
721 
724  std::vector<int> firWeights_;
725 
728  int ebZsThr_;
729 
732  int eeZsThr_;
733 
736  bool tpInGeV_;
737 
742 
747 
752  std::vector<bool> logErrForDccs_;
753 
756  int nEb_;
757 
760  int nEe_;
761 
764  int nEeLI_;
765 
768  int nEeHI_;
769 
772  int nEbLI_;
773 
776  int nEbHI_;
777 
781 
785 
789 
790 
794 
798 
802 
803 
805 
810 
812 
816 
819  int ievt_;
820 
826 
831 
837 
841 
845  std::set<std::string> histList_;
846 
849  bool allHists_;
850 
854 
858  std::map<std::string, std::string> availableHistList_;
859 
860 
864 
868 
873  bool registerHist(const std::string& name, const std::string& title);
874 
878  void printAvailableHists();
879 
883  void normalizeHists(double eventCount);
884 
890  void configFirWeights(const std::vector<double>& weightsForZsFIR);
891 
897 
902 
911  template<class T>
912  void compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf);
913 
918  template<class T>
919  void checkSrApplication(const edm::Event& event, T& srfs);
920 
921 
925  int ruGraphX(const EcalScDetId& id) const{
927  return id.ix() + (id.zside()>0?20:-40);
928  }
929 
930  int ruGraphY(const EcalScDetId& id) const{
931  return id.iy();
932  }
933 
934  int ruGraphX(const EcalTrigTowerDetId& id) const{
935  return id.ieta();
936  }
937 
938  int ruGraphY(const EcalTrigTowerDetId& id) const{
939  return id.iphi();
940  }
941 
942  int xtalGraphX(const EEDetId& id) const{
943  return id.ix() + (id.zside()>0?100:-200);
944  }
945 
946  int xtalGraphY(const EEDetId& id) const{
947  return id.iy();
948  }
949 
950  int xtalGraphX(const EBDetId& id) const{
951  return id.ieta();
952  }
953 
954  int xtalGraphY(const EBDetId& id) const{
955  return id.iphi();
956  }
958 
960 
963  int dccId(const EcalScDetId& detId) const;
964  int dccId(const EcalTrigTowerDetId& detId) const;
966 
972  void selectFedsForLog();
973 
979  int getCrystalCount(int iDcc, int iDccCh);
980 
981 
982 private:
985  class Sorter{
987  public:
989  bool operator()(std::pair<int,int>a, std::pair<int,int>b){
990  return (validation->ebEnergies[a.first][a.second].simE
991  > validation->ebEnergies[b.first][b.second].simE);
992  }
993  };
994 
995  void myAna();
996 };
997 
998 #endif //EcalSelectiveReadoutValidation_H not defined
999 
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)
int i
Definition: DBlmapReader.cc:9
MonitorElement * bookProfile(const std::string &name, const std::string &title, int nbins, double xmin, double xmax)
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.
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
auto zw(V v) -> Vec2< typenamestd::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:62
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
void analyze(edm::Event const &e, edm::EventSetup const &c)
Analyzes the event.
void endRun(const edm::Run &r, const edm::EventSetup &c)
Calls at end of run.
int nEeZsErrors_
Counter of EE ZS errors (LI channel below ZS threshold)
CollHandle< FEDRawDataCollection > fedRaw_
void beginRun(const edm::Run &r, const edm::EventSetup &c)
Calls at begin of run.
void analyzeEE(const edm::Event &event, const edm::EventSetup &es)
static const int nEeDccs
number of DCCs for EE
float float float z
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)
MonitorElement * book1D(const std::string &name, const std::string &title, int nbins, double xmin, double xmax)
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_
void analyzeDataVolume(const edm::Event &e, const edm::EventSetup &es)
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)
DQMStore * dbe_
Histogramming interface.
int nEeFROCnt_
Counter of EE FRO-flagged RUs.
MonitorElement * bookFloat(const std::string &name)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
MonitorElement * book2D(const std::string &name, const std::string &title, int nxbins, double xmin, double xmax, int nybins, double ymin, double ymax)
EcalScDetId superCrystalOf(const EEDetId &xtalId) 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.
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
double b
Definition: hdecay.h:120
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.
double a
Definition: hdecay.h:121
static const int nEbTtEta
Number of Trigger Towers in barrel along Eta.
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
Definition: DDAxes.h:10
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.
static const int nEndcaps
number of endcaps
bool operator()(std::pair< int, int >a, std::pair< int, int >b)
const EcalTrigTowerConstituentsMap * triggerTowerMap_
void analyzeTP(const edm::Event &event, const edm::EventSetup &es)
const EcalElectronicsMapping * elecMap_
CollHandle< RecHitCollection > ebRecHits_
Definition: Run.h:41
bool eeRuActive_[nEndcaps][nEeX/scEdge][nEeY/scEdge]
void SRFlagValidation(const edm::Event &event, const edm::EventSetup &es)
CollHandle< EBSrFlagCollection > ebComputedSrFlags_
MonitorElement * bookProfile2D(const std::string &name, const std::string &title, int nbinx, double xmin, double xmax, int nbiny, double ymin, double ymax, const char *option="")