]>
Commit | Line | Data |
---|---|---|
fa7427d0 | 1 | #/************************************************************************** |
d4232bb6 | 2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // This class provides access to TRD digits in raw data. // | |
21 | // // | |
22 | // It loops over all TRD digits in the raw data given by the AliRawReader. // | |
23 | // The Next method goes to the next digit. If there are no digits left // | |
24 | // it returns kFALSE. // | |
25 | // Several getters provide information about the current digit. // | |
26 | // // | |
27 | // Author: M. Ploskon (ploskon@ikf.uni-frankfurt.de) // | |
28 | // // | |
29 | /////////////////////////////////////////////////////////////////////////////// | |
30 | ||
31 | #include "TString.h" | |
32 | #include "TFile.h" | |
33 | #include "TTreeStream.h" | |
34 | ||
35 | #include "AliTRDrawStreamTB.h" | |
36 | #include "AliTRDgeometry.h" | |
37 | #include "AliTRDfeeParam.h" | |
38 | #include "AliTRDdigitsManager.h" | |
625f5260 | 39 | #include "AliTRDdataArrayS.h" |
6bd744d3 | 40 | #include "AliTRDdataArrayI.h" |
fb44eb8e | 41 | #include "AliTRDdataArrayDigits.h" |
d4232bb6 | 42 | #include "AliTRDSignalIndex.h" |
0e09df31 | 43 | #include "AliTRDrecoParam.h" |
fa7427d0 | 44 | #include "AliTRDcalibDB.h" |
45 | #include "Cal/AliTRDCalPadStatus.h" | |
d4232bb6 | 46 | |
e16f790e | 47 | //[mj tracklet writing] #include "AliTRDrawTracklet.h" |
48 | ||
d4232bb6 | 49 | #include "AliLog.h" |
50 | #include "AliRawReader.h" | |
51 | ||
52 | #define END_OF_TRACKLET_MARKEROLD 0xaaaaaaaa | |
53 | #define END_OF_TRACKLET_MARKERNEW 0x10001000 | |
54 | #define ENDOFRAWDATAMARKER 0x00000000 | |
55 | #define WORD_SIZE sizeof(UInt_t) // size of a word in bytes | |
56 | #define EXTRA_LEAD_WORDS 24 | |
57 | #define CDH_WORDS 8 | |
58 | ||
59 | #define IS_BIT_SET(w,b) ( ((w) >> (b)) & 0x1 ) // 1 if bit b is set in word w | |
60 | #define GET_VALUE_AT(w,m,s) (( (w) >> (s)) & (m) ) // get value of word w rshifted by s and mask with m | |
61 | ||
62 | // SM index word masks: | |
63 | #define SM_HEADER_SIZE(w) GET_VALUE_AT(w,0xffff,16) | |
64 | #define TRACKLETS_ENABLED(w) IS_BIT_SET(w,5) | |
65 | #define STACK_MASK(w) ((w) & 0x1f) | |
66 | ||
67 | // Stack word masks | |
68 | #define STACK_HEADER_SIZE(w) GET_VALUE_AT(w,0xffff,16) | |
69 | #define STACK_LINK_WORD(w) ((w) & 0xfff) | |
e16f790e | 70 | #define LINK0_DATA_TYPE_FLAG(w) (GET_VALUE_AT(w,0x3,4) == (0x0) ? 0 : 1) // 0 if physics data |
71 | #define LINK1_DATA_TYPE_FLAG(w) (GET_VALUE_AT(w,0x3,20) == (0x0) ? 0 : 1) // 0 if physics data | |
72 | #define LINK0_MONITOR_FLAG(w) (GET_VALUE_AT(w,0xf,0) == (0x0) ? 0 : 1) // 0 if OK | |
73 | #define LINK1_MONITOR_FLAG(w) (GET_VALUE_AT(w,0xf,16) == (0x0) ? 0 : 1) // 0 if OK | |
d4232bb6 | 74 | |
75 | // HC word masks | |
76 | //#define HC_HEADER_MASK_ERR(w) ( ((w) & (0x80000003)) == (0x80000001) ? 0 : 1) // 0 if OK!!! | |
77 | #define HC_HEADER_MASK_ERR(w) ( ((w) & (0x3)) == (0x1) ? 0 : 1) // 0 if OK!!! | |
78 | ||
79 | // HC word 0 | |
80 | #define HC_SPECIAL_RAW_VERSION(w) IS_BIT_SET(w,31) | |
81 | #define HC_MAJOR_RAW_VERSION(w) GET_VALUE_AT(w,0x7f,24) | |
dc25a859 | 82 | #define HC_MAJOR_RAW_VERSION_OPT(w) GET_VALUE_AT(w,0x7,24) |
d4232bb6 | 83 | #define HC_MINOR_RAW_VERSION(w) GET_VALUE_AT(w,0x7f,17) |
84 | #define HC_EXTRA_WORDS(w) GET_VALUE_AT(w,0x7,14) | |
85 | #define HC_DCS_BOARD(w) GET_VALUE_AT(w,0xfff<<20,20) | |
86 | #define HC_SM_NUMBER(w) GET_VALUE_AT(w,0x1f,9) | |
87 | #define HC_LAYER_NUMBER(w) GET_VALUE_AT(w,0x7,6) | |
88 | #define HC_STACK_NUMBER(w) GET_VALUE_AT(w,0x7,3) | |
89 | #define HC_SIDE_NUMBER(w) IS_BIT_SET(w,2) | |
90 | ||
91 | // HC word 1 | |
92 | #define HC_NTIMEBINS(w) GET_VALUE_AT(w,0x3f,26) | |
93 | #define HC_BUNCH_CROSS_COUNTER(w) GET_VALUE_AT(w,0xffff,10) | |
94 | #define HC_PRETRIGGER_COUNTER(w) GET_VALUE_AT(w,0xf,6) | |
95 | #define HC_PRETRIGGER_PHASE(w) GET_VALUE_AT(w,0xf,6) | |
96 | ||
d4232bb6 | 97 | // MCM word and ADC mask |
98 | #define MCM_HEADER_MASK_ERR(w) ( ((w) & (0xf)) == (0xc) ? 0 : 1) // 0 if OK!!! | |
99 | #define MCM_ADCMASK_MASK_ERR(w) ( ((w) & (0xf)) == (0xc) ? 0 : 1) // 0 if OK!!! | |
100 | #define MCM_MCM_NUMBER(w) GET_VALUE_AT(w,0x0f,24) | |
101 | #define MCM_ROB_NUMBER(w) GET_VALUE_AT(w,0x7,28) | |
102 | #define MCM_EVENT_COUNTER(w) GET_VALUE_AT(w,0x00fffff,4) | |
103 | #define MCM_ADCMASK_VAL(w) GET_VALUE_AT(w,0x1fffff,4) | |
bb1009bf | 104 | #define MCM_ADCMASK_NADC(w) GET_VALUE_AT(w,0x1f,25) |
d4232bb6 | 105 | |
bb1009bf | 106 | #define MCM_DUMMY_ADCMASK_VAL 0x015fffffc // updated |
2e2bc4a1 | 107 | #define ADCDATA_VAL1 0x2 // updated |
108 | #define ADCDATA_VAL2 0x3 // updated | |
109 | ||
d4232bb6 | 110 | //-------------------------------------------------------- |
111 | #define ADC_WORD_MASK(w) ((w) & 0x3) | |
112 | //-------------------------------------------------------- | |
dc25a859 | 113 | |
114 | ||
d4232bb6 | 115 | ClassImp(AliTRDrawStreamTB) |
116 | ||
117 | Bool_t AliTRDrawStreamTB::fgExtraSkip = kFALSE; | |
118 | Bool_t AliTRDrawStreamTB::fgSkipCDH = kFALSE; | |
119 | Bool_t AliTRDrawStreamTB::fgWarnError = kTRUE; | |
e16f790e | 120 | Bool_t AliTRDrawStreamTB::fgCleanDataOnly = kFALSE; |
d4232bb6 | 121 | Bool_t AliTRDrawStreamTB::fgDebugFlag = kTRUE; |
6bd744d3 | 122 | Bool_t AliTRDrawStreamTB::fgStackNumberChecker = kTRUE; |
7e8f4d17 | 123 | Bool_t AliTRDrawStreamTB::fgStackLinkNumberChecker = kTRUE; |
bb1009bf | 124 | Bool_t AliTRDrawStreamTB::fgSkipData = kTRUE; |
d4232bb6 | 125 | UInt_t AliTRDrawStreamTB::fgStreamEventCounter = 0; |
7e8f4d17 | 126 | UInt_t AliTRDrawStreamTB::fgFirstEquipmentID = 0; |
d4232bb6 | 127 | UInt_t AliTRDrawStreamTB::fgDumpHead = 0; |
1ced3838 | 128 | Int_t AliTRDrawStreamTB::fgCommonAdditive = 0; |
d4232bb6 | 129 | Int_t AliTRDrawStreamTB::fgEmptySignals[] = |
130 | { | |
131 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 | |
132 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 | |
133 | }; | |
9c7c9ec1 | 134 | Short_t AliTRDrawStreamTB::fgMCMordering[] = |
135 | { | |
136 | 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3 | |
137 | }; | |
138 | Short_t AliTRDrawStreamTB::fgROBordering[] = | |
139 | { | |
140 | 0, 1, 2, 3 | |
141 | }; | |
142 | Int_t AliTRDrawStreamTB::fgLastHC = -1; | |
143 | Int_t AliTRDrawStreamTB::fgLastROB = -1; | |
144 | Int_t AliTRDrawStreamTB::fgLastIndex = -1; | |
3be28fbf | 145 | Bool_t AliTRDrawStreamTB::fDumpingEnable = kFALSE; |
146 | Int_t AliTRDrawStreamTB::fDumpingSM = -1; | |
147 | Int_t AliTRDrawStreamTB::fDumpingStack = -1; | |
148 | Int_t AliTRDrawStreamTB::fDumpingLayer = -1; | |
149 | Int_t AliTRDrawStreamTB::fDumpingROB = -1; | |
150 | Int_t AliTRDrawStreamTB::fDumpingMCM = -1; | |
151 | ||
d4232bb6 | 152 | |
153 | AliTRDrawStreamTB::AliTRDrawStreamTB() | |
dfbb4bb9 | 154 | : AliTRDrawStreamBase() |
d4232bb6 | 155 | , fSM() |
156 | , fStack(0) | |
157 | , fHC(0) | |
158 | , fMCM(0) | |
159 | , fADC(0) | |
160 | , fpPos(0) | |
161 | , fpBegin(0) | |
162 | , fpEnd(0) | |
163 | , fWordLength(0) | |
7e8f4d17 | 164 | , fEquipmentID(0) |
d4232bb6 | 165 | , fStackNumber(-1) |
166 | , fStackLinkNumber(-1) | |
167 | , fhcMCMcounter(0) | |
168 | , fmcmADCcounter(0) | |
169 | , fLinkTrackletCounter(-1) | |
170 | , fEndOfTrackletCount(-1) | |
171 | , fMaskADCword(0) | |
172 | , fTbinADC(0) | |
173 | , fDecodedADCs(-1) | |
174 | , fEventCounter(0) | |
175 | , fLastEventCounter(0) | |
d4232bb6 | 176 | , fSharedPadsOn(kFALSE) |
177 | , fMaxADCgeom(0) | |
e16f790e | 178 | , fBufferRead(0) |
d4232bb6 | 179 | , fGeometry(0) |
180 | , fRawReader(0) | |
181 | , fTRDfeeParam(0) | |
d4232bb6 | 182 | { |
183 | // | |
184 | // default constructor | |
185 | // | |
186 | ||
187 | if (Init() == kFALSE) | |
188 | { | |
189 | AliWarning("Unable to Init."); | |
190 | } | |
191 | } | |
192 | ||
193 | //-------------------------------------------------------- | |
194 | AliTRDrawStreamTB::AliTRDrawStreamTB(AliRawReader *rawReader) | |
dfbb4bb9 | 195 | : AliTRDrawStreamBase(rawReader) |
d4232bb6 | 196 | , fSM() |
197 | , fStack(0) | |
198 | , fHC(0) | |
199 | , fMCM(0) | |
200 | , fADC(0) | |
201 | , fpPos(0) | |
202 | , fpBegin(0) | |
203 | , fpEnd(0) | |
204 | , fWordLength(0) | |
7e8f4d17 | 205 | , fEquipmentID(0) |
d4232bb6 | 206 | , fStackNumber(-1) |
207 | , fStackLinkNumber(-1) | |
208 | , fhcMCMcounter(0) | |
209 | , fmcmADCcounter(0) | |
210 | , fLinkTrackletCounter(-1) | |
211 | , fEndOfTrackletCount(-1) | |
212 | , fMaskADCword(0) | |
213 | , fTbinADC(0) | |
214 | , fDecodedADCs(-1) | |
215 | , fEventCounter(0) | |
216 | , fLastEventCounter(0) | |
d4232bb6 | 217 | , fSharedPadsOn(kFALSE) |
218 | , fMaxADCgeom(0) | |
e16f790e | 219 | , fBufferRead(0) |
d4232bb6 | 220 | , fGeometry(0) |
221 | , fRawReader(rawReader) | |
222 | , fTRDfeeParam(0) | |
d4232bb6 | 223 | { |
224 | // | |
225 | // default constructor | |
226 | // | |
227 | if (fRawReader) | |
228 | { | |
229 | if (Init() == kFALSE) | |
230 | { | |
231 | AliWarning("Unable to Init. Try setting up the reader with SetReader or buffer with Init(void *, UInt_t )"); | |
232 | } | |
233 | } | |
234 | else | |
235 | { | |
236 | AliWarning("Unable to setup reader. Use SetReader(AliRawReader*)."); | |
237 | } | |
238 | } | |
239 | ||
240 | //------------------------------------------------------------ | |
241 | ||
242 | AliTRDrawStreamTB::AliTRDrawStreamTB(const AliTRDrawStreamTB& /*st*/) | |
dfbb4bb9 | 243 | : AliTRDrawStreamBase() |
d4232bb6 | 244 | , fSM() |
245 | , fStack(0) | |
246 | , fHC(0) | |
247 | , fMCM(0) | |
248 | , fADC(0) | |
249 | , fpPos(0) | |
250 | , fpBegin(0) | |
251 | , fpEnd(0) | |
252 | , fWordLength(0) | |
7e8f4d17 | 253 | , fEquipmentID(0) |
d4232bb6 | 254 | , fStackNumber(-1) |
255 | , fStackLinkNumber(-1) | |
256 | , fhcMCMcounter(0) | |
257 | , fmcmADCcounter(0) | |
258 | , fLinkTrackletCounter(-1) | |
259 | , fEndOfTrackletCount(-1) | |
260 | , fMaskADCword(0) | |
261 | , fTbinADC(0) | |
262 | , fDecodedADCs(-1) | |
263 | , fEventCounter(0) | |
264 | , fLastEventCounter(0) | |
d4232bb6 | 265 | , fSharedPadsOn(kFALSE) |
266 | , fMaxADCgeom(0) | |
e16f790e | 267 | , fBufferRead(0) |
d4232bb6 | 268 | , fGeometry(0) |
269 | , fRawReader(0) | |
270 | , fTRDfeeParam(0) | |
d4232bb6 | 271 | { |
272 | // | |
273 | // Copy constructor | |
274 | // | |
275 | AliError("Not implemeneted."); | |
276 | } | |
277 | ||
278 | //------------------------------------------------------------ | |
dfbb4bb9 | 279 | Bool_t AliTRDrawStreamTB::SetRawVersion(Int_t fraw) |
d4232bb6 | 280 | { |
281 | // | |
282 | // function provided for backward compatibility | |
283 | // | |
284 | AliWarning("Raw data version is read from raw data stream! No point of setting it in here."); | |
285 | fraw = 0; // avoid warnings | |
dfbb4bb9 | 286 | return kFALSE; |
d4232bb6 | 287 | } |
288 | ||
289 | //------------------------------------------------------------ | |
290 | AliTRDrawStreamTB::~AliTRDrawStreamTB() | |
291 | { | |
292 | // | |
293 | // destructor | |
294 | // | |
295 | delete fGeometry; | |
d4232bb6 | 296 | } |
297 | ||
298 | //------------------------------------------------------------ | |
299 | ||
300 | AliTRDrawStreamTB & | |
301 | AliTRDrawStreamTB::operator=(const AliTRDrawStreamTB &) | |
302 | { | |
303 | // | |
304 | // we are not using this functionality | |
305 | // | |
306 | AliFatal("May not use."); | |
307 | return *this; | |
308 | } | |
309 | ||
d4232bb6 | 310 | //___________________________________________________________ |
311 | void | |
312 | AliTRDrawStreamTB::SwapOnEndian() | |
313 | { | |
314 | // | |
315 | // Check the endian and swap if needed | |
316 | // | |
d4232bb6 | 317 | int itemp = 1; |
318 | char* ptemp = (char*) &itemp; | |
319 | if (ptemp[0] != 1) | |
320 | { | |
d4232bb6 | 321 | if (fgDebugFlag) AliDebug(8, "Swapping."); |
322 | ||
323 | fpPos = fpBegin; | |
324 | UInt_t iutmp = 0; | |
325 | while (fpPos < fpEnd) | |
326 | { | |
327 | fpPos += 1; | |
328 | iutmp = (((*fpPos & 0x000000ffU) << 24) | ((*fpPos & 0x0000ff00U) << 8) | | |
329 | ((*fpPos & 0x00ff0000U) >> 8) | ((*fpPos & 0xff000000U) >> 24)); | |
330 | // here we override the value in the buffer! | |
331 | *fpPos = iutmp; | |
332 | } | |
333 | fpPos = fpBegin; | |
334 | } | |
335 | } | |
336 | ||
d4232bb6 | 337 | //------------------------------------------------------------ |
338 | Bool_t | |
339 | AliTRDrawStreamTB::DumpWords(UInt_t *px, UInt_t iw, UInt_t marker) | |
340 | { | |
e16f790e | 341 | |
d4232bb6 | 342 | TString tsreturn = Form("\n[ Dump Sequence at 0x%08x ] : ", px); |
343 | for (UInt_t i = 0; i < iw; i++) | |
344 | { | |
345 | if (px + iw >= fpEnd) | |
346 | return kFALSE; | |
347 | ||
348 | if (i % 8 == 0) | |
349 | tsreturn += "\n "; | |
350 | if (marker != 0 && marker == px[i]) | |
351 | tsreturn += Form(" *>0x%08x<* ", px[i]); | |
352 | else | |
353 | tsreturn += Form("0x%08x ", px[i]); | |
354 | } | |
355 | tsreturn += "\n"; | |
356 | ||
357 | AliInfo(tsreturn.Data()); | |
358 | ||
359 | return kTRUE; | |
360 | } | |
361 | ||
362 | //------------------------------------------------------------ | |
363 | Bool_t | |
364 | AliTRDrawStreamTB::SkipWords(UInt_t iw) | |
365 | { | |
366 | // | |
e16f790e | 367 | // Skip words corresponding to iw |
d4232bb6 | 368 | // |
d4232bb6 | 369 | if ( fpPos + iw < fpEnd ) |
370 | { | |
371 | fpPos += iw; | |
372 | return kTRUE; | |
373 | } | |
374 | else | |
375 | { | |
376 | if (fgWarnError) AliWarning(Form("Skip %d words failed. %d available", iw, fpEnd - fpPos - 1)); | |
d4232bb6 | 377 | return kFALSE; |
378 | } | |
379 | ||
380 | return kTRUE; | |
381 | } | |
382 | ||
383 | //------------------------------------------------------------ | |
384 | Bool_t | |
385 | AliTRDrawStreamTB::SetReader(AliRawReader *reader) | |
386 | { | |
d4232bb6 | 387 | |
388 | if (reader != 0) | |
389 | { | |
390 | fRawReader = reader; | |
391 | if (fRawReader) | |
392 | { | |
393 | return Init(); | |
394 | } | |
395 | else | |
396 | { | |
397 | AliWarning("Unable to setup reader."); | |
398 | return kFALSE; | |
399 | } | |
400 | } | |
401 | else | |
402 | { | |
403 | AliWarning("AliRawReader argument is 0."); | |
404 | fRawReader = 0; | |
405 | } | |
406 | ||
407 | return kFALSE; | |
408 | } | |
409 | ||
410 | //------------------------------------------------------------ | |
411 | Int_t | |
412 | AliTRDrawStreamTB::NextBuffer() | |
413 | { | |
414 | // | |
415 | // return -1 if no more buffers available | |
e16f790e | 416 | // return 0 DecodeSM failed (clean data required for example) but still maybe more data to come |
417 | // return 1 DecodeSM OK | |
d4232bb6 | 418 | // |
419 | ||
420 | if (fRawReader != 0) | |
421 | { | |
422 | UChar_t *buffer = 0; | |
423 | UInt_t length = 0; | |
424 | Bool_t kBufferSet = fRawReader->ReadNextData(buffer); | |
425 | if (kBufferSet == kTRUE) | |
426 | { | |
427 | if (fgDebugFlag) AliDebug(9, "Buffer is set."); | |
428 | length = fRawReader->GetDataSize(); | |
429 | if (fgExtraSkip == kTRUE) | |
430 | { | |
431 | buffer += EXTRA_LEAD_WORDS * WORD_SIZE; | |
432 | length -= EXTRA_LEAD_WORDS * WORD_SIZE; | |
433 | } | |
434 | ||
435 | if (fgSkipCDH == kTRUE) | |
436 | { | |
437 | buffer += CDH_WORDS * WORD_SIZE; | |
438 | length -= CDH_WORDS * WORD_SIZE; | |
439 | } | |
440 | ||
441 | if (length > 0) | |
442 | { | |
443 | if (fgDebugFlag) AliDebug(9, Form("Buffer length : %d", length)); | |
d4232bb6 | 444 | if (DecodeSM((void*)buffer, length) == kTRUE) |
445 | return 1; | |
446 | else | |
447 | return 0; | |
448 | } | |
449 | } | |
450 | else | |
451 | { | |
452 | return -1; | |
453 | } | |
454 | } | |
455 | ||
456 | return -1; | |
457 | } | |
458 | ||
459 | //------------------------------------------------------------ | |
460 | void | |
461 | AliTRDrawStreamTB::ResetCounters() | |
462 | { | |
463 | // | |
464 | // reset some global counters | |
465 | // | |
e16f790e | 466 | fBufferRead = kFALSE; // important to read buffer |
d4232bb6 | 467 | |
e16f790e | 468 | fEquipmentID = 0; |
d4232bb6 | 469 | fStackNumber = 0; |
470 | fStackLinkNumber = 0; | |
d4232bb6 | 471 | fDecodedADCs = 0; |
472 | ||
473 | fSM.fActiveStacks = 0; | |
474 | fSM.fNexpectedHalfChambers = 0; | |
475 | ||
476 | fLinkTrackletCounter = 0; | |
d4232bb6 | 477 | fLastEventCounter = 0; |
478 | fEventCounter = 0; | |
479 | } | |
480 | ||
481 | //------------------------------------------------------------ | |
482 | void | |
483 | AliTRDrawStreamTB::ResetIterators() | |
484 | { | |
485 | // | |
e16f790e | 486 | // reset data which should be reset every sm |
d4232bb6 | 487 | // |
e16f790e | 488 | fStackNumber = 0; // reset for Next() function |
489 | fStackLinkNumber = 0; // reset for Next() function | |
d4232bb6 | 490 | fhcMCMcounter = 0; |
491 | fmcmADCcounter = 0; | |
492 | } | |
493 | ||
e16f790e | 494 | //------------------------------------------------------------ |
495 | void | |
496 | AliTRDrawStreamTB::ResetPerHC() | |
497 | { | |
498 | // | |
499 | // reset every HC | |
500 | // | |
501 | fEventCounter = 0; | |
502 | } | |
503 | ||
d4232bb6 | 504 | //------------------------------------------------------------ |
505 | ||
506 | Bool_t | |
507 | AliTRDrawStreamTB::Next() | |
508 | { | |
509 | // | |
510 | // returns with true on next adc read | |
511 | // returns false on errors and end of buffer | |
512 | // | |
e16f790e | 513 | if (fBufferRead) |
514 | { | |
515 | ||
516 | while (fStackNumber < 5 && fSM.fActiveStacks > 0) | |
517 | { | |
518 | if(fSM.fStackActive[fStackNumber] == kTRUE) | |
519 | { | |
520 | fStack = &fSM.fStacks[fStackNumber]; | |
521 | while (fStackLinkNumber < 12) | |
522 | { | |
9c7c9ec1 | 523 | if (fStack->fLinksActive[fStackLinkNumber] == kTRUE && fStack->fLinksMonitor[fStackLinkNumber] == 0) |
e16f790e | 524 | { |
525 | fHC = &fStack->fHalfChambers[fStackLinkNumber]; | |
526 | if (!fHC) | |
527 | { | |
528 | AliError(Form("HC missing at stack %d link %d", fStackNumber, fStackLinkNumber)); | |
529 | return kFALSE; | |
530 | } | |
9c7c9ec1 | 531 | if (fHC->fCorrupted == 0 && (fHC->fH0Corrupted == 0 && fHC->fH1Corrupted == 0)) // if HC data corrupted(in any case), we don't read data at all from this HC |
e16f790e | 532 | { |
533 | while (fhcMCMcounter < fHC->fMCMmax) | |
534 | { | |
535 | fMCM = &fHC->fMCMs[fhcMCMcounter]; | |
536 | if (!fMCM) | |
537 | { | |
538 | AliError(Form("HC missing at stack %d link %d atMCMslot %d", | |
539 | fStackNumber, fStackLinkNumber, fhcMCMcounter)); | |
540 | return kFALSE; | |
541 | } | |
542 | while(fmcmADCcounter < fMCM->fADCmax) | |
543 | { | |
544 | fADC = &fMCM->fADCs[fmcmADCcounter]; | |
545 | if (!fADC) | |
546 | { | |
547 | AliError(Form("ADC missing at stack %d link %d MCMslot %d ADCslot %d", | |
548 | fStackNumber, fStackLinkNumber, fhcMCMcounter, fmcmADCcounter)); | |
549 | return kFALSE; | |
550 | } | |
551 | fmcmADCcounter++; | |
552 | if (fSharedPadsOn) | |
553 | { | |
d4232bb6 | 554 | return kTRUE; |
e16f790e | 555 | } |
556 | else | |
557 | { | |
558 | if (fADC->fIsShared == kFALSE) | |
559 | return kTRUE; | |
560 | } | |
561 | } //while adc in MCM | |
562 | fhcMCMcounter++; | |
563 | // next MCM should go through all active ADCs | |
564 | fmcmADCcounter = 0; | |
565 | } // while mcm | |
566 | } // if HC OK | |
567 | }// if link active | |
568 | fStackLinkNumber++; | |
569 | // next stack link (HC) should go through all active MCMs | |
570 | fhcMCMcounter = 0; | |
571 | }// while links | |
572 | }// if stack active | |
573 | fStackNumber++; | |
574 | // next stack should go through all links - start from 0 | |
575 | fStackLinkNumber = 0; | |
576 | } | |
577 | } // fBufferRead | |
578 | ||
579 | // in case rawreader manages the mem buffers, go for the next buffer | |
580 | if (fRawReader) | |
581 | { | |
582 | Int_t nextBuff = NextBuffer(); | |
583 | while (nextBuff != -1) | |
584 | { | |
585 | if (nextBuff > 0) | |
586 | { | |
587 | fBufferRead = kTRUE; | |
588 | return Next(); | |
589 | } | |
590 | nextBuff = NextBuffer(); | |
591 | } | |
592 | } | |
d4232bb6 | 593 | |
594 | return kFALSE; | |
595 | } | |
596 | ||
597 | //------------------------------------------------------------ | |
d4232bb6 | 598 | Int_t |
9c7c9ec1 | 599 | //AliTRDrawStreamTB::NextChamber(AliTRDdigitsManager *digitsManager) |
600 | AliTRDrawStreamTB::NextChamber(AliTRDdigitsManager *digitsManager, UInt_t **trackletContainer) //[mj] | |
d4232bb6 | 601 | { |
602 | // | |
603 | // Fills single chamber digit array | |
604 | // Return value is the detector number | |
605 | // | |
606 | ||
fa7427d0 | 607 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); |
fb44eb8e | 608 | AliTRDdataArrayDigits *digits = 0; |
d4232bb6 | 609 | AliTRDdataArrayI *track0 = 0; |
610 | AliTRDdataArrayI *track1 = 0; | |
611 | AliTRDdataArrayI *track2 = 0; | |
612 | AliTRDSignalIndex *indexes = 0; | |
613 | ||
0e09df31 | 614 | // Get the ADC baseline |
615 | Int_t adcBaseline = 0; | |
e16f790e | 616 | // if (!AliTRDReconstructor::RecoParam()) |
617 | // { | |
618 | // AliError("RecoParam does not exist\n"); | |
619 | // return 0; | |
620 | // } | |
621 | // else | |
622 | // { | |
623 | // adcBaseline = ((Int_t) AliTRDReconstructor::RecoParam()->GetADCbaseline()); | |
624 | // } | |
74d2e0c7 | 625 | |
626 | static AliTRDrecoParam * par = AliTRDrecoParam::GetLowFluxParam(); | |
627 | adcBaseline = par->GetADCbaseline(); | |
d4232bb6 | 628 | // Loop through the digits |
629 | Int_t lastdet = -1; | |
c5f589b9 | 630 | Int_t det = -1; |
e16f790e | 631 | // Int_t returnDet = -1; |
9c7c9ec1 | 632 | Int_t lastside = -1; //[mj] |
633 | Int_t side = -1; //[mj] | |
d4232bb6 | 634 | Int_t it = 0; |
9c7c9ec1 | 635 | Int_t ntracklets = 0; |
636 | ||
637 | if (trackletContainer){ | |
638 | for (Int_t i = 0; i < 2; i++) //[mj] | |
639 | for (Int_t j = 0; j < MAX_TRACKLETS_PERHC; j++) //[mj] | |
640 | trackletContainer[i][j] = 0; //[mj] | |
641 | } | |
642 | ||
d4232bb6 | 643 | while (Next()) |
644 | { | |
645 | det = GetDet(); | |
e16f790e | 646 | //[mj tracklet writing] |
e16f790e | 647 | side = GetSide(); |
9c7c9ec1 | 648 | //printf("det= %d lastdet= %d side= %d lastside= %d\n",det,lastdet,side,lastside); |
649 | ||
e16f790e | 650 | if (trackletContainer) |
651 | { | |
652 | if ((det + side*AliTRDgeometry::kNdet) != (lastdet + lastside*AliTRDgeometry::kNdet)) | |
653 | { | |
654 | if (det != lastdet) | |
655 | { | |
656 | if (lastdet != -1) | |
657 | { | |
658 | return lastdet; | |
659 | } | |
660 | } | |
661 | ||
9c7c9ec1 | 662 | //if(GetTrackletWords()) trackletContainer[side] = GetTrackletWords(); |
663 | //printf("test= %u \n",*(trackletContainer[side])); | |
664 | ||
665 | ||
666 | ntracklets = GetNTracklets(); | |
667 | if(ntracklets > 0) memcpy(trackletContainer[side], GetTrackletWords(), sizeof(UInt_t) * ntracklets); //copy tracklet words to trackletContainer array [mj] | |
668 | //memcpy(trackletContainer[side], GetTrackletWords(), sizeof(UInt_t) * MAX_TRACKLETS_PERHC); //copy tracklet words to trackletContainer array [mj] | |
669 | //if(ntracklets > 0) memcpy(trackletContainer[side], GetTrackletWords(), sizeof(UInt_t) * MAX_TRACKLETS_PERHC); //copy tracklet words to trackletContainer array [mj] | |
e16f790e | 670 | lastside = side; |
671 | } | |
9c7c9ec1 | 672 | } |
673 | ||
d4232bb6 | 674 | if (det != lastdet) |
675 | { | |
676 | // If new detector found | |
677 | if (lastdet == -1) | |
678 | { | |
679 | lastdet = det; | |
680 | } | |
681 | else | |
682 | { | |
683 | return lastdet; | |
684 | } | |
dad68eff | 685 | |
686 | if (det < 0 || det >= AliTRDgeometry::kNdet) | |
687 | { | |
688 | if (fSM.fClean == kTRUE) | |
689 | { | |
690 | AliError(Form("Strange Det Number %d BUT event buffer seems to be clean.", det)); | |
691 | } | |
692 | else | |
693 | { | |
694 | AliError(Form("Strange Det Number %d. Event buffer marked NOT clean!", det)); | |
695 | } | |
696 | continue; | |
697 | } | |
698 | ||
d4232bb6 | 699 | // Add a container for the digits of this detector |
fb44eb8e | 700 | digits = (AliTRDdataArrayDigits *) digitsManager->GetDigits(det); |
fa7427d0 | 701 | |
c5f589b9 | 702 | if (digitsManager->UsesDictionaries()) |
703 | { | |
704 | track0 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,0); | |
705 | track1 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,1); | |
706 | track2 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,2); | |
707 | } | |
d4232bb6 | 708 | |
dad68eff | 709 | if (!digits) |
710 | { | |
711 | if (fSM.fClean == kTRUE) | |
712 | { | |
713 | AliError(Form("Unable to get digits for det %d BUT event buffer seems to be clean.", det)); | |
714 | } | |
715 | else | |
716 | { | |
717 | AliError(Form("Unable to get digits for det %d. Event buffer is NOT clean!", det)); | |
718 | } | |
719 | return -1; | |
dad68eff | 720 | } |
721 | ||
d4232bb6 | 722 | Int_t rowMax = GetRowMax(); |
723 | Int_t colMax = GetColMax(); | |
724 | Int_t ntbins = GetNumberOfTimeBins(); | |
725 | ||
726 | // Allocate memory space for the digits buffer | |
727 | if (digits->GetNtime() == 0) | |
728 | { | |
729 | digits->Allocate(rowMax, colMax, ntbins); | |
c5f589b9 | 730 | if (digitsManager->UsesDictionaries()) |
731 | { | |
732 | track0->Allocate(rowMax, colMax, ntbins); | |
733 | track1->Allocate(rowMax, colMax, ntbins); | |
734 | track2->Allocate(rowMax, colMax, ntbins); | |
735 | } | |
d4232bb6 | 736 | } |
737 | ||
738 | indexes = digitsManager->GetIndexes(det); | |
739 | indexes->SetSM(GetSM()); | |
740 | indexes->SetStack(GetStack()); | |
741 | indexes->SetLayer(GetLayer()); | |
742 | indexes->SetDetNumber(det); | |
743 | if (indexes->IsAllocated() == kFALSE) | |
744 | indexes->Allocate(rowMax, colMax, ntbins); | |
745 | } | |
fa7427d0 | 746 | |
747 | Char_t padStatus = cal->GetPadStatus(det, GetCol(), GetRow()); | |
e16f790e | 748 | |
d4232bb6 | 749 | // ntimebins data are ready to read |
750 | for (it = 0; it < GetNumberOfTimeBins(); it++) | |
751 | { | |
0e09df31 | 752 | if ((GetSignals()[it] - adcBaseline) > 0) |
d4232bb6 | 753 | { |
fb44eb8e | 754 | digits->SetDataUnchecked(GetRow(), GetCol(), it, GetSignals()[it] - adcBaseline); |
f5375dcb | 755 | if(padStatus) |
756 | digits->SetPadStatus(GetRow(), GetCol(), it, padStatus); | |
fb44eb8e | 757 | |
d4232bb6 | 758 | indexes->AddIndexTBin(GetRow(), GetCol(), it); |
c5f589b9 | 759 | if (digitsManager->UsesDictionaries()) |
760 | { | |
761 | track0->SetDataUnchecked(GetRow(), GetCol(), it, 0); | |
762 | track1->SetDataUnchecked(GetRow(), GetCol(), it, 0); | |
763 | track2->SetDataUnchecked(GetRow(), GetCol(), it, 0); | |
764 | } | |
d4232bb6 | 765 | } |
766 | } // tbins | |
767 | }// while Next() | |
768 | ||
d4232bb6 | 769 | return det; |
d4232bb6 | 770 | } |
771 | ||
772 | //------------------------------------------------------------ | |
773 | Bool_t | |
774 | AliTRDrawStreamTB::Init() | |
775 | { | |
776 | // | |
e16f790e | 777 | // Initialize geometry and fee parameters |
d4232bb6 | 778 | // |
779 | ||
780 | TDirectory *saveDir = gDirectory; | |
781 | ||
782 | if (!fGeometry) | |
783 | { | |
784 | fGeometry = new AliTRDgeometry(); | |
785 | } | |
786 | ||
787 | if (!fGeometry) | |
788 | { | |
789 | AliError("Geometry FAILED!"); | |
790 | return kFALSE; | |
791 | } | |
792 | ||
793 | fTRDfeeParam = AliTRDfeeParam::Instance(); | |
794 | if (!fTRDfeeParam) | |
795 | { | |
796 | AliError("AliTRDfeeParam FAILED!"); | |
797 | return kFALSE; | |
798 | } | |
799 | ||
800 | fMaxADCgeom = (Int_t)fGeometry->ADCmax(); | |
801 | ||
e16f790e | 802 | ResetCounters(); // fBufferRead is set to kFALSE - important |
d4232bb6 | 803 | |
e16f790e | 804 | /* |
bb1009bf | 805 | // in case rawreader manages the mem buffers |
806 | // lets go for the next buffer | |
807 | if (fRawReader) | |
808 | { | |
809 | Int_t nextBuff = NextBuffer(); | |
810 | while (nextBuff != -1) | |
811 | { | |
812 | if (nextBuff > 0) | |
813 | return kTRUE; | |
814 | nextBuff = NextBuffer(); | |
815 | } | |
816 | } | |
e16f790e | 817 | */ |
d4232bb6 | 818 | saveDir->cd(); |
819 | ||
820 | return kTRUE; | |
821 | } | |
822 | ||
d4232bb6 | 823 | //------------------------------------------------------------ |
824 | Bool_t | |
825 | AliTRDrawStreamTB::InitBuffer(void *buffer, UInt_t length) | |
826 | { | |
827 | // | |
e16f790e | 828 | // set initial information about the buffer |
d4232bb6 | 829 | // |
830 | ||
e16f790e | 831 | if (fgDebugFlag) AliDebug(5, Form("Equipment ID: %d",fRawReader->GetEquipmentId())); |
3be28fbf | 832 | if (fRawReader->GetEquipmentId()<1024 || fRawReader->GetEquipmentId()>1041) //tmp protection |
833 | return kFALSE; | |
e16f790e | 834 | |
7e8f4d17 | 835 | if(fgStreamEventCounter == 0) fgFirstEquipmentID = fRawReader->GetEquipmentId(); |
836 | fEquipmentID = fRawReader->GetEquipmentId(); | |
e16f790e | 837 | if(fEquipmentID == fgFirstEquipmentID) fgStreamEventCounter++; // [mj] risky if the order of sm in data changed |
838 | // since it is still for debug event counter, doesn't give an effect on decoded data | |
d4232bb6 | 839 | ResetCounters(); |
840 | ||
841 | fpBegin = (UInt_t *)buffer; | |
842 | ||
843 | if (WORD_SIZE == 0) | |
844 | { | |
e16f790e | 845 | AliFatal("Strange word size. size of UInt_t == 0"); |
d4232bb6 | 846 | return kFALSE; |
847 | } | |
848 | ||
849 | fWordLength = length/WORD_SIZE; | |
850 | fpEnd = fpBegin + fWordLength; | |
851 | fpPos = fpBegin; | |
852 | ||
853 | if (fpBegin == 0 || length <= 0) | |
854 | { | |
e16f790e | 855 | AliError(Form("Buffer size or pointer is strange. pointer to the buffer is 0x%08x of size %d", fpBegin, length)); |
d4232bb6 | 856 | return kFALSE; |
857 | } | |
858 | ||
859 | SwapOnEndian(); | |
860 | ||
861 | if (fgDumpHead > 0) | |
862 | { | |
e16f790e | 863 | AliInfo(Form("---------- Dumping %u words from the beginnig of the buffer ----------",fgDumpHead)); |
d4232bb6 | 864 | if (DumpWords(fpBegin, fgDumpHead) == kFALSE) |
865 | { | |
866 | AliError("Dump failed. Not enough data."); | |
867 | } | |
e16f790e | 868 | AliInfo(Form("---------- Dumping ended ----------------------------------------------")); |
d4232bb6 | 869 | } |
870 | ||
e16f790e | 871 | return kTRUE; |
872 | } | |
873 | ||
874 | //------------------------------------------------------------ | |
875 | Bool_t | |
876 | AliTRDrawStreamTB::DecodeGTUheader() | |
877 | { | |
878 | // Decode Supermodule Index Word | |
d4232bb6 | 879 | DecodeSMInfo(fpPos, &fSM); |
880 | ||
881 | if (fgDebugFlag) AliDebug(5, DumpSMInfo(&fSM)); | |
882 | ||
883 | fpPos++; | |
884 | if (fpPos < fpEnd) | |
885 | { | |
e16f790e | 886 | // fSM.fHeaderSize represent additional Supermodule header size which contains additional information regarding hardware design. |
887 | // For the moment, we skip decoding these words | |
d4232bb6 | 888 | if (SkipWords(fSM.fHeaderSize) == kTRUE) |
889 | { | |
d4232bb6 | 890 | for (Int_t istack = 0; istack < 5; istack++) |
891 | { | |
892 | if (fSM.fStackActive[istack] == kFALSE) | |
893 | continue; | |
894 | ||
895 | fStack = &fSM.fStacks[istack]; | |
e16f790e | 896 | |
897 | // Decode Stack Index Word of given stack | |
d4232bb6 | 898 | DecodeStackInfo(fpPos, fStack); |
899 | fpPos++; | |
900 | ||
901 | fSM.fNexpectedHalfChambers += fStack->fActiveLinks; | |
902 | ||
903 | if (fgDebugFlag) AliDebug(5, DumpStackInfo(fStack)); | |
904 | ||
e16f790e | 905 | if (SkipWords(fStack->fHeaderSize-6) == kFALSE) // 6 is the 6 stack header words for 12 links |
d4232bb6 | 906 | { |
e16f790e | 907 | if (fRawReader) fRawReader->AddMajorErrorLog(kDecodeStackInfo, "Stack header words missing"); |
d4232bb6 | 908 | return kFALSE; |
909 | } | |
e16f790e | 910 | for (Int_t iword=0; iword<6; iword++) // decode 6 stack header words |
911 | { | |
912 | // Decode Stack Header Word of given stack | |
913 | DecodeStackHeader(fpPos, fStack, iword); | |
914 | fpPos++; | |
915 | } | |
d4232bb6 | 916 | } |
917 | } | |
918 | else | |
919 | { | |
920 | return kFALSE; | |
921 | } | |
922 | } | |
923 | else | |
924 | { | |
e16f790e | 925 | if (fgWarnError) AliWarning("No additional sm headers and stack index words present."); |
d4232bb6 | 926 | if (fRawReader) fRawReader->AddMajorErrorLog(kDecodeStackInfo, "Stack info missing"); |
927 | return kFALSE; | |
928 | } | |
929 | ||
d4232bb6 | 930 | if (fpPos < fpEnd) |
931 | { | |
e16f790e | 932 | if (fgDebugFlag) AliDebug(5, "GTU headers are OK."); |
d4232bb6 | 933 | } |
934 | else | |
935 | { | |
e16f790e | 936 | if (fgWarnError) AliWarning("No data just after GTU headers."); |
937 | if (fRawReader) fRawReader->AddMajorErrorLog(kMissingData, "Missing sm data"); | |
d4232bb6 | 938 | return kFALSE; |
939 | } | |
940 | ||
e16f790e | 941 | if (fgDebugFlag) AliDebug(5, Form("Expected half chambers from GTU header: %d", fSM.fNexpectedHalfChambers)); |
942 | ||
d4232bb6 | 943 | return kTRUE; |
944 | } | |
945 | ||
946 | //------------------------------------------------------------ | |
947 | Bool_t | |
948 | AliTRDrawStreamTB::DecodeSM(void *buffer, UInt_t length) | |
949 | { | |
950 | // | |
e16f790e | 951 | // decode one sm data in buffer |
d4232bb6 | 952 | // |
953 | ||
e16f790e | 954 | ResetIterators(); |
d4232bb6 | 955 | |
956 | fSM.fClean = kTRUE; | |
e16f790e | 957 | if (InitBuffer(buffer, length) == kFALSE) |
d4232bb6 | 958 | { |
e16f790e | 959 | if (fgWarnError) AliError("InitBuffer failed."); |
d4232bb6 | 960 | fSM.fClean = kFALSE; |
961 | return kFALSE; | |
962 | } | |
963 | ||
e16f790e | 964 | if (DecodeGTUheader()== kFALSE) |
965 | return kFALSE; | |
966 | ||
d4232bb6 | 967 | for (Int_t istack = 0; istack < 5; istack++) |
968 | { | |
e16f790e | 969 | fStackNumber = istack; |
d4232bb6 | 970 | if (fSM.fStackActive[istack] == kFALSE) |
971 | continue; | |
972 | ||
973 | fStack = &fSM.fStacks[istack]; | |
974 | ||
9c7c9ec1 | 975 | fgLastHC = -1; // to check rob number odering |
d4232bb6 | 976 | for (Int_t ilink = 0; ilink < 12; ilink++) |
977 | { | |
e16f790e | 978 | fStackLinkNumber = ilink; |
d4232bb6 | 979 | if (fStack->fLinksActive[ilink] == kFALSE) |
980 | continue; | |
981 | ||
e16f790e | 982 | // check GTU link monitor |
983 | if (!(fStack->fLinksDataType[ilink] == 0 && fStack->fLinksMonitor[ilink] == 0)) | |
984 | { | |
985 | fStack->fLinkMonitorError[ilink] = 1; | |
986 | SeekEndOfData(); // skip this HC data if GTU link monitor report error | |
987 | continue; | |
988 | } | |
989 | ||
d4232bb6 | 990 | if (fpPos >= fpEnd) |
991 | { | |
992 | if (fRawReader) fRawReader->AddMajorErrorLog(kLinkDataMissing, "Link data missing"); | |
993 | fSM.fClean = kFALSE; | |
994 | break; | |
995 | } | |
996 | ||
997 | fHC = &fStack->fHalfChambers[ilink]; | |
e16f790e | 998 | ResetPerHC(); |
7e8f4d17 | 999 | |
d4232bb6 | 1000 | if (fSM.fTrackletEnable == kTRUE) |
1001 | { | |
1002 | if (DecodeTracklets() == kFALSE) | |
1003 | { | |
d4232bb6 | 1004 | |
1005 | fSM.fClean = kFALSE; | |
1006 | SeekEndOfData(); | |
1007 | ||
1008 | if (fgWarnError) | |
1009 | { | |
1010 | AliError(Form("Failed stack %d link %d", fStackNumber, fStackLinkNumber)); | |
1011 | AliError(Form("Debug Event Counter : %d", fgStreamEventCounter)); | |
1012 | } | |
1013 | continue; | |
d4232bb6 | 1014 | } |
1015 | } | |
1016 | ||
1017 | if (fpPos >= fpEnd) | |
1018 | { | |
1019 | if (fRawReader) fRawReader->AddMajorErrorLog(kHCdataMissing, "HC data missing"); | |
1020 | fSM.fClean = kFALSE; | |
1021 | break; | |
1022 | } | |
1023 | ||
9c7c9ec1 | 1024 | fgLastROB = -1; // to check mcm number odering |
1025 | fgLastIndex = -1 ; // to check mcm number odering | |
d4232bb6 | 1026 | if (DecodeHC() == kFALSE) |
1027 | { | |
d4232bb6 | 1028 | fSM.fClean = kFALSE; |
e16f790e | 1029 | if (fHC->fCorrupted < 16) SeekEndOfData(); // In case that we meet END_OF_TRACKLET_MARKERNEW |
1030 | // during ADC data decoding or MCM header decoding | |
bb1009bf | 1031 | // we don't seek ENDOFRAWDATAMARKER |
d4232bb6 | 1032 | |
1033 | if (fgWarnError) | |
1034 | { | |
1035 | AliError(Form("Failed HC : %s", DumpHCinfoH0(fHC))); | |
1036 | AliError(Form("Failed HC : %s", DumpHCinfoH1(fHC))); | |
bb1009bf | 1037 | AliError(Form("Debug Event Counter : %d\n\n\n", fgStreamEventCounter)); |
d4232bb6 | 1038 | } |
d4232bb6 | 1039 | |
1040 | continue; | |
d4232bb6 | 1041 | } |
1042 | else | |
1043 | { | |
bb1009bf | 1044 | SeekEndOfData(); // make sure that finish off with the end of data markers |
d4232bb6 | 1045 | } |
1046 | ||
d4232bb6 | 1047 | } // ilink |
1048 | } // istack | |
1049 | ||
e16f790e | 1050 | ResetIterators(); // need to do it again for Next() function |
d4232bb6 | 1051 | |
1052 | if (fSM.fClean == kTRUE) | |
1053 | return kTRUE; | |
1054 | ||
1055 | if (fgCleanDataOnly && (fSM.fClean == kFALSE)) | |
1056 | { | |
1ced3838 | 1057 | if (fgWarnError) |
1058 | { | |
1059 | AliWarning("Buffer with errors. Returning FALSE."); | |
1060 | AliWarning(Form("--- Failed SM : %s ---", DumpSMInfo(&fSM))); | |
1061 | } | |
e16f790e | 1062 | fSM.fActiveStacks = 0; // Next() will not give data |
d4232bb6 | 1063 | return kFALSE; |
1064 | } | |
1065 | ||
1066 | return kTRUE; | |
1067 | } | |
1068 | ||
1069 | //------------------------------------------------------------ | |
1070 | Int_t | |
1071 | AliTRDrawStreamTB::DecodeSM() | |
1072 | { | |
1073 | // | |
1074 | // decode SM data in case AliRawReader is in use | |
e16f790e | 1075 | // |
d4232bb6 | 1076 | if (fRawReader) |
1077 | { | |
1078 | Int_t nextBuff = NextBuffer(); | |
1079 | while (nextBuff != -1) | |
1080 | { | |
1081 | if (nextBuff > 0) | |
1082 | return nextBuff; | |
1083 | nextBuff = NextBuffer(); | |
1084 | } | |
1085 | return -1; | |
1086 | } | |
1087 | else | |
1088 | { | |
1089 | AliWarning("AliRawReader not set."); | |
1090 | } | |
1091 | return kFALSE; | |
1092 | } | |
1093 | ||
1094 | //------------------------------------------------------------ | |
1095 | Int_t | |
1096 | AliTRDrawStreamTB::DecodeSM(AliRawReader *reader) | |
1097 | { | |
1098 | // | |
1099 | // decode SM with the AliRawReader | |
1100 | // | |
1101 | if (reader != 0) | |
1102 | { | |
1103 | fRawReader = reader; | |
1104 | return DecodeSM(); | |
1105 | } | |
1106 | else | |
1107 | { | |
1108 | AliWarning("Argument AliRawReader is 0."); | |
1109 | } | |
1110 | return kFALSE; | |
1111 | } | |
1112 | ||
1113 | //------------------------------------------------------------ | |
1114 | Bool_t | |
1115 | AliTRDrawStreamTB::SeekEndOfData() | |
1116 | { | |
1117 | // | |
1118 | // go to end of data marker | |
1119 | // | |
1120 | Int_t fEndOfDataCount = 0; | |
1121 | ||
1122 | while ( *fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd ) | |
1123 | { | |
1124 | fpPos++; | |
1125 | } | |
1126 | ||
1127 | while (*fpPos == ENDOFRAWDATAMARKER && fpPos < fpEnd ) | |
1128 | { | |
1129 | fEndOfDataCount++; | |
1130 | fpPos++; | |
1131 | } | |
1132 | ||
d4232bb6 | 1133 | return kTRUE; |
1134 | } | |
1135 | ||
e16f790e | 1136 | //------------------------------------------------------------ |
1137 | Bool_t | |
1138 | AliTRDrawStreamTB::SkipMCMdata(UInt_t iw) | |
1139 | { | |
1140 | ||
1141 | if (fgDebugFlag) AliDebug(11,Form("Skip %d words due to MCM header corruption.",iw)); | |
1142 | UInt_t iwcounter = 0; | |
1143 | while ( *fpPos != ENDOFRAWDATAMARKER && iwcounter < iw) | |
1144 | { | |
1145 | if ( *fpPos == END_OF_TRACKLET_MARKERNEW) | |
1146 | { | |
1147 | if (fgDebugFlag) AliDebug(11,"Met END_OF_TRACKLET_MARKERNEW"); | |
1148 | fMCM->fCorrupted += 16; | |
1149 | fHC->fCorrupted += 16; | |
1150 | return kFALSE; | |
1151 | } | |
1152 | fpPos++; | |
1153 | iwcounter++; | |
1154 | } | |
1155 | ||
1156 | if (iwcounter == iw) | |
1157 | { | |
1158 | fpPos++; | |
1159 | return kTRUE; | |
1160 | } | |
1161 | ||
1162 | if (fgDebugFlag) AliDebug(11,"Met ENDOFRAWDATAMARKER"); | |
1163 | return kFALSE; | |
1164 | } | |
1165 | ||
d4232bb6 | 1166 | //------------------------------------------------------------ |
1167 | Bool_t | |
1168 | AliTRDrawStreamTB::SeekNextMCMheader() | |
1169 | { | |
1170 | // | |
1171 | // go to mcm marker | |
1172 | // | |
1173 | ||
e16f790e | 1174 | fpPos++; |
d4232bb6 | 1175 | |
1176 | while ( *fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd ) | |
1177 | { | |
e16f790e | 1178 | if (MCM_HEADER_MASK_ERR(*fpPos) == 0 && MCM_HEADER_MASK_ERR(*(fpPos+1)) == 0) |
d4232bb6 | 1179 | { |
e16f790e | 1180 | if (fgDebugFlag) AliDebug(11,Form("^^^ Found : Pos 0x%08x : Val 0x%08x", fpPos, *fpPos)); |
d4232bb6 | 1181 | return kTRUE; |
1182 | } | |
e16f790e | 1183 | if ( *fpPos == END_OF_TRACKLET_MARKERNEW) |
1184 | { | |
1185 | fMCM->fCorrupted += 16; | |
1186 | fHC->fCorrupted += 16; | |
1187 | return kFALSE; | |
1188 | } | |
d4232bb6 | 1189 | fpPos++; |
1190 | } | |
1191 | ||
1192 | SeekEndOfData(); | |
1193 | return kFALSE; | |
1194 | } | |
1195 | ||
1196 | //------------------------------------------------------------ | |
1197 | ||
1198 | Bool_t | |
1199 | AliTRDrawStreamTB::DecodeTracklets() | |
1200 | { | |
1201 | // | |
1202 | // decode tracklets | |
1203 | // | |
1204 | ||
1205 | fLinkTrackletCounter = 0; | |
1206 | fEndOfTrackletCount = 0; | |
3be28fbf | 1207 | fHC->fNTracklets = 0; |
d4232bb6 | 1208 | |
9c7c9ec1 | 1209 | for (Int_t i = 0; i < MAX_TRACKLETS_PERHC; i++) //[mj] |
1210 | fHC->fTrackletWords[i] = 0; //[mj] | |
e16f790e | 1211 | |
d4232bb6 | 1212 | if (fgDebugFlag) AliDebug(10, Form("Decode tracklets at 0x%08x : 0x%08x", fpPos, *fpPos)); |
d4232bb6 | 1213 | |
1214 | while ( *fpPos != END_OF_TRACKLET_MARKEROLD && *fpPos != END_OF_TRACKLET_MARKERNEW && fpPos < fpEnd ) | |
1215 | { | |
d4232bb6 | 1216 | if (fgDebugFlag) AliDebug(10, Form("Tracklet found at 0x%08x : 0x%08x", fpPos, *fpPos)); |
1217 | ||
d4232bb6 | 1218 | fLinkTrackletCounter++; |
1219 | ||
1220 | if (fLinkTrackletCounter > MAX_TRACKLETS_PERHC) | |
1221 | { | |
e16f790e | 1222 | if (fgDebugFlag) AliDebug(11,Form("Max number of tracklets exceeded %d > %d.", |
d4232bb6 | 1223 | fLinkTrackletCounter, MAX_TRACKLETS_PERHC)); |
d4232bb6 | 1224 | if (fRawReader) fRawReader->AddMajorErrorLog(kTrackletOverflow,"Too many tracklets"); |
e16f790e | 1225 | fHC->fTrackletError = 1; |
d4232bb6 | 1226 | return kFALSE; |
1227 | } | |
1228 | ||
9c7c9ec1 | 1229 | fHC->fTrackletWords[fLinkTrackletCounter-1] = UInt_t(*fpPos); //store tracklet words into array //[mj] |
1230 | fHC->fNTracklets = fLinkTrackletCounter; | |
d4232bb6 | 1231 | fpPos++; |
1232 | } | |
1233 | ||
1234 | while ( ( *fpPos == END_OF_TRACKLET_MARKEROLD || *fpPos == END_OF_TRACKLET_MARKERNEW ) && fpPos < fpEnd ) | |
1235 | { | |
d4232bb6 | 1236 | if (fgDebugFlag) AliDebug(10, Form("EoTracklets found at 0x%08x : 0x%08x", fpPos, *fpPos)); |
1237 | ||
1238 | fEndOfTrackletCount++; | |
1239 | fpPos++; | |
1240 | } | |
1241 | ||
1242 | if ( fEndOfTrackletCount < 2 ) | |
1243 | { | |
e16f790e | 1244 | if (fgDebugFlag) AliDebug(11,"End of tracklets word missing"); |
d4232bb6 | 1245 | if (fRawReader) fRawReader->AddMajorErrorLog(kEOTrackeltsMissing, "End of tracklets word missing"); |
e16f790e | 1246 | fHC->fTrackletError += 2; |
d4232bb6 | 1247 | return kFALSE; |
1248 | } | |
1249 | ||
1250 | return kTRUE; | |
1251 | } | |
1252 | ||
1253 | //------------------------------------------------------------ | |
1254 | Bool_t | |
1255 | AliTRDrawStreamTB::IsRowValid() | |
1256 | { | |
d4232bb6 | 1257 | if ( (fHC->fStack == 2 && fMCM->fROW >= fGeometry->RowmaxC0()) || |
1258 | (fHC->fStack != 2 && fMCM->fROW >= fGeometry->RowmaxC1()) || fMCM->fROW < 0 ) | |
1259 | { | |
e16f790e | 1260 | if (fgDebugFlag) AliDebug(11,Form("SM%d L%dS%d: Wrong Padrow (%d) fROB=%d, fSIDE=%d, fMCM=%02d" |
d4232bb6 | 1261 | , fHC->fSM, fHC->fLayer, fHC->fStack, fMCM->fROW, fMCM->fROB, fHC->fSide, fMCM->fMCM )); |
d4232bb6 | 1262 | return kFALSE; |
1263 | } | |
1264 | return kTRUE; | |
1265 | } | |
1266 | ||
1267 | //------------------------------------------------------------ | |
1268 | Bool_t | |
1269 | AliTRDrawStreamTB::IsMCMheaderOK() | |
1270 | { | |
1271 | // | |
1272 | // check the mcm header | |
1273 | // | |
1274 | ||
9c7c9ec1 | 1275 | if (fgLastROB != fMCM->fROB) |
1276 | { | |
1277 | fgLastIndex = 0; | |
1278 | if (fgLastROB== -1) fgLastROB = fMCM->fROB; | |
1279 | } | |
1280 | else | |
1281 | { | |
1282 | Int_t matchingcounter = 0; | |
1283 | for (Int_t i=fgLastIndex+1; i<16; i++) | |
1284 | { | |
1285 | if ( fMCM->fMCM == fgMCMordering[i] ) | |
1286 | { | |
1287 | fgLastIndex = i; | |
1288 | matchingcounter++; | |
1289 | break; | |
1290 | } | |
1291 | } | |
1292 | if (matchingcounter == 0) | |
1293 | { | |
1294 | fMCM->fMCMhdCorrupted += 2; | |
1295 | AliDebug(11,Form("MCM number from last MCM is larger: MCM # from last MCM %d, MCM # from current MCM %d \n",(fMCM-1)->fMCM, fMCM->fMCM)); | |
1296 | } | |
1297 | } | |
1298 | ||
1299 | if ( fgLastHC == fHC->fLayer*2 + fHC->fSide ) | |
1300 | { | |
1301 | if ( fMCM->fROB < (fMCM-1)->fROB ) | |
1302 | { | |
1303 | fMCM->fMCMhdCorrupted += 2; | |
1304 | AliDebug(11,Form("ROB number from last MCM is larger: ROB # from last MCM %d, ROB # from current MCM %d \n",(fMCM-1)->fROB, fMCM->fROB)); | |
1305 | } | |
1306 | else fgLastROB = fMCM->fROB; | |
1307 | } | |
1308 | ||
1309 | fgLastHC = fHC->fLayer*2 + fHC->fSide; | |
1310 | ||
1311 | /* | |
1312 | // this check will come back later again when we have "patched MCM map" | |
e16f790e | 1313 | int expectedROB = -1; |
1314 | if(!fHC->fSide) expectedROB = int(fHC->fMCMmax/16)*2; | |
1315 | else expectedROB = int(fHC->fMCMmax/16)*2 + 1; | |
1316 | int expectedMCM = 4*(3-int((fHC->fMCMmax%16)/4)) + fHC->fMCMmax%4; | |
d4232bb6 | 1317 | |
e16f790e | 1318 | if ( expectedROB != fMCM->fROB || expectedMCM != fMCM->fMCM) |
d4232bb6 | 1319 | { |
e16f790e | 1320 | fMCM->fMCMhdCorrupted += 2; |
1321 | AliDebug(11,Form("ROB expected %d ROB read %d, MCM expected %d MCM read %d\n",expectedROB, fMCM->fROB, expectedMCM, fMCM->fMCM)); | |
d4232bb6 | 1322 | } |
9c7c9ec1 | 1323 | */ |
d4232bb6 | 1324 | |
e16f790e | 1325 | // below two conditions are redundant |
1326 | /* | |
d4232bb6 | 1327 | if ( fMCM->fMCM < 0 || fMCM->fMCM > 15 || fMCM->fROB < 0 || fMCM->fROB > 7 ) |
1328 | { | |
e16f790e | 1329 | fMCM->fMCMhdCorrupted += 8; // need to assign new number |
1330 | if (fgDebugFlag) AliDebug(11,Form("ROB or MCM number is out of range. %s\n", DumpMCMinfo(fMCM))); | |
d4232bb6 | 1331 | } |
d4232bb6 | 1332 | if (IsRowValid() == kFALSE) |
e16f790e | 1333 | { |
1334 | fMCM->fMCMhdCorrupted += 16; // need to assign new number | |
1335 | } | |
1336 | */ | |
1337 | ||
bb1009bf | 1338 | if (fEventCounter == 0) |
1339 | { | |
1340 | fEventCounter = fMCM->fEvCounter; | |
1341 | } | |
1342 | ||
e16f790e | 1343 | if (fEventCounter != fMCM->fEvCounter) |
bb1009bf | 1344 | { |
e16f790e | 1345 | fMCM->fMCMhdCorrupted += 4; if (fgDebugFlag) AliDebug(11,Form("Event number(%d) of current MCM is different from that(%d) of reference MCM %s.\n", fMCM->fEvCounter, fEventCounter, DumpMCMinfo(fMCM))); |
bb1009bf | 1346 | } |
1347 | ||
e16f790e | 1348 | if (fEventCounter < fLastEventCounter) |
bb1009bf | 1349 | { |
e16f790e | 1350 | fMCM->fMCMhdCorrupted += 8; if (fgDebugFlag) AliDebug(11,Form("Event from the past? Current %d Last %d %s.\n", fEventCounter, fLastEventCounter, DumpMCMinfo(fMCM))); |
bb1009bf | 1351 | } |
1352 | ||
e16f790e | 1353 | if ( fMCM->fADCmaskCorrupted > 0 ) |
1354 | return kFALSE; | |
1355 | ||
1356 | if ( fMCM->fMCMhdCorrupted > 0 ) | |
1357 | return kFALSE; | |
1358 | ||
bb1009bf | 1359 | return kTRUE; |
1360 | } | |
1361 | ||
d4232bb6 | 1362 | //------------------------------------------------------------ |
1363 | Bool_t | |
1364 | AliTRDrawStreamTB::DecodeMCMheader() | |
1365 | { | |
1366 | // | |
1367 | // decode the mcm header | |
1368 | // | |
1369 | ||
bb1009bf | 1370 | DecodeMCMheader(fpPos, fMCM); |
3be28fbf | 1371 | |
1372 | if (fDumpingEnable) | |
1373 | { | |
1374 | if (fMCM->fMCM == fDumpingMCM) | |
1375 | { | |
1376 | if (fMCM->fROB == fDumpingROB && fHC->fLayer == fDumpingLayer) | |
1377 | { | |
1378 | if (fHC->fSM == fDumpingSM && fHC->fStack == fDumpingStack) | |
1379 | { | |
1380 | if (fgDebugFlag) { | |
1381 | AliDebug(4,DumpHCinfoH0(fHC)); | |
1382 | AliDebug(4,DumpMCMinfo(fMCM)); | |
1383 | } | |
1384 | DumpWords(fpPos, 212); | |
1385 | } | |
1386 | } | |
1387 | } | |
1388 | } | |
1389 | ||
bb1009bf | 1390 | if (fHC->fCorrupted >= 16) |
1391 | { | |
1392 | fpPos--; | |
1393 | return kFALSE; | |
1394 | } | |
d4232bb6 | 1395 | |
bb1009bf | 1396 | fMCM->fROW = fTRDfeeParam->GetPadRowFromMCM(fMCM->fROB, fMCM->fMCM); |
d4232bb6 | 1397 | |
bb1009bf | 1398 | if ((fHC->fRawVMajor > 2 && fHC->fRawVMajor <5) || (fHC->fRawVMajor > 31 && fHC->fRawVMajor < 64)) //cover old and new version definition of ZS data |
d4232bb6 | 1399 | { |
1400 | fpPos++; | |
1401 | if ( fpPos < fpEnd ) | |
1402 | { | |
bb1009bf | 1403 | DecodeMask(fpPos, fMCM); |
1404 | if (fHC->fCorrupted >= 16) | |
1405 | { | |
1406 | fpPos--; | |
1407 | return kFALSE; | |
1408 | } | |
d4232bb6 | 1409 | MCMADCwordsWithTbins(fHC->fTimeBins, fMCM); |
1410 | fMCM->fAdcDataPos = fpPos + 1; | |
1411 | } | |
1412 | else | |
1413 | { | |
e16f790e | 1414 | if (fgDebugFlag) AliDebug(11,"Expected ADC mask word. Fail due to buffer END."); |
d4232bb6 | 1415 | if (fRawReader) fRawReader->AddMajorErrorLog(kMCMADCMaskMissing,"Missing"); |
e16f790e | 1416 | fHC->fCorrupted += 32; |
d4232bb6 | 1417 | return kFALSE; |
1418 | } | |
1419 | } | |
1420 | else | |
1421 | { | |
1422 | UInt_t dummyMask = MCM_DUMMY_ADCMASK_VAL; | |
bb1009bf | 1423 | DecodeMask(&dummyMask, fMCM); |
d4232bb6 | 1424 | MCMADCwordsWithTbins(fHC->fTimeBins, fMCM); |
1425 | fMCM->fAdcDataPos = fpPos + 1; | |
1426 | } | |
1427 | ||
1428 | if (fgDebugFlag) | |
1429 | { | |
1430 | AliDebug(6, DumpMCMinfo(fMCM)); | |
1431 | AliDebug(7, DumpMCMadcMask(fMCM)); | |
1432 | } | |
1433 | ||
1434 | if (IsMCMheaderOK() == kFALSE) | |
d4232bb6 | 1435 | return kFALSE; |
e16f790e | 1436 | |
d4232bb6 | 1437 | return kTRUE; |
d4232bb6 | 1438 | } |
1439 | ||
1440 | //------------------------------------------------------------ | |
1441 | Bool_t | |
1442 | AliTRDrawStreamTB::IsHCheaderOK() | |
1443 | { | |
1444 | // | |
e16f790e | 1445 | // check insanity of half chamber header |
d4232bb6 | 1446 | // |
1447 | ||
e16f790e | 1448 | if (fHC->fStack < 0 || fHC->fStack > 4) |
d4232bb6 | 1449 | { |
e16f790e | 1450 | if (fgDebugFlag) AliDebug(11,Form("Wrong Stack %d", fHC->fStack)); |
1451 | return kFALSE; | |
1452 | } | |
d4232bb6 | 1453 | |
e16f790e | 1454 | if (fHC->fLayer < 0 || fHC->fLayer >= AliTRDgeometry::kNlayer) |
1455 | { | |
1456 | if (fgDebugFlag) AliDebug(11,Form("Wrong layer %d", fHC->fLayer)); | |
d4232bb6 | 1457 | return kFALSE; |
1458 | } | |
1459 | ||
e16f790e | 1460 | if (fHC->fSide < 0 || fHC->fSide > 1) |
d4232bb6 | 1461 | { |
e16f790e | 1462 | if (fgDebugFlag) AliDebug(11,Form("Wrong Side %d", fHC->fSide)); |
d4232bb6 | 1463 | return kFALSE; |
1464 | } | |
1465 | ||
6bd744d3 | 1466 | if (fgStackNumberChecker) |
d4232bb6 | 1467 | { |
6bd744d3 | 1468 | if (fHC->fStack != fStackNumber) |
1469 | { | |
e16f790e | 1470 | if (fgDebugFlag) AliDebug(11,Form("Missmatch: Stack number between HC header %d and GTU link mask %d", |
d4232bb6 | 1471 | fHC->fStack, fStackNumber)); |
6bd744d3 | 1472 | fStackNumber = -1; |
1473 | return kFALSE; | |
1474 | } | |
d4232bb6 | 1475 | } |
1476 | ||
7e8f4d17 | 1477 | if (fgStackLinkNumberChecker) |
d4232bb6 | 1478 | { |
e16f790e | 1479 | //if (fHC->fLayer * 2 + fHC->fSide != fStackLinkNumber) |
1480 | // let it make flexible to consider known fiber swapping | |
1481 | if ((fHC->fLayer * 2 != fStackLinkNumber) && (fHC->fLayer * 2 != fStackLinkNumber - 1)) | |
1482 | { | |
1483 | if (fgDebugFlag) AliDebug(11,Form("Missmatch: Layer number between HC header %d and GTU link mask %d | %s", | |
1484 | fHC->fLayer, fStackLinkNumber, DumpStackInfo(fStack))); | |
1485 | fStackLinkNumber = -1; | |
1486 | return kFALSE; | |
1487 | } | |
d4232bb6 | 1488 | } |
1489 | ||
e16f790e | 1490 | // SLOW GEOM : consistancy check with geometry |
d4232bb6 | 1491 | fHC->fDET = fGeometry->GetDetector(fHC->fLayer, fHC->fStack, fHC->fSM); |
1492 | if (fHC->fDET < 0 || fHC->fDET >= AliTRDgeometry::kNdet) | |
1493 | { | |
e16f790e | 1494 | if (fgDebugFlag) AliDebug(11,Form("Wrong detector %d", fHC->fDET)); |
d4232bb6 | 1495 | if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongDet, "Wrong Det"); |
1496 | return kFALSE; | |
1497 | } | |
1498 | ||
d4232bb6 | 1499 | if (fHC->fSM != fGeometry->GetSector(fHC->fDET) |
053767a4 | 1500 | || fHC->fSM <0 || fHC->fSM >= AliTRDgeometry::kNsector) |
d4232bb6 | 1501 | { |
e16f790e | 1502 | if (fgDebugFlag) AliDebug(11,Form("Wrong SM(sector) %d (Geometry says: %d) Stack=%d Layer=%d Det=%d", |
d4232bb6 | 1503 | fHC->fSM, fGeometry->GetSector(fHC->fDET), |
1504 | fHC->fStack, fHC->fLayer, fHC->fDET)); | |
1505 | if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongSM, "Wrong SM"); | |
1506 | return kFALSE; | |
1507 | } | |
1508 | ||
d4232bb6 | 1509 | fHC->fROC = fGeometry->GetDetectorSec(fHC->fLayer, fHC->fStack); |
1510 | if (fHC->fROC < 0) | |
1511 | { | |
1512 | if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC"); | |
1513 | return kFALSE; | |
1514 | } | |
1515 | ||
1516 | fHC->fRowMax = fGeometry->GetRowMax(fHC->fLayer, fHC->fStack, fHC->fSM); | |
1517 | if (fHC->fRowMax < 1) | |
1518 | { | |
1519 | if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC Row Max"); | |
1520 | return kFALSE; | |
1521 | } | |
1522 | ||
1523 | fHC->fColMax = fGeometry->GetColMax(fHC->fROC); | |
1524 | if (fHC->fColMax < 1) | |
1525 | { | |
1526 | if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC Col Max"); | |
1527 | return kFALSE; | |
1528 | } | |
d4232bb6 | 1529 | |
1530 | return kTRUE; | |
1531 | } | |
1532 | ||
1533 | //------------------------------------------------------------ | |
1534 | Bool_t | |
1535 | AliTRDrawStreamTB::DecodeHCheader() | |
1536 | { | |
1537 | // | |
1538 | // decode the half chamber header | |
1539 | // | |
1540 | ||
e16f790e | 1541 | if (DecodeHCwordH0(fpPos, fHC) == kFALSE) |
1542 | return kFALSE; | |
d4232bb6 | 1543 | |
1544 | if (fHC->fNExtraWords > 0) | |
1545 | { | |
1546 | fpPos++; | |
1547 | if (fpPos < fpEnd) | |
1548 | { | |
e16f790e | 1549 | if (DecodeHCwordH1(fpPos, fHC) == kFALSE) |
1550 | return kFALSE; | |
d4232bb6 | 1551 | } |
1552 | else | |
1553 | { | |
e16f790e | 1554 | if (fgDebugFlag) AliDebug(11,"Expected HC header word 1. Fail due to buffer END."); |
d4232bb6 | 1555 | if (fRawReader) fRawReader->AddMajorErrorLog(kHCWordMissing,"Next HC word 1 (count from 0) missing"); |
1556 | return kFALSE; | |
1557 | } | |
1558 | } | |
1559 | ||
1560 | if (fgDebugFlag) AliDebug(5, DumpHCinfoH0(fHC)); | |
1561 | if (fgDebugFlag) AliDebug(5, DumpHCinfoH1(fHC)); | |
1562 | ||
1563 | fHC->fDET = -1; | |
1564 | if (IsHCheaderOK() == kFALSE) | |
1565 | { | |
e16f790e | 1566 | fHC->fH0Corrupted += 2; |
1567 | if (fgDebugFlag) AliDebug(11,Form("H0 Header Insane. Word 0x%08x", *fHC->fPos)); | |
d4232bb6 | 1568 | return kFALSE; |
1569 | } | |
1570 | ||
1571 | return kTRUE; | |
1572 | } | |
1573 | ||
1574 | //------------------------------------------------------------ | |
1575 | Bool_t | |
1576 | AliTRDrawStreamTB::DecodeHC() | |
1577 | { | |
1578 | // | |
e16f790e | 1579 | // decode hc header and data |
d4232bb6 | 1580 | // |
1581 | ||
1582 | if (DecodeHCheader() == kFALSE) | |
1583 | { | |
e16f790e | 1584 | if (fgWarnError) AliWarning(Form("HC Header decode failed. H0 Error: %d H1 Error: %d",fHC->fH0Corrupted,fHC->fH1Corrupted)); |
1585 | if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderCorrupt, "HC header corrupted"); | |
d4232bb6 | 1586 | return kFALSE; |
1587 | } | |
1588 | else | |
1589 | { | |
1590 | fpPos++; | |
1591 | if (fpPos >= fpEnd) | |
1592 | { | |
e16f790e | 1593 | fHC->fCorrupted += 1; |
1594 | if (fgDebugFlag) AliDebug(11,"No MCM data? Not enough data in the buffer."); | |
d4232bb6 | 1595 | if (fRawReader) fRawReader->AddMajorErrorLog(kMCMdataMissing, "MCM data missing"); |
1596 | return kFALSE; | |
1597 | } | |
1598 | } | |
1599 | ||
1600 | fHC->fMCMmax = 0; | |
1601 | while (*fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd) | |
1602 | { | |
1603 | if (fHC->fMCMmax > TRD_MAX_MCM) | |
1604 | { | |
e16f790e | 1605 | fHC->fCorrupted += 2; |
1606 | if (fgDebugFlag) AliDebug(11,"More mcm data than expected!"); | |
d4232bb6 | 1607 | if (fRawReader) fRawReader->AddMajorErrorLog(kMCMoverflow, "Too many mcms found!"); |
1608 | return kFALSE; | |
1609 | } | |
1610 | ||
1611 | fMCM = &fHC->fMCMs[fHC->fMCMmax]; | |
1612 | ||
1613 | if (DecodeMCMheader() == kFALSE) | |
1614 | { | |
e16f790e | 1615 | if (fHC->fCorrupted < 4) fHC->fCorrupted += 4; // benchmark hc data corruption as 4 |
d4232bb6 | 1616 | |
e16f790e | 1617 | if (fgSkipData == kTRUE || fHC->fCorrupted >= 16) |
1618 | return kFALSE; // stop HC data reading | |
1619 | ||
1620 | fHC->fMCMmax++; // increase mcm counter to match with expected rob/mcm number | |
1621 | ||
1622 | // in case we decide to keep reading data, skip this mcm data and find next mcm header | |
1623 | if (fMCM->fADCmaskCorrupted < 2) | |
1624 | { | |
1625 | if (SkipMCMdata(fMCM->fADCcount*fMCM->fSingleADCwords) == kFALSE) | |
1626 | return kFALSE; | |
1627 | continue; | |
1628 | } | |
1629 | else | |
1630 | { | |
1631 | if (SeekNextMCMheader() == kFALSE) | |
1632 | return kFALSE; | |
1633 | continue; | |
1634 | } | |
d4232bb6 | 1635 | } |
1636 | ||
1637 | fHC->fMCMmax++; | |
e16f790e | 1638 | |
d4232bb6 | 1639 | if (fMCM->fADCmax > 0) |
1640 | { | |
1641 | fpPos++; | |
1642 | if (fpPos >= fpEnd) | |
1643 | { | |
e16f790e | 1644 | fMCM->fCorrupted += 1; |
1645 | if (fHC->fCorrupted < 4) fHC->fCorrupted += 4; // benchmark hc data corruption as 4 | |
d4232bb6 | 1646 | if (fgDebugFlag) AliDebug(9, Form("Buffer short of data. ADC data expected.")); |
e16f790e | 1647 | return kFALSE; |
d4232bb6 | 1648 | } |
dc25a859 | 1649 | |
d4232bb6 | 1650 | for (Int_t iadc = 0; iadc < fMCM->fADCmax; iadc++) |
1651 | { | |
1652 | fADC = &fMCM->fADCs[iadc]; | |
1653 | fADC->fADCnumber = fMCM->fADCchannel[iadc]; | |
1654 | ||
1655 | if (fgDebugFlag) AliDebug(9, Form("This is ADC %d of %d. ADC number is %d.", | |
1656 | iadc+1, fMCM->fADCmax, fMCM->fADCchannel[iadc])); | |
1657 | ||
1658 | if (fpPos + fMCM->fSingleADCwords >= fpEnd) | |
1659 | { | |
d4232bb6 | 1660 | |
e16f790e | 1661 | fMCM->fCorrupted += 2; |
1662 | if (fHC->fCorrupted < 4) fHC->fCorrupted += 4; // benchmark hc data corruption as 4 | |
1663 | if (fgDebugFlag) AliDebug(11,"ADC (10 words) expected. Not enough data in the buffer."); | |
d4232bb6 | 1664 | return kFALSE; |
1665 | } | |
1666 | ||
bb1009bf | 1667 | if (fHC->fRawVMajor < 64) // normal(real) ADC data |
1668 | { | |
1669 | if (DecodeADC() == kFALSE) | |
1670 | { | |
e16f790e | 1671 | if (fMCM->fCorrupted < 4) fMCM->fCorrupted += 4; // benchmark mcm data corruption as 4 |
1672 | if (fHC->fCorrupted < 4) fHC->fCorrupted += 4; // benchmark hc data corruption as 4 | |
1673 | if (fADC->fIsShared && fADC->fCorrupted == 16) // check if we are out of the det when the pad is shared | |
bb1009bf | 1674 | { |
1675 | fADC->fCOL = -1; | |
1676 | fpPos = fADC->fPos + fMCM->fSingleADCwords; | |
1677 | } | |
1678 | else | |
1679 | { | |
e16f790e | 1680 | if (fgDebugFlag) AliDebug(11,Form("ADC decode failed.")); |
bb1009bf | 1681 | if (fgSkipData == kTRUE || fHC->fCorrupted >= 16) |
e16f790e | 1682 | return kFALSE; // stop HC data reading |
bb1009bf | 1683 | } |
1684 | } | |
1685 | } | |
1686 | else // test pattern data | |
dc25a859 | 1687 | { |
e16f790e | 1688 | if (fgWarnError) AliError("These are test pattern data. You need other reader"); // will be served in other class |
bb1009bf | 1689 | } |
1690 | } | |
1691 | } | |
d4232bb6 | 1692 | else |
1693 | { | |
1694 | fpPos++; | |
1695 | } | |
1696 | }//while eof data | |
1697 | ||
1698 | if (fpPos >= fpEnd) | |
1699 | { | |
e16f790e | 1700 | if (fgDebugFlag) AliDebug(11,"We are at the end of buffer. There should be one more word left."); |
d4232bb6 | 1701 | return kFALSE; |
1702 | } | |
1703 | ||
1704 | return kTRUE; | |
1705 | } | |
d4232bb6 | 1706 | //------------------------------------------------------------ |
dc25a859 | 1707 | |
d4232bb6 | 1708 | Bool_t |
1709 | AliTRDrawStreamTB::DecodeADC() | |
1710 | { | |
1711 | // | |
1712 | // decode single ADC channel | |
1713 | // | |
1714 | ||
1715 | fADC->fCorrupted = 0; | |
2e2bc4a1 | 1716 | if(fADC->fADCnumber%2==1) fMaskADCword = ADC_WORD_MASK(ADCDATA_VAL1); |
1717 | if(fADC->fADCnumber%2==0) fMaskADCword = ADC_WORD_MASK(ADCDATA_VAL2); | |
1718 | ||
d4232bb6 | 1719 | fADC->fPos = fpPos; |
d4232bb6 | 1720 | fTbinADC = 0; |
1721 | ||
1722 | for (Int_t i = 0; i < TRD_MAX_TBINS; i++) | |
1723 | fADC->fSignals[i] = 0; | |
1724 | ||
1725 | for (Int_t iw = 0; iw < fMCM->fSingleADCwords; iw++) | |
1726 | { | |
bb1009bf | 1727 | if (HC_HEADER_MASK_ERR(*fpPos) == 0 || *fpPos == END_OF_TRACKLET_MARKERNEW) |
1728 | { | |
1729 | if (fgWarnError) AliError(Form("There should be ADC data. We meet HC header or END_OF_TRACKLET_MARKER 0x%08x",*fpPos)); | |
e16f790e | 1730 | fADC->fCorrupted += 16; |
bb1009bf | 1731 | fHC->fCorrupted += 16; |
1732 | fpPos--; | |
1733 | ||
1734 | return kFALSE; | |
1735 | } | |
d4232bb6 | 1736 | if (fMaskADCword != ADC_WORD_MASK(*fpPos)) |
1737 | { | |
d4232bb6 | 1738 | fADC->fCorrupted += 1; |
e16f790e | 1739 | if (fgDebugFlag) AliDebug(11,Form("Wrong ADC data mask! ADC channel number: %02d [Expected mask: 0x%08x Current mask: 0x%08x] MCM= %s Error : %d", |
2e2bc4a1 | 1740 | fADC->fADCnumber, fMaskADCword, ADC_WORD_MASK(*fpPos),DumpMCMinfo(fMCM),fADC->fCorrupted)); |
e16f790e | 1741 | fpPos++; |
1742 | continue; | |
d4232bb6 | 1743 | } |
1ced3838 | 1744 | |
1745 | // here we subtract the baseline ( == common additive) | |
1746 | fADC->fSignals[fTbinADC + 0] = ((*fpPos & 0x00000ffc) >> 2) - fgCommonAdditive; | |
1747 | fADC->fSignals[fTbinADC + 1] = ((*fpPos & 0x003ff000) >> 12) - fgCommonAdditive; | |
1748 | fADC->fSignals[fTbinADC + 2] = ((*fpPos & 0xffc00000) >> 22) - fgCommonAdditive; | |
d4232bb6 | 1749 | |
1750 | fTbinADC += 3; | |
1751 | fpPos++; | |
1752 | } | |
1753 | ||
1754 | if (fADC->fADCnumber <= 1 || fADC->fADCnumber == fMaxADCgeom - 1) | |
1755 | { | |
1756 | fADC->fIsShared = kTRUE; | |
1757 | } | |
1758 | else | |
1759 | { | |
1760 | fADC->fIsShared = kFALSE; | |
1761 | } | |
1762 | ||
1763 | if ( fADC->fADCnumber >= fMaxADCgeom - 1) | |
1764 | { | |
d4232bb6 | 1765 | fADC->fCOL = AliTRDfeeParam::Instance()->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber - 1); |
1766 | fADC->fCOL--; | |
1767 | } | |
1768 | else | |
1769 | { | |
1770 | fADC->fCOL = fTRDfeeParam->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber); | |
1771 | } | |
1772 | ||
1773 | if (fADC->fCOL >= fHC->fColMax || fADC->fCOL < 0) | |
1774 | { | |
1775 | if (fADC->fIsShared == kFALSE) | |
1776 | { | |
e16f790e | 1777 | fADC->fCorrupted += 32; |
1778 | if (fgDebugFlag) AliDebug(11,Form("Wrong column! ADCnumber %d MaxIs %d Col %d MaxIs %d MCM= %s", | |
d4232bb6 | 1779 | fADC->fADCnumber, fMaxADCgeom, fADC->fCOL, fHC->fColMax, DumpMCMinfo(fMCM))); |
d4232bb6 | 1780 | } |
3be28fbf | 1781 | //else |
1782 | //{ | |
e16f790e | 1783 | // we are out of the det when the pad is shared |
3be28fbf | 1784 | //if (fgDebugFlag) AliDebug(11, Form("Column out of the detector! ADCnumber %d MaxIs %d Col %d MaxIs %d MCM= %s", |
1785 | // fADC->fADCnumber, fMaxADCgeom, fADC->fCOL, fHC->fColMax, DumpMCMinfo(fMCM))); | |
1786 | //fADC->fCorrupted += 32; | |
1787 | //} | |
d4232bb6 | 1788 | } |
1789 | ||
1790 | if (fADC->fCorrupted > 0) | |
1791 | { | |
1792 | return kFALSE; | |
1793 | } | |
1794 | ||
1795 | fDecodedADCs++; | |
1796 | return kTRUE; | |
1797 | } | |
dc25a859 | 1798 | |
d4232bb6 | 1799 | //-------------------------------------------------------- |
dc25a859 | 1800 | |
bb1009bf | 1801 | |
d4232bb6 | 1802 | void AliTRDrawStreamTB::DecodeSMInfo(const UInt_t *word, struct AliTRDrawSM *sm) const |
1803 | { | |
1804 | // | |
e16f790e | 1805 | // Decode Supermodule Index Word |
1806 | // The Supermodule Index Word is a 32-Bit word wit following structure | |
1807 | // ssssssss ssssssss vvvv rrrr r d t mmmm | |
1808 | // s: Size of the Supermodule Header, v: Supermodule Header Version, r: Reserved for future use | |
1809 | // d: Track Data Enabled Bit, t: Tracklet Data Enabled Bit, m: Stack Mask | |
d4232bb6 | 1810 | // |
e16f790e | 1811 | sm->fPos = (UInt_t*)word; |
d4232bb6 | 1812 | |
d4232bb6 | 1813 | UInt_t vword = *word; |
1814 | sm->fHeaderSize = SM_HEADER_SIZE(vword); | |
1815 | ||
1816 | if (TRACKLETS_ENABLED(vword) > 0) | |
1817 | sm->fTrackletEnable = kTRUE; | |
1818 | else | |
1819 | sm->fTrackletEnable = kFALSE; | |
1820 | ||
1821 | UInt_t stackMask = STACK_MASK(vword); | |
1822 | sm->fActiveStacks = 0; | |
1823 | for (Int_t i = 0; i < 5; i++) | |
1824 | { | |
d4232bb6 | 1825 | if (IS_BIT_SET(stackMask,i) > 0) |
1826 | { | |
1827 | sm->fStackActive[i] = kTRUE; | |
1828 | sm->fActiveStacks++; | |
1829 | } | |
1830 | else | |
1831 | { | |
1832 | sm->fStackActive[i] = kFALSE; | |
1833 | } | |
1834 | } | |
1835 | } | |
1836 | ||
1837 | //-------------------------------------------------------- | |
1838 | const char *AliTRDrawStreamTB::DumpSMInfo(const struct AliTRDrawSM *sm) | |
1839 | { | |
1840 | // | |
1841 | // Get SM structure into a const char | |
1842 | // | |
d4232bb6 | 1843 | return Form("[ SM Info 0x%08x] : Hsize %d TrackletEnable %d Stacks %d %d %d %d %d", |
1844 | *sm->fPos, | |
1845 | sm->fHeaderSize, sm->fTrackletEnable, | |
1846 | sm->fStackActive[0], sm->fStackActive[1], sm->fStackActive[2], | |
1847 | sm->fStackActive[3], sm->fStackActive[4]); | |
1848 | } | |
1849 | ||
1850 | //-------------------------------------------------------- | |
1851 | void AliTRDrawStreamTB::DecodeStackInfo(const UInt_t *word, struct AliTRDrawStack *st) const | |
1852 | { | |
1853 | // | |
e16f790e | 1854 | // Decode Stack #i Index Word |
1855 | // The Stack #i Index Word is a 32-Bit word wit following structure | |
1856 | // ssssssss ssssssss vvvv mmmm mmmmmmmm | |
1857 | // s: Size of the Stack #i Header, v: Supermodule Header Version, m: Link Mask | |
d4232bb6 | 1858 | // |
d4232bb6 | 1859 | st->fPos = (UInt_t*)word; |
1860 | ||
d4232bb6 | 1861 | UInt_t vword = *word; |
1862 | st->fHeaderSize = STACK_HEADER_SIZE(vword); | |
1863 | ||
1864 | UInt_t linkMask = STACK_LINK_WORD(vword); | |
1865 | st->fActiveLinks = 0; | |
1866 | for (Int_t i = 0; i < 12; i++) | |
1867 | { | |
d4232bb6 | 1868 | if (IS_BIT_SET(linkMask,i) > 0) |
1869 | { | |
1870 | st->fLinksActive[i] = kTRUE; | |
d4232bb6 | 1871 | st->fActiveLinks++; |
1872 | } | |
1873 | else | |
1874 | { | |
d4232bb6 | 1875 | st->fLinksActive[i] = kFALSE; |
d4232bb6 | 1876 | } |
1877 | } | |
1878 | } | |
1879 | ||
e16f790e | 1880 | //-------------------------------------------------------- |
1881 | void AliTRDrawStreamTB::DecodeStackHeader(const UInt_t *word, struct AliTRDrawStack *st, Int_t iword) const | |
1882 | { | |
1883 | st->fPos = (UInt_t*)word; | |
1884 | ||
1885 | UInt_t vword = *word; | |
1886 | st->fLinksDataType[2*iword] = LINK0_DATA_TYPE_FLAG(vword); | |
1887 | st->fLinksMonitor[2*iword] = LINK0_MONITOR_FLAG(vword); | |
1888 | st->fLinksDataType[2*iword+1] = LINK1_DATA_TYPE_FLAG(vword); | |
1889 | st->fLinksMonitor[2*iword+1] = LINK1_MONITOR_FLAG(vword); | |
1890 | } | |
1891 | ||
d4232bb6 | 1892 | //-------------------------------------------------------- |
1893 | const char *AliTRDrawStreamTB::DumpStackInfo(const struct AliTRDrawStack *st) | |
1894 | { | |
1895 | // | |
1896 | // format the string with the stack info | |
1897 | // | |
1e7cdb95 | 1898 | |
d4232bb6 | 1899 | return Form("[ Stack Info 0x%08x ] : Hsize %d Links Active %d %d %d %d %d %d %d %d %d %d %d %d", |
1900 | *st->fPos, | |
1901 | st->fHeaderSize, | |
1902 | st->fLinksActive[0], st->fLinksActive[1], st->fLinksActive[2], st->fLinksActive[3], | |
1903 | st->fLinksActive[4], st->fLinksActive[5], st->fLinksActive[6], st->fLinksActive[7], | |
1904 | st->fLinksActive[8], st->fLinksActive[9], st->fLinksActive[10], st->fLinksActive[11]); | |
1e7cdb95 | 1905 | |
d4232bb6 | 1906 | } |
1907 | ||
1908 | //-------------------------------------------------------- | |
e16f790e | 1909 | Bool_t AliTRDrawStreamTB::DecodeHCwordH0(const UInt_t *word, struct AliTRDrawHC *hc) const |
d4232bb6 | 1910 | { |
1911 | // | |
1912 | // decode the hc header word 0 | |
1913 | // | |
d4232bb6 | 1914 | UInt_t vword = *word; |
1915 | ||
e16f790e | 1916 | hc->fH0Corrupted = HC_HEADER_MASK_ERR(vword); |
1917 | if (hc->fH0Corrupted > 0) | |
d4232bb6 | 1918 | { |
e16f790e | 1919 | if (fgDebugFlag) AliDebug(11,Form("H0 Header Mask Error. Word 0x%08x", *fHC->fPos)); |
1920 | return kFALSE; | |
d4232bb6 | 1921 | } |
1922 | ||
1923 | hc->fSpecialRawV = HC_SPECIAL_RAW_VERSION(vword); | |
1924 | hc->fRawVMajor = HC_MAJOR_RAW_VERSION(vword); | |
dc25a859 | 1925 | hc->fRawVMajorOpt = HC_MAJOR_RAW_VERSION_OPT(vword); |
d4232bb6 | 1926 | hc->fRawVMinor = HC_MINOR_RAW_VERSION(vword); |
1927 | hc->fNExtraWords = HC_EXTRA_WORDS(vword); | |
1928 | hc->fDCSboard = HC_DCS_BOARD(vword); | |
1929 | hc->fSM = HC_SM_NUMBER(vword); | |
1930 | hc->fStack = HC_STACK_NUMBER(vword); | |
1931 | hc->fLayer = HC_LAYER_NUMBER(vword); | |
1932 | hc->fSide = HC_SIDE_NUMBER(vword); | |
1933 | ||
1934 | hc->fPos[0] = (UInt_t*)word; | |
1935 | ||
e16f790e | 1936 | return kTRUE; |
d4232bb6 | 1937 | } |
1938 | ||
1939 | //-------------------------------------------------------- | |
e16f790e | 1940 | Bool_t AliTRDrawStreamTB::DecodeHCwordH1(const UInt_t *word, struct AliTRDrawHC *hc) const |
d4232bb6 | 1941 | { |
1942 | // | |
e16f790e | 1943 | // decode the hc header word 1 |
d4232bb6 | 1944 | // |
1945 | ||
d4232bb6 | 1946 | UInt_t vword = *word; |
1947 | ||
e16f790e | 1948 | hc->fH1Corrupted = HC_HEADER_MASK_ERR(vword); |
1949 | if (hc->fH1Corrupted > 0) | |
1950 | { | |
1951 | if (fgDebugFlag) AliDebug(11,Form("H1 Header Mask Error. Word 0x%08x", *fHC->fPos)); | |
1952 | return kFALSE; | |
d4232bb6 | 1953 | } |
1954 | ||
1955 | hc->fTimeBins = HC_NTIMEBINS(vword); | |
1956 | hc->fBunchCrossCounter = HC_BUNCH_CROSS_COUNTER(vword); | |
1957 | hc->fPreTriggerCounter = HC_PRETRIGGER_COUNTER(vword); | |
1958 | hc->fPreTriggerPhase = HC_PRETRIGGER_PHASE(vword); | |
1959 | ||
1960 | hc->fPos[1] = (UInt_t*)word; | |
e16f790e | 1961 | |
1962 | return kTRUE; | |
d4232bb6 | 1963 | } |
1964 | ||
1965 | //-------------------------------------------------------- | |
1966 | const char *AliTRDrawStreamTB::DumpHCinfoH0(const struct AliTRDrawHC *hc) | |
1967 | { | |
1968 | // | |
e16f790e | 1969 | // dump the hc header word 0 |
d4232bb6 | 1970 | // |
1971 | if (!hc) | |
1972 | return Form("Unable to dump. Null received as parameter!?!"); | |
1973 | else | |
1974 | return Form("[ HC[0] at 0x%08x ] : 0x%08x Info is : RawV %d SM %d Stack %d Layer %d Side %d DCSboard %d", | |
1975 | hc->fPos[0], *(hc->fPos[0]), hc->fRawVMajor, hc->fSM, hc->fStack, hc->fLayer, hc->fSide, hc->fDCSboard); | |
1976 | } | |
1977 | ||
1978 | //-------------------------------------------------------- | |
1979 | const char *AliTRDrawStreamTB::DumpHCinfoH1(const struct AliTRDrawHC *hc) | |
1980 | { | |
1981 | // | |
e16f790e | 1982 | // dump the hc header word 1 |
d4232bb6 | 1983 | // |
1984 | if (!hc) | |
1985 | return Form("Unable to dump. Null received as parameter!?!"); | |
1986 | else | |
1987 | return Form("[ HC[1] at 0x%08x ] : 0x%08x Info is : TBins %d BCcount %d PreTrigCount %d PreTrigPhase %d", | |
1988 | hc->fPos[1], *(hc->fPos[1]), hc->fTimeBins, hc->fBunchCrossCounter, hc->fPreTriggerCounter, hc->fPreTriggerPhase); | |
1989 | } | |
1990 | ||
1991 | //-------------------------------------------------------- | |
1992 | void AliTRDrawStreamTB::DecodeMCMheader(const UInt_t *word, struct AliTRDrawMCM *mcm) const | |
1993 | { | |
1994 | // | |
1995 | // decode the mcm header | |
1996 | // | |
d4232bb6 | 1997 | UInt_t vword = *word; |
1998 | ||
bb1009bf | 1999 | if (vword == END_OF_TRACKLET_MARKERNEW) |
6bd744d3 | 2000 | { |
bb1009bf | 2001 | if (fgWarnError) AliError(Form("There should be MCM header. We meet END_OF_TRACKLET_MARKER 0x%08x",vword)); |
e16f790e | 2002 | mcm->fMCMhdCorrupted += 16; |
bb1009bf | 2003 | fHC->fCorrupted += 16; //to finish data reading of this HC |
6bd744d3 | 2004 | } |
e16f790e | 2005 | |
2006 | mcm->fMCMhdCorrupted = MCM_HEADER_MASK_ERR(vword); //if MCM header mask has error | |
2007 | if (fgDebugFlag && mcm->fMCMhdCorrupted != 0) AliDebug(11,Form("Wrong MCM header mask 0x%08x.\n", *fpPos)); | |
2008 | ||
d4232bb6 | 2009 | mcm->fROB = MCM_ROB_NUMBER(vword); |
2010 | mcm->fMCM = MCM_MCM_NUMBER(vword); | |
2011 | mcm->fEvCounter = MCM_EVENT_COUNTER(vword); | |
d4232bb6 | 2012 | mcm->fPos = (UInt_t*)word; |
2013 | } | |
2014 | ||
2015 | //-------------------------------------------------------- | |
2016 | UInt_t AliTRDrawStreamTB::GetMCMadcMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const | |
2017 | { | |
2018 | // | |
2019 | // get the adc mask | |
2020 | // | |
d4232bb6 | 2021 | UInt_t vword = *word; |
2022 | ||
bb1009bf | 2023 | mcm->fADCmax = 0; |
2024 | mcm->fADCMask = 0; | |
2025 | mcm->fADCcount = 0; | |
d4232bb6 | 2026 | mcm->fADCMaskWord = vword; |
bb1009bf | 2027 | |
2028 | if (vword == END_OF_TRACKLET_MARKERNEW) | |
2029 | { | |
2030 | if (fgWarnError) AliError(Form("There should be MCMadcMask. We meet END_OF_TRACKLET_MARKER 0x%08x",vword)); | |
e16f790e | 2031 | mcm->fADCmaskCorrupted += 16; |
bb1009bf | 2032 | fHC->fCorrupted += 16; //to finish data reading of this HC |
2033 | } | |
2034 | ||
d4232bb6 | 2035 | if ( MCM_ADCMASK_MASK_ERR(vword) == 0 ) |
2036 | { | |
bb1009bf | 2037 | mcm->fADCMask = MCM_ADCMASK_VAL(vword); |
2038 | mcm->fADCcount = MCM_ADCMASK_NADC(~vword); | |
d4232bb6 | 2039 | } |
2040 | else | |
2041 | { | |
2042 | mcm->fADCMask = 0xffffffff; | |
e16f790e | 2043 | mcm->fADCmaskCorrupted = 1; // mcm adc mask error |
2044 | if (fgDebugFlag) AliDebug(11,Form("Wrong ADC Mask word 0x%08x.\n", *fpPos)); | |
d4232bb6 | 2045 | } |
2046 | ||
2047 | return mcm->fADCMask; | |
2048 | } | |
2049 | ||
2050 | //-------------------------------------------------------- | |
2051 | void AliTRDrawStreamTB::DecodeMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const | |
2052 | { | |
2053 | // | |
2054 | // decode the adc mask - adcs to be read out | |
2055 | // | |
d4232bb6 | 2056 | mcm->fMCMADCWords = 0; |
2057 | mcm->fSingleADCwords = 0; | |
2058 | mcm->fADCmax = 0; | |
2059 | mcm->fADCMask = GetMCMadcMask(word, mcm); | |
bb1009bf | 2060 | |
d4232bb6 | 2061 | if (mcm->fADCMask > 0) |
2062 | { | |
2063 | for (Int_t i = 0; i < TRD_MAX_ADC; i++) | |
2064 | { | |
2065 | mcm->fADCchannel[mcm->fADCmax] = 0; | |
2066 | if( IS_BIT_SET(mcm->fADCMask,i) ) | |
2067 | { | |
2068 | mcm->fADCchannel[mcm->fADCmax] = i; | |
2069 | mcm->fADCmax++; | |
2070 | } | |
2071 | } | |
2072 | } | |
bb1009bf | 2073 | if (mcm->fADCcount != mcm->fADCmax && fHC->fRawVMajor >= 32) // backward compatibility |
2074 | { | |
e16f790e | 2075 | mcm->fADCmaskCorrupted += 2; |
2076 | if (fgDebugFlag) AliDebug(11,Form("ADC counts from ADCMask are different %d %d : ADCMask word 0x%08x\n", mcm->fADCcount, mcm->fADCmax, *fMCM->fPos)); | |
bb1009bf | 2077 | } |
d4232bb6 | 2078 | } |
2079 | ||
2080 | //-------------------------------------------------------- | |
2081 | void AliTRDrawStreamTB::MCMADCwordsWithTbins(UInt_t fTbins, struct AliTRDrawMCM *mcm) const | |
2082 | { | |
2083 | // | |
2084 | // count the expected mcm words for a given tbins | |
2085 | // | |
2086 | mcm->fMCMADCWords = ( mcm->fADCmax ) * ( fTbins / 3 ); | |
2087 | mcm->fSingleADCwords = 0; | |
2088 | if (mcm->fADCmax > 0) | |
2089 | { | |
2090 | mcm->fSingleADCwords = mcm->fMCMADCWords/mcm->fADCmax; | |
2091 | } | |
2092 | } | |
2093 | ||
2094 | //-------------------------------------------------------- | |
2095 | const char *AliTRDrawStreamTB::DumpMCMinfo(const struct AliTRDrawMCM *mcm) | |
2096 | { | |
2097 | // | |
2098 | // mcm info in a string | |
2099 | // | |
2100 | if (!mcm) | |
2101 | return Form("Unable to dump. Null received as parameter!?!"); | |
2102 | else | |
2103 | return Form("[ MCM 0x%08x ] : ROB %d MCM %d EvCounter %d", *(mcm->fPos), mcm->fROB, mcm->fMCM, mcm->fEvCounter); | |
2104 | } | |
2105 | ||
2106 | //-------------------------------------------------------- | |
d4232bb6 | 2107 | const char *AliTRDrawStreamTB::DumpMCMadcMask(const struct AliTRDrawMCM *mcm) |
2108 | { | |
2109 | // | |
2110 | // mcm adc mask in a string | |
2111 | // | |
2112 | if (!mcm) | |
2113 | return Form("Unable to dump. Null received as parameter!?!"); | |
2114 | ||
2115 | TString tsreturn = Form("[Word] : 0x%08x => [Mask] : 0x%08x : ", mcm->fADCMaskWord, mcm->fADCMask); | |
2116 | for (Int_t i = 0; i < 21; i++) | |
2117 | { | |
2118 | tsreturn += Form("%d ", mcm->fADCchannel[i]); | |
2119 | } | |
2120 | tsreturn += ""; | |
2121 | return tsreturn.Data(); | |
2122 | } |