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