]>
Commit | Line | Data |
---|---|---|
ecf39416 | 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 {return fTBins;} | |
73 | ||
74 | private : | |
75 | ||
76 | Int_t fSig[3]; // Signals in the three time bins from Data Word | |
77 | Int_t fADC; // MCM ADC channel and Time Bin of word 1 | |
78 | Int_t fTB; // MCM ADC channel and Time Bin of word 1 | |
79 | Int_t fEv; // MCM Event number and position of current MCM on TRD chamber | |
80 | Int_t fROB; // MCM Event number and position of current MCM on TRD chamber | |
81 | Int_t fMCM; // MCM Event number and position of current MCM on TRD chamber | |
82 | Int_t fSM; // Position of CURRENT half chamber in full TRD | |
83 | Int_t fLAYER; // Position of CURRENT half chamber in full TRD | |
84 | Int_t fSTACK; // Position of CURRENT half chamber in full TRD | |
85 | Int_t fROC; // Position of CURRENT half chamber in full TRD | |
86 | Int_t fSIDE; // Position of CURRENT half chamber in full TRD | |
87 | Int_t fDCS; // DCS board number read from data (HC header) | |
88 | Int_t fROW; // Detector Row coordinates | |
89 | Int_t fCOL; // Detector Pad coordinates | |
90 | Int_t fDET; // Current detector - version > 1 | |
91 | Int_t fLastDET; // Previous detector - version > 1 | |
92 | ||
93 | Int_t fBCctr; // Counters from HC header (>=V2) | |
94 | Int_t fPTctr; // Counters from HC header (>=V2) | |
95 | Int_t fPTphase; // Counters from HC header (>=V2) | |
96 | Int_t fRVmajor; // Raw version numbers and number of additional HC headerwords (>=V2) | |
97 | Int_t fRVminor; // Raw version numbers and number of additional HC headerwords (>=V2) | |
98 | Int_t fHCHWords; // Raw version numbers and number of additional HC headerwords (>=V2) | |
99 | Int_t fTBins; // Number of time bins read from HC header (>=V2) | |
100 | Bool_t fTCon; // Filter settings read from HC header (>=V2) | |
101 | Bool_t fPEDon; // Filter settings read from HC header (>=V2) | |
102 | Bool_t fGAINon; // Filter settings read from HC header (>=V2) | |
103 | Bool_t fXTon; // Filter settings read from HC header (>=V2) | |
104 | Bool_t fNonLinOn; // Filter settings read from HC header (>=V2) | |
105 | Bool_t fBypass; // Filter settings read from HC header (>=V2) | |
106 | Int_t fCommonAdditive; // Common baseline additive read from HC header (>=V2) | |
107 | ||
108 | Bool_t fZeroSuppressed; // Data is zero suppressed | |
109 | ||
110 | Int_t fHCHctr1; // HC and MCM Header counter | |
111 | Int_t fHCHctr2; // HC and MCM Header counter | |
112 | Int_t fMCMHctr1; // HC and MCM Header counter | |
113 | Int_t fMCMHctr2; // HC and MCM Header counter | |
114 | Int_t fGTUctr1; // GTU LinkMask Counter | |
115 | Int_t fGTUctr2; // GTU LinkMask Counter | |
116 | Int_t fHCdataCtr; // Data Counter for half chamber | |
117 | ||
118 | Float_t fTracklPID; // Tracklet parameters | |
119 | Float_t fTracklDefL; // Tracklet parameters | |
120 | Float_t fTracklPadPos; // Tracklet parameters | |
121 | Int_t fTracklPadRow; // Tracklet parameters | |
122 | ||
123 | UShort_t fGTUlinkMask[18][5]; // Mask with active links | |
124 | ||
125 | Int_t fMCMWordCrt; // Word Counter for a single MCM | |
126 | Int_t fMCMWordsExpected; // Expected Words from MCM | |
127 | ||
128 | AliTRDRawStreamV2(const AliTRDRawStreamV2 &stream); | |
129 | AliTRDRawStreamV2 &operator=(const AliTRDRawStreamV2 &stream); | |
130 | ||
131 | AliRawReader *fRawReader; // Object for reading the raw data | |
132 | ||
133 | Int_t fRawVersion; // Which version of raw data decoding is used | |
134 | Int_t fRawDigitThreshold; // Naive "zero"(threshold) supression. Usefull for Raw Data ver 2. | |
135 | ||
136 | Int_t fNextStatus; // Navigation in raw versions > 1 | |
137 | Int_t fLastStatus; // 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 | UInt_t fLastADCmask; // Last ADC read out | |
148 | ||
149 | UShort_t fChamberDone[540]; // Chamber was processed already (1=1HC, 2=full chamber) | |
150 | ||
151 | Int_t fRetVal; // Datadecode return | |
152 | Int_t fEqID; // Equipment id | |
153 | UInt_t fDataSize; // Size of the data available in the current buffer | |
154 | Bool_t fSizeOK; // Did we read anything | |
155 | UInt_t fCountBytes; // Bytes traversed in the buffer | |
156 | UInt_t fBufSize; // Size of the current RawReader buffer | |
157 | Bool_t fkBufferSet; // Is the RawReader buffer available | |
158 | UChar_t *fPos; // Position in the buffer of the RawReader | |
159 | UInt_t *fDataWord; // The pointer to the current 32 bit data word | |
160 | UInt_t fTimeBinsCalib; // N of time bins retrieved from calibration | |
161 | ||
162 | Int_t fADClookup[32]; // Lookup for version 3 (1[entries]+1[index]+30[fADC channels] = 32) | |
163 | Int_t fNActiveADCs; // Number of active ADC channels | |
164 | Bool_t fEndOfDataFlag; // End of data flag | |
165 | ||
166 | enum ETRDzRawStreamError { | |
167 | kHCWordMissing = 1 // | |
168 | ,kMCMADCMaskMissing = 2 // | |
169 | ,kWrongMCMorROB = 3 // | |
170 | ,kGTULinkMaskMissing = 4 // | |
171 | ,kHCHeaderCorrupt = 5 // | |
172 | ,kHCHeaderMissing = 6 // | |
173 | ,kROBSideMismatch = 7 // | |
174 | ,kWrongPadrow = 8 // | |
175 | ,kWrongPadcolumn = 9 // | |
176 | ,kTrackletRowMismatch = 10 // | |
177 | ,kDataMaskError = 11 // | |
178 | ,kADCNumberOverflow = 12 // | |
179 | ,kADCChannelOverflow = 13 // | |
180 | }; | |
181 | ||
182 | protected: | |
183 | ||
184 | AliTRDgeometry *fGeo; // TRD geometry | |
185 | ||
186 | Bool_t DecodeGTUlinkMask(); | |
187 | Bool_t DecodeNextRawWord(); | |
188 | Bool_t DecodeMCM(); | |
189 | Bool_t DecodeHC(); | |
190 | Bool_t DecodeSM(); | |
191 | inline void ChangeStatus(Int_t kstat); | |
192 | /* { */ | |
193 | /* fLastStatus = fNextStatus; */ | |
194 | /* fNextStatus = kstat; */ | |
195 | /* } */ | |
196 | ||
197 | void DecodeHCheader(Int_t timeBins = 0); | |
198 | void DecodeMCMheader(); | |
199 | void DecodeTracklet(); | |
200 | ||
201 | void SetRawDigitThreshold (Int_t ith) {fRawDigitThreshold = ith;} // set the naive zero suppression threshold | |
202 | ||
203 | Int_t NextData(); // get the next piece of memory | |
204 | ||
205 | Int_t ChannelsToRead(Int_t ADCmask); // Get the active ADC channels from the mask (V3 and 2) | |
206 | ||
207 | enum { fkStart, fkStop, fkWordOK, fkNoMoreData, fkNextSM, fkNextHC, fkSeekNonEoTracklet, fkDecodeHC, fkNextMCM, fkNextData, fkReading}; | |
208 | ||
209 | // Some constants: | |
210 | static const UInt_t kEndoftrackletmarker = 0xAAAAAAAA; /*This marks the end of tracklet data words*/ | |
211 | static const UInt_t kEndofrawdatamarker = 0x00000000; /*This marks the end of half-chamber-data*/ | |
212 | static const UInt_t kSizeWord = sizeof(UInt_t); // size of a word in bytes | |
213 | ||
214 | ClassDef(AliTRDRawStreamV2, 1) // Class for reading TRD raw digits | |
215 | ||
216 | }; | |
217 | #endif |