Making online tracklets usable in offline reconstruction
[u/mrichter/AliRoot.git] / TRD / AliTRDrawOldStream.h
CommitLineData
0b5aef7f 1#ifndef ALITRDRAWOLDSTREAM_H
2#define ALITRDRAWOLDSTREAM_H
b864d801 3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
987ba9a3 6/* $Id: AliTRDrawOldStream.h 27493 2008-07-22 07:55:01Z cblume $ */
b864d801 7
c8ab4518 8////////////////////////////////////////////////////////////////////////////
9// //
10// This class provides access to TRD digits in raw data. //
11// //
12////////////////////////////////////////////////////////////////////////////
b864d801 13
14#include <TObject.h>
dfbb4bb9 15#include "AliTRDrawStreamBase.h"
b864d801 16
17class AliRawReader;
c8ab4518 18
19class AliTRDgeometry;
ca21baaa 20class AliTRDdigitsManager;
7925de54 21
22// Some constants:
bd63bf88 23const UInt_t kEndoftrackletmarker = 0xAAAAAAAA; /*This marks the end of tracklet data words*/
24const UInt_t kEndofrawdatamarker = 0x00000000; /*This marks the end of half-chamber-data*/
c8ab4518 25const UInt_t kSizeWord = sizeof(UInt_t);
b864d801 26
987ba9a3 27//class AliTRDrawOldStream: public TObject {
28class AliTRDrawOldStream: public AliTRDrawStreamBase {
2745a409 29
b864d801 30 public :
2745a409 31
987ba9a3 32 AliTRDrawOldStream();
33 AliTRDrawOldStream(AliRawReader *rawReader);
34 virtual ~AliTRDrawOldStream();
b864d801 35
c8ab4518 36 virtual Bool_t Next(); // Read the next data
3be28fbf 37 virtual Int_t NextChamber(AliTRDdigitsManager *man, UInt_t **trackletContainer); // Read next chamber data
dfbb4bb9 38 virtual Bool_t Init(); // Init for the fRawVersion > 1
7925de54 39
c8ab4518 40 enum { kDDLOffset = 0x400 }; // Offset for DDL numbers
7925de54 41
7925de54 42 Bool_t SetRawVersion(Int_t rv);
43 Int_t GetRawVersion() const { return fRawVersion; };
50378239 44 void SetRawReader(AliRawReader *rawReader);
7925de54 45
bd63bf88 46 // Get Filter settings (does not make a lot of sense):
41235089 47 Int_t TRAPfilterTCon() const { return fTCon; };
48 Int_t TRAPfilterPEDon() const { return fPEDon; };
49 Int_t TRAPfilterGAINon() const { return fGAINon; };
bd63bf88 50 Int_t TRAPsendsUnfilteredData() const { return fBypass; };
41235089 51
bd63bf88 52 // Get Tracklet parameters (does not make a lot of sense):
41235089 53 Float_t GetTrackletPID() const { return fTracklPID; };
54 Float_t GetTrackletDeflLength() const { return fTracklDefL; };
55 Float_t GetTrackletPadPos() const { return fTracklPadPos; };
bd63bf88 56 Int_t GetTrackletPadRow() const { return fTracklPadRow; };
41235089 57
7925de54 58 // Check if the link has optical power (HC sends data)
59 Bool_t IsGTULinkActive(Int_t sm, Int_t la, Int_t sta, Int_t side)
41235089 60 { return ( ((fGTUlinkMask[sm][sta]) >> (2*la+side)) & 0x1 ); };
61
dfbb4bb9 62 Int_t *GetSignals() const { return (Int_t*)fSig; } // Signals in the three time bins from Data Word
c8ab4518 63 Int_t GetADC() const { return fADC; } // MCM ADC channel and Time Bin of word 1
64 Int_t GetTimeBin() const { return fTB - 3; } // MCM ADC channel and Time Bin of word 1
65 Int_t GetEventNumber() const { return fEv; } // MCM Event number and position of current MCM
66 Int_t GetROB() const { return fROB; } // MCM Event number and position of current MCM
67 Int_t GetMCM() const { return fMCM; } // MCM Event number and position of current MCM
68 Int_t GetSM() const { return fSM; } // Position of CURRENT half chamber in full TRD
69 Int_t GetLayer() const { return fLAYER; } // PLANE = Position of CURRENT half chamber in full TRD
70 Int_t GetStack() const { return fSTACK; } // CHAMBER = Position of CURRENT half chamber in full TRD
71 Int_t GetROC() const { return fROC; } // Position of CURRENT half chamber in full TRD
72 Int_t GetSide() const { return fSIDE; } // Position of CURRENT half chamber in full TRD
73 Int_t GetDCS() const { return fDCS; } // DCS board number read from data (HC header)
74 Int_t GetRow() const { return fROW; }
75 Int_t GetCol() const { return fCOL; } // Detector Pad coordinates
76 Int_t GetDet() const { return fDET; } // Helper
77 Int_t GetLastDet() const { return fLastDET; } // Helper
78 Int_t GetMaxRow() const { return fRowMax; }
79 Int_t GetMaxCol() const { return fColMax; }
80 Int_t GetNumberOfTimeBins() const { return fTBins; }
81
82 protected:
83
84 AliTRDgeometry *fGeo; // TRD geometry
85
86 void DecodeHCheader(Int_t timeBins);
87 void DecodeMCMheader();
88 void DecodeTracklet();
89 void DecodeGTUlinkMask();
90 Int_t DecodeDataWord();
91 Int_t DecodeDataWordV1V2(); // Valid for fRawversion = 1, 2, ...
92 Int_t DecodeDataWordV3(); // Valid for fRawversion = 3, ...
93
94 Int_t NextData(); // Get the next piece of memory
95
96 enum { kStart
97 , kStop
98 , kWordOK
99 , kNoMoreData
100 , kNextSM
101 , kNextHC
102 , kSeekNonEoTracklet
103 , kDecodeHC
104 , kNextMCM
105 , kNextData
106 , kReading };
7925de54 107
41235089 108 private :
7925de54 109
110 Int_t fSig[3]; // Signals in the three time bins from Data Word
111 Int_t fADC; // MCM ADC channel and Time Bin of word 1
112 Int_t fTB; // MCM ADC channel and Time Bin of word 1
113 Int_t fEv; // MCM Event number and position of current MCM on TRD chamber
114 Int_t fROB; // MCM Event number and position of current MCM on TRD chamber
115 Int_t fMCM; // MCM Event number and position of current MCM on TRD chamber
116 Int_t fSM; // Position of CURRENT half chamber in full TRD
117 Int_t fLAYER; // Position of CURRENT half chamber in full TRD
118 Int_t fSTACK; // Position of CURRENT half chamber in full TRD
119 Int_t fROC; // Position of CURRENT half chamber in full TRD
120 Int_t fSIDE; // Position of CURRENT half chamber in full TRD
121 Int_t fDCS; // DCS board number read from data (HC header)
50378239 122 Int_t fROW; // Detector Row coordinates
7925de54 123 Int_t fCOL; // Detector Pad coordinates
50378239 124 Int_t fDET; // Current detector - version > 1
ca21baaa 125 Int_t fLastDET; // Previous detector - version > 1
7925de54 126
127 Int_t fBCctr; // Counters from HC header (>=V2)
128 Int_t fPTctr; // Counters from HC header (>=V2)
129 Int_t fPTphase; // Counters from HC header (>=V2)
130 Int_t fRVmajor; // Raw version numbers and number of additional HC headerwords (>=V2)
131 Int_t fRVminor; // Raw version numbers and number of additional HC headerwords (>=V2)
132 Int_t fHCHWords; // Raw version numbers and number of additional HC headerwords (>=V2)
133 Int_t fTBins; // Number of time bins read from HC header (>=V2)
bd63bf88 134 Bool_t fTCon; // Filter settings read from HC header (>=V2)
135 Bool_t fPEDon; // Filter settings read from HC header (>=V2)
136 Bool_t fGAINon; // Filter settings read from HC header (>=V2)
137 Bool_t fXTon; // Filter settings read from HC header (>=V2)
138 Bool_t fNonLinOn; // Filter settings read from HC header (>=V2)
139 Bool_t fBypass; // Filter settings read from HC header (>=V2)
140 Int_t fCommonAdditive; // Common baseline additive read from HC header (>=V2)
141
142 Bool_t fZeroSuppressed; // Data is zero suppressed
7925de54 143
144 Int_t fHCHctr1; // HC and MCM Header counter
145 Int_t fHCHctr2; // HC and MCM Header counter
146 Int_t fMCMHctr1; // HC and MCM Header counter
147 Int_t fMCMHctr2; // HC and MCM Header counter
148 Int_t fGTUctr1; // GTU LinkMask Counter
149 Int_t fGTUctr2; // GTU LinkMask Counter
bd63bf88 150 Int_t fHCdataCtr; // Data Counter for half chamber
7925de54 151
152 Float_t fTracklPID; // Tracklet parameters
153 Float_t fTracklDefL; // Tracklet parameters
154 Float_t fTracklPadPos; // Tracklet parameters
155 Int_t fTracklPadRow; // Tracklet parameters
156
157 UShort_t fGTUlinkMask[18][5]; // Mask with active links
b864d801 158
987ba9a3 159 AliTRDrawOldStream(const AliTRDrawOldStream &stream);
160 AliTRDrawOldStream &operator=(const AliTRDrawOldStream &stream);
2745a409 161
7925de54 162 AliRawReader *fRawReader; // Object for reading the raw data
2745a409 163
7925de54 164 Int_t fRawVersion; // Which version of raw data decoding is used
50378239 165
166 Int_t fNextStatus; // Navigation in raw versions > 1
bd63bf88 167 UInt_t fTbSwitch; // Time Bin Switch for internal use
168 UInt_t fTbSwitchCtr; // Counter for internal use
169 UInt_t fTimeWords; // Number of Words needed to store the data of 1 ADC ch.
170 UInt_t fWordCtr; // Word Counter
b864d801 171
7925de54 172 Int_t fRowMax; // Maximum number of pad rows and columns
173 Int_t fColMax; // Maximum number of pad rows and columns
bd63bf88 174
175 Bool_t fADCmask[21]; // Mask of active ADCs for zero suppression
176 UShort_t fChamberDone[540]; // Chamber was processed already (1=1HC, 2=full chamber)
b864d801 177
f162af62 178 Int_t fRetVal; // Datadecode return
179 Int_t fEqID; // Equipment id
180 UInt_t fDataSize; // Size of the data available in the current buffer
181 Bool_t fSizeOK; // Did we read anything
50378239 182 UInt_t fCountBytes; // Bytes traversed in the buffer
183 UInt_t fBufSize; // Size of the current RawReader buffer
c8ab4518 184 Bool_t fBufferSet; // Is the RawReader buffer available
f162af62 185 UChar_t *fPos; // Position in the buffer of the RawReader
186 UInt_t *fDataWord; // The pointer to the current 32 bit data word
50378239 187 UInt_t fTimeBinsCalib; // N of time bins retrieved from calibration
188
189 enum ETRDzRawStreamError {
190 kHCWordMissing = 1 //
191 ,kMCMADCMaskMissing = 2 //
192 ,kWrongMCMorROB = 3 //
193 ,kGTULinkMaskMissing = 4 //
194 ,kHCHeaderCorrupt = 5 //
195 ,kHCHeaderMissing = 6 //
196 ,kROBSideMismatch = 7 //
197 ,kWrongPadrow = 8 //
198 ,kWrongPadcolumn = 9 //
199 ,kTrackletRowMismatch = 10 //
200 ,kDataMaskError = 11 //
201 ,kADCNumberOverflow = 12 //
202 ,kADCChannelOverflow = 13 //
203 };
50378239 204
987ba9a3 205 ClassDef(AliTRDrawOldStream, 6) // Class for reading TRD raw digits
7925de54 206
207};
b864d801 208#endif