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