Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:51

0001 #ifndef CondFormats_EcalObjects_EcalErrorDictionary_H
0002 #define CondFormats_EcalObjects_EcalErrorDictionary_H
0003 
0004 /**
0005  *  A dictionary of bitmasks for ECAL channel errors and their meaning
0006  *  This object is not meant to be stored in the offline DB, but the bits
0007  *  defined here are stored in EcalChannelStatus.
0008  *
0009  *  This class holds no dynamic data and all the methods are static.
0010  */
0011 #include <iostream>
0012 #include <vector>
0013 #include <cstdint>
0014 
0015 class EcalErrorDictionary {
0016 public:
0017   struct errorDef_t {
0018     uint64_t bitmask;
0019     char shortDesc[64];
0020     char longDesc[128];
0021   };
0022 
0023   static uint64_t hasError(std::string shortDesc, uint64_t bitcode) { return getMask(shortDesc) & bitcode; }
0024 
0025   static uint64_t getMask(std::string shortDesc) {
0026     for (unsigned int i = 0; i < DICTSIZE; i++) {
0027       if (getDef(i).shortDesc == shortDesc) {
0028         return getDef(i).bitmask;
0029       }
0030     }
0031     return 0;
0032   }
0033 
0034   static void printErrors(uint64_t bitcode) {
0035     for (unsigned int i = 0; i < DICTSIZE; i++) {
0036       if (bitcode & getDef(i).bitmask) {
0037       }
0038     }
0039   }
0040 
0041   static void getErrors(std::vector<errorDef_t>& errorVec, uint64_t bitcode) {
0042     errorVec.clear();
0043     for (unsigned int i = 0; i < DICTSIZE; i++) {
0044       if (bitcode & getDef(i).bitmask) {
0045         errorVec.push_back(getDef(i));
0046       }
0047     }
0048   }
0049 
0050   static void getDictionary(std::vector<errorDef_t>& dict) {
0051     dict.clear();
0052     for (unsigned int i = 0; i < DICTSIZE; i++) {
0053       dict.push_back(getDef(i));
0054     }
0055   }
0056 
0057 private:
0058   EcalErrorDictionary(){};   // Hidden to force static use
0059   ~EcalErrorDictionary(){};  // Hidden to force static use
0060 
0061   const static unsigned int DICTSIZE = 55;
0062 
0063   static errorDef_t getDef(unsigned int i) {
0064     const static errorDef_t ERRORDICT[DICTSIZE] = {
0065 
0066         {((uint64_t)1 << 0), "CH_ID_WARNING", "Channel id warning"},
0067         {((uint64_t)1 << 1), "CH_GAIN_ZERO_WARNING", "Channel gain zero warning"},
0068         {((uint64_t)1 << 2), "CH_GAIN_SWITCH_WARNING", "Channel gain switch warning"},
0069         {((uint64_t)1 << 3), "CH_ID_ERROR", "Channel id error"},
0070         {((uint64_t)1 << 4), "CH_GAIN_ZERO_ERROR", "Channel gain zero error"},
0071         {((uint64_t)1 << 5), "CH_GAIN_SWITCH_ERROR", "Channel gain switch error"},
0072 
0073         {((uint64_t)1 << 6), "TT_ID_WARNING", "TT id warning"},
0074         {((uint64_t)1 << 7), "TT_SIZE_WARNING", "TT size warning"},
0075         {((uint64_t)1 << 8), "TT_LV1_WARNING", "TT LV1 warning"},
0076         {((uint64_t)1 << 9), "TT_BUNCH_X_WARNING", "TT bunch-x warning"},
0077         {((uint64_t)1 << 10), "TT_ID_ERROR", "TT id error"},
0078         {((uint64_t)1 << 11), "TT_SIZE_ERROR", "TT size error"},
0079         {((uint64_t)1 << 12), "TT_LV1_ERROR", "TT LV1 error"},
0080         {((uint64_t)1 << 13), "TT_BUNCH_X_ERROR", "TT bunch-x error"},
0081 
0082         {((uint64_t)1 << 16), "PEDESTAL_LOW_GAIN_MEAN_WARNING", "Pedestal low gain mean amplitude outside range"},
0083         {((uint64_t)1 << 17), "PEDESTAL_MIDDLE_GAIN_MEAN_WARNING", "Pedestal middle gain mean amplitude outside range"},
0084         {((uint64_t)1 << 18), "PEDESTAL_HIGH_GAIN_MEAN_WARNING", "Pedestal high gain mean amplitude outside range"},
0085         {((uint64_t)1 << 19), "PEDESTAL_LOW_GAIN_MEAN_ERROR", "Pedestal low gain mean amplitude error"},
0086         {((uint64_t)1 << 20), "PEDESTAL_MIDDLE_GAIN_MEAN_ERROR", "Pedestal middle gain mean amplitude error"},
0087         {((uint64_t)1 << 21), "PEDESTAL_HIGH_GAIN_MEAN_ERROR", "Pedestal high gain mean amplitude error"},
0088 
0089         {((uint64_t)1 << 22), "PEDESTAL_LOW_GAIN_RMS_WARNING", "Pedestal low gain rms amplitude outside range"},
0090         {((uint64_t)1 << 23), "PEDESTAL_MIDDLE_GAIN_RMS_WARNING", "Pedestal middle gain rms amplitude outside range"},
0091         {((uint64_t)1 << 24), "PEDESTAL_HIGH_GAIN_RMS_WARNING", "Pedestal high gain rms amplitude outside range"},
0092         {((uint64_t)1 << 25), "PEDESTAL_LOW_GAIN_RMS_ERROR", "Pedestal low gain rms amplitude error"},
0093         {((uint64_t)1 << 26), "PEDESTAL_MIDDLE_GAIN_RMS_ERROR", "Pedestal middle gain rms amplitude error"},
0094         {((uint64_t)1 << 27), "PEDESTAL_HIGH_GAIN_RMS_ERROR", "Pedestal high gain rms amplitude error"},
0095 
0096         {((uint64_t)1 << 28),
0097          "PEDESTAL_ONLINE_HIGH_GAIN_MEAN_WARNING",
0098          "Pedestal online high gain mean amplitude outside range"},
0099         {((uint64_t)1 << 29),
0100          "PEDESTAL_ONLINE_HIGH_GAIN_RMS_WARNING",
0101          "Pedestal online high gain rms amplitude outside range"},
0102         {((uint64_t)1 << 30), "PEDESTAL_ONLINE_HIGH_GAIN_MEAN_ERROR", "Pedestal online high gain mean amplitude error"},
0103         {((uint64_t)1 << 31), "PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR", "Pedestal online high gain rms amplitude error"},
0104 
0105         {((uint64_t)1 << 32), "TESTPULSE_LOW_GAIN_MEAN_WARNING", "Testpulse low gain mean amplitude outside range"},
0106         {((uint64_t)1 << 33),
0107          "TESTPULSE_MIDDLE_GAIN_MEAN_WARNING",
0108          "Testpulse middle gain mean amplitude outside range"},
0109         {((uint64_t)1 << 34), "TESTPULSE_HIGH_GAIN_MEAN_WARNING", "Testpulse high gain mean amplitude outside range"},
0110         {((uint64_t)1 << 35), "TESTPULSE_LOW_GAIN_RMS_WARNING", "Testpulse low gain rms amplitude outside range"},
0111         {((uint64_t)1 << 36), "TESTPULSE_MIDDLE_GAIN_RMS_WARNING", "Testpulse middle gain rms amplitude outside range"},
0112         {((uint64_t)1 << 37), "TESTPULSE_HIGH_GAIN_RMS_WARNING", "Testpulse high gain rms amplitude outside range"},
0113 
0114         {((uint64_t)1 << 38), "LASER_MEAN_WARNING", "Laser mean amplitude outside range"},
0115         {((uint64_t)1 << 39), "LASER_RMS_WARNING", "Laser rms amplitude outside range"},
0116 
0117         {((uint64_t)1 << 40), "LASER_MEAN_OVER_PN_WARNING", "Laser mean amplitude over PN outside range"},
0118         {((uint64_t)1 << 41), "LASER_RMS_OVER_PN_WARNING", "Laser rms amplitude over PN outside range"},
0119 
0120         {((uint64_t)1 << 42), "LASER_MEAN_TIMING_WARNING", "Laser channel mean timing outside range"},
0121         {((uint64_t)1 << 43), "LASER_RMS_TIMING_WARNING", "Laser channel rms timing outside range"},
0122 
0123         {((uint64_t)1 << 44), "LASER_MEAN_TT_TIMING_WARNING", "Laser tower mean timing outside range"},
0124         {((uint64_t)1 << 45), "LASER_RMS_TT_TIMING_WARNING", "Laser tower rms timing outside range"},
0125 
0126         {((uint64_t)1 << 46), "PHYSICS_MEAN_TIMING_WARNING", "Channel mean timing outside range for physics events"},
0127         {((uint64_t)1 << 47), "PHYSICS_RMS_TIMING_WARNING", "Channel rms timing outside range for physics events"},
0128 
0129         {((uint64_t)1 << 48), "PHYSICS_MEAN_TT_TIMING_WARNING", "TT mean timing outside range for physics events"},
0130         {((uint64_t)1 << 49), "PHYSICS_RMS_TT_TIMING_WARNING", "TT rms timing outside range for physics events"},
0131 
0132         {((uint64_t)1 << 50), "PHYSICS_BAD_CHANNEL_WARNING", "Bad signal for physics events"},
0133         {((uint64_t)1 << 51), "PHYSICS_BAD_CHANNEL_ERROR", "No signal for physics events"},
0134 
0135         {((uint64_t)1 << 52), "STATUS_FLAG_ERROR", "Readout tower front end error (any type)"},
0136 
0137         {((uint64_t)1 << 53), "LED_MEAN_WARNING", "Led mean amplitude outside range"},
0138         {((uint64_t)1 << 54), "LED_RMS_WARNING", "Led rms amplitude outside range"}
0139 
0140     };
0141 
0142     return ERRORDICT[i];
0143   }
0144 };
0145 #endif