]>
Commit | Line | Data |
---|---|---|
71d7c760 | 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> * | |
a38a7850 | 8 | * Jochen Thaeder <thaeder@kip.uni-heidelberg.de> * |
71d7c760 | 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 | ||
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | // // | |
22 | // a TPC cluster finder processing component for the HLT // | |
a38a7850 | 23 | // useable for packed data or unpacked data // |
71d7c760 | 24 | // // |
25 | /////////////////////////////////////////////////////////////////////////////// | |
26 | ||
a38a7850 | 27 | |
db16520a | 28 | #if __GNUC__>= 3 |
71d7c760 | 29 | using namespace std; |
30 | #endif | |
db16520a | 31 | #include "AliHLTTPCLogging.h" |
71d7c760 | 32 | #include "AliHLTTPCClusterFinderComponent.h" |
a38a7850 | 33 | #include "AliHLTTPCDigitReaderPacked.h" |
34 | #include "AliHLTTPCDigitReaderUnpacked.h" | |
db16520a | 35 | #include "AliHLTTPCDigitReaderRaw.h" |
a38a7850 | 36 | #include "AliHLTTPCClusterFinder.h" |
a6c02c85 | 37 | #include "AliHLTTPCSpacePointData.h" |
71d7c760 | 38 | #include "AliHLTTPCRawDataFormat.h" |
39 | #include "AliHLTTPCClusterDataFormat.h" | |
a6c02c85 | 40 | #include "AliHLTTPCTransform.h" |
71d7c760 | 41 | #include <stdlib.h> |
42 | #include <errno.h> | |
43 | ||
44 | // this is a global object used for automatic component registration, do not use this | |
a38a7850 | 45 | AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentPacked(true); |
46 | AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponentUnpacked(false); | |
71d7c760 | 47 | |
48 | ClassImp(AliHLTTPCClusterFinderComponent) | |
49 | ||
a38a7850 | 50 | AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(bool packed) |
74c73e5a | 51 | : |
52 | // use fPackedSwitch = true for packed inputtype "gkDDLPackedRawDataType" | |
53 | // use fPackedSwitch = false for unpacked inputtype "gkUnpackedRawDataType" | |
54 | fPackedSwitch(packed), | |
55 | ||
56 | fClusterFinder(NULL), | |
57 | fReader(NULL), | |
58 | fClusterDeconv(true), | |
59 | fXYClusterError(-1), | |
60 | fZClusterError(-1) | |
61 | { | |
62 | } | |
63 | ||
64 | AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(const AliHLTTPCClusterFinderComponent&) | |
65 | : | |
66 | fPackedSwitch(0), | |
67 | fClusterFinder(NULL), | |
68 | fReader(NULL), | |
69 | fClusterDeconv(true), | |
70 | fXYClusterError(-1), | |
71 | fZClusterError(-1) | |
72 | { | |
73 | HLTFatal("copy constructor untested"); | |
74 | } | |
75 | ||
76 | AliHLTTPCClusterFinderComponent& AliHLTTPCClusterFinderComponent::operator=(const AliHLTTPCClusterFinderComponent&) | |
77 | { | |
78 | HLTFatal("assignment operator untested"); | |
79 | return *this; | |
80 | } | |
71d7c760 | 81 | |
82 | AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent() | |
83 | { | |
84 | } | |
85 | ||
86 | // Public functions to implement AliHLTComponent's interface. | |
87 | // These functions are required for the registration process | |
88 | ||
89 | const char* AliHLTTPCClusterFinderComponent::GetComponentID() | |
90 | { | |
a38a7850 | 91 | if (fPackedSwitch) return "TPCClusterFinderPacked"; |
92 | else return "TPCClusterFinderUnpacked"; | |
71d7c760 | 93 | } |
94 | ||
95 | void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list) | |
96 | { | |
a38a7850 | 97 | list.clear(); |
98 | if (fPackedSwitch) list.push_back( AliHLTTPCDefinitions::gkDDLPackedRawDataType ); | |
99 | else list.push_back( AliHLTTPCDefinitions::gkUnpackedRawDataType ); | |
100 | ||
71d7c760 | 101 | } |
102 | ||
103 | AliHLTComponent_DataType AliHLTTPCClusterFinderComponent::GetOutputDataType() | |
104 | { | |
105 | return AliHLTTPCDefinitions::gkClustersDataType; | |
106 | } | |
107 | ||
108 | void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
109 | { | |
a38a7850 | 110 | // XXX TODO: Find more realistic values. |
71d7c760 | 111 | constBase = 0; |
a38a7850 | 112 | if (fPackedSwitch) inputMultiplier = (6 * 0.4); |
113 | else inputMultiplier = 0.4; | |
71d7c760 | 114 | } |
115 | ||
116 | AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn() | |
117 | { | |
a38a7850 | 118 | return new AliHLTTPCClusterFinderComponent(fPackedSwitch); |
71d7c760 | 119 | } |
120 | ||
121 | int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv ) | |
122 | { | |
123 | if ( fClusterFinder ) | |
124 | return EINPROGRESS; | |
a38a7850 | 125 | |
126 | fClusterFinder = new AliHLTTPCClusterFinder(); | |
127 | ||
db16520a | 128 | Int_t rawreadermode = -1; |
84645eb0 | 129 | Int_t sigthresh = -1; |
5235c3e9 | 130 | Float_t occulimit = 1.0; |
db16520a | 131 | |
132 | // Data Format version numbers: | |
133 | // 0: RCU Data format as delivered during TPC commissioning, pads/padrows are sorted, RCU trailer is one 32 bit word. | |
134 | // 1: As 0, but pads/padrows are delivered "as is", without sorting | |
135 | // 2: As 0, but RCU trailer is 3 32 bit words. | |
136 | // 3: As 1, but RCU trailer is 3 32 bit words. | |
137 | // -1: use offline raw reader | |
138 | ||
139 | Int_t i = 0; | |
140 | Char_t* cpErr; | |
141 | ||
142 | while ( i < argc ) { | |
143 | ||
144 | // -- raw reader mode option | |
145 | if ( !strcmp( argv[i], "rawreadermode" ) ) { | |
146 | if ( argc <= i+1 ) { | |
147 | Logging( kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Missing rawreadermode", "Raw Reader Mode not specified" ); | |
148 | return ENOTSUP; | |
149 | } | |
150 | ||
151 | if ( !strcmp( argv[i+1], "sorted_1_trailerword" ) ) { | |
152 | rawreadermode = 0; | |
153 | } | |
154 | else if ( !strcmp( argv[i+1], "sorted_3_trailerword" ) ) { | |
155 | rawreadermode = 2; | |
156 | } | |
157 | else if ( !strcmp( argv[i+1], "unsorted_1_trailerword" ) ) { | |
158 | rawreadermode = 1; | |
159 | } | |
160 | else if ( !strcmp( argv[i+1], "unsorted_3_trailerword" ) ) { | |
161 | rawreadermode = 3; | |
162 | } | |
163 | else if ( !strcmp( argv[i+1], "offline" ) ) { | |
164 | rawreadermode = -1; | |
165 | } | |
166 | else { | |
167 | rawreadermode = strtoul( argv[i+1], &cpErr ,0); | |
168 | if ( *cpErr ) { | |
169 | Logging( kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Missing rawreadermode", "Cannot convert rawreadermode specifier '%s'.", argv[i+1] ); | |
170 | return EINVAL; | |
171 | } | |
172 | } | |
173 | ||
174 | i += 2; | |
175 | continue; | |
176 | } | |
177 | ||
178 | // -- pp run option | |
179 | if ( !strcmp( argv[i], "pp-run" ) ) { | |
180 | fClusterDeconv = false; | |
181 | i++; | |
182 | continue; | |
183 | } | |
184 | ||
84645eb0 | 185 | // -- zero suppression threshold |
186 | if ( !strcmp( argv[i], "adc-threshold" ) ) { | |
187 | sigthresh = strtoul( argv[i+1], &cpErr ,0); | |
188 | if ( *cpErr ) { | |
189 | HLTError("Cannot convert threshold specifier '%s'.", argv[i+1]); | |
190 | return EINVAL; | |
191 | } | |
192 | i+=2; | |
193 | continue; | |
194 | } | |
195 | ||
5235c3e9 | 196 | // -- pad occupancy limit |
197 | if ( !strcmp( argv[i], "occupancy-threshold" ) ) { | |
198 | occulimit = strtof( argv[i+1], &cpErr); | |
199 | if ( *cpErr ) { | |
200 | HLTError("Cannot convert occupancy specifier '%s'.", argv[i+1]); | |
201 | return EINVAL; | |
202 | } | |
203 | i+=2; | |
204 | continue; | |
205 | } | |
206 | ||
db16520a | 207 | Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); |
208 | return EINVAL; | |
209 | ||
210 | } | |
211 | ||
212 | // Choose reader | |
213 | ||
214 | if (fPackedSwitch) { | |
215 | if (rawreadermode == -1) { | |
74c73e5a | 216 | #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) |
db16520a | 217 | fReader = new AliHLTTPCDigitReaderPacked(); |
218 | fClusterFinder->SetReader(fReader); | |
74c73e5a | 219 | #else // ! defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) |
db16520a | 220 | HLTFatal("DigitReaderPacked not available - check your build"); |
221 | return -ENODEV; | |
74c73e5a | 222 | #endif // defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) |
db16520a | 223 | } else { |
224 | #if defined(HAVE_TPC_MAPPING) | |
225 | fReader = new AliHLTTPCDigitReaderRaw(rawreadermode); | |
226 | fClusterFinder->SetReader(fReader); | |
227 | #else //! defined(HAVE_TPC_MAPPING) | |
228 | HLTFatal("DigitReaderRaw not available - check your build"); | |
229 | return -ENODEV; | |
230 | #endif //defined(HAVE_TPC_MAPPING) | |
231 | } | |
a38a7850 | 232 | } |
233 | else { | |
74c73e5a | 234 | fReader = new AliHLTTPCDigitReaderUnpacked(); |
235 | fClusterFinder->SetReader(fReader); | |
a38a7850 | 236 | } |
5235c3e9 | 237 | |
238 | // if pp-run use occupancy limit else set to 1. ==> use all | |
239 | if ( !fClusterDeconv ) | |
240 | fClusterFinder->SetOccupancyLimit(occulimit); | |
241 | else | |
242 | fClusterFinder->SetOccupancyLimit(1.0); | |
db16520a | 243 | |
a38a7850 | 244 | // Variables to setup the Clusterfinder |
5235c3e9 | 245 | // TODO: this sounds strange and has to be verified; is the cluster finder not working when |
246 | // fClusterDeconv = false ? | |
71d7c760 | 247 | fClusterDeconv = true; |
248 | fXYClusterError = -1; | |
249 | fZClusterError = -1; | |
a38a7850 | 250 | |
db16520a | 251 | |
a38a7850 | 252 | fClusterFinder->SetDeconv( fClusterDeconv ); |
253 | fClusterFinder->SetXYError( fXYClusterError ); | |
254 | fClusterFinder->SetZError( fZClusterError ); | |
255 | if ( (fXYClusterError>0) && (fZClusterError>0) ) | |
256 | fClusterFinder->SetCalcErr( false ); | |
84645eb0 | 257 | fClusterFinder->SetSignalThreshold(sigthresh); |
a38a7850 | 258 | |
71d7c760 | 259 | return 0; |
260 | } | |
261 | ||
262 | int AliHLTTPCClusterFinderComponent::DoDeinit() | |
263 | { | |
a38a7850 | 264 | |
71d7c760 | 265 | if ( fClusterFinder ) |
266 | delete fClusterFinder; | |
267 | fClusterFinder = NULL; | |
a38a7850 | 268 | |
74c73e5a | 269 | if ( fReader ) |
270 | delete fReader; | |
271 | fReader = NULL; | |
a38a7850 | 272 | |
71d7c760 | 273 | return 0; |
274 | } | |
275 | ||
a38a7850 | 276 | int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponent_EventData& evtData, |
277 | const AliHLTComponent_BlockData* blocks, | |
71d7c760 | 278 | AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, |
a38a7850 | 279 | AliHLTUInt32_t& size, |
280 | vector<AliHLTComponent_BlockData>& outputBlocks ) | |
71d7c760 | 281 | { |
db16520a | 282 | |
a38a7850 | 283 | // == init iter (pointer to datablock) |
71d7c760 | 284 | const AliHLTComponent_BlockData* iter = NULL; |
285 | unsigned long ndx; | |
a38a7850 | 286 | |
287 | // == OUTdatatype pointer | |
71d7c760 | 288 | AliHLTTPCClusterData* outPtr; |
a38a7850 | 289 | |
71d7c760 | 290 | AliHLTUInt8_t* outBPtr; |
291 | UInt_t offset, mysize, nSize, tSize = 0; | |
a38a7850 | 292 | |
71d7c760 | 293 | outBPtr = outputPtr; |
294 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
a38a7850 | 295 | |
71d7c760 | 296 | Int_t slice, patch, row[2]; |
297 | unsigned long maxPoints, realPoints = 0; | |
a38a7850 | 298 | |
71d7c760 | 299 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
300 | { | |
301 | iter = blocks+ndx; | |
302 | mysize = 0; | |
303 | offset = tSize; | |
a38a7850 | 304 | |
305 | ||
306 | if (fPackedSwitch) { | |
307 | char tmp1[14], tmp2[14]; | |
308 | DataType2Text( iter->fDataType, tmp1 ); | |
309 | DataType2Text( AliHLTTPCDefinitions::gkDDLPackedRawDataType, tmp2 ); | |
310 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Event received", | |
311 | "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
312 | evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
313 | ||
314 | if ( iter->fDataType != AliHLTTPCDefinitions::gkDDLPackedRawDataType ) continue; | |
315 | ||
316 | } | |
317 | else { | |
318 | char tmp1[14], tmp2[14]; | |
319 | DataType2Text( iter->fDataType, tmp1 ); | |
320 | DataType2Text( AliHLTTPCDefinitions::gkUnpackedRawDataType, tmp2 ); | |
321 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Event received", | |
322 | "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
323 | evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
324 | ||
325 | if ( iter->fDataType != AliHLTTPCDefinitions::gkUnpackedRawDataType ) continue; | |
326 | ||
327 | } | |
328 | ||
71d7c760 | 329 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); |
330 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
a6c02c85 | 331 | row[0] = AliHLTTPCTransform::GetFirstRow( patch ); |
332 | row[1] = AliHLTTPCTransform::GetLastRow( patch ); | |
71d7c760 | 333 | |
334 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", | |
335 | "Input: Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.", | |
336 | realPoints, slice, patch, row[0], row[1] ); | |
337 | ||
338 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
a38a7850 | 339 | |
a6c02c85 | 340 | maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData); |
db16520a | 341 | |
71d7c760 | 342 | fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints ); |
71d7c760 | 343 | fClusterFinder->SetOutputArray( outPtr->fSpacePoints ); |
a38a7850 | 344 | fClusterFinder->Read(iter->fPtr, iter->fSize ); |
71d7c760 | 345 | fClusterFinder->ProcessDigits(); |
346 | realPoints = fClusterFinder->GetNumberOfClusters(); | |
347 | ||
348 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints", | |
349 | "Number of spacepoints found: %lu.", realPoints ); | |
350 | ||
351 | outPtr->fSpacePointCnt = realPoints; | |
a6c02c85 | 352 | nSize = sizeof(AliHLTTPCSpacePointData)*realPoints; |
71d7c760 | 353 | mysize += nSize+sizeof(AliHLTTPCClusterData); |
354 | ||
355 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", | |
356 | "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.", | |
357 | realPoints, slice, patch, row[0], row[1] ); | |
71d7c760 | 358 | AliHLTComponent_BlockData bd; |
359 | FillBlockData( bd ); | |
360 | bd.fOffset = offset; | |
361 | bd.fSize = mysize; | |
362 | bd.fSpecification = iter->fSpecification; | |
363 | //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes ); | |
364 | outputBlocks.push_back( bd ); | |
365 | ||
366 | tSize += mysize; | |
367 | outBPtr += mysize; | |
368 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
369 | ||
370 | if ( tSize > size ) | |
371 | { | |
372 | Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data", | |
373 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", | |
374 | tSize, size ); | |
375 | return EMSGSIZE; | |
376 | } | |
377 | } | |
378 | ||
379 | size = tSize; | |
db16520a | 380 | |
71d7c760 | 381 | return 0; |
382 | } | |
383 | ||
a38a7850 | 384 |