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