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 */
8 ///////////////////////////////////////////////////////////////////////////////
10 // This class provides access to TRD digits in raw data. //
12 ///////////////////////////////////////////////////////////////////////////////
15 #include "AliTRDrawStreamBase.h"
19 class AliTRDdigitsManager;
21 //class AliTRDRawStreamV2: public TObject {
22 class AliTRDRawStreamV2 : public AliTRDrawStreamBase {
27 AliTRDRawStreamV2(AliRawReader *rawReader);
28 virtual ~AliTRDRawStreamV2();
30 virtual Bool_t Next(); // Read the next data
31 virtual Int_t NextChamber(AliTRDdigitsManager *man, UInt_t **trackletContainer); // Read next chamber data
32 virtual Bool_t Init(); // Init for the fRawVersion > 1
34 enum { kDDLOffset = 0x400 }; // Offset for DDL numbers
36 Bool_t SetRawVersion(Int_t rv);
37 Int_t GetRawVersion() const { return fRawVersion; };
38 void SetRawReader(AliRawReader *rawReader);
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; };
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; };
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 ); };
56 Int_t *GetSignals() const { return (Int_t*)fSig; } // Signals in the three time bins from Data Word
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
78 static void SetDumpHead(UInt_t iv) {fgDumpHead = iv;} // set number of words to be dumped on the screen
82 AliTRDgeometry *fGeo; // TRD geometry
84 Bool_t DecodeGTUlinkMask();
85 Bool_t DecodeNextRawWord();
89 Bool_t DumpWords(UInt_t *px, UInt_t iw, UInt_t marker = 0); // dump some words onto the screen - debugging purpose
90 inline void ChangeStatus(Int_t kstat);
92 /* fLastStatus = fNextStatus; */
93 /* fNextStatus = kstat; */
96 void DecodeHCheader(Int_t timeBins = 0);
97 void DecodeMCMheader();
98 void DecodeTracklet();
100 void SetRawDigitThreshold (Int_t ith)
101 { fRawDigitThreshold = ith; } // Set the naive zero suppression threshold
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)
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
123 static UInt_t fgDumpHead; // number of words to be dumped (from the start of the buffer)
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
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)
159 Bool_t fZeroSuppressed; // Data is zero suppressed
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
169 Float_t fTracklPID; // Tracklet parameters
170 Float_t fTracklDefL; // Tracklet parameters
171 Float_t fTracklPadPos; // Tracklet parameters
172 Int_t fTracklPadRow; // Tracklet parameters
174 UShort_t fGTUlinkMask[18][5]; // Mask with active links
176 Int_t fMCMWordCrt; // Word Counter for a single MCM
177 Int_t fMCMWordsExpected; // Expected Words from MCM
179 AliTRDRawStreamV2(const AliTRDRawStreamV2 &stream);
180 AliTRDRawStreamV2 &operator=(const AliTRDRawStreamV2 &stream);
182 AliRawReader *fRawReader; // Object for reading the raw data
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.
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
194 Int_t fRowMax; // Maximum number of pad rows and columns
195 Int_t fColMax; // Maximum number of pad rows and columns
197 Bool_t fADCmask[21]; // Mask of active ADCs for zero suppression
198 UInt_t fLastADCmask; // Last ADC read out
200 UShort_t fChamberDone[540]; // Chamber was processed already (1=1HC, 2=full chamber)
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
210 UInt_t *fpBegin; // begin - pointer to the buffer word 0
211 UInt_t *fpEnd; // end of the buffer
212 UInt_t *fDataWord; // The pointer to the current 32 bit data word
213 UInt_t fTimeBinsCalib; // N of time bins retrieved from calibration
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
219 enum ETRDzRawStreamError {
220 kHCWordMissing = 1 //
221 ,kMCMADCMaskMissing = 2 //
222 ,kWrongMCMorROB = 3 //
223 ,kGTULinkMaskMissing = 4 //
224 ,kHCHeaderCorrupt = 5 //
225 ,kHCHeaderMissing = 6 //
226 ,kROBSideMismatch = 7 //
228 ,kWrongPadcolumn = 9 //
229 ,kTrackletRowMismatch = 10 //
230 ,kDataMaskError = 11 //
231 ,kADCNumberOverflow = 12 //
232 ,kADCChannelOverflow = 13 //
235 ClassDef(AliTRDRawStreamV2,1) // Class for reading TRD raw digits