Print EMCAL OCDB parameters for the reconstruction
[u/mrichter/AliRoot.git] / TRD / AliTRDrawStream.h
CommitLineData
e2e85093 1#ifndef ALITRDRAWSTREAM_H
2#define ALITRDRAWSTREAM_H
3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/* $Id: AliTRDrawStream.h 27696 2008-07-31 09:18:53Z cblume $ */
8
9///////////////////////////////////////////////////////////////////////////////
10// //
11// This class provides access to TRD digits in raw data. //
12// //
13///////////////////////////////////////////////////////////////////////////////
14
15#include "AliTRDrawStreamBase.h"
16
17class AliTRDgeometry;
18class AliRawReader;
19class AliTRDdigitsManager;
20class TTreeSRedirector;
21class AliTRDfeeParam;
22
23
24class AliTRDrawStream : public AliTRDrawStreamBase
25{ // class def begin
26
27 public:
28
29 //--------------------------------------------------------
30 // THE STRUCTURES
31 //--------------------------------------------------------
32
33 struct AliTRDrawADC
34 {//adc struct
35
36 UInt_t *fPos; //! position of ADC 1st word in the buffer
37 Short_t fADCnumber; // number of the ADC 0 .. 20
38 Short_t fCOL; // column - row from MCM
39 Int_t fSignals[TRDMAXTBINS]; // signals for this adc
40 Bool_t fIsShared; // is pad chared between MCMs
41 Short_t fCorrupted; // is adc word corrupted
42
43 AliTRDrawADC()
44 : fPos(0)
45 , fADCnumber(0)
46 , fCOL(0)
47 , fSignals()
48 , fIsShared(kFALSE)
49 , fCorrupted(0)
50 {
51 // default constructor
52 };
53
54 AliTRDrawADC(const AliTRDrawADC& p):
55 fPos(p.fPos)
56 , fADCnumber(p.fADCnumber)
57 , fCOL(p.fCOL)
58 , fSignals()
59 , fIsShared(p.fIsShared)
60 , fCorrupted(p.fCorrupted)
61 {
62 // copy constructor
63 };
64
65 AliTRDrawADC &operator=(const AliTRDrawADC &)
66 {
67 // assignment operator
68 // not implemented
69 return *this;
70 };
71
72 };
73
74 //--------------------------------------------------------
75
76 struct AliTRDrawMCM
77 { // mcm struct
78 Int_t fROB; // ROB number
79 Int_t fMCM; // MCM number
80 Int_t fROW; // row number filed during decoding
81
82 UInt_t fEvCounter; // MCM event counter
83 UInt_t fADCMask; // ADC mask
84 UInt_t fADCMaskWord; // word with ADC mask in
85 UInt_t fADCchannel[TRDMAXADC]; // channels to be decoded accrording to ADC mask
86
87 Int_t fADCmax; // number of ADCs fired
88 Int_t fADCcount; // number of ADCs fired from double checking bit
89 Int_t fMCMADCWords; // mcm words to expect
90 Int_t fSingleADCwords; // n of words per ADC
91
92 Int_t fMCMhdCorrupted; // is mcm header corrupted
93 Int_t fADCmaskCorrupted; // is mcm adc mask corrupted
94 Int_t fCorrupted; // is mcm data missing
95
96 UInt_t *fPos; //! position of mcm header in the buffer
97 UInt_t *fAdcDataPos; //! start of ADC data for this mcm
98
99 Int_t fADCcounter; // count the adcs decoded
100 AliTRDrawADC fADCs[TRDMAXADC]; // 21 adcs
101
102 AliTRDrawMCM()
103 : fROB(-1)
104 , fMCM(-1)
105 , fROW(-1)
106 , fEvCounter(0)
107 , fADCMask(0)
108 , fADCMaskWord(0)
109 , fADCchannel()
110 , fADCmax(0)
111 , fADCcount(0)
112 , fMCMADCWords(0)
113 , fSingleADCwords(0)
114 , fMCMhdCorrupted(0)
115 , fADCmaskCorrupted(0)
116 , fCorrupted(0)
117 , fPos(0)
118 , fAdcDataPos(0)
119 , fADCcounter(0)
120 , fADCs()
121 {
122 // default constructor
123 };
124
125 AliTRDrawMCM(const AliTRDrawMCM & p):
126 fROB(p.fROB)
127 , fMCM(p.fMCM)
128 , fROW(p.fROW)
129 , fEvCounter(p.fEvCounter)
130 , fADCMask(p.fADCMask)
131 , fADCMaskWord(p.fADCMaskWord)
132 , fADCchannel()
133 , fADCmax(p.fADCmax)
134 , fADCcount(p.fADCcount)
135 , fMCMADCWords(p.fMCMADCWords)
136 , fSingleADCwords(p.fSingleADCwords)
137 , fMCMhdCorrupted(p.fMCMhdCorrupted)
138 , fADCmaskCorrupted(p.fADCmaskCorrupted)
139 , fCorrupted(p.fCorrupted)
140 , fPos(p.fPos)
141 , fAdcDataPos(p.fAdcDataPos)
142 , fADCcounter(p.fADCcounter)
143 , fADCs()
144 {
145 // copy constructor
146 };
147
148 AliTRDrawMCM &operator=(const AliTRDrawMCM &)
149 {
150 // assignment operator
151 // not implemented
152 return *this;
153 };
154
155 };
156
157 //--------------------------------------------------------
158
159 struct AliTRDrawHC
160 { // hc struct
161
162 //tacklet words of given HC
163 UInt_t fTrackletWords[MAXTRACKLETSPERHC]; // array to keep tracklet words [mj]
164 Short_t fTrackletError; // tracklet error
165 Short_t fNTracklets; // number of tracklet
166
167 // header word 0
168 Int_t fSpecialRawV; // Raw data version
169 Int_t fRawVMajor; // Raw data version
170 Int_t fRawVMajorOpt; // Raw data version
171 Int_t fRawVMinor; // Raw data version
172 Int_t fNExtraWords; // N extra HC header words
173 Int_t fDCSboard; // DCS board number
174 Int_t fSM; // Super Module number
175 Int_t fStack; // Stack number (some people might call it a chamber)
176 Int_t fLayer; // Layer number (some people might call it a plane)
177 Int_t fSide; // Side of HC
178
179 // header word 1
180 Int_t fTimeBins; // N of t bins
181 UInt_t fBunchCrossCounter; // Bunch crossing counter
182 UInt_t fPreTriggerCounter; // Pre Trigger counter
183 UInt_t fPreTriggerPhase; // Pre Trigger phase
184
185 // error
186 Int_t fH0Corrupted; // is hc header 0 corrupted
187 Int_t fH1Corrupted; // is hc header 1 corrupted
188 Int_t fCorrupted; // is hc data corrupted
189
190 UInt_t *fPos[2]; //! position of the header words in buffer
191
192 Int_t fDET; // filled while decoding
193 Int_t fROC; // filled while decoding
194 Int_t fRowMax; // filled while decoding
195 Int_t fColMax; // filled while decoding
196
197 // hc data
198 Int_t fMCMmax; // number of mcm found
199 AliTRDrawMCM fMCMs[TRDMAXMCM]; // 4 ROBS 16 each
200
201 AliTRDrawHC()
202 : fTrackletWords() //[mj]
203 , fTrackletError(0)
204 , fNTracklets(0)
205 , fSpecialRawV(0)
206 , fRawVMajor(0)
207 , fRawVMajorOpt(0)
208 , fRawVMinor(0)
209 , fNExtraWords(0)
210 , fDCSboard(-1)
211 , fSM(-1)
212 , fStack(-1)
213 , fLayer(-1)
214 , fSide(-1)
215 , fTimeBins(0)
216 , fBunchCrossCounter(0)
217 , fPreTriggerCounter(0)
218 , fPreTriggerPhase(0)
219 , fH0Corrupted(0)
220 , fH1Corrupted(0)
221 , fCorrupted(0)
222 , fPos()
223 , fDET(-1)
224 , fROC(-1)
225 , fRowMax(-1)
226 , fColMax(-1)
227 , fMCMmax(0)
228 , fMCMs()
229 {
230 // default constructor hc info
231 };
232
233 AliTRDrawHC(const AliTRDrawHC & p):
234 fTrackletWords() //[mj]
235 , fTrackletError(p.fTrackletError)
236 , fNTracklets(p.fNTracklets)
237 , fSpecialRawV(p.fSpecialRawV)
238 , fRawVMajor(p.fRawVMajor)
239 , fRawVMajorOpt(p.fRawVMajorOpt)
240 , fRawVMinor(p.fRawVMinor)
241 , fNExtraWords(p.fNExtraWords)
242 , fDCSboard(p.fDCSboard)
243 , fSM(p.fSM)
244 , fStack(p.fStack)
245 , fLayer(p.fLayer)
246 , fSide(p.fSide)
247 , fTimeBins(p.fTimeBins)
248 , fBunchCrossCounter(p.fBunchCrossCounter)
249 , fPreTriggerCounter(p.fPreTriggerCounter)
250 , fPreTriggerPhase(p.fPreTriggerPhase)
251 , fH0Corrupted(p.fH0Corrupted)
252 , fH1Corrupted(p.fH1Corrupted)
253 , fCorrupted(p.fCorrupted)
254 , fPos()
255 , fDET(p.fDET)
256 , fROC(p.fROC)
257 , fRowMax(p.fRowMax)
258 , fColMax(p.fColMax)
259 , fMCMmax(p.fMCMmax)
260 , fMCMs()
261 {
262 // copy constructor
263 };
264
265 AliTRDrawHC &operator=(const AliTRDrawHC &)
266 {
267 // assignment operator
268 // not implemented
269 return *this;
270 };
271
272 };
273
274 //--------------------------------------------------------
275
276 struct AliTRDrawStack
277 {
278 UInt_t fHeaderSize; // header size of the stack info
279 Bool_t fLinksActive[12]; // data links active - 1 per half chamber
280 Short_t fLinksDataType[12]; // 0 indicating real data for the front-end electronics
281 Short_t fLinksMonitor[12]; // 0 indicating properly operating link
282 Short_t fLinkMonitorError[12]; // record link monitor error
283 Int_t fActiveLinks; // number of active links
284 UInt_t *fPos; //! position in the buffer
285
286 AliTRDrawHC fHalfChambers[12]; // 12 half chambers in a stack
287
288 AliTRDrawStack()
289 : fHeaderSize(0)
290 , fLinksActive()
291 , fLinksDataType()
292 , fLinksMonitor()
293 , fLinkMonitorError()
294 , fActiveLinks(0)
295 , fPos(0)
296 , fHalfChambers()
297 {
298 // default constructor
299 };
300
301 AliTRDrawStack(const AliTRDrawStack & p):
302 fHeaderSize(p.fHeaderSize)
303 , fLinksActive()
304 , fLinksDataType()
305 , fLinksMonitor()
306 , fLinkMonitorError()
307 , fActiveLinks(p.fActiveLinks)
308 , fPos(p.fPos)
309 , fHalfChambers()
310 {
311 // copy constructor
312 };
313
314 AliTRDrawStack &operator=(const AliTRDrawStack &)
315 {
316 // assignment operator
317 // not implemented
318 return *this;
319 };
320
321 };
322
323 //--------------------------------------------------------
324
325 struct AliTRDrawSM
326 {
327 UInt_t fHeaderSize; // size of the header in words
328 Bool_t fTrackletEnable; // tracklet enable bit
329 Bool_t fStackActive[5]; // map of active/expected stacks
330 Int_t fActiveStacks; // number of active stacks
331 Int_t fCorrupted; // is sm info corrupted
332 Int_t fNexpectedHalfChambers; // number of half chambers to be read out in this sm
333 Bool_t fClean; // true if everything went OK - false is some error occured
334 UInt_t *fPos; // location of the sm info - should be the first word (after CDH if not DDL buffer)
335
336 AliTRDrawStack fStacks[5]; // objects for 5 stacks
337
338 AliTRDrawSM()
339 : fHeaderSize(0)
340 , fTrackletEnable(0)
341 , fStackActive()
342 , fActiveStacks(0)
343 , fCorrupted(0)
344 , fNexpectedHalfChambers(0)
345 , fClean(kTRUE)
346 , fPos(0)
347 , fStacks()
348 {
349 // Default constructor
350 };
351
352 AliTRDrawSM(const AliTRDrawSM & p):
353 fHeaderSize(p.fHeaderSize)
354 , fTrackletEnable(p.fTrackletEnable)
355 , fStackActive()
356 , fActiveStacks(p.fActiveStacks)
357 , fCorrupted(p.fCorrupted)
358 , fNexpectedHalfChambers(p.fNexpectedHalfChambers)
359 , fClean(p.fClean)
360 , fPos(p.fPos)
361 , fStacks()
362 {
363 // copy constructor
364 };
365
366 AliTRDrawSM &operator=(const AliTRDrawSM &)
367 {
368 // assignment operator
369 // not implemented
370 return *this;
371 };
372
373 };
374
375 //--------------------------------------------------------
376
377 AliTRDrawStream();
378 AliTRDrawStream(AliRawReader *rawReader);
379 virtual ~AliTRDrawStream();
380
381 //--------------------------------------------------------
382
383 virtual Bool_t Next(); // read the next data in the memory
384 //virtual Int_t NextChamber(AliTRDdigitsManager *man); // read next chamber data in the momory
385 virtual Int_t NextChamber(AliTRDdigitsManager *man, UInt_t **trackletContainer); // read next chamber data in the memory
386 virtual Bool_t Init(); // initialize some internal variables
387
388 Int_t NextBuffer(); // go and init next buffer if available - check the implementation file for return values
389
390 Bool_t SetRawVersion(Int_t fraw); // set the raw version - used for backward compat.
391
392 Bool_t IsCurrentPadShared() const {return fADC->fIsShared;} // is current pad shared between mcms
393 void SetSharedPadReadout(Bool_t fv) {fSharedPadsOn = fv;} // set the flag on if the reader should return the shared pads
394
395 Bool_t DecodeSM(void *buffer, UInt_t length); // decode a buffer
396 Int_t DecodeSM(); // used with raw reader
397 Int_t DecodeSM(AliRawReader *reader); // used with raw reader
398
399 Bool_t SetReader(AliRawReader *reader); // set the raw reader to use
400
401 // info from Supermodule Index Word
402 Bool_t IsTrackletEnableBitSet() const {return fSM.fTrackletEnable;} // get status of tracklet enable bit
403 Bool_t IsStackActive(Int_t is) const {return fSM.fStackActive[is];} // get status of stack enable bit
404 Int_t GetNofActiveStacks() const {return fSM.fActiveStacks;} // get number of active stacks from stack mask
405 UInt_t *GetGTUheaderWords() const {return fSM.fPos;} // get number of active stacks from stack mask
406
407 // info from Stack Index Word
408 Int_t GetNexpectedHalfChambers() const {return fSM.fNexpectedHalfChambers;} // get number of expected HC in a sm
409 Int_t GetNofActiveLinksInStack(Int_t is) const {return fSM.fStacks[is].fActiveLinks;} // get number of active links in a stack
410 Bool_t IsLinkActiveInStack(Int_t is, Int_t il) const {return fSM.fStacks[is].fLinksActive[il];} // check whether the link is active
411
412 // info from Stack Header Word
413 Short_t GetLinkMonitorError(Int_t is, Int_t il) const {return fSM.fStacks[is].fLinkMonitorError[il];} // get link monitor error
414
415 // info from Tracklet Data
416 Int_t GetTrackletErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fTrackletError;}
417 Int_t GetNTracklets(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fNTracklets;} // get number of tracklets
418
419 // info from HC Header Word
420 Int_t GetSM(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fSM;}
421 Int_t GetLayer(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fLayer;}
422 Int_t GetStack(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fStack;}
423 Int_t GetSide(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fSide;}
424 Int_t GetH0ErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fH0Corrupted;}
425 Int_t GetH1ErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fH1Corrupted;}
426 Int_t GetNumberOfTimeBins(Int_t is, Int_t il) const { return fSM.fStacks[is].fHalfChambers[il].fTimeBins;}
427 UInt_t *GetTrackletWords(Int_t is, Int_t il) { return fSM.fStacks[is].fHalfChambers[il].fTrackletWords;}
428
429 // info from HC data
430 Int_t GetHCErrorCode(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fCorrupted;}
431 Int_t GetHCMCMmax(Int_t is, Int_t il) const {return fSM.fStacks[is].fHalfChambers[il].fMCMmax;}
432
433 // from MCM Header Word
434 // rob and mcm ordering
435 // side 0(even link) - ROB: 0 2 4 6 MCM: 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3
436 // side 1( odd link) - ROB: 1 3 5 7 MCM: 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3
437 Int_t GetMCM(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fMCM;}
438 Int_t GetROB(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fROB;}
439 Int_t GetMCMhdErrorCode(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fMCMhdCorrupted;}
440 Int_t GetMCMADCMaskErrorCode(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCmaskCorrupted;}
441 Int_t GetEventNumber(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fEvCounter;}
442 Int_t GetADCcount(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCcount;}
443
444 // info from MCM data words
445 Int_t GetMCMErrorCode(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fCorrupted;} // get MCM data error code
446 Int_t GetADCErrorCode(Int_t stack, Int_t link, Int_t mcm, Int_t adc) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fCorrupted;} // get ADC error code
447 Int_t GetADCnumber(Int_t stack, Int_t link, Int_t mcm, Int_t adc) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fADCnumber;} // get ADC error code
448
449 Int_t GetRow(Int_t stack, Int_t link, Int_t mcm) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fROW;} // get current row number
450 Int_t GetCol(Int_t stack, Int_t link, Int_t mcm, Int_t adc) const {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fCOL;} // get current column number
451
452 // info from ADC data words
453 Int_t *GetSignalDirect(Int_t stack, Int_t link, Int_t mcm, Int_t adc) {return fSM.fStacks[stack].fHalfChambers[link].fMCMs[mcm].fADCs[adc].fSignals;}
454
455
456 // from here, only works with returning ADC channel pointer using Next()
457 UInt_t *GetTrackletWords() const { return fHC->fTrackletWords;} // return tracklet words pointer per hc [mj]
458 Int_t GetTrackletErrorCode() const {return fHC ? fHC->fTrackletError : -1;} // get tracklet error code
459 Int_t GetNTracklets() const {return fHC ? fHC->fNTracklets : -1;} // get number of tracklets
460
461 Int_t GetSpecialRawVersion() const {return fHC ? fHC->fSpecialRawV : -1;} // return special raw version
462 Int_t GetMajorRawVersion() const {return fHC ? fHC->fRawVMajor : -1;} // major raw version getter
463 Int_t GetRawVersion() const {return fHC ? fHC->fRawVMajor : -1;} // compatibility see funtion above
464 Int_t GetMinorRawVersion() const {return fHC ? fHC->fRawVMinor : -1;} // minor raw version
465
466 Int_t GetSM() const {return fHC ? fHC->fSM : -1;} // SM Position of CURRENT half chamber in full TRD
467 Int_t GetLayer() const {return fHC ? fHC->fLayer : -1;} // Layer Position of CURRENT half chamber in full TRD
468 Int_t GetStack() const {return fHC ? fHC->fStack : -1;} // Stack Position of CURRENT half chamber in full TRD
469 Int_t GetSide() const {return fHC ? fHC->fSide : -1;} // get side
470 Int_t GetDCS() const { return fHC ? fHC->fDCSboard : -1;} // DCS board number read from data (HC header)
471 Int_t GetROC() const { return fHC ? fHC->fROC : -1;} // ROB Position of CURRENT half chamber in full TRD
472 Int_t GetNumberOfTimeBins() const { return fHC ? fHC->fTimeBins : 0;} // Get Ntime bins
473 UInt_t GetBunchCrossCounter() const {return fHC ? fHC->fBunchCrossCounter : 0;} // get bunch cross counter
474 UInt_t GetPreTriggerCounter() const {return fHC ? fHC->fPreTriggerCounter : 0;} // get pre trigger info
475 UInt_t GetPreTriggerPhase() const {return fHC ? fHC->fPreTriggerPhase : 0;} // get trigger phase
476
477 Int_t GetRow() const {return fMCM ? fMCM->fROW : -1;} // get current row number
478 Int_t GetCol() const {return fADC ? fADC->fCOL : -1;} // get current column number
479 Int_t GetRowMax() const { return fHC ? fHC->fRowMax : -1;} // Get maximum rows in the current HC
480 Int_t GetColMax() const { return fHC ? fHC->fColMax : -1;} // Get maximum cols in the current HC
481 // compatibility
482 Int_t GetMaxRow() const { return fHC ? fHC->fRowMax : -1;} // Get maximum rows in the current HC
483 Int_t GetMaxCol() const { return fHC ? fHC->fColMax : -1;} // Get maximum cols in the current HC
484
485 UInt_t GetHCword0() const {return fHC ? *fHC->fPos[0] : 0;} // get the HC word 0
486 UInt_t GetHCword1() const {return fHC ? *fHC->fPos[1] : 0;} // get the HC word 1
487
488 Int_t GetDET() const {return fHC ? fHC->fDET : -1;} // get current det number
489 Int_t GetDet() const {return fHC ? fHC->fDET : -1;} // get current det number
490
491 Int_t GetROB() const {return fMCM ? fMCM->fROB : -1;} // get current ROB number
492 Int_t GetMCM() const {return fMCM ? fMCM->fMCM : -1;} // get current MCM number
493 Int_t GetEventNumber() const { return fMCM->fEvCounter;} // MCM Event number and position of current MCM on TRD chamber
494
495 Int_t GetADC() const { return fADC ? fADC->fADCnumber : -1;} // MCM ADC channel and Time Bin of word 1
496 Int_t GetTimeBin() const { return 0;} // MCM ADC channel and Time Bin of word 1
497 Int_t *GetSignals() const { return fADC ? fADC->fSignals : (Int_t *)fgEmptySignals;} // signals in the n-time bins from data word
498
499 Int_t GetHCErrorCode() const {return fHC ? fHC->fCorrupted : -1;} // get HC error code
500 Int_t GetH0ErrorCode() const {return fHC ? fHC->fH0Corrupted : -1;} // get HC header word0 error code
501 Int_t GetH1ErrorCode() const {return fHC ? fHC->fH1Corrupted : -1;} // get HC header word1 error code
502 Int_t GetMCMErrorCode() const {return fMCM ? fMCM->fCorrupted : -1;} // get MCM data error code
503 Int_t GetADCErrorCode() const {return fADC ? fADC->fCorrupted : -1;} // get ADC data error code
504 Int_t GetMCMhdErrorCode() const {return fMCM ? fMCM->fMCMhdCorrupted: -1;} // get MCM header word error code
505 Int_t GetMCMADCMaskErrorCode() const {return fMCM ? fMCM->fADCmaskCorrupted: -1;} // get MCM adc mask error code
506
507 UInt_t *GetSMstreamPosition() const {return fSM.fPos;} // get position of the SM index word in the buffer
508
509 Bool_t IsSMbufferClean() const {return fSM.fClean;} // is data clean
510
511 //----------------------------------------------------------
512
513 static void SetNoDebug() {fgDebugFlag = kFALSE;} // allow debug info
514 static void EnableMemoryReset() {fgEnableMemoryReset = kTRUE;} // allow memory reset
515 static void SetNoErrorWarning() {fgWarnError = kFALSE;} // disable warning and error info
516 static void SetForceCleanDataOnly() {fgCleanDataOnly = kTRUE;} // clean data only
517 static void AllowCorruptedData() {fgCleanDataOnly = kFALSE;} // accept corrupted data
518
519 static void SetExtraWordsFix() {fgExtraSkip = kTRUE;} // extra skip of 24 32-bit words
520 static void SetSkipCDH() {fgSkipCDH = kTRUE;} // skip of 8 32-bit words
521 static void SetDumpHead(Int_t iv) {fgDumpHead = iv;}
522 static void DisableStackNumberChecker() {fgStackNumberChecker = kFALSE;} // set false to cleanroom data
523 static void DisableStackLinkNumberChecker() {fgStackLinkNumberChecker = kFALSE;}
524 static void DisableSkipData() {fgSkipData = kFALSE;} // keep reading next words even previous words were corrupted - debugging purpose
525 static void SetDumpingEnable() {fgDumpingEnable = kTRUE;}
526 static void SetDumpingMCM(Int_t sm, Int_t stack, Int_t layer, Int_t rob, Int_t mcm) {fgDumpingSM = sm; fgDumpingStack = stack; fgDumpingLayer = layer; fgDumpingROB = rob; fgDumpingMCM = mcm;}
527
528 // this is a temporary solution!
529 // baseline should come with the HC header word 2 (count from 0!)
530 static void SetSubtractBaseline(Int_t baseline) {fgCommonAdditive = baseline;}
531 Int_t GetCommonAdditive() const {return fgCommonAdditive;} // return the common additive
532
533 static void EnableDecodeConfigData() {fgEnableDecodeConfigData = kTRUE;} // allow configuration data decoding
534 static Bool_t fgEnableDecodeConfigData; // flag to decode configuration data
535
536
537 //--------------------------------------------------------
538 // Decoding functions
539 //--------------------------------------------------------
540
541 void DecodeSMInfo(const UInt_t *word, struct AliTRDrawSM *sm) const ;
542 const char *DumpSMInfo(const struct AliTRDrawSM *sm);
543 void DecodeStackInfo(const UInt_t *word, struct AliTRDrawStack *st) const;
544 void DecodeStackHeader(const UInt_t *word, struct AliTRDrawStack *st, Int_t iword) const;
545 const char *DumpStackInfo(const struct AliTRDrawStack *st);
546 Bool_t DecodeHCwordH0(const UInt_t *word, struct AliTRDrawHC *hc) const;
547 Bool_t DecodeHCwordH1(const UInt_t *word, struct AliTRDrawHC *hc) const;
548 const char *DumpHCinfoH0(const struct AliTRDrawHC *hc);
549 const char *DumpHCinfoH1(const struct AliTRDrawHC *hc);
550 void DecodeMCMheader(const UInt_t *word, struct AliTRDrawMCM *mcm) const;
551 UInt_t GetMCMadcMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const;
552 void DecodeMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const;
553 void MCMADCwordsWithTbins(UInt_t fTbins, struct AliTRDrawMCM *mcm) const;
554 const char *DumpMCMinfo(const struct AliTRDrawMCM *mcm);
555 const char *DumpMCMadcMask(const struct AliTRDrawMCM *mcm);
556
557
558 protected:
559
560 Bool_t InitBuffer(void *buffer, UInt_t length); // init the buffer - called by DecodeSM(void*, UInt_t)
561 Bool_t DumpWords(UInt_t *px, UInt_t iw, UInt_t marker = 0); // dump some words onto the screen
562
563 void SwapOnEndian(); // swap if endian is BIG
564 Bool_t SkipWords(UInt_t iw); // skip number of words
565 Bool_t DecodeGTUheader(); // decode data in GTU header
566 Bool_t DecodeTracklets(); // decode tracklets
567 Bool_t DecodeHC(); // decode data in HC
568
569 Bool_t DecodeADC(); // decode 10 ADC words
570 Bool_t DecodeADCExtended(); // decode TRAP data with ZS and more than 32 samples
571
572 Bool_t DecodeHCheader(); // decode HC header
573 Bool_t SeekEndOfData(); // go to next end of raw data marker (actually 1 word after)
574 Bool_t SkipMCMdata(UInt_t iw); // skip this mcm data due to mcm header corruption
575 Bool_t SeekNextMCMheader(); // go to next mcm header
576 Bool_t DecodeMCMheader(); // decode mcm header
577
578 Bool_t IsRowValid(); // check if row within the range
579 Bool_t IsHCheaderOK(); // check if current hc header data make sense
580 Bool_t IsMCMheaderOK(); // check if current mcm header data make sense
581
582 void ResetCounters(); // reset some counters
583 void ResetIterators(); // needed for Next()
584 void ResetPerSM(); // reset every SM
585 void ResetPerStack(); // reset every Stack
586 void ResetPerHC(); // reset every HC
587 void ResetPerMCM(); // reset every MCM
588 void ResetPerADC(); // reset every ADC
589 void ResetMemory(); // reset all data members
590
591 AliTRDrawStream(const AliTRDrawStream& st);
592 AliTRDrawStream &operator=(const AliTRDrawStream &);
593
594 // ----------------- DATA MEMBERS START
595
596 struct AliTRDrawSM fSM; // one SM per buffer
597 struct AliTRDrawStack *fStack; //! pointer to the current stack
598 struct AliTRDrawHC *fHC; //! current HC
599 struct AliTRDrawMCM *fMCM; //! current MCM
600 struct AliTRDrawADC *fADC; //! current ADC
601
602 UInt_t *fpPos; // current position in the buffer
603 UInt_t *fpBegin; // begin - pointer to the buffer word 0
604 UInt_t *fpEnd; // end of the buffer
605
606 UInt_t fWordLength; // length of the buffer in 32bit words
607
608 Int_t fStackNumber; // current stack number
609 Int_t fStackLinkNumber; // current link in the stack
610
611 Int_t fhcMCMcounter; // mcm counter inside single hc - used in Next()
612 Int_t fmcmADCcounter; // adc counrer inside single adc - used in Next()
613
614 Int_t fLinkTrackletCounter; // count the tracklets in the current HC
615 Int_t fEndOfTrackletCount; // count link by link (hc by hc) used for debug
616 Int_t fNWordsCounter; // counts words of given hc having link monitor error
617
618 UInt_t fMaskADCword; // temp mask when decoding adcs
619 UInt_t fTbinADC; // temp adc
620 Int_t fDecodedADCs; // counter of decoded adcs [mj] do we need?
621
622 UInt_t fEventCounter; // stores the valid/current MCM event counter
623 UInt_t fLastEventCounter; // last known event counter of MCM
624
625 Bool_t fSharedPadsOn; // do we want to output shared pads - default is off
626 Int_t fMaxADCgeom; // maximum ADC channels per mcm
627
628 Bool_t fBufferRead; // set to be true if buffer is read for a given equipment
629
630 AliTRDgeometry *fGeometry; //! TRD geometry
631 AliRawReader *fRawReader; //! raw reader
632
633 AliTRDfeeParam *fTRDfeeParam; // pointer to the fee params
634
635 // STATIC
636
637 static Bool_t fgExtraSkip; // whether we should skip the leading 24 words
638 static Bool_t fgSkipCDH; // whether we should skip CDH (8 words)
639 static Bool_t fgWarnError; // no errors no warnings
640 static Bool_t fgCleanDataOnly; // release only clean events = no errors
641 static Bool_t fgDebugFlag; // allow debugging info
642 static Bool_t fgEnableMemoryReset; // allow memory reset
643 static Bool_t fgStackNumberChecker; // decide if we check stack number insanity - set false to cleanroom data
644 static Bool_t fgStackLinkNumberChecker; // decide if we check stack link number insanity - debuging purpose
645 static Bool_t fgSkipData; // decide if we skip corrupted data of given HC
646 static Int_t fgDumpHead; // number of words to dump (from the start of the buffer) on each Init
647 static Int_t fgEmptySignals[30]; // empty signals in case of ADC pointer = NULL
648 static Short_t fgMCMordering[16]; // mcm number odering for mcm header corruption check
649 static Short_t fgROBordering[16]; // mcm number odering for mcm header corruption check
650 static Int_t fgLastHC; // HC number indicator to check HC numbering
651 static Int_t fgLastROB; // ROB number indicator to check ROB numbering
652 static Int_t fgLastIndex; // variable to check mcm number odering
653
654 static Bool_t fgDumpingEnable; // flag to dump MCM data words
655
656 static Int_t fgDumpingSM; // sm number to dump MCM data words
657 static Int_t fgDumpingStack; // stack number to dump MCM data words
658 static Int_t fgDumpingLayer; // layer number to dump MCM data words
659 static Int_t fgDumpingROB; // rob number to dump MCM data words
660 static Int_t fgDumpingMCM; // mcm number to dump MCM data words
661
662 // this is a temporary solution!
663 // baseline should come with the HC header word 2 (count from 0!)
664 static Int_t fgCommonAdditive; // common additive - should be decoded! from HC word2
665
666 // ----------------- DATA MEMBERS STOP
667
668 enum ETRDzRawStreamError
669 {
670 kDecodeStackInfo = 1 //
671 , kMissingData = 2 //
672 , kLinkDataMissing = 3 //
673 , kHCdataMissing = 4 //
674 , kTrackletOverflow = 5 //
675 , kEOTrackeltsMissing = 6 //
676 , kWrongPadrow = 7 //
677 , kMCMheaderCorrupted = 8 //
678 , kWrongMCMorROB = 9 //
679 , kMCMeventMissmatch = 10 //
680 , kMCMADCMaskMissing = 11 //
681 , kHCHeaderCorrupt = 12 //
682 , kHCHeaderWrongStack = 13 //
683 , kHCHeaderWrongLayer = 14 //
684 , kHCHeaderWrongSide = 15 //
685 , kHCHeaderWrongSM = 16 //
686 , kHCHeaderWrongDet = 17 //
687 , kHCHeaderWrongROC = 18 //
688 , kHCWordMissing = 19 //
689 , kMCMdataMissing = 20 //
690 , kMCMoverflow = 21 //
691 , kADCdataMissing = 22 //
692 , kADCmaskMissmatch = 23 //
693 , kWrongPadcolumn = 24 //
694 };
695
696 ClassDef(AliTRDrawStream, 0)
697}; //clas def end
698
699#endif