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