Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /****************************************************************************
0002 *
0003 * This is a part of TOTEM offline software.
0004 * Authors:
0005 *   Maciej Wróbel (wroblisko@gmail.com)
0006 *   Jan Kašpar (jan.kaspar@gmail.com)
0007 *
0008 ****************************************************************************/
0009 
0010 #ifndef DataFormats_CTPPSDigi_TotemVFATStatus
0011 #define DataFormats_CTPPSDigi_TotemVFATStatus
0012 
0013 #include <bitset>
0014 #include <map>
0015 #include <cstdint>
0016 
0017 //----------------------------------------------------------------------------------------------------
0018 
0019 /**
0020  * Class which contains information about conversion from RAW to DIGI for a single read-out chip (VFAT).
0021  */
0022 class TotemVFATStatus {
0023 public:
0024   TotemVFATStatus(uint8_t cp = 0)
0025       : chipPosition_(cp), status(0), numberOfClustersSpecified(false), numberOfClusters_(0), eventCounter(0) {}
0026 
0027   /// Chip position
0028   inline uint8_t chipPosition() const { return chipPosition_; }
0029   inline void setChipPosition(uint8_t cp) { chipPosition_ = cp; }
0030 
0031   /// VFAT is present in mapping but no data is present int raw event
0032   inline bool isMissing() const { return status[0]; }
0033   inline void setMissing(bool val = true) { status[0] = val; }
0034 
0035   /// 12-bit hw id from the header of the vfat frame is diffrent from the 16-bit one from hw mapping
0036   inline bool isIDMismatch() const { return status[1]; }
0037   inline void setIDMismatch(bool val = true) { status[1] = val; }
0038 
0039   /// Footprint error
0040   inline bool isFootprintError() const { return status[2]; }
0041   inline void setFootprintError(bool val = true) { status[2] = val; }
0042 
0043   /// CRC error
0044   inline bool isCRCError() const { return status[3]; }
0045   inline void setCRCError(bool val = true) { status[3] = val; }
0046 
0047   /// VFATFrame event number doesn't follow the number derived from DAQ
0048   inline bool isECProgressError() const { return status[4]; }
0049   inline void setECProgressError(bool val = true) { status[4] = val; }
0050 
0051   /// BC number is incorrect
0052   inline bool isBCProgressError() const { return status[5]; }
0053   inline void setBCProgressError(bool val = true) { status[5] = val; }
0054 
0055   /// All channels from that VFAT are not taken into account
0056   inline bool isFullyMaskedOut() const { return status[6]; }
0057   inline void setFullyMaskedOut() { status[6] = true; }
0058 
0059   /// Some channels from VFAT ale masked out, but not all
0060   inline bool isPartiallyMaskedOut() const { return status[7]; }
0061   inline void setPartiallyMaskedOut() { status[7] = true; }
0062 
0063   /// No channels are masked out
0064   inline bool isNotMasked() const { return !(status[6] || status[7]); }
0065   inline void setNotMasked() { status[6] = status[7] = false; }
0066 
0067   bool isOK() const { return !(status[0] || status[1] || status[2] || status[3] || status[4] || status[5]); }
0068 
0069   /// number of clusters
0070   inline bool isNumberOfClustersSpecified() const { return numberOfClustersSpecified; }
0071   inline void setNumberOfClustersSpecified(bool v) { numberOfClustersSpecified = v; }
0072 
0073   inline uint8_t numberOfClusters() const { return numberOfClusters_; }
0074   inline void setNumberOfClusters(uint8_t v) { numberOfClusters_ = v; }
0075 
0076   bool operator<(const TotemVFATStatus& cmp) const { return (status.to_ulong() < cmp.status.to_ulong()); }
0077 
0078   friend std::ostream& operator<<(std::ostream& s, const TotemVFATStatus& st);
0079 
0080   /// event Counter
0081   inline uint8_t ec() const { return eventCounter; }
0082   inline void setEC(const uint8_t ec) { eventCounter = ec; }
0083 
0084 private:
0085   /// describes placement of the VFAT within the detector
0086   uint8_t chipPosition_;
0087 
0088   /// the status bits
0089   std::bitset<8> status;
0090 
0091   /// the number of hit clusters before DAQ trimming
0092   bool numberOfClustersSpecified;
0093   uint8_t numberOfClusters_;
0094 
0095   /// event counter in the VFAT frame
0096   uint8_t eventCounter;
0097 };
0098 
0099 #endif