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