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  * $Date: 2010/01/04 15:10:59 $
8  * $Revision: 1.12 $
9  *
10  */
11 
15 
19 
20 
24 
26 //#include "DataFormats/EcalDetId/interface/EEDetId.h"
27 //#include "DataFormats/EcalDetId/interface/EBDetId.h"
31 
33 
34 #include <string>
35 #include <set>
36 #include <utility>
37 #include <fstream>
38 #include <inttypes.h>
41 
42 class DQMStore;
43 class MonitorElement;
44 class EBDetId;
45 class EEDetId;
46 class EcalTPParameters;
48 
50 
51  //typedef EcalUncalibratedRecHitCollection RecHitCollection;
52  //typedef EcalUncalibratedRecHit RecHit;
54  typedef EcalRecHit RecHit;
55 
56 public:
57 
60 
63 
64 protected:
65 
67  void analyze(edm::Event const & e, edm::EventSetup const & c);
68 
70  void beginRun(const edm::Run& r, const edm::EventSetup& c);
71 
73  void endRun(const edm::Run& r, const edm::EventSetup& c);
74 
75 private:
77  enum subdet_t {EB, EE};
78 
82  template<class T, class U>
83  void anaDigi(const T& frame, const U& srFlagColl);
84 
88  void anaDigiInit();
89 
94  void analyzeDataVolume(const edm::Event& e, const edm::EventSetup& es);
95 
100  void analyzeEB(const edm::Event& event, const edm::EventSetup& es);
101 
106  void analyzeEE(const edm::Event& event, const edm::EventSetup& es);
107 
112  void analyzeTP(const edm::Event& event, const edm::EventSetup& es);
113 
114  // /** Selective Readout decisions Validation
115  // * @param event EDM event
116  // * @param es event setup
117  // */
118  // void SRFlagValidation(const edm::Event& event, const edm::EventSetup& es);
119 
125  void SRFlagValidation(const edm::Event& event, const edm::EventSetup& es);
126 
130  double frame2Energy(const EcalDataFrame& frame) const;
131 
138  template<class T>
139  double frame2EnergyForTp(const T& frame, int offset = 0) const;
140 
141  // double getEcalEventSize(double nReadXtals) const{
142  // return getDccOverhead(EB)*nEbDccs+getDccOverhead(EE)*nEeDccs
143  // + nReadXtals*getBytesPerCrystal()
144  // + (nEeRus+nEbRus)*8;
145  // }
146 
151  double getEbEventSize(double nReadXtals) const;
152 
157  double getEeEventSize(double nReadXtals) const;
158 
162  double getDccOverhead(subdet_t subdet) const{
163  // return (subdet==EB?34:25)*8;
164  return (subdet==EB?34:52)*8;
165  }
166 
171  double getBytesPerCrystal() const{
172  return 3*8;
173  }
174 
180  double getDccEventSize(int iDcc0, double nReadXtals) const{
181  subdet_t subdet;
182  if(iDcc0<9 || iDcc0>=45){
183  subdet = EE;
184  } else{
185  subdet = EB;
186  }
187  // return getDccOverhead(subdet)+nReadXtals*getBytesPerCrystal()
188  // + getRuCount(iDcc0)*8;
189  return getDccOverhead(subdet)
190  + getDccSrDependentPayload(iDcc0, getRuCount(iDcc0), nReadXtals);
191  }
192 
200  double getDccSrDependentPayload(int iDcc0, double nReadRus,
201  double nReadXtals) const{
202  subdet_t subdet;
203  if(iDcc0<9 || iDcc0>=45){
204  subdet = EE;
205  } else{
206  subdet = EB;
207  }
208  return nReadXtals*getBytesPerCrystal() + nReadRus*8;
209  }
210 
215  int getRuCount(int iDcc0) const;
216 
221  void readAllCollections(const edm::Event& e);
222 
231  void setTtEtSums(const edm::EventSetup& es,
232  const EBDigiCollection& ebDigis,
233  const EEDigiCollection& eeDigis);
234 
235  // /** Retrieves the logical number of the DCC reading a given crystal channel.
236  // * @param xtarId crystal channel identifier
237  // * @return the DCC logical number starting from 1.
238  // */
239  // unsigned dccNum(const DetId& xtalId) const;
240 
248  std::pair<int,int> dccCh(const DetId& xtalId) const;
249 
250 
254  int iEta2cIndex(int iEta) const{
255  return (iEta<0)?iEta+85:iEta+84;
256  }
257 
261  int iPhi2cIndex(int iPhi) const{
262  // return iPhi-1;
263  int iPhi0 = iPhi - 11;
264  if(iPhi0<0) iPhi0 += 360;
265  return iPhi0;
266  }
267 
271  int iXY2cIndex(int iX) const{
272  return iX-1;
273  }
274 
277  int cIndex2iXY(int iX0) const{
278  return iX0+1;
279  }
280 
283  int cIndex2iEta(int i) const{
284  return (i<85)?i-85:i-84;
285  }
286 
287 
290  int cIndex2iPhi(int i) const {
291  return (i+11) % 360;
292  }
293 
299  int iTtEta2cIndex(int iEta) const{
300  return (iEta<0)?iEta+28:iEta+27;
301  }
302 
308  int iTtPhi2cIndex(int iPhi) const{
309  return iPhi-1;
310  //int iPhi0 = iPhi - 3;
311  //if(iPhi0<0) iPhi0 += 72;
312  //return iPhi0;
313  }
314 
317  int cIndex2iTtEta(int i) const{
318  return (i<27)?i-28:i-27;
319  }
320 
323  int cIndex2iTtPhi(int i) const{
324  return i + 1;
325  }
326 
331  EcalScDetId superCrystalOf(const EEDetId& xtalId) const;
332 
334 
339  EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
340 
341  EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
343 
354  static int dccZsFIR(const EcalDataFrame& frame,
355  const std::vector<int>& firWeights,
356  int firstFIRSample,
357  bool* saturated = 0);
358 
359 
364  static std::vector<int> getFIRWeights(const std::vector<double>&
365  normalizedWeights);
366 
368 
371  MonitorElement* bookFloat(const std::string& name);
372 
373  MonitorElement* book1D(const std::string& name,
374  const std::string& title, int nbins,
375  double xmin, double xmax);
376 
377  MonitorElement* book2D(const std::string& name,
378  const std::string& title,
379  int nxbins, double xmin, double xmax,
380  int nybins, double ymin, double ymax);
381 
382  MonitorElement* bookProfile(const std::string& name,
383  const std::string& title,
384  int nbins, double xmin, double xmax);
385 
386  MonitorElement* bookProfile2D(const std::string& name,
387  const std::string& title,
388  int nbinx, double xmin, double xmax,
389  int nbiny, double ymin, double ymax,
390  const char* option = "");
392 
394 
396  void fill(MonitorElement* me, float x){
397  if(me) me->Fill(x);
398  }
399  void fill(MonitorElement* me,float x, float yw){
400  if(me) me->Fill(x, yw);
401  }
402  void fill(MonitorElement* me,float x, float y, float zw){
403  if(me) me->Fill(x, y, zw);
404  }
405  void fill(MonitorElement* me,float x, float y, float z, float w){
406  if(me) me->Fill(x, y, z, w);
407  }
409 
410  void initAsciiFile();
411 
415  void updateL1aRate(const edm::Event& event);
416 
421  double getL1aRate() const;
422 
423 private:
426  struct energiesEb_t{
427  double simE;
428  double noZsRecE;
429  double recE;
430  // EBDigiCollection::const_iterator itNoZsFrame; //
431  int simHit;
432  double phi;
433  double eta;
434  bool gain12; //all MGPA samples at gain 12?
435  };
436 
439  struct energiesEe_t{
440  double simE;
441  double noZsRecE;
442  double recE;
443  // EEDigiCollection::const_iterator itNoZsFrame;
444  int simHit;
445  double phi;
446  double eta;
447  bool gain12; //all MGPA samples at gain 12?
448  };
449 
451  static const int kByte_ = 1024;
452 
454  static const unsigned nDccs_ = 54;
455 
457  // = maximum number of RUs read by a DCC
458  static const unsigned nDccChs_ = 68;
459 
460  //Lower bound of DCC ID range
461  static const int minDccId_ = 1 ;
462 
463  //Upper bound of DCC ID range
464  static const int maxDccId_ = minDccId_ + nDccs_ -1;
465 
467  static const int nEbDccs = 36;
468 
470  static const int nEeDccs = 18;
471 
473  static const int nEbRus = 36*68;
474 
476  static const int nEeRus = 2*(34+32+33+33+32+34+33+34+33);
477 
479  static const int nDccRus_[nDccs_];
480 
482  static const int nEndcaps = 2;
483 
485  static const int nEbEta = 170;
486 
488  static const int nEbPhi = 360;
489 
491  static const int nEeX = 100;
492 
494  static const int nEeY = 100;
495 
497  static const int ebTtEdge = 5;
498 
500  static const int scEdge = 5;
501 
503  static const int nOneEeTtEta = 11;
504 
506  static const int nEbTtEta = 34;
507 
509  static const int nTtEta = 2*nOneEeTtEta + nEbTtEta;
510 
512  static const int nTtPhi = 72;
513 
515  static const int nMaxXtalPerRu = 25;
517  static const double rad2deg;
518 
520  bool verbose_;
521 
524 
526  std::string outputFile_;
527 
530 
534 
538 
540  std::ofstream srpAlgoErrorLog_;
541 
543  std::ofstream srApplicationErrorLog_;
544 
546  std::ofstream zsErrorLog_;
547 
549 
566 
568 
570  int64_t tmax;
571  int64_t tmin;
572  int64_t l1aOfTmin;
573  int64_t l1aOfTmax;
576 
578 
594 
600 
608 
616 
620 
625 
627 
631 
635 
641 
645 
649 
653 
664 
666 
673 
677 
680 
683 
686 
689 
692 
695 
698 
702 
706 
707 
711 
715  const EcalTPParameters* tpParam_;
716 
720 
725 
728  std::vector<double> weights_;
729 
732  std::vector<int> firWeights_;
733 
736  int ebZsThr_;
737 
740  int eeZsThr_;
741 
744  bool tpInGeV_;
745 
750 
755 
760  std::vector<bool> logErrForDccs_;
761 
764  int nEb_;
765 
768  int nEe_;
769 
772  int nEeLI_;
773 
776  int nEeHI_;
777 
780  int nEbLI_;
781 
784  int nEbHI_;
785 
789 
793 
797 
798 
802 
806 
810 
811 
813 
818 
820 
824 
827  int ievt_;
828 
834 
839 
845 
849 
853  std::set<std::string> histList_;
854 
857  bool allHists_;
858 
861  std::string histDir_;
862 
866  std::map<std::string, std::string> availableHistList_;
867 
868 
872 
876 
881  bool registerHist(const std::string& name, const std::string& title);
882 
886  void printAvailableHists();
887 
891  void normalizeHists(double eventCount);
892 
898  void configFirWeights(std::vector<double> weightsForZsFIR);
899 
905 
910 
919  template<class T>
920  void compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf);
921 
926  template<class T>
927  void checkSrApplication(const edm::Event& event, T& srfs);
928 
929 
933  int ruGraphX(const EcalScDetId& id) const{
935  return id.ix() + (id.zside()>0?20:-40);
936  }
937 
938  int ruGraphY(const EcalScDetId& id) const{
939  return id.iy();
940  }
941 
942  int ruGraphX(const EcalTrigTowerDetId& id) const{
943  return id.ieta();
944  }
945 
946  int ruGraphY(const EcalTrigTowerDetId& id) const{
947  return id.iphi();
948  }
949 
950  int xtalGraphX(const EEDetId& id) const{
951  return id.ix() + (id.zside()>0?100:-200);
952  }
953 
954  int xtalGraphY(const EEDetId& id) const{
955  return id.iy();
956  }
957 
958  int xtalGraphX(const EBDetId& id) const{
959  return id.ieta();
960  }
961 
962  int xtalGraphY(const EBDetId& id) const{
963  return id.iphi();
964  }
966 
968 
971  int dccId(const EcalScDetId& detId) const;
972  int dccId(const EcalTrigTowerDetId& detId) const;
974 
980  void selectFedsForLog();
981 
987  int getCrystalCount(int iDcc, int iDccCh);
988 
989 
990 private:
993  class Sorter{
995  public:
997  bool operator()(std::pair<int,int>a, std::pair<int,int>b){
998  return (validation->ebEnergies[a.first][a.second].simE
999  > validation->ebEnergies[b.first][b.second].simE);
1000  }
1001  };
1002 
1003  void myAna();
1004 };
1005 
1006 #endif //EcalSelectiveReadoutValidation_H not defined
1007 
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.
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
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
double double double 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)
unsigned int offset(bool)
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:20
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.
void configFirWeights(std::vector< double > weightsForZsFIR)
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)
mathSSE::Vec4< T > v
const EcalTrigTowerConstituentsMap * triggerTowerMap_
void analyzeTP(const edm::Event &event, const edm::EventSetup &es)
const EcalElectronicsMapping * elecMap_
CollHandle< RecHitCollection > ebRecHits_
Definition: Run.h:32
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="")