Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:18

0001 // @file PixelData.h
0002 // @brief Transient data classes for single pixel and set of pixels from current chip
0003 // @sa <O2/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PixelData.h>
0004 //     <0ec4d22ed>
0005 
0006 #ifndef MVTXDECODER_PIXELDATA_H
0007 #define MVTXDECODER_PIXELDATA_H
0008 
0009 #include "DecodingStat.h"
0010 #include <cstdint>
0011 #include <vector>
0012 
0013 namespace mvtx
0014 {
0015 ///< single pixel datum
0016 class PixelData
0017 {
0018 
0019  public:
0020   PixelData(uint16_t r = 0, uint16_t c = 0) : mRow(r), mCol(c) {}
0021   uint16_t getRow() const { return mRow; }
0022   uint16_t getCol() const { return mCol; }
0023 
0024  private:
0025   uint16_t mRow = 0;                    ///< pixel row
0026   uint16_t mCol = 0;                    ///< pixel column
0027 
0028   // ClassDefNV(PixelData, 1);
0029 };
0030 
0031 ///< Transient data for single chip fired pixeld
0032 ///< Assumes that the digits data is sorted in chip/col/row
0033 class ChipPixelData
0034 {
0035 
0036  public:
0037   // total number of raw data bytes to save in case of error and number of bytes (if any) after problematic one
0038   static constexpr size_t MAXDATAERRBYTES = 16, MAXDATAERRBYTES_AFTER = 2;
0039   ChipPixelData() = default;
0040   ~ChipPixelData() = default;
0041   uint16_t getChipID() const { return mChipID; }
0042   const std::vector<PixelData>& getData() const { return mPixels; }
0043   std::vector<PixelData>& getData() { return (std::vector<PixelData>&)mPixels; }
0044 
0045 //  void setROFlags(uint8_t f = 0) { mROFlags = f; }
0046   void setChipID(uint16_t id) { mChipID = id; }
0047 //  void setROFrame(uint32_t r) { mROFrame = r; }
0048 
0049   void setError(ChipStat::DecErrors i) { mErrors |= 0x1 << i; }
0050   void addErrorInfo(uint64_t b) { mErrorInfo |= b; }
0051   void setErrorFlags(uint32_t f) { mErrors |= f; }
0052   bool isErrorSet(ChipStat::DecErrors i) const { return mErrors & (0x1 << i); }
0053   bool isErrorSet() const { return mErrors != 0; }
0054   auto getErrorFlags() const { return mErrors; }
0055   auto getErrorInfo() const { return mErrorInfo; }
0056   auto getNBytesInRawBuff() const { return int(mErrorInfo >> 32) & 0xff; }
0057   void setNBytesInRawBuff(int n) { mErrorInfo |= (uint64_t(n & 0xff)) << 32; }
0058   auto& getRawErrBuff() { return mRawBuff; }
0059   auto& getRawErrBuff() const { return mRawBuff; }
0060   std::string getErrorDetails(int pos) const;
0061 
0062   void resetChipID()
0063   {
0064     mChipID = -1;
0065   }
0066 
0067   void clear()
0068   {
0069     resetChipID();
0070     mPixels.clear();
0071     mErrors = 0;
0072     mErrorInfo = 0;
0073   }
0074 
0075   void swap(ChipPixelData& other)
0076   {
0077     std::swap(mChipID, other.mChipID);
0078     std::swap(mErrors, other.mErrors);
0079     mPixels.swap(other.mPixels);
0080   }
0081 
0082   void print() const;
0083 
0084  private:
0085   uint16_t mChipID = 0;                            // chip id within the detector
0086   uint32_t mErrors = 0;                            // errors set during decoding
0087   uint64_t mErrorInfo = 0;                         // optional extra info on the error
0088   std::array<uint8_t, MAXDATAERRBYTES> mRawBuff{}; // buffer for raw data showing an error
0089   std::vector<PixelData> mPixels;                  // vector of pixels
0090 
0091   // ClassDefNV(ChipPixelData, 1);
0092 };
0093 } // namespace mvtx
0094 
0095 #endif // MVTXDECODER_PIXELDATA_H