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