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