ATLAS Offline Software
LUCID_RawData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8  m_word0 (0),
9  m_word1 (0),
10  m_word2 (0),
11  m_word3 (0),
12  m_word0p(0),
13  m_word1p(0),
14  m_word2p(0),
15  m_word3p(0),
16  m_word0n(0),
17  m_word1n(0),
18  m_word2n(0),
19  m_word3n(0),
20  m_status(0)
21 {}
22 
23 LUCID_RawData::LUCID_RawData(const unsigned int word0,
24  const unsigned int word1,
25  const unsigned int word2,
26  const unsigned int word3,
27  const unsigned int word0p,
28  const unsigned int word1p,
29  const unsigned int word2p,
30  const unsigned int word3p,
31  const unsigned int word0n,
32  const unsigned int word1n,
33  const unsigned int word2n,
34  const unsigned int word3n,
35  const unsigned int status) :
36  m_word0 (word0),
37  m_word1 (word1),
38  m_word2 (word2),
39  m_word3 (word3),
40  m_word0p(word0p),
41  m_word1p(word1p),
42  m_word2p(word2p),
43  m_word3p(word3p),
44  m_word0n(word0n),
45  m_word1n(word1n),
46  m_word2n(word2n),
47  m_word3n(word3n),
48  m_status(status)
49 {}
50 
51 LUCID_RawData::LUCID_RawData(std::vector<uint32_t>& data_block) {
52 
53  m_word0p = 0;
54  m_word1p = 0;
55  m_word2p = 0;
56  m_word3p = 0;
57 
58  m_word0 = 0;
59  m_word1 = 0;
60  m_word2 = 0;
61  m_word3 = 0;
62 
63  m_word0n = 0;
64  m_word1n = 0;
65  m_word2n = 0;
66  m_word3n = 0;
67 
68  m_status = 0;
69 
70  unsigned int size = data_block.size();
71 
72  if (size == 5) {
73 
74  m_word0 = data_block[0];
75  m_word1 = data_block[1];
76  m_word2 = data_block[2];
77  m_word3 = data_block[3];
78 
79  m_word0p = 0;
80  m_word1p = 0;
81  m_word2p = 0;
82  m_word3p = 0;
83 
84  m_word0n = 0;
85  m_word1n = 0;
86  m_word2n = 0;
87  m_word3n = 0;
88 
89  m_status = data_block[4];
90  }
91  else if (size == 13) {
92 
93  m_word0p = data_block[0];
94  m_word1p = data_block[1];
95  m_word2p = data_block[2];
96  m_word3p = data_block[3];
97 
98  m_word0 = data_block[4];
99  m_word1 = data_block[5];
100  m_word2 = data_block[6];
101  m_word3 = data_block[7];
102 
103  m_word0n = data_block[8];
104  m_word1n = data_block[9];
105  m_word2n = data_block[10];
106  m_word3n = data_block[11];
107 
108  m_status = data_block[12];
109  }
110  else std::cout << " ERROR! LUCID_RawData::LUCID_RawData, unexpected datablock size: " << size << std::endl;
111 }
112 
114 
115 bool LUCID_RawData::isTubeFired(unsigned int tubeNumber, unsigned int bxID) const {
116 
117  bool isTubeFired = 0;
118 
119  if (tubeNumber < 16) { // word0
120 
121  int bit = tubeNumber;
122 
123  if (bxID == 0) isTubeFired = (m_word0 >>bit)&1;
124  else if (bxID == 1) isTubeFired = (m_word0p>>bit)&1;
125  else if (bxID == 2) isTubeFired = (m_word0n>>bit)&1;
126  else { std::cout << " ERROR! LUCID_RawData::isTubeFired, unknown operation for bxID: " << bxID << std::endl; return 0; }
127  }
128  else if (tubeNumber < 20) { // word2
129 
130  int bit = tubeNumber - 16;
131 
132  if (bxID == 0) isTubeFired = (m_word2 >>bit)&1;
133  else if (bxID == 1) isTubeFired = (m_word2p>>bit)&1;
134  else if (bxID == 2) isTubeFired = (m_word2n>>bit)&1;
135  else { std::cout << " ERROR! LUCID_RawData::isTubeFired, unknown operation for bxID: " << bxID << std::endl; return 0; }
136  }
137  else if (tubeNumber < 36) { // word1
138 
139  int bit = tubeNumber - 20;
140 
141  if (bxID == 0) isTubeFired = (m_word1 >>bit)&1;
142  else if (bxID == 1) isTubeFired = (m_word1p>>bit)&1;
143  else if (bxID == 2) isTubeFired = (m_word1n>>bit)&1;
144  else { std::cout << " ERROR! LUCID_RawData::isTubeFired, unknown operation for bxID: " << bxID << std::endl; return 0; }
145  }
146  else if (tubeNumber < 40) { // word3
147 
148  int bit = tubeNumber - 36;
149 
150  if (bxID == 0) isTubeFired = (m_word3 >>bit)&1;
151  else if (bxID == 1) isTubeFired = (m_word3p>>bit)&1;
152  else if (bxID == 2) isTubeFired = (m_word3n>>bit)&1;
153  else { std::cout << " ERROR! LUCID_RawData::isTubeFired, unknown operation for bxID: " << bxID << std::endl; return 0; }
154  }
155  else { std::cout << " ERROR! LUCID_RawData::isTubeFired, unknown operation for tubeNumber: " << tubeNumber << std::endl; return 0; }
156 
157  return isTubeFired;
158 }
159 
160 int LUCID_RawData::getLumatBitPosition(unsigned int tubeNumber) {
161 
162  if (tubeNumber == 0) return 13; // word0
163  else if (tubeNumber == 1) return 0;
164  else if (tubeNumber == 2) return 1;
165  else if (tubeNumber == 3) return 5;
166  else if (tubeNumber == 4) return 6;
167  else if (tubeNumber == 5) return 8;
168  else if (tubeNumber == 6) return 9;
169  else if (tubeNumber == 7) return 14;
170  else if (tubeNumber == 8) return 15;
171  else if (tubeNumber == 9) return 2;
172  else if (tubeNumber == 10) return 3;
173  else if (tubeNumber == 11) return 4;
174  else if (tubeNumber == 12) return 7;
175  else if (tubeNumber == 13) return 10;
176  else if (tubeNumber == 14) return 11;
177  else if (tubeNumber == 15) return 12;
178  else if (tubeNumber == 16) return 0; // word2
179  else if (tubeNumber == 17) return 1;
180  else if (tubeNumber == 18) return 2;
181  else if (tubeNumber == 19) return 3;
182  else if (tubeNumber == 20) return 21; // word1
183  else if (tubeNumber == 21) return 16;
184  else if (tubeNumber == 22) return 17;
185  else if (tubeNumber == 23) return 13;
186  else if (tubeNumber == 24) return 14;
187  else if (tubeNumber == 25) return 8;
188  else if (tubeNumber == 26) return 9;
189  else if (tubeNumber == 27) return 22;
190  else if (tubeNumber == 28) return 23;
191  else if (tubeNumber == 29) return 18;
192  else if (tubeNumber == 30) return 19;
193  else if (tubeNumber == 31) return 20;
194  else if (tubeNumber == 32) return 15;
195  else if (tubeNumber == 33) return 10;
196  else if (tubeNumber == 34) return 11;
197  else if (tubeNumber == 35) return 12;
198  else if (tubeNumber == 36) return 0; // word3
199  else if (tubeNumber == 37) return 1;
200  else if (tubeNumber == 38) return 2;
201  else if (tubeNumber == 39) return 3;
202  else { std::cout << " ERROR! LUCID_RawData::getLumatBitPosition, unknown operation for tubeNumber: " << tubeNumber << std::endl; return -1; }
203 }
204 
206 
207  uint32_t data_word0 = 0;
208  uint32_t data_word1 = 0;
209  uint32_t data_word2 = 0;
210  uint32_t data_word3 = 0;
211  uint32_t data_word0p = 0;
212  uint32_t data_word1p = 0;
213  uint32_t data_word2p = 0;
214  uint32_t data_word3p = 0;
215  uint32_t data_word0n = 0;
216  uint32_t data_word1n = 0;
217  uint32_t data_word2n = 0;
218  uint32_t data_word3n = 0;
219 
220  int hitcounter0 = 0;
221  int hitcounter1 = 0;
222  int hitcounter2 = 0;
223  int hitcounter3 = 0;
224  int hitcounter0p = 0;
225  int hitcounter1p = 0;
226  int hitcounter2p = 0;
227  int hitcounter3p = 0;
228  int hitcounter0n = 0;
229  int hitcounter1n = 0;
230  int hitcounter2n = 0;
231  int hitcounter3n = 0;
232 
233  for (int tubeID=0; tubeID<40; tubeID++) {
234 
235  bool isHit = 0;
236 
237  int bit = getLumatBitPosition(tubeID);
238 
239  if (tubeID < 16) {
240 
241  isHit = (m_word0 >>bit)&1; if (isHit) { data_word0 |= (1 << tubeID); hitcounter0++; }
242  isHit = (m_word0p>>bit)&1; if (isHit) { data_word0p |= (1 << tubeID); hitcounter0p++; }
243  isHit = (m_word0n>>bit)&1; if (isHit) { data_word0n |= (1 << tubeID); hitcounter0n++; }
244  }
245  else if (tubeID < 20) {
246 
247  isHit = (m_word2 >>bit)&1; if (isHit) { data_word2 |= (1 << (tubeID-16)); hitcounter2++; }
248  isHit = (m_word2p>>bit)&1; if (isHit) { data_word2p |= (1 << (tubeID-16)); hitcounter2p++; }
249  isHit = (m_word2n>>bit)&1; if (isHit) { data_word2n |= (1 << (tubeID-16)); hitcounter2n++; }
250  }
251  else if (tubeID < 36) {
252 
253  isHit = (m_word1 >>bit)&1; if (isHit) { data_word1 |= (1 << (tubeID-20)); hitcounter1++; }
254  isHit = (m_word1p>>bit)&1; if (isHit) { data_word1p |= (1 << (tubeID-20)); hitcounter1p++; }
255  isHit = (m_word1n>>bit)&1; if (isHit) { data_word1n |= (1 << (tubeID-20)); hitcounter1n++; }
256  }
257  else {
258 
259  isHit = (m_word3 >>bit)&1; if (isHit) { data_word3 |= (1 << (tubeID-36)); hitcounter3++; }
260  isHit = (m_word3p>>bit)&1; if (isHit) { data_word3p |= (1 << (tubeID-36)); hitcounter3p++; }
261  isHit = (m_word3n>>bit)&1; if (isHit) { data_word3n |= (1 << (tubeID-36)); hitcounter3n++; }
262  }
263  }
264 
265  setWord0(data_word0 |= (hitcounter0 << 24));
266  setWord1(data_word1 |= (hitcounter1 << 24));
267  setWord2(data_word2 |= (hitcounter2 << 24));
268  setWord3(data_word3 |= (hitcounter3 << 24));
269 
270  setWord0p(data_word0p |= (hitcounter0p << 24));
271  setWord1p(data_word1p |= (hitcounter1p << 24));
272  setWord2p(data_word2p |= (hitcounter2p << 24));
273  setWord3p(data_word3p |= (hitcounter3p << 24));
274 
275  setWord0n(data_word0n |= (hitcounter0n << 24));
276  setWord1n(data_word1n |= (hitcounter1n << 24));
277  setWord2n(data_word2n |= (hitcounter2n << 24));
278  setWord3n(data_word3n |= (hitcounter3n << 24));
279 }
280 
282 
283  uint32_t data_word0 = 0;
284  uint32_t data_word1 = 0;
285  uint32_t data_word2 = 0;
286  uint32_t data_word3 = 0;
287 
288  int hitcounter0 = 0;
289  int hitcounter1 = 0;
290  int hitcounter2 = 0;
291  int hitcounter3 = 0;
292 
293  std::cout << std::hex
294  << " m_word0: " << m_word0 << std::endl
295  << " m_word1: " << m_word1 << std::endl
296  << " m_word2: " << m_word2 << std::endl
297  << " m_word3: " << m_word3 << std::endl
298  << std::dec;
299 
300  for (int tubeID=0; tubeID<40; tubeID++) {
301 
302  if (!isTubeFired(tubeID, 0)) continue;
303 
304  int bit = getLumatBitPosition(tubeID);
305 
306  if (tubeID < 16) { data_word0 |= (1 << bit); hitcounter0++; }
307  else if (tubeID < 20) { data_word2 |= (1 << bit); hitcounter2++; }
308  else if (tubeID < 36) { data_word1 |= (1 << bit); hitcounter1++; }
309  else { data_word3 |= (1 << bit); hitcounter3++; }
310  }
311 
312  std::cout << " hitcounter0: " << std::setw(10) << hitcounter0 << std::endl
313  << " hitcounter1: " << std::setw(10) << hitcounter1 << std::endl
314  << " hitcounter2: " << std::setw(10) << hitcounter2 << std::endl
315  << " hitcounter3: " << std::setw(10) << hitcounter3 << std::endl;
316 
317  data_word0 |= (hitcounter0 << 24);
318  data_word1 |= (hitcounter1 << 24);
319  data_word2 |= (hitcounter2 << 24);
320  data_word3 |= (hitcounter3 << 24);
321 
322  std::cout << std::hex
323  << " data_word0: " << data_word0 << std::endl
324  << " data_word1: " << data_word1 << std::endl
325  << " data_word2: " << data_word2 << std::endl
326  << " data_word3: " << data_word3 << std::endl
327  << std::dec;
328 
329  setWord0(data_word0);
330  setWord1(data_word1);
331  setWord2(data_word2);
332  setWord3(data_word3);
333 }
LUCID_RawData::m_word3p
unsigned int m_word3p
Definition: LUCID_RawData.h:177
LUCID_RawData::~LUCID_RawData
virtual ~LUCID_RawData()
Definition: LUCID_RawData.cxx:113
LUCID_RawData::setWord0
void setWord0(uint32_t word)
Definition: LUCID_RawData.h:80
xAOD::word1
word1
Definition: eFexEMRoI_v1.cxx:82
LUCID_RawData.h
LUCID_RawData::setWord3n
void setWord3n(uint32_t word)
Definition: LUCID_RawData.h:93
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
LUCID_RawData::m_word2
unsigned int m_word2
Definition: LUCID_RawData.h:171
LUCID_RawData::m_word2n
unsigned int m_word2n
Definition: LUCID_RawData.h:181
LUCID_RawData::decodeLumatMapping
void decodeLumatMapping(void)
Definition: LUCID_RawData.cxx:205
LUCID_RawData::setWord2n
void setWord2n(uint32_t word)
Definition: LUCID_RawData.h:92
LUCID_RawData::isTubeFired
bool isTubeFired(unsigned int tubeNumber, unsigned int bxID) const
Definition: LUCID_RawData.cxx:115
LUCID_RawData::setWord3
void setWord3(uint32_t word)
Definition: LUCID_RawData.h:83
LUCID_RawData::m_word3
unsigned int m_word3
Definition: LUCID_RawData.h:172
LUCID_RawData::m_word0n
unsigned int m_word0n
Definition: LUCID_RawData.h:179
LUCID_RawData::m_word1
unsigned int m_word1
Definition: LUCID_RawData.h:170
LUCID_RawData::setWord0n
void setWord0n(uint32_t word)
Definition: LUCID_RawData.h:90
LUCID_RawData::setWord2p
void setWord2p(uint32_t word)
Definition: LUCID_RawData.h:87
LUCID_RawData::m_word3n
unsigned int m_word3n
Definition: LUCID_RawData.h:182
LUCID_RawData::m_word1p
unsigned int m_word1p
Definition: LUCID_RawData.h:175
LUCID_RawData::m_word0
unsigned int m_word0
Definition: LUCID_RawData.h:169
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
LUCID_RawData::encodeLumatMapping
void encodeLumatMapping(void)
Definition: LUCID_RawData.cxx:281
LUCID_RawData::LUCID_RawData
LUCID_RawData()
Definition: LUCID_RawData.cxx:7
LUCID_RawData::m_word2p
unsigned int m_word2p
Definition: LUCID_RawData.h:176
LUCID_RawData::setWord1n
void setWord1n(uint32_t word)
Definition: LUCID_RawData.h:91
LUCID_RawData::m_word0p
unsigned int m_word0p
Definition: LUCID_RawData.h:174
LUCID_RawData::m_status
unsigned int m_status
Definition: LUCID_RawData.h:184
LUCID_RawData::setWord0p
void setWord0p(uint32_t word)
Definition: LUCID_RawData.h:85
LUCID_RawData::setWord1
void setWord1(uint32_t word)
Definition: LUCID_RawData.h:81
LUCID_RawData::getLumatBitPosition
static int getLumatBitPosition(unsigned int tubeNumber)
Definition: LUCID_RawData.cxx:160
merge.status
status
Definition: merge.py:17
LUCID_RawData::setWord1p
void setWord1p(uint32_t word)
Definition: LUCID_RawData.h:86
LUCID_RawData::m_word1n
unsigned int m_word1n
Definition: LUCID_RawData.h:180
LUCID_RawData::setWord3p
void setWord3p(uint32_t word)
Definition: LUCID_RawData.h:88
LUCID_RawData::setWord2
void setWord2(uint32_t word)
Definition: LUCID_RawData.h:82