]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDRawStreamV2.h
remove old version
[u/mrichter/AliRoot.git] / TRD / AliTRDRawStreamV2.h
1 #ifndef ALITRDRAWSTREAMV2_H
2 #define ALITRDRAWSTREAMV2_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////////////////
9 //                                                                           //
10 // This class provides access to TRD digits in raw data.                     //
11 //                                                                           //
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #include <TObject.h>
15
16 class AliTRDgeometry;
17 class AliRawReader;
18 class AliTRDdigitsManager;
19
20 class AliTRDRawStreamV2: public TObject {
21
22   public :
23
24     AliTRDRawStreamV2();
25     AliTRDRawStreamV2(AliRawReader *rawReader);
26     virtual ~AliTRDRawStreamV2();
27
28     virtual Bool_t       Next();                                //  Read the next data
29     virtual Int_t        NextChamber(AliTRDdigitsManager *man); //  Read next chamber data
30     virtual Int_t        Init();                                //  Init for the fRawVersion > 1
31
32     enum { kDDLOffset = 0x400 };                                //  Offset for DDL numbers
33
34     Bool_t               SetRawVersion(Int_t rv);
35     Int_t                GetRawVersion() const                      { return fRawVersion;     };
36     void                 SetRawReader(AliRawReader *rawReader);
37
38     // Get Filter settings (does not make a lot of sense):
39     Int_t                TRAPfilterTCon() const                     { return fTCon;           };
40     Int_t                TRAPfilterPEDon() const                    { return fPEDon;          };
41     Int_t                TRAPfilterGAINon() const                   { return fGAINon;         };
42     Int_t                TRAPsendsUnfilteredData() const            { return fBypass;         };
43
44     // Get Tracklet parameters (does not make a lot of sense):
45     Float_t              GetTrackletPID() const                     { return fTracklPID;      };
46     Float_t              GetTrackletDeflLength() const              { return fTracklDefL;     };
47     Float_t              GetTrackletPadPos() const                  { return fTracklPadPos;   };
48     Int_t                GetTrackletPadRow() const                  { return fTracklPadRow;   };
49
50     // Check if the link has optical power (HC sends data)
51     Bool_t               IsGTULinkActive(Int_t sm, Int_t la, Int_t sta, Int_t side)
52       { return ( ((fGTUlinkMask[sm][sta]) >> (2*la+side)) & 0x1 ); };
53
54     Int_t *GetSignals()          { return fSig;     } //  Signals in the three time bins from Data Word
55     Int_t GetADC() const         { return fADC;     } //  MCM ADC channel and Time Bin of word 1
56     Int_t GetTimeBin() const     { return fTB - 3;  } //  MCM ADC channel and Time Bin of word 1
57     Int_t GetEventNumber() const { return fEv;      } //  MCM Event number and position of current MCM on TRD chamber
58     Int_t GetROB() const         { return fROB;     } //  MCM Event number and position of current MCM on TRD chamber
59     Int_t GetMCM() const         { return fMCM;     } //  MCM Event number and position of current MCM on TRD chamber
60     Int_t GetSM() const          { return fSM;      } //  Position of CURRENT half chamber in full TRD
61     Int_t GetLayer() const       { return fLAYER;   } //  PLANE = Position of CURRENT half chamber in full TRD
62     Int_t GetStack() const       { return fSTACK;   } //  CHAMBER = Position of CURRENT half chamber in full TRD
63     Int_t GetROC() const         { return fROC;     } //  Position of CURRENT half chamber in full TRD
64     Int_t GetSide() const        { return fSIDE;    } //  Position of CURRENT half chamber in full TRD
65     Int_t GetDCS() const         { return fDCS;     } //  DCS board number read from data (HC header)
66     Int_t GetRow() const         { return fROW;     }
67     Int_t GetCol() const         { return fCOL;     } //  Detector Pad coordinates
68     Int_t GetDet() const         { return fDET;     } //  Helper
69     Int_t GetLastDet() const     { return fLastDET; } //  Helper
70     Int_t GetMaxRow() const      { return fRowMax;  }
71     Int_t GetMaxCol() const      { return fColMax;  }
72     Int_t GetNumberOfTimeBins() const 
73                                  { return fTBins;   }
74     
75     void SwapOnEndian();
76
77  protected:
78
79     AliTRDgeometry *fGeo;                     //  TRD geometry
80
81     Bool_t DecodeGTUlinkMask();
82     Bool_t DecodeNextRawWord();
83     Bool_t DecodeMCM();
84     Bool_t DecodeHC();
85     Bool_t DecodeSM();
86     inline void ChangeStatus(Int_t kstat);
87 /*       { */
88 /*      fLastStatus = fNextStatus; */
89 /*      fNextStatus = kstat;   */
90 /*       } */
91
92     void  DecodeHCheader(Int_t timeBins = 0);
93     void  DecodeMCMheader();
94     void  DecodeTracklet();
95
96     void  SetRawDigitThreshold (Int_t ith) 
97                 { fRawDigitThreshold = ith; } //  Set the naive zero suppression threshold
98
99     Int_t NextData();                         //  Get the next piece of memory
100     Int_t ChannelsToRead(Int_t ADCmask);      //  Get the active ADC channels from the mask (V3 and 2)
101
102     enum { kStart
103          , kStop
104          , kWordOK
105          , kNoMoreData
106          , kNextSM
107          , kNextHC
108          , kSeekNonEoTracklet
109          , kDecodeHC
110          , kNextMCM
111          , kNextData
112          , kReading };
113
114     // Some constants:
115     static const UInt_t fgkEndoftrackletmarker = 0xAAAAAAAA;     //  This marks the end of tracklet data words
116     static const UInt_t fgkEndofrawdatamarker  = 0x00000000;     //  This marks the end of half-chamber-data
117     static const UInt_t fgkSizeWord            = sizeof(UInt_t); //  Size of a word in bytes
118
119   private :
120
121     Int_t    fSig[3];                                            //  Signals in the three time bins from Data Word
122     Int_t    fADC;                                               //  MCM ADC channel and Time Bin of word 1
123     Int_t    fTB;                                                //  MCM ADC channel and Time Bin of word 1
124     Int_t    fEv;                                                //  MCM Event number and position of current MCM on TRD chamber
125     Int_t    fROB;                                               //  MCM Event number and position of current MCM on TRD chamber
126     Int_t    fMCM;                                               //  MCM Event number and position of current MCM on TRD chamber
127     Int_t    fSM;                                                //  Position of CURRENT half chamber in full TRD
128     Int_t    fLAYER;                                             //  Position of CURRENT half chamber in full TRD
129     Int_t    fSTACK;                                             //  Position of CURRENT half chamber in full TRD
130     Int_t    fROC;                                               //  Position of CURRENT half chamber in full TRD
131     Int_t    fSIDE;                                              //  Position of CURRENT half chamber in full TRD
132     Int_t    fDCS;                                               //  DCS board number read from data (HC header)
133     Int_t    fROW;                                               //  Detector Row coordinates
134     Int_t    fCOL;                                               //  Detector Pad coordinates
135     Int_t    fDET;                                               //  Current detector - version > 1
136     Int_t    fLastDET;                                           //  Previous detector - version > 1
137
138     Int_t    fBCctr;                                             //  Counters from HC header (>=V2)
139     Int_t    fPTctr;                                             //  Counters from HC header (>=V2)
140     Int_t    fPTphase;                                           //  Counters from HC header (>=V2)
141     Int_t    fRVmajor;                                           //  Raw version numbers and number of additional HC headerwords (>=V2)
142     Int_t    fRVminor;                                           //  Raw version numbers and number of additional HC headerwords (>=V2)
143     Int_t    fHCHWords;                                          //  Raw version numbers and number of additional HC headerwords (>=V2)
144     Int_t    fTBins;                                             //  Number of time bins read from HC header (>=V2)
145     Bool_t   fTCon;                                              //  Filter settings read from HC header (>=V2)
146     Bool_t   fPEDon;                                             //  Filter settings read from HC header (>=V2)
147     Bool_t   fGAINon;                                            //  Filter settings read from HC header (>=V2)
148     Bool_t   fXTon;                                              //  Filter settings read from HC header (>=V2)
149     Bool_t   fNonLinOn;                                          //  Filter settings read from HC header (>=V2)
150     Bool_t   fBypass;                                            //  Filter settings read from HC header (>=V2)
151     Int_t    fCommonAdditive;                                    //  Common baseline additive read from HC header (>=V2)
152
153     Bool_t   fZeroSuppressed;                                    //  Data is zero suppressed
154
155     Int_t    fHCHctr1;                        //  HC and MCM Header counter
156     Int_t    fHCHctr2;                        //  HC and MCM Header counter
157     Int_t    fMCMHctr1;                       //  HC and MCM Header counter
158     Int_t    fMCMHctr2;                       //  HC and MCM Header counter
159     Int_t    fGTUctr1;                        //  GTU LinkMask Counter
160     Int_t    fGTUctr2;                        //  GTU LinkMask Counter
161     Int_t    fHCdataCtr;                      //  Data Counter for half chamber
162     
163     Float_t  fTracklPID;                      //  Tracklet parameters
164     Float_t  fTracklDefL;                     //  Tracklet parameters
165     Float_t  fTracklPadPos;                   //  Tracklet parameters
166     Int_t    fTracklPadRow;                   //  Tracklet parameters
167
168     UShort_t fGTUlinkMask[18][5];             //  Mask with active links
169
170     Int_t    fMCMWordCrt;                     //  Word Counter for a single MCM
171     Int_t    fMCMWordsExpected;               //  Expected Words from MCM 
172
173     AliTRDRawStreamV2(const AliTRDRawStreamV2 &stream);
174     AliTRDRawStreamV2 &operator=(const AliTRDRawStreamV2 &stream);
175
176     AliRawReader *fRawReader;                 //  Object for reading the raw data
177
178     Int_t    fRawVersion;                     //  Which version of raw data decoding is used
179     Int_t    fRawDigitThreshold;              //  Naive "zero"(threshold) supression. Usefull for Raw Data ver 2.
180
181     Int_t    fNextStatus;                     //  Navigation in raw versions > 1
182     Int_t    fLastStatus;                     //  Navigation in raw versions > 1
183     UInt_t   fTbSwitch;                       //  Time Bin Switch for internal use
184     UInt_t   fTbSwitchCtr;                    //  Counter for internal use
185     UInt_t   fTimeWords;                      //  Number of Words needed to store the data of 1 ADC ch.
186     UInt_t   fWordCtr;                        //  Word Counter
187
188     Int_t    fRowMax;                         //  Maximum number of pad rows and columns
189     Int_t    fColMax;                         //  Maximum number of pad rows and columns
190
191     Bool_t   fADCmask[21];                    //  Mask of active ADCs for zero suppression
192     UInt_t   fLastADCmask;                    //  Last ADC read out
193
194     UShort_t fChamberDone[540];               //  Chamber was processed already (1=1HC, 2=full chamber)
195
196     Int_t    fRetVal;                         //  Datadecode return
197     Int_t    fEqID;                           //  Equipment id
198     UInt_t   fDataSize;                       //  Size of the data available in the current buffer
199     Bool_t   fSizeOK;                         //  Did we read anything
200     UInt_t   fCountBytes;                     //  Bytes traversed in the buffer
201     UInt_t   fBufSize;                        //  Size of the current RawReader buffer
202     Bool_t   fkBufferSet;                     //  Is the RawReader buffer available
203     UChar_t *fPos;                            //  Position in the buffer of the RawReader
204     UInt_t  *fDataWord;                       //  The pointer to the current 32 bit data word
205     UInt_t   fTimeBinsCalib;                  //  N of time bins retrieved from calibration
206
207     Int_t    fADClookup[32];                  //  Lookup for version 3 (1[entries]+1[index]+30[fADC channels] = 32)
208     Int_t    fNActiveADCs;                    //  Number of active ADC channels
209     Bool_t   fEndOfDataFlag;                  //  End of data flag
210
211     enum ETRDzRawStreamError {
212        kHCWordMissing       =  1              //
213       ,kMCMADCMaskMissing   =  2              //
214       ,kWrongMCMorROB       =  3              //
215       ,kGTULinkMaskMissing  =  4              //
216       ,kHCHeaderCorrupt     =  5              //
217       ,kHCHeaderMissing     =  6              //
218       ,kROBSideMismatch     =  7              //
219       ,kWrongPadrow         =  8              //
220       ,kWrongPadcolumn      =  9              //
221       ,kTrackletRowMismatch = 10              //
222       ,kDataMaskError       = 11              //
223       ,kADCNumberOverflow   = 12              //
224       ,kADCChannelOverflow  = 13              //
225     };
226     
227     ClassDef(AliTRDRawStreamV2,1)                                //  Class for reading TRD raw digits
228
229 };
230 #endif