Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PixelData.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PixelData.h
1 // @file PixelData.h
2 // @brief Transient data classes for single pixel and set of pixels from current chip
3 // @sa <O2/Detectors/ITSMFT/common/reconstruction/include/ITSMFTReconstruction/PixelData.h>
4 // <0ec4d22ed>
5 
6 #ifndef MVTXDECODER_PIXELDATA_H
7 #define MVTXDECODER_PIXELDATA_H
8 
10 #include <cstdint>
11 #include <vector>
12 
13 namespace mvtx
14 {
16 class PixelData
17 {
18 
19  public:
20  PixelData(uint16_t r = 0, uint16_t c = 0) : mRow(r), mCol(c) {}
21  uint16_t getRow() const { return mRow; }
22  uint16_t getCol() const { return mCol; }
23 
24  private:
25  uint16_t mRow = 0;
26  uint16_t mCol = 0;
27 
28  // ClassDefNV(PixelData, 1);
29 };
30 
34 {
35 
36  public:
37  // total number of raw data bytes to save in case of error and number of bytes (if any) after problematic one
38  static constexpr size_t MAXDATAERRBYTES = 16, MAXDATAERRBYTES_AFTER = 2;
39  ChipPixelData() = default;
40  ~ChipPixelData() = default;
41  uint16_t getChipID() const { return mChipID; }
42  const std::vector<PixelData>& getData() const { return mPixels; }
43  std::vector<PixelData>& getData() { return (std::vector<PixelData>&)mPixels; }
44 
45 // void setROFlags(uint8_t f = 0) { mROFlags = f; }
46  void setChipID(uint16_t id) { mChipID = id; }
47 // void setROFrame(uint32_t r) { mROFrame = r; }
48 
49  void setError(ChipStat::DecErrors i) { mErrors |= 0x1 << i; }
50  void addErrorInfo(uint64_t b) { mErrorInfo |= b; }
51  void setErrorFlags(uint32_t f) { mErrors |= f; }
52  bool isErrorSet(ChipStat::DecErrors i) const { return mErrors & (0x1 << i); }
53  bool isErrorSet() const { return mErrors != 0; }
54  auto getErrorFlags() const { return mErrors; }
55  auto getErrorInfo() const { return mErrorInfo; }
56  auto getNBytesInRawBuff() const { return int(mErrorInfo >> 32) & 0xff; }
57  void setNBytesInRawBuff(int n) { mErrorInfo |= (uint64_t(n & 0xff)) << 32; }
58  auto& getRawErrBuff() { return mRawBuff; }
59  auto& getRawErrBuff() const { return mRawBuff; }
60  std::string getErrorDetails(int pos) const;
61 
62  void resetChipID()
63  {
64  mChipID = -1;
65  }
66 
67  void clear()
68  {
69  resetChipID();
70  mPixels.clear();
71  mErrors = 0;
72  mErrorInfo = 0;
73  }
74 
75  void swap(ChipPixelData& other)
76  {
77  std::swap(mChipID, other.mChipID);
78  std::swap(mErrors, other.mErrors);
79  mPixels.swap(other.mPixels);
80  }
81 
82  void print() const;
83 
84  private:
85  uint16_t mChipID = 0; // chip id within the detector
86  uint32_t mErrors = 0; // errors set during decoding
87  uint64_t mErrorInfo = 0; // optional extra info on the error
88  std::array<uint8_t, MAXDATAERRBYTES> mRawBuff{}; // buffer for raw data showing an error
89  std::vector<PixelData> mPixels; // vector of pixels
90 
91  // ClassDefNV(ChipPixelData, 1);
92 };
93 } // namespace mvtx
94 
95 #endif // MVTXDECODER_PIXELDATA_H