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: 2012/01/31 22:28:20 $
8  * $Revision: 1.14 $
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  return nReadXtals*getBytesPerCrystal() + nReadRus*8;
203  }
204 
209  int getRuCount(int iDcc0) const;
210 
215  void readAllCollections(const edm::Event& e);
216 
225  void setTtEtSums(const edm::EventSetup& es,
226  const EBDigiCollection& ebDigis,
227  const EEDigiCollection& eeDigis);
228 
229  // /** Retrieves the logical number of the DCC reading a given crystal channel.
230  // * @param xtarId crystal channel identifier
231  // * @return the DCC logical number starting from 1.
232  // */
233  // unsigned dccNum(const DetId& xtalId) const;
234 
242  std::pair<int,int> dccCh(const DetId& xtalId) const;
243 
244 
248  int iEta2cIndex(int iEta) const{
249  return (iEta<0)?iEta+85:iEta+84;
250  }
251 
255  int iPhi2cIndex(int iPhi) const{
256  // return iPhi-1;
257  int iPhi0 = iPhi - 11;
258  if(iPhi0<0) iPhi0 += 360;
259  return iPhi0;
260  }
261 
265  int iXY2cIndex(int iX) const{
266  return iX-1;
267  }
268 
271  int cIndex2iXY(int iX0) const{
272  return iX0+1;
273  }
274 
277  int cIndex2iEta(int i) const{
278  return (i<85)?i-85:i-84;
279  }
280 
281 
284  int cIndex2iPhi(int i) const {
285  return (i+11) % 360;
286  }
287 
293  int iTtEta2cIndex(int iEta) const{
294  return (iEta<0)?iEta+28:iEta+27;
295  }
296 
302  int iTtPhi2cIndex(int iPhi) const{
303  return iPhi-1;
304  //int iPhi0 = iPhi - 3;
305  //if(iPhi0<0) iPhi0 += 72;
306  //return iPhi0;
307  }
308 
311  int cIndex2iTtEta(int i) const{
312  return (i<27)?i-28:i-27;
313  }
314 
317  int cIndex2iTtPhi(int i) const{
318  return i + 1;
319  }
320 
325  EcalScDetId superCrystalOf(const EEDetId& xtalId) const;
326 
328 
333  EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
334 
335  EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
337 
348  static int dccZsFIR(const EcalDataFrame& frame,
349  const std::vector<int>& firWeights,
350  int firstFIRSample,
351  bool* saturated = 0);
352 
353 
358  static std::vector<int> getFIRWeights(const std::vector<double>&
359  normalizedWeights);
360 
362 
365  MonitorElement* bookFloat(const std::string& name);
366 
367  MonitorElement* book1D(const std::string& name,
368  const std::string& title, int nbins,
369  double xmin, double xmax);
370 
371  MonitorElement* book2D(const std::string& name,
372  const std::string& title,
373  int nxbins, double xmin, double xmax,
374  int nybins, double ymin, double ymax);
375 
376  MonitorElement* bookProfile(const std::string& name,
377  const std::string& title,
378  int nbins, double xmin, double xmax);
379 
380  MonitorElement* bookProfile2D(const std::string& name,
381  const std::string& title,
382  int nbinx, double xmin, double xmax,
383  int nbiny, double ymin, double ymax,
384  const char* option = "");
386 
388 
390  void fill(MonitorElement* me, float x){
391  if(me) me->Fill(x);
392  }
393  void fill(MonitorElement* me,float x, float yw){
394  if(me) me->Fill(x, yw);
395  }
396  void fill(MonitorElement* me,float x, float y, float zw){
397  if(me) me->Fill(x, y, zw);
398  }
399  void fill(MonitorElement* me,float x, float y, float z, float w){
400  if(me) me->Fill(x, y, z, w);
401  }
403 
404  void initAsciiFile();
405 
409  void updateL1aRate(const edm::Event& event);
410 
415  double getL1aRate() const;
416 
417 private:
420  struct energiesEb_t{
421  double simE;
422  double noZsRecE;
423  double recE;
424  // EBDigiCollection::const_iterator itNoZsFrame; //
425  int simHit;
426  double phi;
427  double eta;
428  bool gain12; //all MGPA samples at gain 12?
429  };
430 
433  struct energiesEe_t{
434  double simE;
435  double noZsRecE;
436  double recE;
437  // EEDigiCollection::const_iterator itNoZsFrame;
438  int simHit;
439  double phi;
440  double eta;
441  bool gain12; //all MGPA samples at gain 12?
442  };
443 
445  static const int kByte_ = 1024;
446 
448  static const unsigned nDccs_ = 54;
449 
451  // = maximum number of RUs read by a DCC
452  static const unsigned nDccChs_ = 68;
453 
454  //Lower bound of DCC ID range
455  static const int minDccId_ = 1 ;
456 
457  //Upper bound of DCC ID range
458  static const int maxDccId_ = minDccId_ + nDccs_ -1;
459 
461  static const int nEbDccs = 36;
462 
464  static const int nEeDccs = 18;
465 
467  static const int nEbRus = 36*68;
468 
470  static const int nEeRus = 2*(34+32+33+33+32+34+33+34+33);
471 
473  static const int nDccRus_[nDccs_];
474 
476  static const int nEndcaps = 2;
477 
479  static const int nEbEta = 170;
480 
482  static const int nEbPhi = 360;
483 
485  static const int nEeX = 100;
486 
488  static const int nEeY = 100;
489 
491  static const int ebTtEdge = 5;
492 
494  static const int scEdge = 5;
495 
497  static const int nOneEeTtEta = 11;
498 
500  static const int nEbTtEta = 34;
501 
503  static const int nTtEta = 2*nOneEeTtEta + nEbTtEta;
504 
506  static const int nTtPhi = 72;
507 
509  static const int nMaxXtalPerRu = 25;
511  static const double rad2deg;
512 
514  bool verbose_;
515 
518 
520  std::string outputFile_;
521 
524 
528 
532 
534  std::ofstream srpAlgoErrorLog_;
535 
537  std::ofstream srApplicationErrorLog_;
538 
540  std::ofstream zsErrorLog_;
541 
543 
560 
562 
564  int64_t tmax;
565  int64_t tmin;
566  int64_t l1aOfTmin;
567  int64_t l1aOfTmax;
570 
572 
588 
594 
602 
610 
614 
619 
621 
625 
629 
635 
639 
643 
647 
658 
660 
667 
671 
674 
677 
680 
683 
686 
689 
692 
696 
700 
701 
705 
709  const EcalTPParameters* tpParam_;
710 
714 
719 
722  std::vector<double> weights_;
723 
726  std::vector<int> firWeights_;
727 
730  int ebZsThr_;
731 
734  int eeZsThr_;
735 
738  bool tpInGeV_;
739 
744 
749 
754  std::vector<bool> logErrForDccs_;
755 
758  int nEb_;
759 
762  int nEe_;
763 
766  int nEeLI_;
767 
770  int nEeHI_;
771 
774  int nEbLI_;
775 
778  int nEbHI_;
779 
783 
787 
791 
792 
796 
800 
804 
805 
807 
812 
814 
818 
821  int ievt_;
822 
828 
833 
839 
843 
847  std::set<std::string> histList_;
848 
851  bool allHists_;
852 
855  std::string histDir_;
856 
860  std::map<std::string, std::string> availableHistList_;
861 
862 
866 
870 
875  bool registerHist(const std::string& name, const std::string& title);
876 
880  void printAvailableHists();
881 
885  void normalizeHists(double eventCount);
886 
892  void configFirWeights(std::vector<double> weightsForZsFIR);
893 
899 
904 
913  template<class T>
914  void compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf);
915 
920  template<class T>
921  void checkSrApplication(const edm::Event& event, T& srfs);
922 
923 
927  int ruGraphX(const EcalScDetId& id) const{
929  return id.ix() + (id.zside()>0?20:-40);
930  }
931 
932  int ruGraphY(const EcalScDetId& id) const{
933  return id.iy();
934  }
935 
936  int ruGraphX(const EcalTrigTowerDetId& id) const{
937  return id.ieta();
938  }
939 
940  int ruGraphY(const EcalTrigTowerDetId& id) const{
941  return id.iphi();
942  }
943 
944  int xtalGraphX(const EEDetId& id) const{
945  return id.ix() + (id.zside()>0?100:-200);
946  }
947 
948  int xtalGraphY(const EEDetId& id) const{
949  return id.iy();
950  }
951 
952  int xtalGraphX(const EBDetId& id) const{
953  return id.ieta();
954  }
955 
956  int xtalGraphY(const EBDetId& id) const{
957  return id.iphi();
958  }
960 
962 
965  int dccId(const EcalScDetId& detId) const;
966  int dccId(const EcalTrigTowerDetId& detId) const;
968 
974  void selectFedsForLog();
975 
981  int getCrystalCount(int iDcc, int iDccCh);
982 
983 
984 private:
987  class Sorter{
989  public:
991  bool operator()(std::pair<int,int>a, std::pair<int,int>b){
992  return (validation->ebEnergies[a.first][a.second].simE
993  > validation->ebEnergies[b.first][b.second].simE);
994  }
995  };
996 
997  void myAna();
998 };
999 
1000 #endif //EcalSelectiveReadoutValidation_H not defined
1001 
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:33
bool eeRuActive_[nEndcaps][nEeX/scEdge][nEeY/scEdge]
T w() const
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="")