]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDRawStreamV2.h
Merging THbtp and HBTP in one library. Comiplation on Windows/Cygwin
[u/mrichter/AliRoot.git] / TRD / AliTRDRawStreamV2.h
CommitLineData
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
17class AliTRDgeometry;
18class AliRawReader;
19class AliTRDdigitsManager;
20
dfbb4bb9 21//class AliTRDRawStreamV2: public TObject {
22class 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
31 virtual Int_t NextChamber(AliTRDdigitsManager *man); // 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();
0c349049 78
79 protected:
80
81 AliTRDgeometry *fGeo; // TRD geometry
82
83 Bool_t DecodeGTUlinkMask();
84 Bool_t DecodeNextRawWord();
85 Bool_t DecodeMCM();
86 Bool_t DecodeHC();
87 Bool_t DecodeSM();
88 inline void ChangeStatus(Int_t kstat);
89/* { */
90/* fLastStatus = fNextStatus; */
91/* fNextStatus = kstat; */
92/* } */
93
94 void DecodeHCheader(Int_t timeBins = 0);
95 void DecodeMCMheader();
96 void DecodeTracklet();
97
98 void SetRawDigitThreshold (Int_t ith)
99 { fRawDigitThreshold = ith; } // Set the naive zero suppression threshold
100
101 Int_t NextData(); // Get the next piece of memory
102 Int_t ChannelsToRead(Int_t ADCmask); // Get the active ADC channels from the mask (V3 and 2)
103
104 enum { kStart
105 , kStop
106 , kWordOK
107 , kNoMoreData
108 , kNextSM
109 , kNextHC
110 , kSeekNonEoTracklet
111 , kDecodeHC
112 , kNextMCM
113 , kNextData
114 , kReading };
115
116 // Some constants:
117 static const UInt_t fgkEndoftrackletmarker = 0xAAAAAAAA; // This marks the end of tracklet data words
118 static const UInt_t fgkEndofrawdatamarker = 0x00000000; // This marks the end of half-chamber-data
119 static const UInt_t fgkSizeWord = sizeof(UInt_t); // Size of a word in bytes
ecf39416 120
121 private :
122
0c349049 123 Int_t fSig[3]; // Signals in the three time bins from Data Word
124 Int_t fADC; // MCM ADC channel and Time Bin of word 1
125 Int_t fTB; // MCM ADC channel and Time Bin of word 1
126 Int_t fEv; // MCM Event number and position of current MCM on TRD chamber
127 Int_t fROB; // MCM Event number and position of current MCM on TRD chamber
128 Int_t fMCM; // MCM Event number and position of current MCM on TRD chamber
129 Int_t fSM; // Position of CURRENT half chamber in full TRD
130 Int_t fLAYER; // Position of CURRENT half chamber in full TRD
131 Int_t fSTACK; // Position of CURRENT half chamber in full TRD
132 Int_t fROC; // Position of CURRENT half chamber in full TRD
133 Int_t fSIDE; // Position of CURRENT half chamber in full TRD
134 Int_t fDCS; // DCS board number read from data (HC header)
135 Int_t fROW; // Detector Row coordinates
136 Int_t fCOL; // Detector Pad coordinates
137 Int_t fDET; // Current detector - version > 1
138 Int_t fLastDET; // Previous detector - version > 1
139
140 Int_t fBCctr; // Counters from HC header (>=V2)
141 Int_t fPTctr; // Counters from HC header (>=V2)
142 Int_t fPTphase; // Counters from HC header (>=V2)
143 Int_t fRVmajor; // Raw version numbers and number of additional HC headerwords (>=V2)
144 Int_t fRVminor; // Raw version numbers and number of additional HC headerwords (>=V2)
145 Int_t fHCHWords; // Raw version numbers and number of additional HC headerwords (>=V2)
146 Int_t fTBins; // Number of time bins read from HC header (>=V2)
147 Bool_t fTCon; // Filter settings read from HC header (>=V2)
148 Bool_t fPEDon; // Filter settings read from HC header (>=V2)
149 Bool_t fGAINon; // Filter settings read from HC header (>=V2)
150 Bool_t fXTon; // Filter settings read from HC header (>=V2)
151 Bool_t fNonLinOn; // Filter settings read from HC header (>=V2)
152 Bool_t fBypass; // Filter settings read from HC header (>=V2)
153 Int_t fCommonAdditive; // Common baseline additive read from HC header (>=V2)
154
155 Bool_t fZeroSuppressed; // Data is zero suppressed
ecf39416 156
157 Int_t fHCHctr1; // HC and MCM Header counter
158 Int_t fHCHctr2; // HC and MCM Header counter
159 Int_t fMCMHctr1; // HC and MCM Header counter
160 Int_t fMCMHctr2; // HC and MCM Header counter
161 Int_t fGTUctr1; // GTU LinkMask Counter
162 Int_t fGTUctr2; // GTU LinkMask Counter
163 Int_t fHCdataCtr; // Data Counter for half chamber
164
165 Float_t fTracklPID; // Tracklet parameters
166 Float_t fTracklDefL; // Tracklet parameters
167 Float_t fTracklPadPos; // Tracklet parameters
168 Int_t fTracklPadRow; // Tracklet parameters
169
170 UShort_t fGTUlinkMask[18][5]; // Mask with active links
171
172 Int_t fMCMWordCrt; // Word Counter for a single MCM
0c349049 173 Int_t fMCMWordsExpected; // Expected Words from MCM
ecf39416 174
175 AliTRDRawStreamV2(const AliTRDRawStreamV2 &stream);
176 AliTRDRawStreamV2 &operator=(const AliTRDRawStreamV2 &stream);
177
0c349049 178 AliRawReader *fRawReader; // Object for reading the raw data
ecf39416 179
0c349049 180 Int_t fRawVersion; // Which version of raw data decoding is used
181 Int_t fRawDigitThreshold; // Naive "zero"(threshold) supression. Usefull for Raw Data ver 2.
ecf39416 182
0c349049 183 Int_t fNextStatus; // Navigation in raw versions > 1
184 Int_t fLastStatus; // Navigation in raw versions > 1
185 UInt_t fTbSwitch; // Time Bin Switch for internal use
186 UInt_t fTbSwitchCtr; // Counter for internal use
187 UInt_t fTimeWords; // Number of Words needed to store the data of 1 ADC ch.
188 UInt_t fWordCtr; // Word Counter
ecf39416 189
0c349049 190 Int_t fRowMax; // Maximum number of pad rows and columns
191 Int_t fColMax; // Maximum number of pad rows and columns
ecf39416 192
0c349049 193 Bool_t fADCmask[21]; // Mask of active ADCs for zero suppression
194 UInt_t fLastADCmask; // Last ADC read out
ecf39416 195
0c349049 196 UShort_t fChamberDone[540]; // Chamber was processed already (1=1HC, 2=full chamber)
ecf39416 197
0c349049 198 Int_t fRetVal; // Datadecode return
199 Int_t fEqID; // Equipment id
200 UInt_t fDataSize; // Size of the data available in the current buffer
201 Bool_t fSizeOK; // Did we read anything
202 UInt_t fCountBytes; // Bytes traversed in the buffer
203 UInt_t fBufSize; // Size of the current RawReader buffer
204 Bool_t fkBufferSet; // Is the RawReader buffer available
205 UChar_t *fPos; // Position in the buffer of the RawReader
206 UInt_t *fDataWord; // The pointer to the current 32 bit data word
207 UInt_t fTimeBinsCalib; // N of time bins retrieved from calibration
ecf39416 208
0c349049 209 Int_t fADClookup[32]; // Lookup for version 3 (1[entries]+1[index]+30[fADC channels] = 32)
210 Int_t fNActiveADCs; // Number of active ADC channels
211 Bool_t fEndOfDataFlag; // End of data flag
ecf39416 212
213 enum ETRDzRawStreamError {
0c349049 214 kHCWordMissing = 1 //
215 ,kMCMADCMaskMissing = 2 //
216 ,kWrongMCMorROB = 3 //
217 ,kGTULinkMaskMissing = 4 //
218 ,kHCHeaderCorrupt = 5 //
219 ,kHCHeaderMissing = 6 //
220 ,kROBSideMismatch = 7 //
221 ,kWrongPadrow = 8 //
222 ,kWrongPadcolumn = 9 //
223 ,kTrackletRowMismatch = 10 //
224 ,kDataMaskError = 11 //
225 ,kADCNumberOverflow = 12 //
226 ,kADCChannelOverflow = 13 //
ecf39416 227 };
ecf39416 228
0c349049 229 ClassDef(AliTRDRawStreamV2,1) // Class for reading TRD raw digits
ecf39416 230
231};
232#endif