Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:57

0001 #ifndef CastorChannelStatus_h
0002 #define CastorChannelStatus_h
0003 
0004 /* 
0005 \class CastorChannelStatus
0006 \author Radek Ofierzynski
0007 contains one channel status and corresponding DetId
0008 */
0009 
0010 #include "CondFormats/Serialization/interface/Serializable.h"
0011 
0012 #include <string>
0013 #include <cstdint>
0014 
0015 class CastorChannelStatus {
0016 public:
0017   // contains the defined bits for easy access, see https://twiki.cern.ch/twiki/bin/view/CMS/CastorDataValidationWorkflow
0018   /* Original Hcal stuff
0019   enum StatusBit {       
0020     HcalCellOff=0,      // 1=Hcal cell is off
0021     HcalCellL1Mask=1,   // 1=Hcal cell is masked/to be masked by L1 trigger
0022     HcalCellDead=5,     // 1=Hcal cell is dead (from DQM algo)
0023     HcalCellHot=6,      // 1=Hcal cell is hot (from DQM algo)
0024     HcalCellStabErr=7,  // 1=Hcal cell has stability error
0025     HcalCellTimErr=8    // 1=Hcal cell has timing error
0026   };*/
0027   enum StatusBit { UNKNOWN = 0, BAD = 1, GOOD = 2, HOT = 3, DEAD = 4, END = 5 };
0028 
0029   CastorChannelStatus() : mId(0), mStatus(0) {}
0030   CastorChannelStatus(unsigned long fid, uint32_t status) : mId(fid), mStatus(status) {}
0031   CastorChannelStatus(unsigned long fid, std::string status) : mId(fid) {
0032     if (status == "BAD")
0033       mStatus = BAD;
0034     else if (status == "GOOD")
0035       mStatus = GOOD;
0036     else if (status == "HOT")
0037       mStatus = HOT;
0038     else if (status == "DEAD")
0039       mStatus = DEAD;
0040     else if (status == "END")
0041       mStatus = END;
0042     else
0043       mStatus = UNKNOWN;
0044   }
0045 
0046   //  void setDetId(unsigned long fid) {mId = fid;}
0047   void setValue(uint32_t value) { mStatus = value; }
0048 
0049   // for the following, one can use unsigned int values or CastorChannelStatus::StatusBit values
0050   //   e.g. 4 or CastorChannelStatus::DEAD
0051   void setBit(unsigned int bitnumber) {
0052     uint32_t statadd = 0x1 << (bitnumber);
0053     mStatus = mStatus | statadd;
0054   }
0055   void unsetBit(unsigned int bitnumber) {
0056     uint32_t statadd = 0x1 << (bitnumber);
0057     statadd = ~statadd;
0058     mStatus = mStatus & statadd;
0059   }
0060 
0061   bool isBitSet(unsigned int bitnumber) const {
0062     uint32_t statadd = 0x1 << (bitnumber);
0063     return (mStatus & statadd) ? (true) : (false);
0064   }
0065 
0066   uint32_t rawId() const { return mId; }
0067 
0068   uint32_t getValue() const { return mStatus; }
0069 
0070 private:
0071   uint32_t mId;
0072   uint32_t mStatus;
0073 
0074   COND_SERIALIZABLE;
0075 };
0076 #endif