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