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