Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:09:31

0001 /*
0002  * =====================================================================================
0003  *
0004  *       Filename:  Summary.h
0005  *
0006  *    Description:  CSC summary map and appropriate functions.
0007  *
0008  *        Version:  1.0
0009  *        Created:  05/19/2008 10:52:21 AM
0010  *       Revision:  none
0011  *       Compiler:  gcc
0012  *
0013  *         Author:  Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch
0014  *        Company:  CERN, CH
0015  *
0016  * =====================================================================================
0017  */
0018 
0019 #ifndef CSCDQM_Summary_H
0020 #define CSCDQM_Summary_H
0021 
0022 #include <TH2.h>
0023 #include <cmath>
0024 #include <vector>
0025 #include <bitset>
0026 #include <iostream>
0027 
0028 #include "CSCDQM_Detector.h"
0029 #include "CSCDQM_Logger.h"
0030 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0031 
0032 #define HWSTATUSBITSETSIZE 14
0033 #define HWSTATUSERRORBITS 0xffc
0034 #define HWSTATUSEQUALS(s, m) (((std::bitset<HWSTATUSBITSETSIZE>)m & s) == m)
0035 #define HWSTATUSANY(s, m) (((std::bitset<HWSTATUSBITSETSIZE>)m & s).any())
0036 #define HWSTATUSANYERROR(s) (HWSTATUSANY(s, HWSTATUSERRORBITS))
0037 
0038 #define NTICS 100
0039 
0040 namespace cscdqm {
0041 
0042   /**
0043  * @brief Hardware Status Bit values used in Summary efficiency calculation
0044  */
0045   enum HWStatusBit {
0046 
0047     DATA,    /// Data available (reporting)
0048     MASKED,  /// HW element was masked out (not in readout)
0049 
0050     HOT,   /// HW element is hot by comparing with reference histogram
0051     COLD,  /// HW element is cold comparing with reference histogram
0052 
0053     FORMAT_ERR,    /// Format errors
0054     L1SYNC_ERR,    /// L1A out of sync errors
0055     FIFOFULL_ERR,  /// DMB FIFO full error
0056     INPUTTO_ERR,   /// DMB Input timeout error
0057 
0058     NODATA_ALCT,  /// No ALCT data
0059     NODATA_CLCT,  /// No CLCT data
0060     NODATA_CFEB,  /// No CFEB data
0061     CFEB_BWORDS,  /// Data with CFEB BWORDS
0062 
0063     STANDBY,  /// HW element in standby mode
0064     WAS_ON    /// HW element ever in the run was ON (off standby mode)
0065 
0066   };
0067 
0068   /**
0069  * @brief  Hardware Status Bits structure used in Summary efficiency
0070  * calculation and storage
0071  */
0072   typedef std::bitset<HWSTATUSBITSETSIZE> HWStatusBitSet;
0073 
0074   /**
0075  * @class Summary
0076  * @brief Hardware and Physics Efficiency data structures and routines 
0077  */
0078   class Summary {
0079   public:
0080     Summary();
0081     ~Summary();
0082 
0083     void Reset();
0084 
0085     const Detector getDetector() const { return detector; }
0086 
0087     void ReadReportingChambers(const TH2*& h2, const double threshold = 1.0);
0088     void ReadReportingChambersRef(const TH2*& h2,
0089                                   const TH2*& refh2,
0090                                   const double cold_coef = 0.1,
0091                                   const double cold_Sfail = 5.0,
0092                                   const double hot_coef = 2.0,
0093                                   const double hot_Sfail = 5.0);
0094     void ReadErrorChambers(
0095         const TH2*& evs, const TH2*& err, const HWStatusBit bit, const double eps_max = 0.1, const double Sfail = 5.0);
0096 
0097     const unsigned int setMaskedHWElements(std::vector<std::string>& tokens);
0098 
0099     void Write(TH2*& h2, const unsigned int station) const;
0100     void WriteMap(TH2*& h2);
0101     void WriteChamberState(
0102         TH2*& h2, const int mask, const int value = 1, const bool reset = true, const bool op_any = false) const;
0103 
0104     void ReSetValue(const HWStatusBit bit);
0105     void ReSetValue(const Address& adr, const HWStatusBit bit);
0106     void SetValue(const HWStatusBit bit, const int value = 1);
0107     void SetValue(Address adr, const HWStatusBit bit, const int value = 1);
0108 
0109     const HWStatusBitSet GetValue(Address adr) const;
0110     const int IsPhysicsReady(const unsigned int px, const unsigned int py);
0111     //const int IsPhysicsReady(const float xmin, const float xmax, const float ymin, const float ymax) const;
0112 
0113     const double GetEfficiencyHW() const;
0114     const double GetEfficiencyHW(const unsigned int station) const;
0115     const double GetEfficiencyHW(Address adr) const;
0116     const double GetEfficiencyArea(const unsigned int station) const;
0117     const double GetEfficiencyArea(const Address& adr) const;
0118 
0119     bool isChamberStandby(unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const;
0120     bool isChamberStandby(CSCDetId cid) const;
0121 
0122   private:
0123     const bool ChamberCoordsToAddress(const unsigned int x, const unsigned int y, Address& adr) const;
0124     const bool ChamberAddressToCoords(const Address& adr, unsigned int& x, unsigned int& y) const;
0125     const double GetReportingArea(Address adr) const;
0126 
0127     /** Atomic HW element status matrix */
0128     HWStatusBitSet map[N_SIDES][N_STATIONS][N_RINGS][N_CHAMBERS][N_LAYERS][N_CFEBS][N_HVS];
0129 
0130     /** Detector routines object */
0131     Detector detector;
0132   };
0133 
0134 }  // namespace cscdqm
0135 
0136 #endif