@@ -29,27 +29,27 @@ namespace iotof
2929// / Compact encoding for ALICE3 IOTOF cluster parameters inside a single 64-bit word.
3030struct ClusterInfo {
3131 // Bit widths (Total: 52 bits out of 64)
32- static constexpr int NBitsRow = 9 ;
33- static constexpr int NBitsCol = 8 ;
34- static constexpr int NBitsRowSpan = 4 ;
35- static constexpr int NBitsColSpan = 4 ;
36- static constexpr int NBitsPattern = 16 ;
32+ static constexpr int NBitsRow = 9 ;
33+ static constexpr int NBitsCol = 8 ;
34+ static constexpr int NBitsRowSpan = 4 ;
35+ static constexpr int NBitsColSpan = 4 ;
36+ static constexpr int NBitsPattern = 16 ;
3737 static constexpr int NBitsTopology = 11 ;
3838
3939 // Bit offsets (ordered logically from LSB to MSB)
40- static constexpr int ShiftRow = 0 ;
41- static constexpr int ShiftCol = ShiftRow + NBitsRow; // 9
42- static constexpr int ShiftRowSpan = ShiftCol + NBitsCol; // 17
43- static constexpr int ShiftColSpan = ShiftRowSpan + NBitsRowSpan; // 21
44- static constexpr int ShiftPattern = ShiftColSpan + NBitsColSpan; // 25
45- static constexpr int ShiftTopology = ShiftPattern + NBitsPattern; // 41
40+ static constexpr int ShiftRow = 0 ;
41+ static constexpr int ShiftCol = ShiftRow + NBitsRow; // 9
42+ static constexpr int ShiftRowSpan = ShiftCol + NBitsCol; // 17
43+ static constexpr int ShiftColSpan = ShiftRowSpan + NBitsRowSpan; // 21
44+ static constexpr int ShiftPattern = ShiftColSpan + NBitsColSpan; // 25
45+ static constexpr int ShiftTopology = ShiftPattern + NBitsPattern; // 41
4646
4747 // Bit masks
48- static constexpr uint64_t MaskRow = (1ULL << NBitsRow) - 1 ;
49- static constexpr uint64_t MaskCol = (1ULL << NBitsCol) - 1 ;
50- static constexpr uint64_t MaskRowSpan = (1ULL << NBitsRowSpan) - 1 ;
51- static constexpr uint64_t MaskColSpan = (1ULL << NBitsColSpan) - 1 ;
52- static constexpr uint64_t MaskPattern = (1ULL << NBitsPattern) - 1 ;
48+ static constexpr uint64_t MaskRow = (1ULL << NBitsRow) - 1 ;
49+ static constexpr uint64_t MaskCol = (1ULL << NBitsCol) - 1 ;
50+ static constexpr uint64_t MaskRowSpan = (1ULL << NBitsRowSpan) - 1 ;
51+ static constexpr uint64_t MaskColSpan = (1ULL << NBitsColSpan) - 1 ;
52+ static constexpr uint64_t MaskPattern = (1ULL << NBitsPattern) - 1 ;
5353 static constexpr uint64_t MaskTopology = (1ULL << NBitsTopology) - 1 ;
5454
5555 uint64_t data{0 };
@@ -59,41 +59,48 @@ struct ClusterInfo {
5959 constexpr ClusterInfo (uint64_t d) : data(d) {}
6060
6161 // Static packer
62- static constexpr uint64_t pack (uint32_t row, uint32_t col, uint32_t rowSpan,
63- uint32_t colSpan, uint32_t pattern, uint32_t topology) {
64- return ((static_cast <uint64_t >(row) & MaskRow) << ShiftRow) |
65- ((static_cast <uint64_t >(col) & MaskCol) << ShiftCol) |
66- ((static_cast <uint64_t >(rowSpan) & MaskRowSpan) << ShiftRowSpan) |
67- ((static_cast <uint64_t >(colSpan) & MaskColSpan) << ShiftColSpan) |
68- ((static_cast <uint64_t >(pattern) & MaskPattern) << ShiftPattern) |
62+ static constexpr uint64_t pack (uint32_t row, uint32_t col, uint32_t rowSpan,
63+ uint32_t colSpan, uint32_t pattern, uint32_t topology)
64+ {
65+ return ((static_cast <uint64_t >(row) & MaskRow) << ShiftRow) |
66+ ((static_cast <uint64_t >(col) & MaskCol) << ShiftCol) |
67+ ((static_cast <uint64_t >(rowSpan) & MaskRowSpan) << ShiftRowSpan) |
68+ ((static_cast <uint64_t >(colSpan) & MaskColSpan) << ShiftColSpan) |
69+ ((static_cast <uint64_t >(pattern) & MaskPattern) << ShiftPattern) |
6970 ((static_cast <uint64_t >(topology) & MaskTopology) << ShiftTopology);
7071 }
7172
7273 // Getters
73- constexpr uint32_t getRow () const { return (data >> ShiftRow) & MaskRow; }
74- constexpr uint32_t getCol () const { return (data >> ShiftCol) & MaskCol; }
75- constexpr uint32_t getRowSpan () const { return (data >> ShiftRowSpan) & MaskRowSpan; }
76- constexpr uint32_t getColSpan () const { return (data >> ShiftColSpan) & MaskColSpan; }
77- constexpr uint32_t getPattern () const { return (data >> ShiftPattern) & MaskPattern; }
74+ constexpr uint32_t getRow () const { return (data >> ShiftRow) & MaskRow; }
75+ constexpr uint32_t getCol () const { return (data >> ShiftCol) & MaskCol; }
76+ constexpr uint32_t getRowSpan () const { return (data >> ShiftRowSpan) & MaskRowSpan; }
77+ constexpr uint32_t getColSpan () const { return (data >> ShiftColSpan) & MaskColSpan; }
78+ constexpr uint32_t getPattern () const { return (data >> ShiftPattern) & MaskPattern; }
7879 constexpr uint32_t getTopology () const { return (data >> ShiftTopology) & MaskTopology; }
7980
8081 // Setters
81- constexpr void setRow (uint32_t r) {
82+ constexpr void setRow (uint32_t r)
83+ {
8284 data = (data & ~(MaskRow << ShiftRow)) | ((static_cast <uint64_t >(r) & MaskRow) << ShiftRow);
8385 }
84- constexpr void setCol (uint32_t c) {
86+ constexpr void setCol (uint32_t c)
87+ {
8588 data = (data & ~(MaskCol << ShiftCol)) | ((static_cast <uint64_t >(c) & MaskCol) << ShiftCol);
8689 }
87- constexpr void setRowSpan (uint32_t rs) {
90+ constexpr void setRowSpan (uint32_t rs)
91+ {
8892 data = (data & ~(MaskRowSpan << ShiftRowSpan)) | ((static_cast <uint64_t >(rs) & MaskRowSpan) << ShiftRowSpan);
8993 }
90- constexpr void setColSpan (uint32_t cs) {
94+ constexpr void setColSpan (uint32_t cs)
95+ {
9196 data = (data & ~(MaskColSpan << ShiftColSpan)) | ((static_cast <uint64_t >(cs) & MaskColSpan) << ShiftColSpan);
9297 }
93- constexpr void setPattern (uint32_t p) {
98+ constexpr void setPattern (uint32_t p)
99+ {
94100 data = (data & ~(MaskPattern << ShiftPattern)) | ((static_cast <uint64_t >(p) & MaskPattern) << ShiftPattern);
95101 }
96- constexpr void setTopology (uint32_t t) {
102+ constexpr void setTopology (uint32_t t)
103+ {
97104 data = (data & ~(MaskTopology << ShiftTopology)) | ((static_cast <uint64_t >(t) & MaskTopology) << ShiftTopology);
98105 }
99106
@@ -120,13 +127,14 @@ class Cluster
120127 }
121128
122129 // Unpack Getters
123- uint32_t getRow () const { return mClusterInfo .getRow (); }
124- uint32_t getCol () const { return mClusterInfo .getCol (); }
125- uint32_t getRowSpan () const { return mClusterInfo .getRowSpan (); }
126- uint32_t getColSpan () const { return mClusterInfo .getColSpan (); }
127- uint32_t getPattern () const { return mClusterInfo .getPattern (); }
130+ uint32_t getRow () const { return mClusterInfo .getRow (); }
131+ uint32_t getCol () const { return mClusterInfo .getCol (); }
132+ uint32_t getRowSpan () const { return mClusterInfo .getRowSpan (); }
133+ uint32_t getColSpan () const { return mClusterInfo .getColSpan (); }
134+ uint32_t getPattern () const { return mClusterInfo .getPattern (); }
128135 uint32_t getTopology () const { return mClusterInfo .getTopology (); }
129- int getSize () const {
136+ int getSize () const
137+ {
130138 // Count the number of set bits in the pattern to determine the size of the cluster
131139 uint32_t pattern = getPattern ();
132140 int size = 0 ;
@@ -138,20 +146,20 @@ class Cluster
138146 }
139147
140148 // BaseCluster / Interface Compatibility Getters
141- uint32_t getChipID () const { return mChipID ; }
149+ uint32_t getChipID () const { return mChipID ; }
142150 uint32_t getSensorID () const { return mChipID ; }
143- time_t getTime () const { return mTime ; }
151+ time_t getTime () const { return mTime ; }
144152 uint64_t getPackedData () const { return mClusterInfo .data ; }
145153
146154 // Setters
147- void setRow (UShort_t r) { mClusterInfo .setRow (r); }
148- void setCol (UShort_t c) { mClusterInfo .setCol (c); }
149- void setRowSpan (UShort_t rs) { mClusterInfo .setRowSpan (rs); }
150- void setColSpan (UShort_t cs) { mClusterInfo .setColSpan (cs); }
151- void setPatternID (UShort_t p) { mClusterInfo .setPattern (p); }
152- void setTopology (UShort_t t) { mClusterInfo .setTopology (t); }
153- void setChipID (UShort_t c) { mChipID = c; }
154- void setTime (time_t t) { mTime = t; }
155+ void setRow (UShort_t r) { mClusterInfo .setRow (r); }
156+ void setCol (UShort_t c) { mClusterInfo .setCol (c); }
157+ void setRowSpan (UShort_t rs) { mClusterInfo .setRowSpan (rs); }
158+ void setColSpan (UShort_t cs) { mClusterInfo .setColSpan (cs); }
159+ void setPatternID (UShort_t p) { mClusterInfo .setPattern (p); }
160+ void setTopology (UShort_t t) { mClusterInfo .setTopology (t); }
161+ void setChipID (UShort_t c) { mChipID = c; }
162+ void setTime (time_t t) { mTime = t; }
155163
156164 // Operators & Debugging
157165 bool operator ==(const Cluster& cl) const
0 commit comments