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