Project
Loading...
Searching...
No Matches
GBTFrame.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15#ifndef ALICEO2_TPC_GBTFRAME_H_
16#define ALICEO2_TPC_GBTFRAME_H_
17
18#include <iosfwd>
19#include <iomanip>
20#include <vector>
21#include <array>
22
23namespace o2
24{
25namespace tpc
26{
27
28#define BIT00(x) ((x & 0x1) >> 0)
29#define BIT01(x) ((x & 0x2) >> 1)
30#define BIT02(x) ((x & 0x4) >> 2)
31#define BIT03(x) ((x & 0x8) >> 3)
32#define BIT04(x) ((x & 0x10) >> 4)
33#define BIT05(x) ((x & 0x20) >> 5)
34#define BIT06(x) ((x & 0x40) >> 6)
35#define BIT07(x) ((x & 0x80) >> 7)
36#define BIT08(x) ((x & 0x100) >> 8)
37#define BIT09(x) ((x & 0x200) >> 9)
38#define BIT10(x) ((x & 0x400) >> 10)
39#define BIT11(x) ((x & 0x800) >> 11)
40#define BIT12(x) ((x & 0x1000) >> 12)
41#define BIT13(x) ((x & 0x2000) >> 13)
42#define BIT14(x) ((x & 0x4000) >> 14)
43#define BIT15(x) ((x & 0x8000) >> 15)
44#define BIT16(x) ((x & 0x10000) >> 16)
45#define BIT17(x) ((x & 0x20000) >> 17)
46#define BIT18(x) ((x & 0x40000) >> 18)
47#define BIT19(x) ((x & 0x80000) >> 19)
48#define BIT20(x) ((x & 0x100000) >> 20)
49#define BIT21(x) ((x & 0x200000) >> 21)
50#define BIT22(x) ((x & 0x400000) >> 22)
51#define BIT23(x) ((x & 0x800000) >> 23)
52#define BIT24(x) ((x & 0x1000000) >> 24)
53#define BIT25(x) ((x & 0x2000000) >> 25)
54#define BIT26(x) ((x & 0x4000000) >> 26)
55#define BIT27(x) ((x & 0x8000000) >> 27)
56#define BIT28(x) ((x & 0x10000000) >> 28)
57#define BIT29(x) ((x & 0x20000000) >> 29)
58#define BIT30(x) ((x & 0x40000000) >> 30)
59#define BIT31(x) ((x & 0x80000000) >> 31)
60
64{
65 public:
67 GBTFrame();
68
74 GBTFrame(unsigned word3, unsigned word2, unsigned word1, unsigned word0);
75
101 GBTFrame(short s0hw0l, short s0hw1l, short s0hw2l, short s0hw3l,
102 short s0hw0h, short s0hw1h, short s0hw2h, short s0hw3h,
103 short s1hw0l, short s1hw1l, short s1hw2l, short s1hw3l,
104 short s1hw0h, short s1hw1h, short s1hw2h, short s1hw3h,
105 short s2hw0, short s2hw1, short s2hw2, short s2hw3,
106 short s0adc, short s1adc, short s2adc, unsigned marker = 0);
107
111
113 ~GBTFrame() = default;
114
117 short getMarker() const { return (mWords[3] >> 16) & 0xFFFF; };
118
124 short getHalfWord(const short sampa, const short halfword, const short chan = 0) const { return mHalfWords[sampa][chan][halfword]; };
125
129 short getAdcClock(short sampa) const { return mAdcClock[sampa]; };
130
134 void setAdcClock(int sampa, int clock);
135
139 // void setData(const GBTFrame& other);
140
146 void setData(unsigned word3, unsigned word2, unsigned word1, unsigned word0);
147
173 void setData(short s0hw0l, short s0hw1l, short s0hw2l, short s0hw3l,
174 short s0hw0h, short s0hw1h, short s0hw2h, short s0hw3h,
175 short s1hw0l, short s1hw1l, short s1hw2l, short s1hw3l,
176 short s1hw0h, short s1hw1h, short s1hw2h, short s1hw3h,
177 short s2hw0, short s2hw1, short s2hw2, short s2hw3,
178 short s0adc, short s1adc, short s2adc, unsigned marker = 0);
179
185 void getGBTFrame(unsigned& word3, unsigned& word2, unsigned& word1, unsigned& word0) const;
186
190 std::ostream& Print(std::ostream& output) const;
191 friend std::ostream& operator<<(std::ostream& out, const GBTFrame& f) { return f.Print(out); }
192
193 private:
194 void calculateHalfWords();
195 void calculateAdcClock();
196
197 std::array<unsigned, 4> mWords;
198 // Word 3 of GBT frame contains bits [127: 96], [127:112] are reserved for marker
199 // Word 2 of GBT frame contains bits [ 95: 64]
200 // Word 1 of GBT frame contains bits [ 63: 32]
201 // Word 0 of GBT frame contains bits [ 31: 0]
202
203 std::array<std::array<std::array<short, 4>, 2>, 3> mHalfWords;
204 // halfWord
205 // channels (low or high)
206 // sampa
207
208 std::array<short, 3> mAdcClock;
209};
210
211inline void GBTFrame::calculateHalfWords()
212{
213
214 mHalfWords[0][0][0] = (BIT19(mWords[0]) << 4) | (BIT15(mWords[0]) << 3) | (BIT11(mWords[0]) << 2) | (BIT07(mWords[0]) << 1) | BIT03(mWords[0]);
215 mHalfWords[0][0][1] = (BIT18(mWords[0]) << 4) | (BIT14(mWords[0]) << 3) | (BIT10(mWords[0]) << 2) | (BIT06(mWords[0]) << 1) | BIT02(mWords[0]);
216 mHalfWords[0][0][2] = (BIT17(mWords[0]) << 4) | (BIT13(mWords[0]) << 3) | (BIT09(mWords[0]) << 2) | (BIT05(mWords[0]) << 1) | BIT01(mWords[0]);
217 mHalfWords[0][0][3] = (BIT16(mWords[0]) << 4) | (BIT12(mWords[0]) << 3) | (BIT08(mWords[0]) << 2) | (BIT04(mWords[0]) << 1) | BIT00(mWords[0]);
218
219 mHalfWords[0][1][0] = (BIT07(mWords[1]) << 4) | (BIT03(mWords[1]) << 3) | (BIT31(mWords[0]) << 2) | (BIT27(mWords[0]) << 1) | BIT23(mWords[0]);
220 mHalfWords[0][1][1] = (BIT06(mWords[1]) << 4) | (BIT02(mWords[1]) << 3) | (BIT30(mWords[0]) << 2) | (BIT26(mWords[0]) << 1) | BIT22(mWords[0]);
221 mHalfWords[0][1][2] = (BIT05(mWords[1]) << 4) | (BIT01(mWords[1]) << 3) | (BIT29(mWords[0]) << 2) | (BIT25(mWords[0]) << 1) | BIT21(mWords[0]);
222 mHalfWords[0][1][3] = (BIT04(mWords[1]) << 4) | (BIT00(mWords[1]) << 3) | (BIT28(mWords[0]) << 2) | (BIT24(mWords[0]) << 1) | BIT20(mWords[0]);
223
224 mHalfWords[1][0][0] = (BIT31(mWords[1]) << 4) | (BIT27(mWords[1]) << 3) | (BIT23(mWords[1]) << 2) | (BIT19(mWords[1]) << 1) | BIT15(mWords[1]);
225 mHalfWords[1][0][1] = (BIT30(mWords[1]) << 4) | (BIT26(mWords[1]) << 3) | (BIT22(mWords[1]) << 2) | (BIT18(mWords[1]) << 1) | BIT14(mWords[1]);
226 mHalfWords[1][0][2] = (BIT29(mWords[1]) << 4) | (BIT25(mWords[1]) << 3) | (BIT21(mWords[1]) << 2) | (BIT17(mWords[1]) << 1) | BIT13(mWords[1]);
227 mHalfWords[1][0][3] = (BIT28(mWords[1]) << 4) | (BIT24(mWords[1]) << 3) | (BIT20(mWords[1]) << 2) | (BIT16(mWords[1]) << 1) | BIT12(mWords[1]);
228
229 mHalfWords[1][1][0] = (BIT19(mWords[2]) << 4) | (BIT15(mWords[2]) << 3) | (BIT11(mWords[2]) << 2) | (BIT07(mWords[2]) << 1) | BIT03(mWords[2]);
230 mHalfWords[1][1][1] = (BIT18(mWords[2]) << 4) | (BIT14(mWords[2]) << 3) | (BIT10(mWords[2]) << 2) | (BIT06(mWords[2]) << 1) | BIT02(mWords[2]);
231 mHalfWords[1][1][2] = (BIT17(mWords[2]) << 4) | (BIT13(mWords[2]) << 3) | (BIT09(mWords[2]) << 2) | (BIT05(mWords[2]) << 1) | BIT01(mWords[2]);
232 mHalfWords[1][1][3] = (BIT16(mWords[2]) << 4) | (BIT12(mWords[2]) << 3) | (BIT08(mWords[2]) << 2) | (BIT04(mWords[2]) << 1) | BIT00(mWords[2]);
233
234 mHalfWords[2][0][0] = (BIT11(mWords[3]) << 4) | (BIT07(mWords[3]) << 3) | (BIT03(mWords[3]) << 2) | (BIT31(mWords[2]) << 1) | BIT27(mWords[2]);
235 mHalfWords[2][0][1] = (BIT10(mWords[3]) << 4) | (BIT06(mWords[3]) << 3) | (BIT02(mWords[3]) << 2) | (BIT30(mWords[2]) << 1) | BIT26(mWords[2]);
236 mHalfWords[2][0][2] = (BIT09(mWords[3]) << 4) | (BIT05(mWords[3]) << 3) | (BIT01(mWords[3]) << 2) | (BIT29(mWords[2]) << 1) | BIT25(mWords[2]);
237 mHalfWords[2][0][3] = (BIT08(mWords[3]) << 4) | (BIT04(mWords[3]) << 3) | (BIT00(mWords[3]) << 2) | (BIT28(mWords[2]) << 1) | BIT24(mWords[2]);
238
239 // mHalfWords[2][1][0] = mHalfWords[2][0][0];
240 // mHalfWords[2][1][1] = mHalfWords[2][0][1];
241 // mHalfWords[2][1][2] = mHalfWords[2][0][2];
242 // mHalfWords[2][1][3] = mHalfWords[2][0][3];
243
244 calculateAdcClock();
245};
246
247inline void GBTFrame::calculateAdcClock()
248{
249 mAdcClock[0] = (mWords[1] >> 8) & 0xF;
250 mAdcClock[1] = (mWords[2] >> 20) & 0xF;
251 mAdcClock[2] = (mWords[3] >> 12) & 0xF;
252};
253
254inline void GBTFrame::setData(unsigned word3, unsigned word2, unsigned word1, unsigned word0)
255{
256 mWords[3] = word3;
257 mWords[2] = word2;
258 mWords[1] = word1;
259 mWords[0] = word0;
260
261 calculateHalfWords();
262};
263
265 : GBTFrame(0, 0, 0, 0){};
266
267inline GBTFrame::GBTFrame(unsigned word3, unsigned word2, unsigned word1, unsigned word0)
268{
269 mWords[3] = word3;
270 mWords[2] = word2;
271 mWords[1] = word1;
272 mWords[0] = word0;
273
274 calculateHalfWords();
275};
276
277inline GBTFrame::GBTFrame(const GBTFrame& other) = default;
278
279inline void GBTFrame::getGBTFrame(unsigned& word3, unsigned& word2, unsigned& word1, unsigned& word0) const
280{
281 word3 = mWords[3];
282 word2 = mWords[2];
283 word1 = mWords[1];
284 word0 = mWords[0];
285};
286
287} // namespace tpc
288} // namespace o2
289
290#endif // ALICEO2_TPC_GBTFRAME_H_
#define BIT21(x)
Definition GBTFrame.h:49
#define BIT31(x)
Definition GBTFrame.h:59
#define BIT10(x)
Definition GBTFrame.h:38
#define BIT05(x)
Definition GBTFrame.h:33
#define BIT12(x)
Definition GBTFrame.h:40
#define BIT24(x)
Definition GBTFrame.h:52
#define BIT19(x)
Definition GBTFrame.h:47
#define BIT16(x)
Definition GBTFrame.h:44
#define BIT18(x)
Definition GBTFrame.h:46
#define BIT11(x)
Definition GBTFrame.h:39
#define BIT17(x)
Definition GBTFrame.h:45
#define BIT27(x)
Definition GBTFrame.h:55
#define BIT20(x)
Definition GBTFrame.h:48
#define BIT06(x)
Definition GBTFrame.h:34
#define BIT13(x)
Definition GBTFrame.h:41
#define BIT30(x)
Definition GBTFrame.h:58
#define BIT15(x)
Definition GBTFrame.h:43
#define BIT00(x)
Definition GBTFrame.h:28
#define BIT07(x)
Definition GBTFrame.h:35
#define BIT02(x)
Definition GBTFrame.h:30
#define BIT28(x)
Definition GBTFrame.h:56
#define BIT22(x)
Definition GBTFrame.h:50
#define BIT25(x)
Definition GBTFrame.h:53
#define BIT04(x)
Definition GBTFrame.h:32
#define BIT26(x)
Definition GBTFrame.h:54
#define BIT23(x)
Definition GBTFrame.h:51
#define BIT09(x)
Definition GBTFrame.h:37
#define BIT01(x)
Definition GBTFrame.h:29
#define BIT29(x)
Definition GBTFrame.h:57
#define BIT03(x)
Definition GBTFrame.h:31
#define BIT14(x)
Definition GBTFrame.h:42
#define BIT08(x)
Definition GBTFrame.h:36
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
GBTFrame class for the TPC.
Definition GBTFrame.h:64
short getAdcClock(short sampa) const
Definition GBTFrame.h:129
void setAdcClock(int sampa, int clock)
Definition GBTFrame.cxx:185
~GBTFrame()=default
Destructor.
GBTFrame(const GBTFrame &other)
void getGBTFrame(unsigned &word3, unsigned &word2, unsigned &word1, unsigned &word0) const
Definition GBTFrame.h:279
short getMarker() const
Definition GBTFrame.h:117
void setData(unsigned word3, unsigned word2, unsigned word1, unsigned word0)
Definition GBTFrame.h:254
short getHalfWord(const short sampa, const short halfword, const short chan=0) const
Definition GBTFrame.h:124
std::ostream & Print(std::ostream &output) const
Definition GBTFrame.cxx:209
GBTFrame()
Default Constructor.
Definition GBTFrame.h:264
friend std::ostream & operator<<(std::ostream &out, const GBTFrame &f)
Definition GBTFrame.h:191
GLdouble f
Definition glcorearb.h:310
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other