@@ -28,118 +28,118 @@ union PadWord {
2828 uint32_t address : 6 ; // /< Bits 12 - 17 : address (0..47)
2929 uint32_t gas : 3 ; // /< Bits 18 - 20 : gasiplex (1..10)
3030 uint32_t dil : 2 ; // /< Bits 21 - 22 : dilogic (1..24)
31- uint32_t zero : 1 ; // /< Bits 23 - 23 : zeroed
31+ uint32_t zero : 1 ; // /< Bits 23 - 23 : control bit (0 -> pad word, 1 -> FEE control word)
3232 };
33- char bytes [4 ];
33+ char mBytes [4 ];
3434};
3535
36- class cpvword
36+ class CpvWord
3737{
3838 public:
39- cpvword () = default ;
40- cpvword (std::vector<char >::const_iterator b, std::vector<char >::const_iterator e)
39+ CpvWord () = default ;
40+ CpvWord (std::vector<char >::const_iterator b, std::vector<char >::const_iterator e)
4141 { // Reading
4242 // resposibility of coller to esure that
4343 // array will not end while reading
4444 for (int i = 0 ; i < 16 && b != e; i++, b++) {
45- bytes [i] = *b;
45+ mBytes [i] = *b;
4646 }
4747 }
48- ~cpvword () = default ;
48+ ~CpvWord () = default ;
4949 bool isOK () const
5050 {
51- return (bytes [9 ] < static_cast <unsigned char >(24 )) &&
52- (bytes [15 ] == 0 ) && (bytes [14 ] == 0 ) && (bytes [13 ] == 0 ) && (bytes [12 ] == 0 ) && (bytes [11 ] == 0 ) && (bytes [10 ] == 0 );
51+ return (mBytes [9 ] < static_cast <unsigned char >(24 )) &&
52+ (mBytes [15 ] == 0 ) && (mBytes [14 ] == 0 ) && (mBytes [13 ] == 0 ) && (mBytes [12 ] == 0 ) && (mBytes [11 ] == 0 ) && (mBytes [10 ] == 0 );
5353 }
54- short ccId () const { return short (bytes [9 ]); }
54+ short ccId () const { return short (mBytes [9 ]); }
5555 uint32_t cpvPadWord (int i) const
5656 {
5757 PadWord p = {0 };
58- p.bytes [0 ] = bytes [3 * i];
59- p.bytes [1 ] = bytes [3 * i + 1 ];
60- p.bytes [2 ] = bytes [3 * i + 2 ];
58+ p.mBytes [0 ] = mBytes [3 * i];
59+ p.mBytes [1 ] = mBytes [3 * i + 1 ];
60+ p.mBytes [2 ] = mBytes [3 * i + 2 ];
6161 return p.mDataWord ;
6262 }
6363
6464 public:
65- unsigned char bytes [16 ] = {0 };
65+ unsigned char mBytes [16 ] = {0 };
6666};
6767
68- class cpvheader
68+ class CpvHeader
6969{
7070 public:
71- cpvheader () = default ;
72- cpvheader (std::vector<char >::const_iterator b, std::vector<char >::const_iterator e)
71+ CpvHeader () = default ;
72+ CpvHeader (std::vector<char >::const_iterator b, std::vector<char >::const_iterator e)
7373 { // reading header from file
74- for (int i = 0 ; i < 16 && b != e; i++, b++) { // read up to 16 bytes
75- bytes [i] = *b;
74+ for (int i = 0 ; i < 16 && b != e; i++, b++) { // read up to 16 mBytes
75+ mBytes [i] = *b;
7676 }
7777 }
78- cpvheader (InteractionRecord orbitBC, bool isNoDataExpected, bool isDataContinued)
78+ CpvHeader (InteractionRecord orbitBC, bool isNoDataExpected, bool isDataContinued)
7979 { // writing header
8080 // header is 128-bit word.
8181 // |127-120|119-112|111-104|103-96|95-88 |87-80 |79-72|71-64|63-56|55-48|47-40|39-32|31-24|23-16|15-8 |7-0 |
8282 // byte15 byte14 byte13 byte12 byte11 byte10 byte9 byte8 byte7 byte6 byte5 byte4 byte3 byte2 byte1 byte0
8383 // byte = |76543210|
84- bytes [0 ] = (0x010 & 0x0ff ); // bits 11 - 0 trigger id (0x010 = physics trigger)
85- bytes [1 ] = ((0x010 & 0xf00 ) >> 8 ) // bits 11 - 0 trigger id (0x010 = physics trigger)
86- + 0b00100000 * isNoDataExpected + 0b0100000 * isDataContinued; // bit 13 (no data for this trigger) + bit 14 (payload continues from previous page)
87- bytes [2 ] = (orbitBC.bc & 0x00ff ); // bits 27 - 16 bunch crossing
88- bytes [3 ] = (orbitBC.bc & 0x0f00 ) >> 8 ; // bits 27 - 16 bunch crossing
89- bytes [4 ] = (orbitBC.orbit & 0x000000ff ); // bits 63 - 32 orbit
90- bytes [5 ] = (orbitBC.orbit & 0x0000ff00 ) >> 8 ; // bits 63 - 32 orbit
91- bytes [6 ] = (orbitBC.orbit & 0x00ff0000 ) >> 16 ; // bits 63 - 32 orbit
92- bytes [7 ] = (orbitBC.orbit & 0xff000000 ) >> 24 ; // bits 63 - 32 orbit
93- bytes [8 ] = 0x00 ; // bits 64-71 reserved
94- bytes [9 ] = 0xe0 ; // word ID of cpv header (bits 79 - 72)
84+ mBytes [0 ] = (0x010 & 0x0ff ); // bits 11 - 0 trigger id (0x010 = physics trigger)
85+ mBytes [1 ] = ((0x010 & 0xf00 ) >> 8 ) // bits 11 - 0 trigger id (0x010 = physics trigger)
86+ + 0b00100000 * isNoDataExpected + 0b0100000 * isDataContinued; // bit 13 (no data for this trigger) + bit 14 (payload continues from previous page)
87+ mBytes [2 ] = (orbitBC.bc & 0x00ff ); // bits 27 - 16 bunch crossing
88+ mBytes [3 ] = (orbitBC.bc & 0x0f00 ) >> 8 ; // bits 27 - 16 bunch crossing
89+ mBytes [4 ] = (orbitBC.orbit & 0x000000ff ); // bits 63 - 32 orbit
90+ mBytes [5 ] = (orbitBC.orbit & 0x0000ff00 ) >> 8 ; // bits 63 - 32 orbit
91+ mBytes [6 ] = (orbitBC.orbit & 0x00ff0000 ) >> 16 ; // bits 63 - 32 orbit
92+ mBytes [7 ] = (orbitBC.orbit & 0xff000000 ) >> 24 ; // bits 63 - 32 orbit
93+ mBytes [8 ] = 0x00 ; // bits 64-71 reserved
94+ mBytes [9 ] = 0xe0 ; // word ID of cpv header (bits 79 - 72)
9595 for (int i = 10 ; i < 16 ; i++) {
96- bytes [i] = 0 ; // bits 127-80 must be zeros
96+ mBytes [i] = 0 ; // bits 127-80 must be zeros
9797 }
9898 }
99- ~cpvheader () = default ;
100- bool isOK () const { return (bytes [9 ] == 0xe0 ) && (bytes [10 ] == 0 ) && (bytes [11 ] == 0 ) && (bytes [12 ] == 0 ) && (bytes [13 ] == 0 ) && (bytes [14 ] == 0 ) && (bytes [15 ] == 0 ); }
101- bool isNoDataExpected () const { return bytes [1 ] & 0b00100000 ; }
102- bool isDataContinued () const { return bytes [1 ] & 0b0100000 ; }
103- uint16_t bc () const { return bytes [2 ] + ((bytes [3 ] & 0x0f ) << 8 ); }
104- uint32_t orbit () const { return bytes [4 ] + (bytes [5 ] << 8 ) + (bytes [6 ] << 16 ) + (bytes [7 ] << 24 ); }
99+ ~CpvHeader () = default ;
100+ bool isOK () const { return (mBytes [9 ] == 0xe0 ) && (mBytes [10 ] == 0 ) && (mBytes [11 ] == 0 ) && (mBytes [12 ] == 0 ) && (mBytes [13 ] == 0 ) && (mBytes [14 ] == 0 ) && (mBytes [15 ] == 0 ); }
101+ bool isNoDataExpected () const { return mBytes [1 ] & 0b00100000 ; }
102+ bool isDataContinued () const { return mBytes [1 ] & 0b0100000 ; }
103+ uint16_t bc () const { return mBytes [2 ] + ((mBytes [3 ] & 0x0f ) << 8 ); }
104+ uint32_t orbit () const { return mBytes [4 ] + (mBytes [5 ] << 8 ) + (mBytes [6 ] << 16 ) + (mBytes [7 ] << 24 ); }
105105
106106 public:
107- unsigned char bytes [16 ] = {0 }; // 0 - 127 bits (16 bytes)
107+ unsigned char mBytes [16 ] = {0 }; // 0 - 127 bits (16 bytes)
108108};
109109
110- class cpvtrailer
110+ class CpvTrailer
111111{
112112 public:
113- cpvtrailer () = default ;
114- cpvtrailer (std::vector<char >::const_iterator b, std::vector<char >::const_iterator e)
113+ CpvTrailer () = default ;
114+ CpvTrailer (std::vector<char >::const_iterator b, std::vector<char >::const_iterator e)
115115 { // reading
116- for (int i = 0 ; i < 16 && b != e; i++, b++) { // read up to 16 bytes
117- bytes [i] = *b;
116+ for (int i = 0 ; i < 16 && b != e; i++, b++) { // read up to 16 mBytes
117+ mBytes [i] = *b;
118118 }
119119 }
120- cpvtrailer (unsigned short wordCounter, uint16_t bunchCrossing, bool isAllDataSent)
121- { // writing
122- bytes [0 ] = bunchCrossing & 0x00ff ; // bits 11 - 0 bunch crossing
123- bytes [1 ] = ((bunchCrossing & 0x0f00 ) >> 8 ) // bits 11 - 0 bunch crossing
124- + ((wordCounter & 0x0f ) << 4 ); // bits 20 - 12 wordCounter
125- bytes [2 ] = (wordCounter & 0b111110000 ) >> 4 ; // bits 20 - 12 wordCounter
120+ CpvTrailer (unsigned short wordCounter, uint16_t bunchCrossing, bool isAllDataSent)
121+ { // writing
122+ mBytes [0 ] = bunchCrossing & 0x00ff ; // bits 11 - 0 bunch crossing
123+ mBytes [1 ] = ((bunchCrossing & 0x0f00 ) >> 8 ) // bits 11 - 0 bunch crossing
124+ + ((wordCounter & 0x0f ) << 4 ); // bits 20 - 12 wordCounter
125+ mBytes [2 ] = (wordCounter & 0b111110000 ) >> 4 ; // bits 20 - 12 wordCounter
126126 for (int i = 3 ; i < 8 ; i++) {
127- bytes [i] = 0 ; // bits 70 - 21 reserved
127+ mBytes [i] = 0 ; // bits 70 - 21 reserved
128128 }
129- bytes [8 ] = isAllDataSent * 0b10000000 ; // bit 71 all data is sent for current trigger
130- bytes [9 ] = char (0xf0 ); // word ID of cpv trailer
129+ mBytes [8 ] = isAllDataSent * 0b10000000 ; // bit 71 all data is sent for current trigger
130+ mBytes [9 ] = char (0xf0 ); // word ID of cpv trailer
131131 for (int i = 10 ; i < 16 ; i++) {
132- bytes [i] = 0 ;
132+ mBytes [i] = 0 ;
133133 }
134134 }
135- ~cpvtrailer () = default ;
136- bool isOK () const { return (bytes [9 ] == 0xf0 ) && (bytes [10 ] == 0 ) && (bytes [11 ] == 0 ) && (bytes [12 ] == 0 ) && (bytes [13 ] == 0 ) && (bytes [14 ] == 0 ) && (bytes [15 ] == 0 ); }
137- uint16_t wordCounter () const { return (bytes [1 ] >> 4 ) + ((bytes [2 ] & 0b00011111 ) << 4 ); }
138- bool isAllDataSent () const { return (bytes [8 ] & 0b10000000 ); }
139- uint16_t bc () const { return bytes [0 ] + ((bytes [1 ] & 0x0f ) << 8 ); }
135+ ~CpvTrailer () = default ;
136+ bool isOK () const { return (mBytes [9 ] == 0xf0 ) && (mBytes [10 ] == 0 ) && (mBytes [11 ] == 0 ) && (mBytes [12 ] == 0 ) && (mBytes [13 ] == 0 ) && (mBytes [14 ] == 0 ) && (mBytes [15 ] == 0 ); }
137+ uint16_t wordCounter () const { return (mBytes [1 ] >> 4 ) + ((mBytes [2 ] & 0b00011111 ) << 4 ); }
138+ bool isAllDataSent () const { return (mBytes [8 ] & 0b10000000 ); }
139+ uint16_t bc () const { return mBytes [0 ] + ((mBytes [1 ] & 0x0f ) << 8 ); }
140140
141141 public:
142- unsigned char bytes [16 ] = {0 };
142+ unsigned char mBytes [16 ] = {0 };
143143};
144144
145145} // namespace cpv
0 commit comments