2525namespace o2 ::tpc::cmv
2626{
2727
28- static constexpr uint32_t NTimeBins = 3564 ; // /< number of time bins (spans 8 orbits)
29- static constexpr uint32_t SignificantBits = 2 ; // /< number of bits used for floating point precision
30- static constexpr float FloatConversion = 1 .f / float (1 << SignificantBits); // /< conversion factor from integer representation to float
28+ static constexpr uint32_t NTimeBins = 3564 ; // /< number of time bins (spans 8 orbits)
29+ static constexpr uint32_t SignificantBits = 2 ; // /< number of bits used for floating point precision
30+ static constexpr float FloatConversion = 1 .f / float (1 << SignificantBits); // /< conversion factor from integer representation to float
3131
3232// / Header definition of the CMVs
3333struct Header {
3434 static constexpr uint8_t MagicWord = 0xDC ;
3535 union {
36- uint32_t word0 = 0 ; // /< bits 0 - 31
36+ uint32_t word0 = 0 ; // /< bits 0 - 31
3737 struct {
38- uint8_t version : 8 ; // /< version
39- uint8_t packetID : 8 ; // /< packet id
40- uint8_t errorCode : 8 ; // /< errors
41- uint8_t magicWord : 8 ; // /< magic word
38+ uint8_t version : 8 ; // /< version
39+ uint8_t packetID : 8 ; // /< packet id
40+ uint8_t errorCode : 8 ; // /< errors
41+ uint8_t magicWord : 8 ; // /< magic word
4242 };
4343 };
4444 union {
45- uint32_t word1 = 0 ; // /< bits 32 - 63
45+ uint32_t word1 = 0 ; // /< bits 32 - 63
4646 struct {
47- uint32_t heartbeatOrbit : 32 ; // /< first heart beat timing of the package
47+ uint32_t heartbeatOrbit : 32 ; // /< first heart beat timing of the package
4848 };
4949 };
5050 union {
51- uint16_t word2 = 0 ; // /< bits 64 - 79
51+ uint16_t word2 = 0 ; // /< bits 64 - 79
5252 struct {
53- uint16_t heartbeatBC : 16 ; // /< first BC id of the package
53+ uint16_t heartbeatBC : 16 ; // /< first BC id of the package
5454 };
5555 };
5656};
5757
5858// / CMV single data container
5959struct Data {
60- uint16_t CMV{0 }; // /< 16bit ADC value
61-
60+ uint16_t CMV{0 }; // /< 16bit ADC value
61+
6262 // Raw integer accessors
6363 uint16_t getCMV () const { return CMV; }
6464 void setCMV (uint16_t value) { CMV = value; }
65-
65+
6666 // Float helpers using SignificantBits for fixed-point conversion
6767 float getCMVFloat () const { return static_cast <float >(CMV) * FloatConversion; }
68- void setCMVFloat (float value) {
68+ void setCMVFloat (float value)
69+ {
6970 // round to nearest representable fixed-point value
7071 setCMV (uint32_t ((value + 0 .5f * FloatConversion) / FloatConversion));
7172 }
7273};
7374
7475// / CMV full data container: one packet carries NTimeBins time bins
7576struct Container {
76- Header header; // /< CMV data header
77- Data data[NTimeBins]; // /< data values for given number of time bins
77+ Header header; // /< CMV data header
78+ Data data[NTimeBins]; // /< data values for given number of time bins
7879
7980 // Header and data accessors
8081 const Header& getHeader () const { return header; }
@@ -89,7 +90,6 @@ struct Container {
8990
9091 float getCMVFloat (uint32_t timeBin) const { return data[timeBin].getCMVFloat (); }
9192 void setCMVFloat (uint32_t timeBin, float value) { data[timeBin].setCMVFloat (value); }
92-
9393};
9494} // namespace o2::tpc::cmv
9595
0 commit comments