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