]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx
Technical fix for bug #58138: VZERO breaks in AliVZEROTrending::~AliVZEROTrending()
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterFinderComponent.cxx
CommitLineData
71d7c760 1// $Id$
2
297174de 3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Timm Steinbeck, Matthias Richter *
8//* Developers: Kenneth Aamodt <kenneth.aamodt@student.uib.no> *
9//* for The ALICE HLT 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//**************************************************************************
71d7c760 19
96bda103 20/** @file AliHLTTPCClusterFinderComponent.cxx
297174de 21 @author Kenneth Aamodt <kenneth.aamodt@student.uib.no>
de554e07 22 @date
23 @brief The TPC cluster finder processing component
24*/
a38a7850 25
db16520a 26#if __GNUC__>= 3
71d7c760 27using namespace std;
28#endif
71d7c760 29#include "AliHLTTPCClusterFinderComponent.h"
a38a7850 30#include "AliHLTTPCDigitReaderPacked.h"
31#include "AliHLTTPCDigitReaderUnpacked.h"
8252a538 32#include "AliHLTTPCDigitReaderDecoder.h"
deba5d85 33#include "AliHLTTPCDigitReader32Bit.h"
a38a7850 34#include "AliHLTTPCClusterFinder.h"
a6c02c85 35#include "AliHLTTPCSpacePointData.h"
71d7c760 36#include "AliHLTTPCClusterDataFormat.h"
a6c02c85 37#include "AliHLTTPCTransform.h"
01f43166 38#include "AliHLTTPCClusters.h"
e67b0680 39#include "AliHLTTPCDefinitions.h"
c3cda394 40#include "AliCDBEntry.h"
41#include "AliCDBManager.h"
d9e5f6f3 42#include "AliTPCcalibDB.h"
43#include "AliTPCCalPad.h"
44#include "AliTPCParam.h"
c3cda394 45
e67b0680 46#include <cstdlib>
47#include <cerrno>
ecefc48a 48#include "TString.h"
c3cda394 49#include "TObjString.h"
3f0fd8f1 50#include "TObjArray.h"
51#include "AliCDBEntry.h"
52#include "AliCDBManager.h"
53#include "AliCDBStorage.h"
54
01f43166 55#include <sys/time.h>
71d7c760 56
c3cda394 57/** ROOT macro for the implementation of ROOT specific class methods */
71d7c760 58ClassImp(AliHLTTPCClusterFinderComponent)
59
4f43db26 60const char* AliHLTTPCClusterFinderComponent::fgkOCDBEntryPacked="HLT/ConfigTPC/TPCClusterFinderPacked";
61const char* AliHLTTPCClusterFinderComponent::fgkOCDBEntryUnpacked="HLT/ConfigTPC/TPCClusterFinderUnpacked";
62const char* AliHLTTPCClusterFinderComponent::fgkOCDBEntryDecoder="HLT/ConfigTPC/TPCClusterFinderDecoder";
63const char* AliHLTTPCClusterFinderComponent::fgkOCDBEntry32Bit="HLT/ConfigTPC/TPCClusterFinder32Bit";
64
8252a538 65AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(int mode)
74c73e5a 66 :
74c73e5a 67 fClusterFinder(NULL),
68 fReader(NULL),
6b15c309 69 fDeconvTime(kFALSE),
70 fDeconvPad(kFALSE),
71 fClusterDeconv(false),
74c73e5a 72 fXYClusterError(-1),
2a083ac4 73 fZClusterError(-1),
8252a538 74 fModeSwitch(mode),
6b15c309 75 fUnsorted(1),
a1dbf058 76 fPatch(0),
6b15c309 77 fGetActivePads(0),
78 fFirstTimeBin(-1),
deba5d85 79 fLastTimeBin(-1),
80 fDoMC(kFALSE)
74c73e5a 81{
2a083ac4 82 // see header file for class documentation
83 // or
84 // refer to README to build package
85 // or
86 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
aca7e630 87 if (fModeSwitch!=kClusterFinderPacked &&
88 fModeSwitch!=kClusterFinderUnpacked &&
deba5d85 89 fModeSwitch!=kClusterFinderDecoder &&
90 fModeSwitch!=kClusterFinder32Bit) {
aca7e630 91 HLTFatal("unknown digit reader type");
92 }
74c73e5a 93}
94
71d7c760 95AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent()
7e99beb3 96{
2a083ac4 97 // see header file for class documentation
7e99beb3 98}
71d7c760 99
100// Public functions to implement AliHLTComponent's interface.
101// These functions are required for the registration process
102
103const char* AliHLTTPCClusterFinderComponent::GetComponentID()
7e99beb3 104{
2a083ac4 105 // see header file for class documentation
8252a538 106 switch(fModeSwitch){
2efb85be 107 case kClusterFinderPacked:
8252a538 108 return "TPCClusterFinderPacked";
109 break;
d1dbb3c1 110 case kClusterFinderUnpacked:
111 return "TPCClusterFinderUnpacked";
112 break;
2efb85be 113 case kClusterFinderDecoder:
8252a538 114 return "TPCClusterFinderDecoder";
115 break;
deba5d85 116 case kClusterFinder32Bit:
117 return "TPCClusterFinder32Bit";
118 break;
8252a538 119 }
b0914d2e 120 return "";
7e99beb3 121}
71d7c760 122
8ede8717 123void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
7e99beb3 124{
2a083ac4 125 // see header file for class documentation
7e99beb3 126 list.clear();
8252a538 127 switch(fModeSwitch){
2efb85be 128 case kClusterFinderPacked:
8252a538 129 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
130 break;
d1dbb3c1 131 case kClusterFinderUnpacked:
132 list.push_back( AliHLTTPCDefinitions::fgkUnpackedRawDataType );
133 break;
2efb85be 134 case kClusterFinderDecoder:
8252a538 135 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
136 break;
deba5d85 137 case kClusterFinder32Bit:
138 list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
139 break;
8252a538 140 }
7e99beb3 141}
71d7c760 142
8ede8717 143AliHLTComponentDataType AliHLTTPCClusterFinderComponent::GetOutputDataType()
7e99beb3 144{
2a083ac4 145 // see header file for class documentation
64defa03 146 return kAliHLTMultipleDataType;
147}
148
149int AliHLTTPCClusterFinderComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
150
151{
152 // see header file for class documentation
153 tgtList.clear();
154 tgtList.push_back(AliHLTTPCDefinitions::fgkClustersDataType);
2fdb1ae7 155 tgtList.push_back(kAliHLTDataTypeHwAddr16);
64defa03 156 return tgtList.size();
7e99beb3 157}
71d7c760 158
159void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
7e99beb3 160{
2a083ac4 161 // see header file for class documentation
7e99beb3 162 // XXX TODO: Find more realistic values.
163 constBase = 0;
8252a538 164 switch(fModeSwitch){
deba5d85 165 case kClusterFinderPacked:
8252a538 166 inputMultiplier = (6 * 0.4);
167 break;
deba5d85 168 case kClusterFinderUnpacked:
8252a538 169 inputMultiplier = 0.4;
170 break;
deba5d85 171 case kClusterFinderDecoder:
172 inputMultiplier = (6 * 0.4);
173 break;
174 case kClusterFinder32Bit:
8252a538 175 inputMultiplier = (6 * 0.4);
176 break;
177 }
7e99beb3 178}
71d7c760 179
180AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn()
7e99beb3 181{
2a083ac4 182 // see header file for class documentation
8252a538 183 return new AliHLTTPCClusterFinderComponent(fModeSwitch);
7e99beb3 184}
71d7c760 185
186int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
7e99beb3 187{
2a083ac4 188 // see header file for class documentation
7e99beb3 189 if ( fClusterFinder )
aac2e4d2 190 return -EINPROGRESS;
7e99beb3 191
d9e5f6f3 192 //Test if the OCDB entries used by AliTPCTransform is availible
193 AliTPCcalibDB* calib=AliTPCcalibDB::Instance();
194 //
f14729cb 195 if(!calib){
196 HLTError("AliTPCcalibCD does not exist");
197 return -ENOENT;
198 }
d9e5f6f3 199 AliTPCCalPad * time0TPC = calib->GetPadTime0();
200 if(!time0TPC){
201 HLTError("OCDB entry TPC/Calib/PadTime0 (AliTPCcalibDB::GetPadTime0()) is not available.");
202 return -ENOENT;
203 }
204
205 AliTPCParam * param = calib->GetParameters();
206 if(!param){
207 HLTError("OCDB entry TPC/Calib/Parameters (AliTPCcalibDB::GetParameters()) is not available.");
208 return -ENOENT;
209 }
210
7e99beb3 211 fClusterFinder = new AliHLTTPCClusterFinder();
212
4f43db26 213 // first configure the default
214 int iResult = 0;
215 switch(fModeSwitch){
216 case kClusterFinderPacked:
217 iResult=ConfigureFromCDBTObjString(fgkOCDBEntryPacked);
218 break;
219 case kClusterFinderUnpacked:
220 iResult=ConfigureFromCDBTObjString(fgkOCDBEntryUnpacked);
221 break;
222 case kClusterFinderDecoder:
223 iResult=ConfigureFromCDBTObjString(fgkOCDBEntryDecoder);
224 break;
225 case kClusterFinder32Bit:
226 iResult=ConfigureFromCDBTObjString(fgkOCDBEntry32Bit);
227 break;
228 }
229
230 // configure from the command line parameters if specified
231 if (iResult>=0 && argc>0)
232 iResult=ConfigureFromArgumentString(argc, argv);
233 // return iResult;
234
f14729cb 235 if(iResult>=0){
236 //initialize the magnetic field from CDB
237 iResult = ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
238 }
239
4f43db26 240 /*
3f0fd8f1 241 Int_t iResult=0;
242 TString configuration="";
243 TString argument="";
244 for (int i=0; i<argc && iResult>=0; i++) {
245 argument=argv[i];
246 if (!configuration.IsNull()) configuration+=" ";
247 configuration+=argument;
248 }
249
250 if (!configuration.IsNull()) {
251 iResult=Configure(configuration.Data());
252 } else {
253 iResult=Reconfigure(NULL, NULL);
7e99beb3 254 }
4f43db26 255 */
db16520a 256
6b15c309 257 //Checking for conflicting arguments
258 if(fClusterDeconv){
259 if(fDeconvPad==kTRUE || fDeconvTime==kTRUE){
260 HLTWarning("Conflicting arguments: argument 'pp-run' will be ignored.");
261 }
262 }
3f0fd8f1 263 if(fClusterFinder->GetOccupancyLimit()!=1.0 && fUnsorted){
6b15c309 264 HLTWarning("Argument 'occupancy-limit' is deprecated when doing unsorted data reading.");
265 }
266 if(fGetActivePads==kTRUE && fUnsorted==kFALSE){
267 HLTWarning("Argument '-active-pads' only work with unsorted data reading. Active pads list will not be produced.");
268 }
269
270
7e99beb3 271 // Choose reader
51b88d1e 272 if (fModeSwitch==kClusterFinderPacked) {
f44e97dc 273 HLTDebug("using AliHLTTPCDigitReaderPacked");
7e99beb3 274 fReader = new AliHLTTPCDigitReaderPacked();
a912b63b 275 if(fUnsorted==1){ fReader->SetUnsorted(kTRUE); }
7e99beb3 276 fClusterFinder->SetReader(fReader);
7e99beb3 277 }
8e3c15c4 278 else if(fModeSwitch==kClusterFinderUnpacked){
279 HLTDebug("using AliHLTTPCDigitReaderUnpacked");
280 fReader = new AliHLTTPCDigitReaderUnpacked();
deba5d85 281 if(fUnsorted==1){ fReader->SetUnsorted(kTRUE); }
8e3c15c4 282 fClusterFinder->SetReader(fReader);
deba5d85 283 }
2efb85be 284 else if(fModeSwitch==kClusterFinderDecoder){
51b88d1e 285 HLTDebug("using AliHLTTPCDigitReaderDecoder");
8252a538 286 fReader = new AliHLTTPCDigitReaderDecoder();
287 fClusterFinder->SetReader(fReader);
288 }
deba5d85 289 else if(fModeSwitch==kClusterFinder32Bit){
290 HLTDebug("using AliHLTTPCDigitReader32Bit");
291 fReader = new AliHLTTPCDigitReader32Bit();
292 fClusterFinder->SetReader(fReader);
293 fClusterFinder->Set32BitFormat(kTRUE);
294 }
8252a538 295 else{
296 HLTFatal("No mode set for clusterfindercomponent");
297 }
3f0fd8f1 298
299 if(fClusterDeconv){
7e99beb3 300 fClusterFinder->SetOccupancyLimit(1.0);
3f0fd8f1 301 }
6b15c309 302
303 fClusterFinder->SetDeconv(fClusterDeconv);
304 fClusterFinder->SetDeconvPad(fDeconvPad);
305 fClusterFinder->SetDeconvTime(fDeconvPad);
7e99beb3 306 fClusterFinder->SetXYError( fXYClusterError );
307 fClusterFinder->SetZError( fZClusterError );
6b15c309 308 if ( (fXYClusterError>0) && (fZClusterError>0) ){
7e99beb3 309 fClusterFinder->SetCalcErr( false );
6b15c309 310 }
6b15c309 311
312 if(fFirstTimeBin>0){
313 fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
314 }
315 if(fLastTimeBin>0 && fLastTimeBin>fFirstTimeBin && fLastTimeBin<=AliHLTTPCTransform::GetNTimeBins()){
316 fClusterFinder->SetLastTimeBin(fLastTimeBin);
317 }
01f43166 318
4f43db26 319 return iResult;
7e99beb3 320}
71d7c760 321
322int AliHLTTPCClusterFinderComponent::DoDeinit()
7e99beb3 323{
2a083ac4 324 // see header file for class documentation
a38a7850 325
7e99beb3 326 if ( fClusterFinder )
327 delete fClusterFinder;
328 fClusterFinder = NULL;
a38a7850 329
7e99beb3 330 if ( fReader )
331 delete fReader;
332 fReader = NULL;
a38a7850 333
7e99beb3 334 return 0;
335}
71d7c760 336
8ede8717 337int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& evtData,
338 const AliHLTComponentBlockData* blocks,
5d2abf3b 339 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
a38a7850 340 AliHLTUInt32_t& size,
8ede8717 341 vector<AliHLTComponentBlockData>& outputBlocks )
7e99beb3 342{
2a083ac4 343 // see header file for class documentation
9758b471 344 int iResult=0;
db16520a 345
a912b63b 346 if(fReader == NULL){
998bd503 347 HLTFatal("Digit reader not initialized, skipping HLT TPC cluster reconstruction.");
a912b63b 348 size=0;
aac2e4d2 349 return -ENODEV;
a912b63b 350 }
351
aac2e4d2 352 if(!IsDataEvent()){
0e588049 353 size=0;
354 return 0;
355 }
356
7e99beb3 357 // == init iter (pointer to datablock)
358 const AliHLTComponentBlockData* iter = NULL;
359 unsigned long ndx;
a38a7850 360
7e99beb3 361 // == OUTdatatype pointer
362 AliHLTTPCClusterData* outPtr;
a38a7850 363
7e99beb3 364 AliHLTUInt8_t* outBPtr;
365 UInt_t offset, mysize, nSize, tSize = 0;
a38a7850 366
7e99beb3 367 outBPtr = outputPtr;
368 outPtr = (AliHLTTPCClusterData*)outBPtr;
a38a7850 369
a912b63b 370 Int_t slice, patch;
7e99beb3 371 unsigned long maxPoints, realPoints = 0;
a38a7850 372
7e99beb3 373 for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
374 {
375 iter = blocks+ndx;
376 mysize = 0;
377 offset = tSize;
a38a7850 378
2d6b17ff 379 // Kenneth 16. July 2009
380 // 32 byte is the size of the common data header (CDH)
381 // this is introduced as a protection of empty files
382 // normally when running with file publisher where
383 // Timms script is used to create the missing files
384 if(iter->fSize <= 32){
385 continue;
386 }
387
a38a7850 388
deba5d85 389 if (fModeSwitch==0 || fModeSwitch==2 || fModeSwitch==3) {
f69743b7 390 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
391 evtData.fEventID, evtData.fEventID,
392 DataType2Text( iter->fDataType).c_str(),
393 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
a38a7850 394
f69743b7 395 if (iter->fDataType == AliHLTTPCDefinitions::fgkDDLPackedRawDataType &&
396 GetEventCount()<2) {
397 HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeDDLRaw)!",
398 DataType2Text(AliHLTTPCDefinitions::fgkDDLPackedRawDataType).c_str(),
399 DataType2Text(kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC).c_str());
400 }
401
402 if ( iter->fDataType != (kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC) &&
403 iter->fDataType != AliHLTTPCDefinitions::fgkDDLPackedRawDataType ) continue;
a38a7850 404
7e99beb3 405 }
8252a538 406 else if(fModeSwitch==1){
f69743b7 407 HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
408 evtData.fEventID, evtData.fEventID,
409 DataType2Text( iter->fDataType).c_str(),
410 DataType2Text(AliHLTTPCDefinitions::fgkUnpackedRawDataType).c_str());
aca7e630 411
412 if ( iter->fDataType != AliHLTTPCDefinitions::fgkUnpackedRawDataType ) continue;
413
7e99beb3 414 }
5863c71a 415
7e99beb3 416 slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
417 patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
8252a538 418
aff6e981 419 if(fUnsorted){
8252a538 420 fClusterFinder->SetUnsorted(fUnsorted);
421 fClusterFinder->SetPatch(patch);
aff6e981 422 }
423
7e99beb3 424 outPtr = (AliHLTTPCClusterData*)outBPtr;
a38a7850 425
7e99beb3 426 maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
db16520a 427
a912b63b 428 fClusterFinder->InitSlice( slice, patch, maxPoints );
e83e889b 429 fClusterFinder->SetOutputArray( (AliHLTTPCSpacePointData*)outPtr->fSpacePoints );
01f43166 430
431 if(fUnsorted){
2fdb1ae7 432 if(fGetActivePads){
433 fClusterFinder->SetDoPadSelection(kTRUE);
a912b63b 434 }
6b15c309 435 if(fDeconvTime){
436 fClusterFinder->ReadDataUnsortedDeconvoluteTime(iter->fPtr, iter->fSize);
437 }
438 else{
439 fClusterFinder->ReadDataUnsorted(iter->fPtr, iter->fSize);
440 }
01f43166 441
01f43166 442 fClusterFinder->FindClusters();
443 }
444 else{
445 fClusterFinder->Read(iter->fPtr, iter->fSize );
446 fClusterFinder->ProcessDigits();
447 }
9758b471 448 fReader->Reset();
a912b63b 449
7e99beb3 450 realPoints = fClusterFinder->GetNumberOfClusters();
71d7c760 451
7e99beb3 452 outPtr->fSpacePointCnt = realPoints;
453 nSize = sizeof(AliHLTTPCSpacePointData)*realPoints;
454 mysize += nSize+sizeof(AliHLTTPCClusterData);
74511e22 455
456 Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints",
7e99beb3 457 "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
a912b63b 458 realPoints, slice, patch,AliHLTTPCTransform::GetFirstRow( patch ) , AliHLTTPCTransform::GetLastRow( patch ) );
7e99beb3 459 AliHLTComponentBlockData bd;
460 FillBlockData( bd );
461 bd.fOffset = offset;
462 bd.fSize = mysize;
463 bd.fSpecification = iter->fSpecification;
64defa03 464 bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
7e99beb3 465 outputBlocks.push_back( bd );
71d7c760 466
7e99beb3 467 tSize += mysize;
468 outBPtr += mysize;
469 outPtr = (AliHLTTPCClusterData*)outBPtr;
71d7c760 470
b1c46961 471
7e99beb3 472 if ( tSize > size )
473 {
474 Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data",
475 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
476 tSize, size );
9758b471 477 iResult=-ENOSPC;
478 break;
71d7c760 479 }
2fdb1ae7 480
481 if(fUnsorted && fGetActivePads){
482 Int_t maxNumberOfHW=(Int_t)((size-tSize)/sizeof(AliHLTUInt16_t)-1);
483 AliHLTUInt16_t* outputHWPtr= (AliHLTUInt16_t*)(outputPtr+tSize);
484 Int_t nHWAdd = fClusterFinder->FillHWAddressList(outputHWPtr, maxNumberOfHW);
485
2fdb1ae7 486 AliHLTComponentBlockData bdHW;
487 FillBlockData( bdHW );
488 bdHW.fOffset = tSize ;
489 bdHW.fSize = nHWAdd*sizeof(AliHLTUInt16_t);
490 bdHW.fSpecification = iter->fSpecification;
491 bdHW.fDataType = kAliHLTDataTypeHwAddr16;
492 outputBlocks.push_back( bdHW );
493
494 tSize+=nHWAdd*sizeof(AliHLTUInt16_t);
495 }
deba5d85 496
497 if(fDoMC){
498 Int_t maxNumberOfClusterMCInfo = (Int_t)((size-tSize)/sizeof(AliHLTTPCClusterFinder::ClusterMCInfo)-1);
499 AliHLTTPCClusterFinder::ClusterMCInfo* outputMCInfo= (AliHLTTPCClusterFinder::ClusterMCInfo*)(outputPtr+tSize);
500 Int_t nMCInfo = fClusterFinder->FillOutputMCInfo(outputMCInfo, maxNumberOfClusterMCInfo);
501
502 AliHLTComponentBlockData bdMCInfo;
503 FillBlockData( bdMCInfo );
504 bdMCInfo.fOffset = tSize ;
505 bdMCInfo.fSize = nMCInfo*sizeof(AliHLTTPCClusterFinder::ClusterMCInfo);
506 bdMCInfo.fSpecification = iter->fSpecification;
507 bdMCInfo.fDataType = AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo;
508 outputBlocks.push_back( bdMCInfo );
509
510 tSize+=nMCInfo*sizeof(AliHLTTPCClusterFinder::ClusterMCInfo);
511
512 }
71d7c760 513 }
514
9758b471 515 if (iResult>=0)
516 size = tSize;
517
518 return iResult;
7e99beb3 519}
c3cda394 520
4f43db26 521int AliHLTTPCClusterFinderComponent::ScanConfigurationArgument(int argc, const char** argv){
522
523 // see header file for class documentation
524
525 if (argc<=0) return 0;
526 int i=0;
527 TString argument=argv[i];
528
f14729cb 529 if (argument.CompareTo("-solenoidBz")==0){
530 if (++i>=argc) return -EPROTO;
531 argument=argv[i];
532 AliTPCcalibDB* calib=AliTPCcalibDB::Instance();
533 if(!calib){
534 HLTError("CalibDB not availible");
535 }
536 Float_t magneticField = argument.Atof();
537 calib->SetExBField(magneticField);
538 HLTInfo("SolenoidBz is set to %f in the calibDB",magneticField);
539 return 2;
540 }
541
4f43db26 542 if (argument.CompareTo("-update-calibdb")==0 || argument.CompareTo("-update-transform")==0 ){
543 if(fClusterFinder->UpdateCalibDB()){
544 HLTDebug("CalibDB and offline transform successfully updated.");
545 }
546 else{
547 HLTError("CalibDB could not be updated.");
548 }
549 return 1;
550 }
551
552 if (argument.CompareTo("-deconvolute-time")==0){
553 HLTDebug("Switching on deconvolution in time direction.");
554 fDeconvTime = kTRUE;
555 fClusterFinder->SetDeconvTime(fDeconvTime);
556 return 1;
557 }
558
559 if (argument.CompareTo("-deconvolute-pad")==0){
560 HLTDebug("Switching on deconvolution in pad direction.");
561 fDeconvPad = kTRUE;
562 fClusterFinder->SetDeconvPad(fDeconvPad);
563 return 1;
564 }
565
566 if (argument.CompareTo("-timebins")==0 || argument.CompareTo("timebins" )==0){
567 HLTWarning("Argument %s is depreciated after moving to the offline AliTPCTransform class for xyz calculations.",argument.Data());
568 /*
569 if (++i>=argc) return -EPROTO;
570 argument=argv[i];
571 AliHLTTPCTransform::SetNTimeBins(argument.Atoi());
572 fClusterFinder->UpdateLastTimeBin();
573 HLTInfo("number of timebins set to %d, zbin=%f", AliHLTTPCTransform::GetNTimeBins(), AliHLTTPCTransform::GetZWidth());
574 return 2;
575 */
576 if(argument.CompareTo("timebins")==0){
577 HLTWarning("Argument 'timebins' is old, please switch to new argument naming convention (-timebins). The timebins argument will still work, but please change anyway.");
578 }
579 return 2;
580 }
581
582 if (argument.CompareTo("-first-timebin")==0){
583 if (++i>=argc) return -EPROTO;
584 argument=argv[i];
585 fFirstTimeBin = argument.Atoi();
586 if(fFirstTimeBin>=0){
587 HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
588 fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
589 }
590 else{
591 HLTError("-first-timebin specifier is negative: %d",fFirstTimeBin);
592 }
593 return 2;
594 }
595
596 if (argument.CompareTo("-last-timebin")==0){
597 if (++i>=argc) return -EPROTO;
598 argument=argv[i];
599 fLastTimeBin = argument.Atoi();
600 if(fLastTimeBin<AliHLTTPCTransform::GetNTimeBins()){
601 HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
602 }
603 else{
604 HLTError("fLastTimeBins is too big: %d. Maximum: %d",fLastTimeBin,AliHLTTPCTransform::GetNTimeBins());
605 }
606 return 2;
607 }
608
609 if (argument.CompareTo("-sorted")==0) {
610 fUnsorted=0;
611 HLTDebug("Swithching unsorted off.");
612 fClusterFinder->SetUnsorted(0);
613 return 1;
614 }
615
616 if (argument.CompareTo("-do-mc")==0) {
617 fDoMC=kTRUE;
618 fClusterFinder->SetDoMC(fDoMC);
619 HLTDebug("Setting fDoMC to true.");
620 return 1;
621 }
622
623 if (argument.CompareTo("-active-pads")==0 || argument.CompareTo("activepads")==0){
624 if(argument.CompareTo("activepads" )==0){
625 HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'activepads'");
626 }
627 HLTDebug("Switching on ActivePads");
628 fGetActivePads = 1;
629 fClusterFinder->SetDoPadSelection(kTRUE);
630 return 1;
631 }
632
633 if (argument.CompareTo("-occupancy-limit")==0 || argument.CompareTo("occupancy-limit")==0){
634 if(argument.CompareTo("occupancy-limit" )==0){
635 HLTWarning("Please switch to new component argument naming convention, use '-occupancy-limit' instead of 'occupancy-limit'");
636 }
637 if (++i>=argc) return -EPROTO;
638 argument=argv[i];
639 fClusterFinder->SetOccupancyLimit(argument.Atof());
640 HLTDebug("Occupancy limit set to occulimit %f", argument.Atof());
641 return 2;
642 }
643
644 if (argument.CompareTo("rawreadermode")==0){
645 if (++i>=argc) return -EPROTO;
646 HLTWarning("Argument 'rawreadermode' is deprecated");
647 return 2;
648 }
649
650 if (argument.CompareTo("pp-run")==0){
651 HLTWarning("Argument 'pp-run' is obsolete, deconvolution is swiched off in both time and pad directions by default.");
652 fClusterDeconv = false;
653 return 1;
654 }
655
656 if (argument.CompareTo("adc-threshold" )==0){
657 if (++i>=argc) return -EPROTO;
658 HLTWarning("'adc-threshold' is no longer a valid argument, please use TPCZeroSuppression component if you want to zerosuppress data.");
659 return 2;
660 }
661
662 if (argument.CompareTo("oldrcuformat" )==0){
663 if (++i>=argc) return -EPROTO;
664 HLTWarning("Argument 'oldrcuformat' is deprecated.");
665 return 2;
666 }
667
668 if (argument.CompareTo("unsorted" )==0 || argument.CompareTo("-unsorted" )==0){
669 HLTWarning("Argument is obsolete, unsorted reading is default.");
670 // fClusterFinder->SetUnsorted(1);
671 return 1;
672 }
673 if (argument.CompareTo("nsigma-threshold")==0){
674 if (++i>=argc) return -EPROTO;
675 HLTWarning("Argument 'nsigma-threshold' argument is obsolete.");
676 return 2;
677 }
678
679 // unknown argument
680 return -EINVAL;
681}
682
683int AliHLTTPCClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
684{
685 // see header file for class documentation
686
687 const char* entry=cdbEntry;
688 if (!entry || entry[0]==0){
689 switch(fModeSwitch){
690 case kClusterFinderPacked:
691 entry=fgkOCDBEntryPacked;
692 break;
693 case kClusterFinderUnpacked:
694 entry=fgkOCDBEntryUnpacked;
695 break;
696 case kClusterFinderDecoder:
697 entry=fgkOCDBEntryDecoder;
698 break;
699 case kClusterFinder32Bit:
700 entry=fgkOCDBEntry32Bit;
701 break;
702 }
703 }
704
705 return ConfigureFromCDBTObjString(entry);
706
707 /*
708 int iResult=0;
709
710 const char* path="HLT/ConfigTPC/ClusterFinderComponent";
711 if (cdbEntry) path=cdbEntry;
712 if (path) {
713 HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
714 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);//,GetRunNo());
715 if (pEntry) {
716 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
717 if (pString) {
718 HLTInfo("received configuration object: %s", pString->GetString().Data());
719 iResult = Configure(pString->GetString().Data());
720 } else {
721 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
722 }
723 } else {
724 HLTError("can not fetch object \"%s\" from CDB", path);
725 }
726 }
727 return iResult;
728 */
729}
730
3f0fd8f1 731int AliHLTTPCClusterFinderComponent::Configure(const char* arguments){
732 // see header file for class documentation
733 int iResult=0;
734 if (!arguments) return iResult;
735
736 TString allArgs=arguments;
737 TString argument;
738 int bMissingParam=0;
739
740 TObjArray* pTokens=allArgs.Tokenize(" ");
741 if (pTokens) {
742
743 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
744 argument=((TObjString*)pTokens->At(i))->GetString();
745
746 if (argument.IsNull()) continue;
747
3f0fd8f1 748 // -- deconvolute-time option
749 if (argument.CompareTo("-deconvolute-time")==0){
750 HLTDebug("Switching on deconvolution in time direction.");
751 fDeconvTime = kTRUE;
2087f3ed 752 fClusterFinder->SetDeconvTime(fDeconvTime);
3f0fd8f1 753 }
754 else if (argument.CompareTo("-deconvolute-pad")==0){
755 HLTDebug("Switching on deconvolution in pad direction.");
756 fDeconvPad = kTRUE;
2087f3ed 757 fClusterFinder->SetDeconvPad(fDeconvPad);
3f0fd8f1 758 }
759 else if (argument.CompareTo("-timebins")==0 || argument.CompareTo("timebins" )==0){
4f43db26 760 HLTWarning("Argument %s is depreciated after moving to the offline AliTPCTransform class for xyz calculations.",argument.Data());
761 /*
3f0fd8f1 762 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
763 AliHLTTPCTransform::SetNTimeBins(((TObjString*)pTokens->At(i))->GetString().Atoi());
764 fClusterFinder->UpdateLastTimeBin();
765 HLTInfo("number of timebins set to %d, zbin=%f", AliHLTTPCTransform::GetNTimeBins(), AliHLTTPCTransform::GetZWidth());
4f43db26 766 */
3f0fd8f1 767 if(argument.CompareTo("timebins")==0){
768 HLTWarning("Argument 'timebins' is old, please switch to new argument naming convention (-timebins). The timebins argument will still work, but please change anyway.");
769 }
4f43db26 770
3f0fd8f1 771 }
772 else if (argument.CompareTo("-first-timebin")==0){
773 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
774 fFirstTimeBin = ((TObjString*)pTokens->At(i))->GetString().Atoi();
2087f3ed 775 if(fFirstTimeBin>=0){
776 HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
777 fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
778 }
779 else{
780 HLTError("-first-timebin specifier is negative: %d",fFirstTimeBin);
781 }
3f0fd8f1 782 }
783 else if (argument.CompareTo("-last-timebin")==0){
784 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
785 fLastTimeBin = ((TObjString*)pTokens->At(i))->GetString().Atoi();
2087f3ed 786 if(fLastTimeBin<AliHLTTPCTransform::GetNTimeBins()){
787 HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
788 }
789 else{
790 HLTError("fLastTimeBins is too big: %d. Maximum: %d",fLastTimeBin,AliHLTTPCTransform::GetNTimeBins());
791 }
3f0fd8f1 792 }
6899b7f5 793 else if (argument.CompareTo("-sorted")==0) {
3f0fd8f1 794 fUnsorted=0;
795 HLTDebug("Swithching unsorted off.");
2087f3ed 796 fClusterFinder->SetUnsorted(0);
3f0fd8f1 797 }
deba5d85 798 else if (argument.CompareTo("-do-mc")==0) {
799 fDoMC=kTRUE;
800 fClusterFinder->SetDoMC(fDoMC);
801 HLTInfo("Setting fDoMC to true.");
802 }
3f0fd8f1 803 else if (argument.CompareTo("-active-pads")==0 || argument.CompareTo("activepads")==0){
804 if(argument.CompareTo("activepads" )==0){
805 HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'activepads'");
806 }
807 HLTDebug("Switching on ActivePads");
808 fGetActivePads = 1;
2087f3ed 809 fClusterFinder->SetDoPadSelection(kTRUE);
3f0fd8f1 810 }
6899b7f5 811 else if (argument.CompareTo("-occupancy-limit")==0 || argument.CompareTo("occupancy-limit")==0){
3f0fd8f1 812 if(argument.CompareTo("occupancy-limit" )==0){
813 HLTWarning("Please switch to new component argument naming convention, use '-occupancy-limit' instead of 'occupancy-limit'");
814 }
815 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
816 fClusterFinder->SetOccupancyLimit(((TObjString*)pTokens->At(i))->GetString().Atof());
817 HLTDebug("Occupancy limit set to occulimit %f", ((TObjString*)pTokens->At(i))->GetString().Atof());
818 }
819 else if (argument.CompareTo("rawreadermode")==0){
820 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
821 HLTWarning("Argument 'rawreadermode' is deprecated");
822 }
823 else if (argument.CompareTo("pp-run")==0){
824 HLTWarning("Argument 'pp-run' is obsolete, deconvolution is swiched off in both time and pad directions by default.");
825 fClusterDeconv = false;
826 }
827 else if (argument.CompareTo("adc-threshold" )==0){
828 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
829 HLTWarning("'adc-threshold' is no longer a valid argument, please use TPCZeroSuppression component if you want to zerosuppress data.");
830 }
831 else if (argument.CompareTo("oldrcuformat" )==0){
832 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
833 HLTWarning("Argument 'oldrcuformat' is deprecated.");
834 }
835 else if (argument.CompareTo("unsorted" )==0){
836 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
2087f3ed 837 HLTDebug("Using unsorted reading.");
838 fClusterFinder->SetUnsorted(1);
3f0fd8f1 839 }
840 else if (argument.CompareTo("nsigma-threshold")==0){
841 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
842 HLTWarning("Argument 'nsigma-threshold' argument is obsolete.");
843 }
4f43db26 844 else if (argument.CompareTo("-update-calibdb")==0){
845 fClusterFinder->UpdateCalibDB();
846 }
3f0fd8f1 847 else {
848 HLTError("unknown argument %s", argument.Data());
849 iResult=-EINVAL;
850 break;
851 }
852 }
853 delete pTokens;
854 }
855 if (bMissingParam) {
856 HLTError("missing parameter for argument %s", argument.Data());
857 iResult=-EINVAL;
858 }
859 return iResult;
860}
861