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