]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDRawStream.h
New TRD raw data reader (v1 + v2) by Christian
[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 class AliTRDdataArrayI;
20
21 // Some constants:
22 const UInt_t end_of_tracklet_marker = 0xAAAAAAAA; /*This marks the end of tracklet data words*/
23 const UInt_t end_of_event_marker    = 0x00000000; /*This marks the end of half-chamber-data*/
24
25 class AliTRDRawStream: public TObject {
26
27   public :
28
29     AliTRDRawStream();
30     AliTRDRawStream(AliRawReader *rawReader);
31     AliTRDRawStream(AliRawReader *rawReader, AliTRDdigitsManager *man, AliTRDdataArrayI *dig);
32     virtual ~AliTRDRawStream();
33
34     virtual Bool_t       Next();              // Next function (for fRawVersion = 0 (Bogdans first version))
35     virtual Bool_t       ReadAll();           // Read function (for fRawVersion > 0)
36
37     Int_t                GetDetector() const                        { return fDetector;       };
38     Int_t                GetPrevDetector() const                    { return fPrevDetector;   };
39     Bool_t               IsNewDetector() const                      { return fDetector != fPrevDetector; };
40     Int_t                GetNPads() const                           { return fNPads;          };
41     Int_t                GetRow() const                             { return fRow;            };
42     Int_t                GetPrevRow() const                         { return fPrevRow;        };
43     Bool_t               IsNewRow() const                           { return (fRow != fPrevRow) || IsNewDetector();  };
44     Int_t                GetColumn() const                          { return fColumn;         };
45     Int_t                GetPrevColumn() const                      { return fPrevColumn;     };
46     Bool_t               IsNewColumn() const                        { return (fColumn != fPrevColumn) || IsNewRow(); };
47     Int_t                GetTime() const                            { return fTime-1;         };
48     Int_t                GetSignal() const                          { return fSignal;         };
49
50     enum { kDDLOffset = 0x400 };              // Offset for DDL numbers
51
52     void                 SetDigitsManager(AliTRDdigitsManager *man) { fDigitsManager   = man; };
53     void                 SetDigits(AliTRDdataArrayI *dig)           { fDigits          = dig; };
54
55     AliTRDdigitsManager *GetDigitsManager() const                   { return fDigitsManager;  };
56
57     Bool_t               SetRawVersion(Int_t rv);
58     Int_t                GetRawVersion() const                      { return fRawVersion;     };
59
60     // Check if the link has optical power (HC sends data)
61     Bool_t               IsGTULinkActive(Int_t sm, Int_t la, Int_t sta, Int_t side)
62                                   { return ( ((fGTUlinkMask[sm][sta]) >> (2*la+side)) & 0x1 ); };
63
64
65     Int_t    fSig[3];                         //  Signals in the three time bins from Data Word
66     Int_t    fADC;                            //  MCM ADC channel and Time Bin of word 1
67     Int_t    fTB;                             //  MCM ADC channel and Time Bin of word 1
68     Int_t    fEv;                             //  MCM Event number and position of current MCM on TRD chamber
69     Int_t    fROB;                            //  MCM Event number and position of current MCM on TRD chamber
70     Int_t    fMCM;                            //  MCM Event number and position of current MCM on TRD chamber
71     Int_t    fSM;                             //  Position of CURRENT half chamber in full TRD
72     Int_t    fLAYER;                          //  Position of CURRENT half chamber in full TRD
73     Int_t    fSTACK;                          //  Position of CURRENT half chamber in full TRD
74     Int_t    fROC;                            //  Position of CURRENT half chamber in full TRD
75     Int_t    fSIDE;                           //  Position of CURRENT half chamber in full TRD
76     Int_t    fDCS;                            //  DCS board number read from data (HC header)
77     Int_t    fROW;
78     Int_t    fCOL;                            //  Detector Pad coordinates
79
80     Int_t    fBCctr;                          //  Counters from HC header (>=V2)
81     Int_t    fPTctr;                          //  Counters from HC header (>=V2)
82     Int_t    fPTphase;                        //  Counters from HC header (>=V2)
83     Int_t    fRVmajor;                        //  Raw version numbers and number of additional HC headerwords (>=V2)
84     Int_t    fRVminor;                        //  Raw version numbers and number of additional HC headerwords (>=V2)
85     Int_t    fHCHWords;                       //  Raw version numbers and number of additional HC headerwords (>=V2)
86     Int_t    fTBins;                          //  Number of time bins read from HC header (>=V2)
87     Int_t    fTCon;                           //  Filter settings read from HC header (>=V2)
88     Int_t    fPEDon;                          //  Filter settings read from HC header (>=V2)
89     Int_t    fGAINon;                         //  Filter settings read from HC header (>=V2)
90     Int_t    fFiltered;                       //  Filter settings read from HC header (>=V2)
91
92     Int_t    fHCHctr1;                        //  HC and MCM Header counter
93     Int_t    fHCHctr2;                        //  HC and MCM Header counter
94     Int_t    fMCMHctr1;                       //  HC and MCM Header counter
95     Int_t    fMCMHctr2;                       //  HC and MCM Header counter
96     Int_t    fGTUctr1;                        //  GTU LinkMask Counter
97     Int_t    fGTUctr2;                        //  GTU LinkMask Counter
98
99     Float_t  fTracklPID;                      //  Tracklet parameters
100     Float_t  fTracklDefL;                     //  Tracklet parameters
101     Float_t  fTracklPadPos;                   //  Tracklet parameters
102     Int_t    fTracklPadRow;                   //  Tracklet parameters
103
104     UShort_t fGTUlinkMask[18][5];             //  Mask with active links
105
106   private :
107
108     AliTRDRawStream(const AliTRDRawStream &stream);
109     AliTRDRawStream &operator=(const AliTRDRawStream &stream);
110
111     AliRawReader *fRawReader;              //  Object for reading the raw data
112
113     // The following is used by V0 (from Bogdan, offline use only):
114     Int_t    fCount;                       //  Counter of bytes to be read for current detector
115     Int_t    fDetector;                    //  Index of current detector
116     Int_t    fPrevDetector;                //  Index of previous detector
117     Int_t    fNPads;                       //  Number of active pads
118     Int_t    fRow;                         //  Index of current pad row
119     Int_t    fPrevRow;                     //  Index of previous pad row
120     Int_t    fColumn;                      //  Index of current pad column
121     Int_t    fPrevColumn;                  //  Index of previous pad column
122     Int_t    fTime;                        //  Index of current time bin
123     Int_t    fSignal;                      //  Signal in ADC counts
124
125     // This is again new:
126     Int_t    fRawVersion;                  //  Which version of raw data decoding is used
127     UInt_t   fDataWord;                    //  The current 32 bit data word
128     Int_t    fStatus;                      //  Status of Raw data Reading
129
130     Int_t    fRowMax;                      //  Maximum number of pad rows and columns
131     Int_t    fColMax;                      //  Maximum number of pad rows and columns
132     Bool_t   fChamberDone[540];            //  Chamber was processed already?
133
134  protected:
135
136     AliTRDgeometry *fGeo;                  //  TRD geometry
137
138     AliTRDdigitsManager *fDigitsManager;   //! Manager for the output digits
139     AliTRDdataArrayI    *fDigits;          //! The Output digits
140     AliTRDdataArrayI    *fTrack0;          //! The track dictionary
141     AliTRDdataArrayI    *fTrack1;          //! The track dictionary
142     AliTRDdataArrayI    *fTrack2;          //! The track dictionary
143
144     void  DecodeHCheader(Int_t timeBins);
145     void  DecodeHCheaderV1();              // Valid for fRawversion = 1
146     void  DecodeHCheaderV2(Int_t imeBins); // Valid for fRawversion = 2,3,4
147
148     void  DecodeMCMheader();
149     void  DecodeMCMheaderV1();             // Valid for fRawversion = 1,2,3,4
150
151     void  DecodeTracklet();
152     void  DecodeTrackletV1();              // Valid for fRawversion = 1,2,3,4
153
154     void  DecodeGTUlinkMask();
155     void  DecodeGTUlinkMaskV1();           // Valid for fRawversion = 1,2,3,4
156
157     ClassDef(AliTRDRawStream, 2)           // Class for reading TRD raw digits
158
159 };
160 #endif