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