Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:20:06

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