]>
Commit | Line | Data |
---|---|---|
a38a7850 | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
9be2600f | 4 | * This file is property of and copyright by the ALICE HLT Project * |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
a38a7850 | 6 | * * |
9be2600f | 7 | * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * |
8 | * Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
9 | * Jochen Thaeder <thaeder@kip.uni-heidelberg.de> * | |
10 | * for The ALICE HLT Project. * | |
a38a7850 | 11 | * * |
12 | * Permission to use, copy, modify and distribute this software and its * | |
13 | * documentation strictly for non-commercial purposes is hereby granted * | |
14 | * without fee, provided that the above copyright notice appears in all * | |
15 | * copies and that both the copyright notice and this permission notice * | |
16 | * appear in the supporting documentation. The authors make no claims * | |
17 | * about the suitability of this software for any purpose. It is * | |
18 | * provided "as is" without express or implied warranty. * | |
19 | **************************************************************************/ | |
20 | ||
84645eb0 | 21 | /** @file AliHLTTPCDigitReaderPacked.cxx |
27f5f8ed | 22 | @author Timm Steinbeck, Jochen Thaeder, Matthias Richter, Kenneth Aamodt |
84645eb0 | 23 | @date |
24 | @brief A digit reader implementation for simulated, packed TPC 'raw' data. | |
25 | */ | |
db16520a | 26 | |
27 | #if __GNUC__>= 3 | |
a38a7850 | 28 | using namespace std; |
29 | #endif | |
30 | ||
74c73e5a | 31 | #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) |
a38a7850 | 32 | #include "AliHLTTPCDigitReaderPacked.h" |
db16520a | 33 | |
a38a7850 | 34 | #include "AliTPCRawStream.h" |
35 | #include "AliRawReaderMemory.h" | |
36 | #include "AliRawDataHeader.h" | |
37 | ||
db16520a | 38 | #if ENABLE_PAD_SORTING |
39 | #include "AliHLTTPCTransform.h" | |
40 | #endif // ENABLE_PAD_SORTING | |
74c73e5a | 41 | #include "AliHLTStdIncludes.h" |
a38a7850 | 42 | |
43 | ClassImp(AliHLTTPCDigitReaderPacked) | |
44 | ||
84645eb0 | 45 | AliHLTTPCDigitReaderPacked::AliHLTTPCDigitReaderPacked() |
46 | : | |
47 | #if ENABLE_PAD_SORTING | |
48 | fCurrentRow(0), | |
49 | fCurrentPad(0), | |
50 | fCurrentBin(-1), | |
51 | fNRows(0), | |
52 | fRowOffset(0), | |
53 | fNMaxRows(0), | |
54 | fNMaxPads(0), | |
55 | fNTimeBins(0), | |
56 | fData(NULL), | |
57 | #endif // ENABLE_PAD_SORTING | |
58 | fRawMemoryReader(NULL), | |
27f5f8ed | 59 | fTPCRawStream(NULL), |
60 | fOldRCUFormat(kFALSE) | |
84645eb0 | 61 | { |
a38a7850 | 62 | fRawMemoryReader = new AliRawReaderMemory; |
db16520a | 63 | |
a38a7850 | 64 | fTPCRawStream = new AliTPCRawStream( fRawMemoryReader ); |
db16520a | 65 | |
66 | #if ENABLE_PAD_SORTING | |
db16520a | 67 | // get max number of rows |
db16520a | 68 | for (Int_t ii=0; ii < 6; ii++) |
69 | if (AliHLTTPCTransform::GetNRows(ii) > fNMaxRows) | |
70 | fNMaxRows = AliHLTTPCTransform::GetNRows(ii); | |
71 | ||
72 | // get max number of pads | |
db16520a | 73 | for (Int_t ii=0; ii < AliHLTTPCTransform::GetNRows();ii++ ) |
74 | if (AliHLTTPCTransform::GetNPads(ii) > fNMaxPads) | |
75 | fNMaxPads = AliHLTTPCTransform::GetNPads(ii); | |
76 | ||
77 | // get max number of bins | |
78 | fNTimeBins = AliHLTTPCTransform::GetNTimeBins(); | |
79 | ||
84645eb0 | 80 | HLTDebug("Array Borders ||| MAXPAD=%d ||| MAXROW=%d ||| MAXBIN=%d ||| MAXMUL=%d", |
db16520a | 81 | fNMaxPads, fNMaxRows, fNTimeBins, fNTimeBins*fNMaxRows*fNMaxPads); |
82 | ||
83 | // init Data array | |
84 | fData = new Int_t[ fNMaxRows*fNMaxPads*fNTimeBins ]; | |
85 | #endif // ENABLE_PAD_SORTING | |
a38a7850 | 86 | } |
87 | ||
84645eb0 | 88 | AliHLTTPCDigitReaderPacked::AliHLTTPCDigitReaderPacked(const AliHLTTPCDigitReaderPacked& src) |
89 | : | |
90 | #if ENABLE_PAD_SORTING | |
91 | fCurrentRow(0), | |
92 | fCurrentPad(0), | |
93 | fCurrentBin(-1), | |
94 | fNRows(0), | |
95 | fRowOffset(0), | |
96 | fNMaxRows(0), | |
97 | fNMaxPads(0), | |
98 | fNTimeBins(0), | |
99 | fData(NULL), | |
100 | #endif // ENABLE_PAD_SORTING | |
101 | fRawMemoryReader(NULL), | |
27f5f8ed | 102 | fTPCRawStream(NULL), |
103 | fOldRCUFormat(kFALSE) | |
84645eb0 | 104 | { |
105 | HLTFatal("copy constructor not for use"); | |
106 | } | |
107 | ||
108 | AliHLTTPCDigitReaderPacked& AliHLTTPCDigitReaderPacked::operator=(const AliHLTTPCDigitReaderPacked& src) | |
109 | { | |
110 | #if ENABLE_PAD_SORTING | |
111 | fCurrentRow=0; | |
112 | fCurrentPad=0; | |
113 | fCurrentBin=-1; | |
114 | fNRows=0; | |
115 | fRowOffset=0; | |
116 | fNMaxRows=0; | |
117 | fNMaxPads=0; | |
118 | fNTimeBins=0; | |
119 | fData=NULL; | |
120 | #endif // ENABLE_PAD_SORTING | |
121 | fRawMemoryReader=NULL; | |
122 | fTPCRawStream=NULL; | |
27f5f8ed | 123 | fOldRCUFormat=kFALSE; |
84645eb0 | 124 | HLTFatal("assignment operator not for use"); |
125 | return (*this); | |
126 | } | |
127 | ||
a38a7850 | 128 | AliHLTTPCDigitReaderPacked::~AliHLTTPCDigitReaderPacked(){ |
129 | if ( fRawMemoryReader ) | |
130 | delete fRawMemoryReader; | |
131 | fRawMemoryReader = NULL; | |
132 | if ( fTPCRawStream ) | |
db16520a | 133 | delete fTPCRawStream; |
a38a7850 | 134 | fTPCRawStream = NULL; |
db16520a | 135 | #if ENABLE_PAD_SORTING |
136 | if ( fData ) | |
137 | delete [] fData; | |
138 | fData = NULL; | |
139 | #endif // ENABLE_PAD_SORTING | |
a38a7850 | 140 | } |
141 | ||
84645eb0 | 142 | Int_t AliHLTTPCDigitReaderPacked::InitBlock(void* ptr,unsigned long size, Int_t patch, Int_t slice){ |
db16520a | 143 | |
a38a7850 | 144 | fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( ptr ), size ); |
db16520a | 145 | |
146 | //get DDL ID in order to tell the memory reader which slice/patch to use | |
147 | Int_t DDLid= 0; | |
148 | if (patch < 2) | |
27f5f8ed | 149 | DDLid = 768 + 2*slice + patch; |
db16520a | 150 | else |
9f968107 | 151 | DDLid = 840 + 4*slice + patch-2; |
db16520a | 152 | |
27f5f8ed | 153 | fRawMemoryReader->SetEquipmentID(DDLid); |
154 | //fRawMemoryReader->SetEquipmentID(1); | |
155 | if(fOldRCUFormat) | |
156 | fTPCRawStream->SetOldRCUFormat(kTRUE); | |
db16520a | 157 | |
158 | #if ENABLE_PAD_SORTING | |
159 | ||
160 | fCurrentRow = 0; | |
161 | fCurrentPad = 0; | |
162 | fCurrentBin = -1; | |
163 | ||
84645eb0 | 164 | Int_t firstrow=AliHLTTPCTransform::GetFirstRow(patch); |
165 | Int_t lastrow=AliHLTTPCTransform::GetLastRow(patch); | |
db16520a | 166 | fNRows = lastrow - firstrow + 1; |
167 | ||
168 | Int_t offset=0; | |
169 | if (patch > 1) offset = AliHLTTPCTransform::GetFirstRow( 2 ); | |
170 | ||
171 | fRowOffset = firstrow - offset; | |
172 | firstrow -= offset; | |
173 | lastrow -= offset; | |
174 | ||
175 | // Init array with -1 | |
176 | memset( fData, 0xFF, sizeof(Int_t)*(fNMaxRows*fNMaxPads*fNTimeBins) ); | |
177 | ||
178 | // read data and fill in array | |
179 | while( fTPCRawStream->Next()){ | |
180 | ||
181 | Int_t row = fTPCRawStream->GetRow(); | |
182 | Int_t pad = fTPCRawStream->GetPad(); | |
183 | Int_t bin = fTPCRawStream->GetTime(); | |
184 | ||
185 | if ( row < firstrow || row > lastrow || pad > AliHLTTPCTransform::GetNPads(row + offset) || bin > fNTimeBins){ | |
186 | HLTFatal("Index out of Range Probably wrong patch! %d - %d", slice, patch); | |
187 | if ( row < firstrow || row > lastrow ) | |
188 | HLTFatal("Row out of Range %d < %d < %d",firstrow, row, lastrow); | |
189 | if ( pad > AliHLTTPCTransform::GetNPads(row + offset) ) | |
190 | HLTFatal("Pad out of Range %d < %d < %d",pad, AliHLTTPCTransform::GetNPads(row + offset)); | |
191 | if ( bin > fNTimeBins ) | |
192 | HLTFatal("Bin out of Range %d < %d < %d",bin, fNTimeBins); | |
193 | } | |
194 | else { | |
195 | if ((row-fRowOffset)*fNMaxPads*fNTimeBins+ pad*fNTimeBins + bin >= fNMaxRows*fNMaxPads*fNTimeBins ) { | |
196 | HLTFatal("Index out of array range PAD=%d ||| ROW=%d ||| BIN=%d ||| OFFSET=%d ||| ROWOFFSET=%d", pad, row, bin, offset, fRowOffset); | |
197 | continue; | |
198 | } | |
199 | else { | |
200 | fData[ (row-fRowOffset)*fNMaxPads*fNTimeBins+ pad*fNTimeBins + bin ] = fTPCRawStream->GetSignal() ; | |
201 | } | |
202 | } | |
203 | } | |
204 | #endif // ENABLE_PAD_SORTING | |
205 | ||
a38a7850 | 206 | return 0; |
207 | } | |
208 | ||
db16520a | 209 | Bool_t AliHLTTPCDigitReaderPacked::Next(){ |
210 | Bool_t readvalue = kTRUE; | |
211 | ||
212 | #if ENABLE_PAD_SORTING | |
213 | while (1) { | |
214 | fCurrentBin++; | |
215 | if (fCurrentBin >= fNTimeBins){ | |
216 | fCurrentBin = 0; | |
217 | fCurrentPad++; | |
218 | ||
219 | if (fCurrentPad >=fNMaxPads){ | |
220 | fCurrentPad = 0; | |
221 | fCurrentRow++; | |
222 | ||
223 | if (fCurrentRow >= fNMaxRows){ | |
224 | readvalue = kFALSE; | |
225 | break; | |
226 | } | |
227 | } | |
228 | } | |
229 | ||
230 | if (fCurrentRow*fNMaxPads*fNTimeBins+ fCurrentPad*fNTimeBins + fCurrentBin >= fNMaxRows*fNMaxPads*fNTimeBins ) { | |
231 | HLTFatal("Overflow: row=%d pad=%d bin=%d", fCurrentRow, fCurrentPad, fCurrentBin); | |
232 | readvalue = kFALSE; | |
233 | break; | |
234 | } | |
235 | ||
236 | if (fData[ fCurrentRow*fNMaxPads*fNTimeBins + fCurrentPad*fNTimeBins + fCurrentBin ] != -1) break; | |
237 | } | |
238 | #else // !ENABLE_PAD_SORTING | |
239 | readvalue = fTPCRawStream->Next(); | |
240 | #endif // ENABLE_PAD_SORTING | |
241 | ||
242 | return readvalue; | |
a38a7850 | 243 | } |
244 | ||
db16520a | 245 | Int_t AliHLTTPCDigitReaderPacked::GetRow(){ |
246 | #if ENABLE_PAD_SORTING | |
247 | return (fCurrentRow + fRowOffset); | |
248 | #else // !ENABLE_PAD_SORTING | |
249 | return (Int_t) fTPCRawStream->GetRow(); | |
250 | #endif // ENABLE_PAD_SORTING | |
a38a7850 | 251 | } |
252 | ||
253 | int AliHLTTPCDigitReaderPacked::GetPad(){ | |
db16520a | 254 | #if ENABLE_PAD_SORTING |
255 | return fCurrentPad; | |
256 | #else // !ENABLE_PAD_SORTING | |
257 | return fTPCRawStream->GetPad(); | |
258 | #endif // ENABLE_PAD_SORTING | |
a38a7850 | 259 | } |
260 | ||
db16520a | 261 | Int_t AliHLTTPCDigitReaderPacked::GetSignal(){ |
262 | #if ENABLE_PAD_SORTING | |
263 | return fData[ fCurrentRow*fNMaxPads*fNTimeBins+ fCurrentPad*fNTimeBins + fCurrentBin ]; | |
264 | #else // !ENABLE_PAD_SORTING | |
265 | return fTPCRawStream->GetSignal(); | |
266 | #endif // ENABLE_PAD_SORTING | |
a38a7850 | 267 | } |
268 | ||
db16520a | 269 | Int_t AliHLTTPCDigitReaderPacked::GetTime(){ |
270 | #if ENABLE_PAD_SORTING | |
271 | return fCurrentBin; | |
272 | #else // !ENABLE_PAD_SORTING | |
273 | return fTPCRawStream->GetTime(); | |
274 | #endif // ENABLE_PAD_SORTING | |
a38a7850 | 275 | } |
74c73e5a | 276 | #endif //defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) |