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