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