]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDRawStream.h
BlockFilter component added; minor corrections
[u/mrichter/AliRoot.git] / TRD / AliTRDRawStream.h
1 #ifndef ALITRDRAWSTREAM_H
2 #define ALITRDRAWSTREAM_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 // Some constants:
21 const UInt_t kEndoftrackletmarker = 0xAAAAAAAA; /*This marks the end of tracklet data words*/
22 const UInt_t kEndofrawdatamarker  = 0x00000000; /*This marks the end of half-chamber-data*/
23 const UInt_t kSizeWord = sizeof(UInt_t);
24
25 class AliTRDRawStream: public TObject {
26
27   public :
28
29     AliTRDRawStream();
30     AliTRDRawStream(AliRawReader *rawReader);
31     virtual ~AliTRDRawStream();
32
33     virtual Bool_t       Next();              // Read the next data
34     virtual Int_t NextChamber(AliTRDdigitsManager *man); // read next chamber data
35     virtual Int_t        Init();              // Init for the fRawVersion > 1
36
37     enum { kDDLOffset = 0x400 };              // Offset for DDL numbers
38
39     Bool_t               SetRawVersion(Int_t rv);
40     Int_t                GetRawVersion() const                      { return fRawVersion;     };
41     void                 SetRawReader(AliRawReader *rawReader);
42
43     // Get Filter settings (does not make a lot of sense):
44     Int_t                TRAPfilterTCon() const                     { return fTCon;           };
45     Int_t                TRAPfilterPEDon() const                    { return fPEDon;          };
46     Int_t                TRAPfilterGAINon() const                   { return fGAINon;         };
47     Int_t                TRAPsendsUnfilteredData() const            { return fBypass;         };
48
49     // Get Tracklet parameters (does not make a lot of sense):
50     Float_t              GetTrackletPID() const                     { return fTracklPID;      };
51     Float_t              GetTrackletDeflLength() const              { return fTracklDefL;     };
52     Float_t              GetTrackletPadPos() const                  { return fTracklPadPos;   };
53     Int_t                GetTrackletPadRow() const                  { return fTracklPadRow;   };
54
55     // Check if the link has optical power (HC sends data)
56     Bool_t               IsGTULinkActive(Int_t sm, Int_t la, Int_t sta, Int_t side)
57       { return ( ((fGTUlinkMask[sm][sta]) >> (2*la+side)) & 0x1 ); };
58
59     Int_t *GetSignals() { return fSig;}                         //  Signals in the three time bins from Data Word
60     Int_t GetADC() const { return fADC;}                            //  MCM ADC channel and Time Bin of word 1
61     Int_t GetTimeBin() const { return fTB - 3;}                             //  MCM ADC channel and Time Bin of word 1
62     Int_t GetEventNumber() const { return fEv;}                             //  MCM Event number and position of current MCM on TRD chamber
63     Int_t GetROB() const { return fROB;}                            //  MCM Event number and position of current MCM on TRD chamber
64     Int_t GetMCM() const { return fMCM;}                           //  MCM Event number and position of current MCM on TRD chamber
65     Int_t GetSM() const { return fSM;}                             //  Position of CURRENT half chamber in full TRD
66     Int_t GetLayer() const { return fLAYER;}                          //  PLANE = Position of CURRENT half chamber in full TRD
67     Int_t GetStack() const { return fSTACK;}                          //  CHAMBER = Position of CURRENT half chamber in full TRD
68     Int_t GetROC() const { return fROC;}                            //  Position of CURRENT half chamber in full TRD
69     Int_t GetSide() const { return fSIDE;}                           //  Position of CURRENT half chamber in full TRD
70     Int_t GetDCS() const { return fDCS;}                            //  DCS board number read from data (HC header)
71     Int_t GetRow() const { return fROW;}
72     Int_t GetCol() const { return fCOL;}                            //  Detector Pad coordinates
73     Int_t GetDet() const { return fDET;} // helper
74     Int_t GetLastDet() const { return fLastDET;} // helper
75     Int_t GetMaxRow() const { return fRowMax;}
76     Int_t GetMaxCol() const { return fColMax;}
77     Int_t GetNumberOfTimeBins() const {return fTBins;}
78
79   private :
80
81     Int_t    fSig[3];                         //  Signals in the three time bins from Data Word
82     Int_t    fADC;                            //  MCM ADC channel and Time Bin of word 1
83     Int_t    fTB;                             //  MCM ADC channel and Time Bin of word 1
84     Int_t    fEv;                             //  MCM Event number and position of current MCM on TRD chamber
85     Int_t    fROB;                            //  MCM Event number and position of current MCM on TRD chamber
86     Int_t    fMCM;                            //  MCM Event number and position of current MCM on TRD chamber
87     Int_t    fSM;                             //  Position of CURRENT half chamber in full TRD
88     Int_t    fLAYER;                          //  Position of CURRENT half chamber in full TRD
89     Int_t    fSTACK;                          //  Position of CURRENT half chamber in full TRD
90     Int_t    fROC;                            //  Position of CURRENT half chamber in full TRD
91     Int_t    fSIDE;                           //  Position of CURRENT half chamber in full TRD
92     Int_t    fDCS;                            //  DCS board number read from data (HC header)
93     Int_t    fROW;                            //  Detector Row coordinates
94     Int_t    fCOL;                            //  Detector Pad coordinates
95     Int_t    fDET;                            //  Current detector - version > 1
96     Int_t    fLastDET;                        //  Previous detector - version > 1
97
98     Int_t    fBCctr;                          //  Counters from HC header (>=V2)
99     Int_t    fPTctr;                          //  Counters from HC header (>=V2)
100     Int_t    fPTphase;                        //  Counters from HC header (>=V2)
101     Int_t    fRVmajor;                        //  Raw version numbers and number of additional HC headerwords (>=V2)
102     Int_t    fRVminor;                        //  Raw version numbers and number of additional HC headerwords (>=V2)
103     Int_t    fHCHWords;                       //  Raw version numbers and number of additional HC headerwords (>=V2)
104     Int_t    fTBins;                          //  Number of time bins read from HC header (>=V2)
105     Bool_t   fTCon;                           //  Filter settings read from HC header (>=V2)
106     Bool_t   fPEDon;                          //  Filter settings read from HC header (>=V2)
107     Bool_t   fGAINon;                         //  Filter settings read from HC header (>=V2)
108     Bool_t   fXTon;                           //  Filter settings read from HC header (>=V2)
109     Bool_t   fNonLinOn;                       //  Filter settings read from HC header (>=V2)
110     Bool_t   fBypass;                         //  Filter settings read from HC header (>=V2)
111     Int_t    fCommonAdditive;                 //  Common baseline additive read from HC header (>=V2)
112
113     Bool_t   fZeroSuppressed;                 // Data is zero suppressed
114
115     Int_t    fHCHctr1;                        //  HC and MCM Header counter
116     Int_t    fHCHctr2;                        //  HC and MCM Header counter
117     Int_t    fMCMHctr1;                       //  HC and MCM Header counter
118     Int_t    fMCMHctr2;                       //  HC and MCM Header counter
119     Int_t    fGTUctr1;                        //  GTU LinkMask Counter
120     Int_t    fGTUctr2;                        //  GTU LinkMask Counter
121     Int_t    fHCdataCtr;                      //  Data Counter for half chamber
122
123     Float_t  fTracklPID;                      //  Tracklet parameters
124     Float_t  fTracklDefL;                     //  Tracklet parameters
125     Float_t  fTracklPadPos;                   //  Tracklet parameters
126     Int_t    fTracklPadRow;                   //  Tracklet parameters
127
128     UShort_t fGTUlinkMask[18][5];             //  Mask with active links
129
130     AliTRDRawStream(const AliTRDRawStream &stream);
131     AliTRDRawStream &operator=(const AliTRDRawStream &stream);
132
133     AliRawReader *fRawReader;              //  Object for reading the raw data
134
135     Int_t    fRawVersion;                  //  Which version of raw data decoding is used
136
137     Int_t    fNextStatus;                  //  Navigation in raw versions > 1
138     UInt_t   fTbSwitch;                    //  Time Bin Switch for internal use
139     UInt_t   fTbSwitchCtr;                 //  Counter for internal use
140     UInt_t   fTimeWords;                   //  Number of Words needed to store the data of 1 ADC ch.
141     UInt_t   fWordCtr;                     //  Word Counter
142
143     Int_t    fRowMax;                      //  Maximum number of pad rows and columns
144     Int_t    fColMax;                      //  Maximum number of pad rows and columns
145
146     Bool_t   fADCmask[21];                 //  Mask of active ADCs for zero suppression
147     UShort_t fChamberDone[540];            //  Chamber was processed already (1=1HC, 2=full chamber)
148
149     Int_t    fRetVal;                      //  Datadecode return
150     Int_t    fEqID;                        //  Equipment id
151     UInt_t   fDataSize;                    //  Size of the data available in the current buffer
152     Bool_t   fSizeOK;                      //  Did we read anything
153     UInt_t   fCountBytes;                  //  Bytes traversed in the buffer
154     UInt_t   fBufSize;                     //  Size of the current RawReader buffer
155     Bool_t   fkBufferSet;                  //  Is the RawReader buffer available
156     UChar_t *fPos;                         //  Position in the buffer of the RawReader
157     UInt_t  *fDataWord;                    //  The pointer to the current 32 bit data word
158     UInt_t   fTimeBinsCalib;               //  N of time bins retrieved from calibration
159
160     enum ETRDzRawStreamError {
161        kHCWordMissing = 1                  //
162       ,kMCMADCMaskMissing = 2              //
163       ,kWrongMCMorROB = 3                  //
164       ,kGTULinkMaskMissing = 4             //
165       ,kHCHeaderCorrupt = 5                //
166       ,kHCHeaderMissing = 6                //
167       ,kROBSideMismatch = 7                //
168       ,kWrongPadrow = 8                    //
169       ,kWrongPadcolumn = 9                 //
170       ,kTrackletRowMismatch = 10           //
171       ,kDataMaskError = 11                 //
172       ,kADCNumberOverflow = 12             //
173       ,kADCChannelOverflow = 13            //
174     };
175
176  protected:
177
178     AliTRDgeometry *fGeo;                  //  TRD geometry
179
180     void  DecodeHCheader(Int_t timeBins);
181     void  DecodeMCMheader();
182     void  DecodeTracklet();
183     void  DecodeGTUlinkMask();
184     Int_t DecodeDataWord();
185     Int_t DecodeDataWordV1V2();                // Valid for fRawversion = 1, 2, ... 
186     Int_t DecodeDataWordV3();                  // Valid for fRawversion = 3, ... 
187
188     Int_t NextData(); // get the next piece of memory
189
190     enum { fkStart, fkStop, fkWordOK, fkNoMoreData, fkNextSM, fkNextHC, fkSeekNonEoTracklet, fkDecodeHC, fkNextMCM, fkNextData, fkReading};
191     
192     ClassDef(AliTRDRawStream, 5)               // Class for reading TRD raw digits
193
194 };
195 #endif