Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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