Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-08 02:27:45

0001 #ifndef EcalSelectiveReadoutValidation_H
0002 #define EcalSelectiveReadoutValidation_H
0003 
0004 /*
0005  * \file EcalSelectiveReadoutValidation.h
0006  *
0007  *
0008  */
0009 
0010 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0011 
0012 #include "DQMServices/Core/interface/DQMStore.h"
0013 
0014 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0015 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0016 
0017 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0018 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0019 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0020 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
0021 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
0022 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0023 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0024 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
0025 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0026 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0027 
0028 #include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h"
0029 #include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h"
0030 #include "CondFormats/EcalObjects/interface/EcalTPGPhysicsConst.h"
0031 #include "CondFormats/DataRecord/interface/EcalTPGLutIdMapRcd.h"
0032 #include "CondFormats/DataRecord/interface/EcalTPGLutGroupRcd.h"
0033 #include "CondFormats/DataRecord/interface/EcalTPGPhysicsConstRcd.h"
0034 
0035 #include "CollHandle.h"
0036 
0037 #include <string>
0038 #include <set>
0039 #include <fstream>
0040 
0041 class EBDetId;
0042 class EEDetId;
0043 class EcalElectronicsMapping;
0044 class EcalTrigTowerConstituentsMap;
0045 
0046 class EcalSelectiveReadoutValidation : public DQMOneEDAnalyzer<> {
0047   typedef EcalRecHitCollection RecHitCollection;
0048   typedef EcalRecHit RecHit;
0049 
0050 public:
0051   /// Constructor
0052   EcalSelectiveReadoutValidation(const edm::ParameterSet& ps);
0053 
0054   /// Destructor
0055   ~EcalSelectiveReadoutValidation() override;
0056   void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0057   void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
0058 
0059 protected:
0060   /// Analyzes the event.
0061   void analyze(edm::Event const& e, edm::EventSetup const& c) override;
0062 
0063   void dqmEndRun(const edm::Run& r, const edm::EventSetup& c) override;
0064 
0065 private:
0066   ///distinguishes barral and endcap of ECAL.
0067   enum subdet_t { EB, EE };
0068 
0069   /** Accumulates statitics for data volume analysis. To be called for each
0070    * ECAL digi. See anaDigiInit().
0071    */
0072   template <class T, class U>
0073   void anaDigi(const T& frame, const U& srFlagColl);
0074 
0075   /** Initializes statistics accumalator for data volume analysis. To
0076    * be call at start of each event analysis.
0077    */
0078   void anaDigiInit();
0079 
0080   /** Data volume analysis. To be called for each event.
0081    * @param event EDM event
0082    * @param es event setup
0083    */
0084   void analyzeDataVolume(const edm::Event& e, const edm::EventSetup& es);
0085 
0086   /** ECAL barrel data analysis. To be called for each event.
0087    * @param event EDM event
0088    * @param es event setup
0089    */
0090   void analyzeEB(const edm::Event& event, const edm::EventSetup& es);
0091 
0092   /** ECAL endcap data analysis. To be called for each event.
0093    * @param event EDM event
0094    * @param es event setup
0095    */
0096   void analyzeEE(const edm::Event& event, const edm::EventSetup& es);
0097 
0098   /** Trigger primitive analysis. To be called for each event.
0099    * @param event EDM event
0100    * @param es event setup
0101    */
0102   void analyzeTP(const edm::Event& event, const edm::EventSetup& es);
0103 
0104   //  /** Selective Readout decisions Validation
0105   //    * @param event EDM event
0106   //    * @param es event setup
0107   //    */
0108   //   void SRFlagValidation(const edm::Event& event, const edm::EventSetup& es);
0109 
0110   /** Energy reconstruction from ADC samples.
0111    * @param frame the ADC sample of an ECA channel
0112    */
0113   double frame2Energy(const EcalDataFrame& frame) const;
0114 
0115   /** Energy reconstruction from ADC samples to be used for trigger primitive
0116    * estimate.
0117    * @param frame the ADC sample of an ECA channel
0118    * @param offset time offset. To be used to evaluate energy of the event
0119    * previous (offset=-1) and next (offset=+1) to the triggered one.
0120    */
0121   template <class T>
0122   double frame2EnergyForTp(const T& frame, int offset = 0) const;
0123 
0124   //   double getEcalEventSize(double nReadXtals) const{
0125   //     return getDccOverhead(EB)*nEbDccs+getDccOverhead(EE)*nEeDccs
0126   //       + nReadXtals*getBytesPerCrystal()
0127   //       + (nEeRus+nEbRus)*8;
0128   //   }
0129 
0130   /** Computes the size of an ECAL barrel event fragment.
0131    * @param nReadXtals number of read crystal channels
0132    * @return the event fragment size in bytes
0133    */
0134   double getEbEventSize(double nReadXtals) const;
0135 
0136   /** Computes the size of an ECAL endcap event fragment.
0137    * @param nReadXtals number of read crystal channels
0138    * @return the event fragment size in bytes
0139    */
0140   double getEeEventSize(double nReadXtals) const;
0141 
0142   /** Gets the size in bytes fixed-size part of a DCC event fragment.
0143    * @return the fixed size in bytes.
0144    */
0145   double getDccOverhead(subdet_t subdet) const {
0146     //  return (subdet==EB?34:25)*8;
0147     return (subdet == EB ? 34 : 52) * 8;
0148   }
0149 
0150   /** Gets the number of bytes per crystal channel of the event part
0151    * depending on the number of read crystal channels.
0152    * @return the number of bytes.
0153    */
0154   double getBytesPerCrystal() const { return 3 * 8; }
0155 
0156   /** Gets the size of an DCC event fragment.
0157    * @param iDcc0 the DCC logical number starting from 0.
0158    * @param nReadXtals number of read crystal channels.
0159    * @return the DCC event fragment size in bytes.
0160    */
0161   double getDccEventSize(int iDcc0, double nReadXtals) const {
0162     subdet_t subdet;
0163     if (iDcc0 < 9 || iDcc0 >= 45) {
0164       subdet = EE;
0165     } else {
0166       subdet = EB;
0167     }
0168     //     return getDccOverhead(subdet)+nReadXtals*getBytesPerCrystal()
0169     //       + getRuCount(iDcc0)*8;
0170     return getDccOverhead(subdet) + getDccSrDependentPayload(iDcc0, getRuCount(iDcc0), nReadXtals);
0171   }
0172 
0173   /** Gets DCC event fragment payload depending on the channel selection
0174    * made by the selective readout.
0175    * @param iDcc0 the DCC logical number starting from 0.
0176    * @param nReadRus number of read-out RUs
0177    * @param nReadXtals number of read-out crystal channels.
0178    * @return the DCC event fragment payload in bytes.
0179    */
0180   double getDccSrDependentPayload(int iDcc0, double nReadRus, double nReadXtals) const {
0181     return nReadXtals * getBytesPerCrystal() + nReadRus * 8;
0182   }
0183 
0184   /** Gets the number of readout unit read by a DCC. A readout unit
0185    * correspond to an active DCC input channel.
0186    * @param iDcc0 DCC logical number starting from 0.
0187    */
0188   int getRuCount(int iDcc0) const;
0189 
0190   /** Reads the data collections from the event. Called at start
0191    * of each event analysis.
0192    * @param event the EDM event.
0193    */
0194   void readAllCollections(const edm::Event& e);
0195 
0196   /** Computes trigger primitive estimates. A sum of crystal deposited
0197    * transverse energy is performed.
0198    * @param es event setup
0199    * @param ebDigis the ECAL barrel unsuppressed digi to use for the
0200    * computation
0201    * @param ebDigis the ECAL endcap unsuppressed digi to use for the
0202    * computation
0203    */
0204   void setTtEtSums(const edm::EventSetup& es, const EBDigiCollection& ebDigis, const EEDigiCollection& eeDigis);
0205 
0206   //   /** Retrieves the logical number of the DCC reading a given crystal channel.
0207   //    * @param xtarId crystal channel identifier
0208   //    * @return the DCC logical number starting from 1.
0209   //    */
0210   //   unsigned dccNum(const DetId& xtalId) const;
0211 
0212   /** Retrieves the DCC channel reading out a crystal, the
0213    * crystals of a barrel trigger tower or the crystals,
0214    * of an endcap supercrystal.
0215    * @param xtarId crystal channel, barrel trigger tower or
0216    * endcap supercrystal identifier
0217    * @return pair of (DCC ID, DCC channel)
0218    */
0219   std::pair<int, int> dccCh(const DetId& xtalId) const;
0220 
0221   /** Converts a std CMSSW crystal eta index to a c-array index (starting from
0222    * zero and without hole).
0223    */
0224   int iEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 85 : iEta + 84; }
0225 
0226   /** Converts a std CMSSW crystal phi index to a c-array index (starting from
0227    * zero and without hole).
0228    */
0229   int iPhi2cIndex(int iPhi) const {
0230     //    return iPhi-1;
0231     int iPhi0 = iPhi - 11;
0232     if (iPhi0 < 0)
0233       iPhi0 += 360;
0234     return iPhi0;
0235   }
0236 
0237   /** Converts a std CMSSW crystal x or y index to a c-array index (starting
0238    * from zero and without hole).
0239    */
0240   int iXY2cIndex(int iX) const { return iX - 1; }
0241 
0242   /** converse of iXY2cIndex() method.
0243    */
0244   int cIndex2iXY(int iX0) const { return iX0 + 1; }
0245 
0246   /** converse of iEta2cIndex() method.
0247    */
0248   int cIndex2iEta(int i) const { return (i < 85) ? i - 85 : i - 84; }
0249 
0250   /** converse of iPhi2cIndex() method.
0251    */
0252   int cIndex2iPhi(int i) const { return (i + 11) % 360; }
0253 
0254   /**Transforms CMSSW eta ECAL TT indices to indices starting at 0
0255    * to use for c-array or vector.
0256    * @param iEta CMSSW eta index (numbering -28...-1,28...56)
0257    * @return index in numbering from 0 to 55
0258    */
0259   int iTtEta2cIndex(int iEta) const { return (iEta < 0) ? iEta + 28 : iEta + 27; }
0260 
0261   /**Transforms CMSSW phi ECAL crystal indices to indices starting at 0
0262    * to use for c-array or vector.
0263    * @param iPhi CMSSW phi index (numbering 1...72)
0264    * @return index in numbering 0...71
0265    */
0266   int iTtPhi2cIndex(int iPhi) const {
0267     return iPhi - 1;
0268     //int iPhi0 = iPhi - 3;
0269     //if(iPhi0<0) iPhi0 += 72;
0270     //return iPhi0;
0271   }
0272 
0273   /** converse of iTtEta2cIndex() method.
0274    */
0275   int cIndex2iTtEta(int i) const { return (i < 27) ? i - 28 : i - 27; }
0276 
0277   /** converse of iTtPhi2cIndex() method.
0278    */
0279   int cIndex2iTtPhi(int i) const { return i + 1; }
0280 
0281   //@{
0282   /** Retrives the readout unit, a trigger tower in the barrel case,
0283    * and a supercrystal in the endcap case, a given crystal belongs to.
0284    * @param xtalId identifier of the crystal
0285    * @return identifer of the supercrystal or of the trigger tower.
0286    */
0287   EcalTrigTowerDetId readOutUnitOf(const EBDetId& xtalId) const;
0288 
0289   EcalScDetId readOutUnitOf(const EEDetId& xtalId) const;
0290   //@}
0291 
0292   /** Emulates the DCC zero suppression FIR filter. If one of the time sample
0293    * is not in gain 12, numeric_limits<int>::max() is returned.
0294    * @param frame data frame
0295    * @param firWeights TAP weights
0296    * @param firstFIRSample index (starting from 1) of the first time
0297    * sample to be used in the filter
0298    * @param saturated if not null, *saturated is set to true if all the time
0299    * sample are not in gain 12 and set to false otherwise.
0300    * @return FIR output or numeric_limits<int>::max().
0301    */
0302   static int dccZsFIR(const EcalDataFrame& frame,
0303                       const std::vector<int>& firWeights,
0304                       int firstFIRSample,
0305                       bool* saturated = nullptr);
0306 
0307   /** Computes the ZS FIR filter weights from the normalized weights.
0308    * @param normalizedWeights the normalized weights
0309    * @return the computed ZS filter weights.
0310    */
0311   static std::vector<int> getFIRWeights(const std::vector<double>& normalizedWeights);
0312 
0313   //@{
0314   /** Wrappers to the book methods of the DQMStore DQM
0315    *  histogramming interface.
0316    */
0317   MonitorElement* bookFloat(DQMStore::IBooker&, const std::string& name);
0318 
0319   MonitorElement* book1D(
0320       DQMStore::IBooker&, const std::string& name, const std::string& title, int nbins, double xmin, double xmax);
0321 
0322   MonitorElement* book2D(DQMStore::IBooker&,
0323                          const std::string& name,
0324                          const std::string& title,
0325                          int nxbins,
0326                          double xmin,
0327                          double xmax,
0328                          int nybins,
0329                          double ymin,
0330                          double ymax);
0331 
0332   MonitorElement* bookProfile(
0333       DQMStore::IBooker&, const std::string& name, const std::string& title, int nbins, double xmin, double xmax);
0334 
0335   MonitorElement* bookProfile2D(DQMStore::IBooker&,
0336                                 const std::string& name,
0337                                 const std::string& title,
0338                                 int nbinx,
0339                                 double xmin,
0340                                 double xmax,
0341                                 int nbiny,
0342                                 double ymin,
0343                                 double ymax,
0344                                 const char* option = "");
0345   //@}
0346 
0347   //@{
0348   /** Wrapper to fill methods of DQM monitor elements.
0349    */
0350   void fill(MonitorElement* me, float x) {
0351     if (me)
0352       me->Fill(x);
0353   }
0354   void fill(MonitorElement* me, float x, float yw) {
0355     if (me)
0356       me->Fill(x, yw);
0357   }
0358   void fill(MonitorElement* me, float x, float y, float zw) {
0359     if (me)
0360       me->Fill(x, y, zw);
0361   }
0362   void fill(MonitorElement* me, float x, float y, float z, float w) {
0363     if (me)
0364       me->Fill(x, y, z, w);
0365   }
0366   //@}
0367 
0368   void initAsciiFile();
0369 
0370   /** Updates estimate of L1A rate
0371    * @param event EDM event
0372    */
0373   void updateL1aRate(const edm::Event& event);
0374 
0375   /** Gets L1A rate estimate.
0376    * @see updateL1aRate(const edm::Event&)
0377    * @return L1A rate estimate
0378    */
0379   double getL1aRate() const;
0380 
0381 private:
0382   /** Used to store barrel crystal channel information
0383    */
0384   struct energiesEb_t {
0385     double simE;      ///sim hit energy sum
0386     double noZsRecE;  ///energy reconstructed from unsuppressed digi
0387     double recE;      ///energy reconstructed from zero-suppressed digi
0388     //    EBDigiCollection::const_iterator itNoZsFrame; //
0389     int simHit;   ///number of sim hits
0390     double phi;   ///phi crystal position in degrees
0391     double eta;   ///eta crystal position
0392     bool gain12;  //all MGPA samples at gain 12?
0393   };
0394 
0395   /** Used to store endcap crystal channel information
0396    */
0397   struct energiesEe_t {
0398     double simE;      ///sim hit energy sum
0399     double noZsRecE;  ///energy reconstructed from unsuppressed digi
0400     double recE;      ///energy reconstructed from zero-suppressed digi
0401     //    EEDigiCollection::const_iterator itNoZsFrame;
0402     int simHit;   ///number of sim hits
0403     double phi;   ///phi crystal position in degrees
0404     double eta;   ///eta crystal position
0405     bool gain12;  //all MGPA samples at gain 12?
0406   };
0407 
0408   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geoToken;
0409   edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> ecalmapping;
0410   edm::ESGetToken<EcalTrigTowerConstituentsMap, IdealGeometryRecord> hTriggerTowerMap;
0411   edm::ESGetToken<EcalTPGPhysicsConst, EcalTPGPhysicsConstRcd> physHandle;
0412   edm::ESGetToken<EcalTPGLutGroup, EcalTPGLutGroupRcd> lutGrpHandle;
0413   edm::ESGetToken<EcalTPGLutIdMap, EcalTPGLutIdMapRcd> lutMapHandle;
0414 
0415   /// number of bytes in 1 kByte:
0416   static const int kByte_ = 1024;
0417 
0418   ///Total number of DCCs
0419   static const unsigned nDccs_ = 54;
0420 
0421   ///Number of input channels of a DCC
0422   // = maximum number of RUs read by a DCC
0423   static const unsigned nDccChs_ = 68;
0424 
0425   //Lower bound of DCC ID range
0426   static const int minDccId_ = 1;
0427 
0428   //Upper bound of DCC ID range
0429   static const int maxDccId_ = minDccId_ + nDccs_ - 1;
0430 
0431   /// number of DCCs for EB
0432   static const int nEbDccs = 36;
0433 
0434   /// number of DCCs for EE
0435   static const int nEeDccs = 18;
0436 
0437   ///number of RUs for EB
0438   static const int nEbRus = 36 * 68;
0439 
0440   ///number of RUs for EE
0441   static const int nEeRus = 2 * (34 + 32 + 33 + 33 + 32 + 34 + 33 + 34 + 33);
0442 
0443   ///number of RUs for each DCC
0444   static const int nDccRus_[nDccs_];
0445 
0446   ///number of endcaps
0447   static const int nEndcaps = 2;
0448 
0449   ///number of crystals along Eta in EB
0450   static const int nEbEta = 170;
0451 
0452   ///number of crystals along Phi in EB
0453   static const int nEbPhi = 360;
0454 
0455   ///EE crystal grid size along X
0456   static const int nEeX = 100;
0457 
0458   ///EE crystal grid size along Y
0459   static const int nEeY = 100;
0460 
0461   ///Number of crystals along an EB TT
0462   static const int ebTtEdge = 5;
0463 
0464   ///Number of crystals along a supercrystal edge
0465   static const int scEdge = 5;
0466 
0467   ///Number of Trigger Towers in an endcap along Eta
0468   static const int nOneEeTtEta = 11;
0469 
0470   ///Number of Trigger Towers in barrel along Eta
0471   static const int nEbTtEta = 34;
0472 
0473   ///Number of Trigger Towers along Eta
0474   static const int nTtEta = 2 * nOneEeTtEta + nEbTtEta;
0475 
0476   ///Number of Trigger Towers along Phi
0477   static const int nTtPhi = 72;
0478 
0479   ///Number of crystals per Readout Unit excepted partial SCs
0480   static const int nMaxXtalPerRu = 25;
0481   ///Conversion factor from radian to degree
0482   static const double rad2deg;
0483 
0484   ///Verbosity switch
0485   bool verbose_;
0486 
0487   ///Output file for histograms
0488   std::string outputFile_;
0489 
0490   ///Switch for collection-not-found warning
0491   bool collNotFoundWarn_;
0492 
0493   ///Output ascii file name for unconsistency between SRFs read from data
0494   ///and SRF obtained by rerunning SRP algorithm on TTFs.
0495   std::string srpAlgoErrorLogFileName_;
0496 
0497   ///Output ascii file name for unconsistency between SRFs and actual number
0498   ///of read-out crystals.
0499   std::string srApplicationErrorLogFileName_;
0500 
0501   ///Output ascii file for unconsistency on SR flags
0502   std::ofstream srpAlgoErrorLog_;
0503 
0504   ///Output ascii file for unconsistency between Xtals and RU Flags
0505   std::ofstream srApplicationErrorLog_;
0506 
0507   ///File to log ZS and other errors
0508   std::ofstream zsErrorLog_;
0509 
0510   //@{
0511   /** The event product collections.
0512    */
0513   CollHandle<EBDigiCollection> ebDigis_;
0514   CollHandle<EEDigiCollection> eeDigis_;
0515   CollHandle<EBDigiCollection> ebNoZsDigis_;
0516   CollHandle<EEDigiCollection> eeNoZsDigis_;
0517   CollHandle<EBSrFlagCollection> ebSrFlags_;
0518   CollHandle<EESrFlagCollection> eeSrFlags_;
0519   CollHandle<EBSrFlagCollection> ebComputedSrFlags_;
0520   CollHandle<EESrFlagCollection> eeComputedSrFlags_;
0521   CollHandle<std::vector<PCaloHit>> ebSimHits_;
0522   CollHandle<std::vector<PCaloHit>> eeSimHits_;
0523   CollHandle<EcalTrigPrimDigiCollection> tps_;
0524   CollHandle<RecHitCollection> ebRecHits_;
0525   CollHandle<RecHitCollection> eeRecHits_;
0526   CollHandle<FEDRawDataCollection> fedRaw_;
0527   //@}
0528 
0529   //@{
0530   /** For L1A rate estimate
0531    */
0532   int64_t tmax;
0533   int64_t tmin;
0534   int64_t l1aOfTmin;
0535   int64_t l1aOfTmax;
0536   bool l1aRateErr;
0537   //@}
0538 
0539   //@{
0540   /** The histograms
0541    */
0542   MonitorElement* meDccVol_;
0543   MonitorElement* meDccLiVol_;
0544   MonitorElement* meDccHiVol_;
0545   MonitorElement* meDccVolFromData_;
0546   MonitorElement* meVol_;
0547   MonitorElement* meVolB_;
0548   MonitorElement* meVolE_;
0549   MonitorElement* meVolBLI_;
0550   MonitorElement* meVolELI_;
0551   MonitorElement* meVolLI_;
0552   MonitorElement* meVolBHI_;
0553   MonitorElement* meVolEHI_;
0554   MonitorElement* meVolHI_;
0555   MonitorElement* meChOcc_;
0556 
0557   MonitorElement* meTp_;
0558   MonitorElement* meTtf_;
0559   MonitorElement* meTtfVsTp_;
0560   MonitorElement* meTtfVsEtSum_;
0561   MonitorElement* meTpVsEtSum_;
0562 
0563   MonitorElement* meEbRecE_;
0564   MonitorElement* meEbEMean_;
0565   MonitorElement* meEbNoise_;
0566   MonitorElement* meEbSimE_;
0567   MonitorElement* meEbRecEHitXtal_;
0568   MonitorElement* meEbRecVsSimE_;
0569   MonitorElement* meEbNoZsRecVsSimE_;
0570 
0571   MonitorElement* meEeRecE_;
0572   MonitorElement* meEeEMean_;
0573   MonitorElement* meEeNoise_;
0574   MonitorElement* meEeSimE_;
0575   MonitorElement* meEeRecEHitXtal_;
0576   MonitorElement* meEeRecVsSimE_;
0577   MonitorElement* meEeNoZsRecVsSimE_;
0578 
0579   MonitorElement* meFullRoRu_;
0580   MonitorElement* meZs1Ru_;
0581   MonitorElement* meForcedRu_;
0582 
0583   MonitorElement* meLiTtf_;
0584   MonitorElement* meMiTtf_;
0585   MonitorElement* meHiTtf_;
0586   MonitorElement* meForcedTtf_;
0587 
0588   MonitorElement* meTpMap_;
0589 
0590   MonitorElement* meFullRoCnt_;
0591   MonitorElement* meEbFullRoCnt_;
0592   MonitorElement* meEeFullRoCnt_;
0593 
0594   MonitorElement* meEbLiZsFir_;
0595   MonitorElement* meEbHiZsFir_;
0596   MonitorElement* meEbIncompleteRUZsFir_;
0597 
0598   MonitorElement* meEeLiZsFir_;
0599   MonitorElement* meEeHiZsFir_;
0600   MonitorElement* meSRFlagsFromData_;
0601   MonitorElement* meSRFlagsComputed_;
0602   MonitorElement* meSRFlagsConsistency_;
0603 
0604   MonitorElement* meIncompleteFRO_;
0605   MonitorElement* meDroppedFRO_;
0606   MonitorElement* meCompleteZS_;
0607 
0608   MonitorElement* meIncompleteFROMap_;
0609   MonitorElement* meDroppedFROMap_;
0610   MonitorElement* meCompleteZSMap_;
0611 
0612   MonitorElement* meIncompleteFRORateMap_;
0613   MonitorElement* meDroppedFRORateMap_;
0614   MonitorElement* meCompleteZSRateMap_;
0615 
0616   MonitorElement* meIncompleteFROCnt_;
0617   MonitorElement* meDroppedFROCnt_;
0618   MonitorElement* meCompleteZSCnt_;
0619   MonitorElement* meEbZsErrCnt_;
0620   MonitorElement* meEeZsErrCnt_;
0621   MonitorElement* meZsErrCnt_;
0622   MonitorElement* meEbZsErrType1Cnt_;
0623   MonitorElement* meEeZsErrType1Cnt_;
0624   MonitorElement* meZsErrType1Cnt_;
0625   //@}
0626 
0627   //@{
0628   /**Event payload that do not depend on the
0629    * number of crystals passing the SR
0630    */
0631   MonitorElement* meEbFixedPayload_;
0632   MonitorElement* meEeFixedPayload_;
0633   MonitorElement* meFixedPayload_;
0634   //@}
0635 
0636   /** Estimate of L1A rate
0637    */
0638   MonitorElement* meL1aRate_;
0639 
0640   ///Counter of FRO-flagged RU dropped from data
0641   int nDroppedFRO_;
0642 
0643   ///Counter of FRO-flagged RU only partial data
0644   int nIncompleteFRO_;
0645 
0646   ///Counter of ZS-flagged RU fully read out
0647   int nCompleteZS_;
0648 
0649   ///Counter of EB FRO-flagged RUs
0650   int nEbFROCnt_;
0651 
0652   ///Counter of EE FRO-flagged RUs
0653   int nEeFROCnt_;
0654 
0655   ///Counter of EB ZS errors (LI channel below ZS threshold)
0656   int nEbZsErrors_;
0657 
0658   ///Counter of EE ZS errors (LI channel below ZS threshold)
0659   int nEeZsErrors_;
0660 
0661   ///Counter of EB ZS errors of type 1: LI channel below ZS threshold and
0662   ///in a RU which was fully readout
0663   int nEbZsErrorsType1_;
0664 
0665   ///Counter of EE ZS errors of tyoe 1: LI channel below ZS threshold and
0666   ///in a RU which was fully readout
0667   int nEeZsErrorsType1_;
0668 
0669   /** ECAL trigger tower mapping
0670    */
0671   const EcalTrigTowerConstituentsMap* triggerTowerMap_;
0672 
0673   /** Ecal electronics/geometrical mapping.
0674    */
0675   const EcalElectronicsMapping* elecMap_;
0676 
0677   /** Local reconstruction switch: true to reconstruct locally the amplitude
0678    * insted of using the Rec Hits.
0679    */
0680   bool localReco_;
0681 
0682   /** Weights for amplitude local reconstruction
0683    */
0684   std::vector<double> weights_;
0685 
0686   /** Weights to be used for the ZS FIR filter
0687    */
0688   std::vector<int> firWeights_;
0689 
0690   /** ZS threshold in 1/4th ADC count for EB
0691    */
0692   int ebZsThr_;
0693 
0694   /** ZS threshold in 1/4th ADC count for EE
0695    */
0696   int eeZsThr_;
0697 
0698   /** Switch for uncompressing TP value
0699    */
0700   bool tpInGeV_;
0701 
0702   /** Time position of the first sample to use in zero suppession FIR
0703    * filter. Numbering starts at 0.
0704    */
0705   int firstFIRSample_;
0706 
0707   /** Switch to fill histograms with event rate instead of event count.
0708    * Applies only to some histograms.
0709    */
0710   bool useEventRate_;
0711 
0712   /** List of TCC masks for validation
0713    * If tccMasks[iTcc-1] is false then TCC is considered to have been
0714    * out of the run and related validations are skipped.
0715    */
0716   std::vector<bool> logErrForDccs_;
0717 
0718   /** ECAL barrel read channel count
0719    */
0720   int nEb_;
0721 
0722   /** ECAL endcap read channel count
0723    */
0724   int nEe_;
0725 
0726   /** ECAL endcap low interest read channel count
0727    */
0728   int nEeLI_;
0729 
0730   /** ECAL endcap high interest read channel count
0731    */
0732   int nEeHI_;
0733 
0734   /** ECAL barrel low interest read channel count
0735    */
0736   int nEbLI_;
0737 
0738   /** ECAL barrel high interest read channel count
0739    */
0740   int nEbHI_;
0741 
0742   /** read-out ECAL channel count for each DCC:
0743    */
0744   int nPerDcc_[nDccs_];
0745 
0746   /** read-out ECAL Low interest channel count for each DCC:
0747    */
0748   int nLiPerDcc_[nDccs_];
0749 
0750   /** read-out ECAL Hiugh interest channel count for each DCC:
0751    */
0752   int nHiPerDcc_[nDccs_];
0753 
0754   /** Count for each DCC of RUs with at leat one channel read out:
0755    */
0756   int nRuPerDcc_[nDccs_];
0757 
0758   /** Count for each DCC of LI RUs with at leat one channel read out:
0759    */
0760   int nLiRuPerDcc_[nDccs_];
0761 
0762   /** Count for each DCC of HI RUs with at leat one channel read out:
0763    */
0764   int nHiRuPerDcc_[nDccs_];
0765 
0766   //@{
0767   /** For book keeping of RU actually read out (not fully zero suppressed)
0768    */
0769   bool ebRuActive_[nEbEta / ebTtEdge][nEbPhi / ebTtEdge];
0770   bool eeRuActive_[nEndcaps][nEeX / scEdge][nEeY / scEdge];
0771   //@}
0772 
0773   bool isRuComplete_[nDccs_][nDccChs_];
0774 
0775   /** Number of crystal read for each DCC channel (aka readout unit).
0776    */
0777   int nPerRu_[nDccs_][nDccChs_];
0778 
0779   /** Event sequence number
0780    */
0781   int ievt_;
0782 
0783   /** Trigger tower Et computed as sum the crystal Et. Indices
0784    * stands for the eta and phi TT index starting from 0 at eta minimum and
0785    * at phi=0+ in std CMS coordinate system.
0786    */
0787   double ttEtSums[nTtEta][nTtPhi];
0788 
0789   /** Permits to skip inner SC
0790    */
0791   bool SkipInnerSC_;
0792 
0793   /** List of enabled histograms. Special name "all" is used to indicate
0794    * all available histograms.
0795    */
0796   std::set<std::string> histList_;
0797 
0798   /** When true, every histogram is enabled.
0799    */
0800   bool allHists_;
0801 
0802   /** Histogram directory PATH in DQM or within the output ROOT file
0803    */
0804   std::string histDir_;
0805 
0806   /** List of available histograms. Filled by the booking methods.
0807    * key: name, value: title.
0808    */
0809   std::map<std::string, std::string> availableHistList_;
0810 
0811   /** Indicates if EE sim hits are available
0812    */
0813   bool withEeSimHit_;
0814 
0815   /** Indicates if EB sim hits are available
0816    */
0817   bool withEbSimHit_;
0818 
0819   /** Register a histogram in the available histogram list and check if
0820    * the histogram is enabled. Called by the histogram booking methods.
0821    * @return true if the histogram is enable, false otherwise
0822    */
0823   bool registerHist(const std::string& name, const std::string& title);
0824 
0825   /** Prints the list of available histograms
0826    * (registered by the registerHist method), including disabled one.
0827    */
0828   void printAvailableHists();
0829 
0830   /** Configure DCC ZS FIR weights. Heuristic is used to determine
0831    * if input weights are normalized weights or integer weights in
0832    * the hardware representation.
0833    * @param weightsForZsFIR weights from configuration file
0834    */
0835   void configFirWeights(const std::vector<double>& weightsForZsFIR);
0836 
0837   /** Switch to log in an ascii file inconsistencies found
0838    * between SRFs read from data and SRFs obtained by rerunning
0839    * SRP algorithm on TTFs.
0840    */
0841   bool logSrpAlgoErrors_;
0842 
0843   /** Switch to log SR decision that fails to be applied on data:
0844    * inconstitencies between SRF and number of read out crystals.
0845    */
0846   bool logSrApplicationErrors_;
0847 
0848   /** Compares two SR flag collection, flags read from data and computed flags.
0849    * Descripencies are recorded in relevant histogram and log file.
0850    * @tparam T collection type. Must be either an EESrFlagCollection or an
0851    * EBSrFlagCollection.
0852    * @param event event currently analyzed. Used in logs.
0853    * @param srfFromData SR flag collection read from data
0854    * @param compareSrf SR flag collection computed from TTF by SRP emulation
0855    */
0856   template <class T>
0857   void compareSrfColl(const edm::Event& event, T& srfFromData, T& computedSrf);
0858 
0859   /** Checks application of SR decision by the DCC.
0860    * @param event event currently analyzed.
0861    * @param srfs Selective readou flags
0862    */
0863   template <class T>
0864   void checkSrApplication(const edm::Event& event, T& srfs);
0865 
0866   /** Functions to compute x and y coordinates of RU maps
0867    * grouping endcap and barrel.
0868    */
0869   ///@{
0870   int ruGraphX(const EcalScDetId& id) const { return id.ix() + (id.zside() > 0 ? 20 : -40); }
0871 
0872   int ruGraphY(const EcalScDetId& id) const { return id.iy(); }
0873 
0874   int ruGraphX(const EcalTrigTowerDetId& id) const { return id.ieta(); }
0875 
0876   int ruGraphY(const EcalTrigTowerDetId& id) const { return id.iphi(); }
0877 
0878   int xtalGraphX(const EEDetId& id) const { return id.ix() + (id.zside() > 0 ? 100 : -200); }
0879 
0880   int xtalGraphY(const EEDetId& id) const { return id.iy(); }
0881 
0882   int xtalGraphX(const EBDetId& id) const { return id.ieta(); }
0883 
0884   int xtalGraphY(const EBDetId& id) const { return id.iphi(); }
0885 
0886   ///@}
0887 
0888   //@{
0889   /** Retrieves the ID of the DCC reading a readout unit
0890    * @param detId detid of the readout unit
0891    */
0892   int dccId(const EcalScDetId& detId) const;
0893   int dccId(const EcalTrigTowerDetId& detId) const;
0894   //@}
0895 
0896   /** Look in events whose DCC has SR flags and
0897    * enable error logging for them. To be called with
0898    * the processed first event. List of monitored DCCs
0899    * is reported in the log file.
0900    */
0901   void selectFedsForLog();
0902 
0903   /** Retrieves number of crystal channel read out by a DCC channel
0904    * @param iDcc DCC ID starting from 1
0905    * @param iDccCh DCC channel starting from 1
0906    * @return crystal count
0907    */
0908   int getCrystalCount(int iDcc, int iDccCh);
0909 };
0910 
0911 #endif  //EcalSelectiveReadoutValidation_H not defined