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