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