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