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