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