]>
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 |
27f5f8ed | 21 | @author Timm Steinbeck, Matthias Richter, Jochen Thaeder, Kenneth Aamodt |
de554e07 | 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; |
27f5f8ed | 143 | Int_t oldRCUFormat=0; |
db16520a | 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 | ||
27f5f8ed | 220 | // -- checking for rcu format |
221 | if ( !strcmp( argv[i], "oldrcuformat" ) ) { | |
222 | oldRCUFormat = strtoul( argv[i+1], &cpErr ,0); | |
223 | if ( *cpErr ){ | |
224 | HLTError("Cannot convert oldrcuformat specifier '%s'. Should be 0(off) or 1(on), must be integer", argv[i+1]); | |
225 | return EINVAL; | |
226 | } | |
227 | i+=2; | |
228 | continue; | |
229 | } | |
230 | ||
231 | ||
db16520a | 232 | Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); |
233 | return EINVAL; | |
234 | ||
235 | } | |
236 | ||
237 | // Choose reader | |
238 | ||
239 | if (fPackedSwitch) { | |
f3f599e0 | 240 | if (rawreadermode == -2) { |
74c73e5a | 241 | #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) |
db16520a | 242 | fReader = new AliHLTTPCDigitReaderPacked(); |
27f5f8ed | 243 | if(oldRCUFormat==1){ |
244 | fReader->SetOldRCUFormat(kTRUE); | |
245 | } | |
246 | else if(oldRCUFormat!=0){ | |
247 | HLTWarning("Wrong oldrcuformat specifier %d; oldrcuformat set to default(kFALSE)",oldRCUFormat); | |
248 | } | |
db16520a | 249 | fClusterFinder->SetReader(fReader); |
74c73e5a | 250 | #else // ! defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) |
db16520a | 251 | HLTFatal("DigitReaderPacked not available - check your build"); |
252 | return -ENODEV; | |
74c73e5a | 253 | #endif // defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H) |
db16520a | 254 | } else { |
255 | #if defined(HAVE_TPC_MAPPING) | |
256 | fReader = new AliHLTTPCDigitReaderRaw(rawreadermode); | |
257 | fClusterFinder->SetReader(fReader); | |
258 | #else //! defined(HAVE_TPC_MAPPING) | |
259 | HLTFatal("DigitReaderRaw not available - check your build"); | |
260 | return -ENODEV; | |
261 | #endif //defined(HAVE_TPC_MAPPING) | |
262 | } | |
a38a7850 | 263 | } |
264 | else { | |
74c73e5a | 265 | fReader = new AliHLTTPCDigitReaderUnpacked(); |
266 | fClusterFinder->SetReader(fReader); | |
a38a7850 | 267 | } |
5235c3e9 | 268 | |
269 | // if pp-run use occupancy limit else set to 1. ==> use all | |
270 | if ( !fClusterDeconv ) | |
271 | fClusterFinder->SetOccupancyLimit(occulimit); | |
272 | else | |
273 | fClusterFinder->SetOccupancyLimit(1.0); | |
db16520a | 274 | |
a38a7850 | 275 | // Variables to setup the Clusterfinder |
5235c3e9 | 276 | // TODO: this sounds strange and has to be verified; is the cluster finder not working when |
277 | // fClusterDeconv = false ? | |
71d7c760 | 278 | fClusterDeconv = true; |
279 | fXYClusterError = -1; | |
280 | fZClusterError = -1; | |
a38a7850 | 281 | |
db16520a | 282 | |
a38a7850 | 283 | fClusterFinder->SetDeconv( fClusterDeconv ); |
284 | fClusterFinder->SetXYError( fXYClusterError ); | |
285 | fClusterFinder->SetZError( fZClusterError ); | |
286 | if ( (fXYClusterError>0) && (fZClusterError>0) ) | |
287 | fClusterFinder->SetCalcErr( false ); | |
84645eb0 | 288 | fClusterFinder->SetSignalThreshold(sigthresh); |
a38a7850 | 289 | |
71d7c760 | 290 | return 0; |
291 | } | |
292 | ||
293 | int AliHLTTPCClusterFinderComponent::DoDeinit() | |
294 | { | |
2a083ac4 | 295 | // see header file for class documentation |
a38a7850 | 296 | |
71d7c760 | 297 | if ( fClusterFinder ) |
298 | delete fClusterFinder; | |
299 | fClusterFinder = NULL; | |
a38a7850 | 300 | |
74c73e5a | 301 | if ( fReader ) |
302 | delete fReader; | |
303 | fReader = NULL; | |
a38a7850 | 304 | |
71d7c760 | 305 | return 0; |
306 | } | |
307 | ||
8ede8717 | 308 | int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData, |
309 | const AliHLTComponentBlockData* blocks, | |
310 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, | |
a38a7850 | 311 | AliHLTUInt32_t& size, |
8ede8717 | 312 | vector<AliHLTComponentBlockData>& outputBlocks ) |
71d7c760 | 313 | { |
2a083ac4 | 314 | // see header file for class documentation |
db16520a | 315 | |
a38a7850 | 316 | // == init iter (pointer to datablock) |
8ede8717 | 317 | const AliHLTComponentBlockData* iter = NULL; |
71d7c760 | 318 | unsigned long ndx; |
a38a7850 | 319 | |
320 | // == OUTdatatype pointer | |
71d7c760 | 321 | AliHLTTPCClusterData* outPtr; |
a38a7850 | 322 | |
71d7c760 | 323 | AliHLTUInt8_t* outBPtr; |
324 | UInt_t offset, mysize, nSize, tSize = 0; | |
a38a7850 | 325 | |
71d7c760 | 326 | outBPtr = outputPtr; |
327 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
a38a7850 | 328 | |
71d7c760 | 329 | Int_t slice, patch, row[2]; |
330 | unsigned long maxPoints, realPoints = 0; | |
a38a7850 | 331 | |
71d7c760 | 332 | for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
333 | { | |
334 | iter = blocks+ndx; | |
335 | mysize = 0; | |
336 | offset = tSize; | |
a38a7850 | 337 | |
338 | ||
339 | if (fPackedSwitch) { | |
340 | char tmp1[14], tmp2[14]; | |
341 | DataType2Text( iter->fDataType, tmp1 ); | |
96bda103 | 342 | DataType2Text( AliHLTTPCDefinitions::fgkDDLPackedRawDataType, tmp2 ); |
a38a7850 | 343 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Event received", |
344 | "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
345 | evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
346 | ||
96bda103 | 347 | if ( iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) continue; |
a38a7850 | 348 | |
349 | } | |
350 | else { | |
351 | char tmp1[14], tmp2[14]; | |
352 | DataType2Text( iter->fDataType, tmp1 ); | |
96bda103 | 353 | DataType2Text( AliHLTTPCDefinitions::fgkUnpackedRawDataType, tmp2 ); |
a38a7850 | 354 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Event received", |
355 | "Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s", | |
356 | evtData.fEventID, evtData.fEventID, tmp1, tmp2 ); | |
357 | ||
96bda103 | 358 | if ( iter->fDataType != AliHLTTPCDefinitions::fgkUnpackedRawDataType ) continue; |
a38a7850 | 359 | |
360 | } | |
361 | ||
71d7c760 | 362 | slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter ); |
363 | patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter ); | |
a6c02c85 | 364 | row[0] = AliHLTTPCTransform::GetFirstRow( patch ); |
365 | row[1] = AliHLTTPCTransform::GetLastRow( patch ); | |
71d7c760 | 366 | |
367 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", | |
368 | "Input: Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.", | |
369 | realPoints, slice, patch, row[0], row[1] ); | |
370 | ||
371 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
a38a7850 | 372 | |
a6c02c85 | 373 | maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData); |
db16520a | 374 | |
71d7c760 | 375 | fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints ); |
71d7c760 | 376 | fClusterFinder->SetOutputArray( outPtr->fSpacePoints ); |
a38a7850 | 377 | fClusterFinder->Read(iter->fPtr, iter->fSize ); |
71d7c760 | 378 | fClusterFinder->ProcessDigits(); |
379 | realPoints = fClusterFinder->GetNumberOfClusters(); | |
380 | ||
381 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints", | |
382 | "Number of spacepoints found: %lu.", realPoints ); | |
383 | ||
384 | outPtr->fSpacePointCnt = realPoints; | |
a6c02c85 | 385 | nSize = sizeof(AliHLTTPCSpacePointData)*realPoints; |
71d7c760 | 386 | mysize += nSize+sizeof(AliHLTTPCClusterData); |
387 | ||
388 | Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", | |
389 | "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.", | |
390 | realPoints, slice, patch, row[0], row[1] ); | |
8ede8717 | 391 | AliHLTComponentBlockData bd; |
71d7c760 | 392 | FillBlockData( bd ); |
393 | bd.fOffset = offset; | |
394 | bd.fSize = mysize; | |
395 | bd.fSpecification = iter->fSpecification; | |
396 | //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes ); | |
397 | outputBlocks.push_back( bd ); | |
398 | ||
399 | tSize += mysize; | |
400 | outBPtr += mysize; | |
401 | outPtr = (AliHLTTPCClusterData*)outBPtr; | |
402 | ||
403 | if ( tSize > size ) | |
404 | { | |
405 | Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data", | |
406 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", | |
407 | tSize, size ); | |
408 | return EMSGSIZE; | |
409 | } | |
410 | } | |
411 | ||
412 | size = tSize; | |
db16520a | 413 | |
71d7c760 | 414 | return 0; |
415 | } | |
416 | ||
a38a7850 | 417 |