]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx
Fixed a bug in the Digit reader, moved clusterfinder to initialize from OCDB, Added...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterFinderComponent.cxx
index 15bc3d75f038afc5de613a96cb9b881900b33039..00a316c212eaaf0d3601f73faadfb29181bf16df 100644 (file)
@@ -30,6 +30,7 @@ using namespace std;
 #include "AliHLTTPCDigitReaderPacked.h"
 #include "AliHLTTPCDigitReaderUnpacked.h"
 #include "AliHLTTPCDigitReaderDecoder.h"
+#include "AliHLTTPCDigitReader32Bit.h"
 #include "AliHLTTPCClusterFinder.h"
 #include "AliHLTTPCSpacePointData.h"
 #include "AliHLTTPCClusterDataFormat.h"
@@ -38,16 +39,29 @@ using namespace std;
 #include "AliHLTTPCDefinitions.h"
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
+#include "AliTPCcalibDB.h"
+#include "AliTPCCalPad.h"
+#include "AliTPCParam.h"
 
 #include <cstdlib>
 #include <cerrno>
 #include "TString.h"
 #include "TObjString.h"
+#include "TObjArray.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+
 #include <sys/time.h>
 
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTTPCClusterFinderComponent)
 
+const char* AliHLTTPCClusterFinderComponent::fgkOCDBEntryPacked="HLT/ConfigTPC/TPCClusterFinderPacked";
+const char* AliHLTTPCClusterFinderComponent::fgkOCDBEntryUnpacked="HLT/ConfigTPC/TPCClusterFinderUnpacked";
+const char* AliHLTTPCClusterFinderComponent::fgkOCDBEntryDecoder="HLT/ConfigTPC/TPCClusterFinderDecoder";
+const char* AliHLTTPCClusterFinderComponent::fgkOCDBEntry32Bit="HLT/ConfigTPC/TPCClusterFinder32Bit";
+
 AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(int mode)
   :
   fClusterFinder(NULL),
@@ -62,13 +76,20 @@ AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent(int mode)
   fPatch(0),
   fGetActivePads(0),
   fFirstTimeBin(-1),
-  fLastTimeBin(-1)
+  fLastTimeBin(-1),
+  fDoMC(kFALSE)
 {
   // see header file for class documentation
   // or
   // refer to README to build package
   // or
   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+  if (fModeSwitch!=kClusterFinderPacked &&
+      fModeSwitch!=kClusterFinderUnpacked &&
+      fModeSwitch!=kClusterFinderDecoder &&
+      fModeSwitch!=kClusterFinder32Bit) {
+    HLTFatal("unknown digit reader type");
+  }
 }
 
 AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent()
@@ -86,14 +107,16 @@ const char* AliHLTTPCClusterFinderComponent::GetComponentID()
   case kClusterFinderPacked:
     return "TPCClusterFinderPacked";
     break;
-  case kClusterFinderUnpacked:
-    return "TPCClusterFinderUnpacked";
+  case kClusterFinderUnpacked:          
+    return "TPCClusterFinderUnpacked";          
     break;
   case kClusterFinderDecoder:
     return "TPCClusterFinderDecoder";
     break;
+  case kClusterFinder32Bit:
+    return "TPCClusterFinder32Bit";
+    break;
   }
-  HLTFatal("unknown digit reader type");
   return "";
 }
 
@@ -105,12 +128,15 @@ void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponentD
   case kClusterFinderPacked:
     list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
     break;
-  case kClusterFinderUnpacked:
-    list.push_back( AliHLTTPCDefinitions::fgkUnpackedRawDataType );
+  case kClusterFinderUnpacked:          
+    list.push_back( AliHLTTPCDefinitions::fgkUnpackedRawDataType );     
     break;
   case kClusterFinderDecoder:
     list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
     break;
+  case kClusterFinder32Bit:
+    list.push_back( kAliHLTDataTypeDDLRaw | kAliHLTDataOriginTPC );
+    break;
   }
 }
 
@@ -136,13 +162,16 @@ void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBas
   // XXX TODO: Find more realistic values.  
   constBase = 0;
   switch(fModeSwitch){
-  case 0:
+  case kClusterFinderPacked:
     inputMultiplier = (6 * 0.4);
     break;
-  case 1:
+  case kClusterFinderUnpacked:
     inputMultiplier = 0.4;
     break;
-  case 2:
+  case kClusterFinderDecoder:
+    inputMultiplier = (6 * 0.4);
+    break;
+  case kClusterFinder32Bit:
     inputMultiplier = (6 * 0.4);
     break;
   }
@@ -160,206 +189,62 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
   if ( fClusterFinder )
     return EINPROGRESS;
 
-  fClusterFinder = new AliHLTTPCClusterFinder();
-
-  //  Int_t sigthresh = -1;
-  //  Double_t sigmathresh= -1;
-  Float_t occulimit = 1.0;
-  //  Int_t oldRCUFormat=0;
-  // Data Format version numbers:
-  // 0: RCU Data format as delivered during TPC commissioning, pads/padrows are sorted, RCU trailer is one 32 bit word.
-  // 1: As 0, but pads/padrows are delivered "as is", without sorting
-  // 2: As 0, but RCU trailer is 3 32 bit words.
-  // 3: As 1, but RCU trailer is 3 32 bit words.
-  // -1: use offline raw reader
-
-  Int_t i = 0;
-  Char_t* cpErr;
-
-  while ( i < argc ) {      
-
-
-
-    // -- deconvolute-time option
-    if ( !strcmp( argv[i], "-deconvolute-time" ) ) {
-      fDeconvTime = kTRUE;
-      i++;
-      continue;
-    }
-
-    // -- deconvolute-pad option
-    if ( !strcmp( argv[i], "-deconvolute-pad" ) ) {
-      fDeconvPad = kTRUE;
-      i++;
-      continue;
-    }
-
-    // -- number of timebins (default 1024)
-    if (!strcmp( argv[i], "-timebins") || !strcmp( argv[i], "timebins" )){
-      TString parameter(argv[i+1]);
-      parameter.Remove(TString::kLeading, ' '); // remove all blanks
-      if (parameter.IsDigit()) {
-       AliHLTTPCTransform::SetNTimeBins(parameter.Atoi());
-       HLTInfo("number of timebins set to %d, zbin=%f", AliHLTTPCTransform::GetNTimeBins(), AliHLTTPCTransform::GetZWidth());
-       fClusterFinder->UpdateLastTimeBin();
-      } else {
-       HLTError("Cannot timebin specifier '%s'.", argv[i+1]);
-       return EINVAL;
-      }
-      if(!strcmp( argv[i], "timebins")){
-       HLTWarning("Argument 'timebins' is old, please switch to new argument naming convention (-timebins). The timebins argument will still work, but please change anyway.");
-      }
-      i+=2;
-      continue;
-    }
-
-    // -first-timebin (default 0)
-    if ( !strcmp( argv[i], "-first-timebin" ) ) {
-      TString parameter(argv[i+1]);
-      parameter.Remove(TString::kLeading, ' '); // remove all blanks
-      if (parameter.IsDigit()){
-       fFirstTimeBin=parameter.Atoi();
-       HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
-      } 
-      else {
-       HLTError("Cannot -first-timebin specifier '%s'. Not a number.", argv[i+1]);
-       return EINVAL;
-      }
-      i+=2;
-      continue;
-    }
-
-    // -last-timebin (default 1024)
-    if ( !strcmp( argv[i], "-last-timebin" ) ) {
-      TString parameter(argv[i+1]);
-      parameter.Remove(TString::kLeading, ' '); // remove all blanks
-      if (parameter.IsDigit()){
-       fLastTimeBin=parameter.Atoi();
-       HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
-      } 
-      else {
-       HLTError("Cannot -last-timebin specifier '%s'. Not a number.", argv[i+1]);
-       return EINVAL;
-      }
-      i+=2;
-      continue;
-    }
-
-    // --  unsorted option
-    if ( !strcmp( argv[i], "-sorted" ) ) {
-      fUnsorted=0;
-      i++;
-      continue;
-    }
-
-      
-    // -- checking for active pads, used in 2007 December run
-    if ( !strcmp( argv[i], "-active-pads" ) || !strcmp( argv[i], "activepads" ) ) {
-      if(!strcmp( argv[i], "activepads" )){
-       HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'active-pads'");
-      }
-      fGetActivePads = strtoul( argv[i+1], &cpErr ,0);
-      if ( *cpErr ){
-       HLTError("Cannot convert activepads specifier '%s'. Should  be 0(off) or 1(on), must be integer", argv[i+1]);
-       return EINVAL;
-      }
-      i+=2;
-      continue;
-    }
-
-    // -- pad occupancy limit
-    if ( !strcmp( argv[i], "-occupancy-limit" ) || !strcmp( argv[i], "occupancy-limit" ) ) {
-      if(!strcmp( argv[i], "occupancy-limit" )){
-       HLTWarning("Please switch to new component argument naming convention, use '-occupancy-limit' instead of 'occupancy-limit'");
-      }
-      occulimit = strtod( argv[i+1], &cpErr);
-      if ( *cpErr ) {
-       HLTError("Cannot convert occupancy specifier '%s'.", argv[i+1]);
-       return EINVAL;
-      }
-      if(fModeSwitch!=kClusterFinderPacked){
-       HLTWarning("Argument '-occupancy-limit' is only used with -sorted set and with the TPCClusterFinderPacked , argument is deprecated");
-      }
-      i+=2;
-      continue;
-    }
-
-
-    // -- raw reader mode option
-    if ( !strcmp( argv[i], "rawreadermode" ) ) {
-      if ( argc <= i+1 ) {
-       Logging( kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Missing rawreadermode", "Raw Reader Mode not specified. rawreadermode is no longer a valid argument and will be deprecated even if rawreadermode is specified." );
-       return ENOTSUP;
-      }
-
-      HLTWarning("Argument 'rawreadermode' is deprecated");      
-
-      i += 2;
-      continue;
-    }
-
-
-    // -- pp-run option
-    if ( !strcmp( argv[i], "pp-run") ) {
-      HLTWarning("Argument 'pp-run' is obsolete, deconvolution is swiched off in both time and pad directions by default.");
-      fClusterDeconv = false;
-      i++;
-      continue;
-    }
-
-    // -- zero suppression threshold
-    if ( !strcmp( argv[i], "adc-threshold" ) ) {
-      strtoul( argv[i+1], &cpErr ,0);
-      if ( *cpErr ) {
-       HLTError("Cannot convert threshold specifier '%s'.", argv[i+1]);
-       return EINVAL;
-      }
-      HLTWarning("'adc-threshold' is no longer a valid argument, please use TPCZeroSuppression component if you want to zerosuppress data.");
-      i+=2;
-      continue;
-    }
+  //Test if the OCDB entries used by AliTPCTransform is availible
+  AliTPCcalibDB*  calib=AliTPCcalibDB::Instance();  
+  //
+  AliTPCCalPad * time0TPC = calib->GetPadTime0(); 
+  if(!time0TPC){
+    HLTError("OCDB entry TPC/Calib/PadTime0 (AliTPCcalibDB::GetPadTime0()) is not available.");
+    return -ENOENT;
+  }
 
+  AliTPCParam  * param    = calib->GetParameters();
+  if(!param){
+    HLTError("OCDB entry TPC/Calib/Parameters (AliTPCcalibDB::GetParameters()) is not available.");
+    return -ENOENT;
+  }
 
-    // -- checking for rcu format
-    if ( !strcmp( argv[i], "oldrcuformat" ) ) {
-      strtoul( argv[i+1], &cpErr ,0);
-      if ( *cpErr ){
-       HLTError("Cannot convert oldrcuformat specifier '%s'. Should  be 0(off) or 1(on), must be integer", argv[i+1]);
-       return EINVAL;
-      }
-      HLTWarning("Argument 'oldrcuformat' is deprecated.");
-      i+=2;
-      continue;
-    }
-      
-    // -- checking for unsorted clusterfinding (default 1)
-    if ( !strcmp( argv[i], "unsorted" ) ) {
-      fUnsorted = strtoul( argv[i+1], &cpErr ,0);
-      if ( *cpErr ){
-       HLTError("Cannot convert unsorted specifier '%s'. Should  be 0(off) or 1(on), must be integer", argv[i+1]);
-       return EINVAL;
-      }
-      HLTWarning("Argument 'unsorted' is old and does not follow the new argument naming convention. A change has been made, and the clusterfinder will read the data unsorted by default. For sorted reading, please use '-sorted' as argument. (unsorted 0 will do the same job, but please change anyway.)");
-      i+=2;
-      continue;
-    }
 
-    // -- checking for nsigma-threshold, used in 2007 December run in ZeroSuppression
-    if ( !strcmp( argv[i], "nsigma-threshold" ) ) {
-      strtoul( argv[i+1], &cpErr ,0);
-      if ( *cpErr ){
-       HLTError("Cannot convert nsigma-threshold specifier '%s'. Must be integer", argv[i+1]);
-       return EINVAL;
-      }
-      i+=2;
-      HLTWarning("Argument 'nsigma-threshold' argument is obsolete.");
-      continue;
-    }
+  fClusterFinder = new AliHLTTPCClusterFinder();
 
-    Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
-    return EINVAL;
+  // first configure the default
+  int iResult = 0;
+  switch(fModeSwitch){
+  case kClusterFinderPacked:
+    iResult=ConfigureFromCDBTObjString(fgkOCDBEntryPacked);
+    break;
+  case kClusterFinderUnpacked:          
+    iResult=ConfigureFromCDBTObjString(fgkOCDBEntryUnpacked);
+    break;
+  case kClusterFinderDecoder:
+    iResult=ConfigureFromCDBTObjString(fgkOCDBEntryDecoder);
+    break;
+  case kClusterFinder32Bit:
+    iResult=ConfigureFromCDBTObjString(fgkOCDBEntry32Bit);
+    break;
+  }
 
+  // configure from the command line parameters if specified
+  if (iResult>=0 && argc>0)
+    iResult=ConfigureFromArgumentString(argc, argv);
+  // return iResult;
+
+  /*
+  Int_t iResult=0;
+  TString configuration="";
+  TString argument="";
+  for (int i=0; i<argc && iResult>=0; i++) {
+    argument=argv[i];
+    if (!configuration.IsNull()) configuration+=" ";
+    configuration+=argument;
   }
+  
+  if (!configuration.IsNull()) {
+    iResult=Configure(configuration.Data());
+  } else {
+    iResult=Reconfigure(NULL, NULL);
+  }
+  */
 
   //Checking for conflicting arguments
   if(fClusterDeconv){
@@ -367,7 +252,7 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
       HLTWarning("Conflicting arguments: argument 'pp-run' will be ignored.");
     }
   }
-  if(occulimit!=1.0 && fUnsorted){
+  if(fClusterFinder->GetOccupancyLimit()!=1.0 && fUnsorted){
     HLTWarning("Argument 'occupancy-limit' is deprecated when doing unsorted data reading.");
   }
   if(fGetActivePads==kTRUE && fUnsorted==kFALSE){
@@ -379,38 +264,33 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
   if (fModeSwitch==kClusterFinderPacked) {
       HLTDebug("using AliHLTTPCDigitReaderPacked");
       fReader = new AliHLTTPCDigitReaderPacked();
-      /*
-       if(oldRCUFormat==1){
-       fReader->SetOldRCUFormat(kTRUE);
-       }
-       else if(oldRCUFormat!=0){
-       HLTWarning("Wrong oldrcuformat specifier %d; oldrcuformat set to default(kFALSE)",oldRCUFormat);
-       }
-      */
-      if(fUnsorted==1){
-       fReader->SetUnsorted(kTRUE);
-      }
+      if(fUnsorted==1){        fReader->SetUnsorted(kTRUE); }
       fClusterFinder->SetReader(fReader);
   }
-  else if(fModeSwitch==kClusterFinderUnpacked){
-    HLTDebug("using AliHLTTPCDigitReaderUnpacked");
-    fReader = new AliHLTTPCDigitReaderUnpacked();
+  else if(fModeSwitch==kClusterFinderUnpacked){         
+    HLTDebug("using AliHLTTPCDigitReaderUnpacked");     
+    fReader = new AliHLTTPCDigitReaderUnpacked();       
+    if(fUnsorted==1){  fReader->SetUnsorted(kTRUE); }
     fClusterFinder->SetReader(fReader);
-  }
+  } 
   else if(fModeSwitch==kClusterFinderDecoder){
     HLTDebug("using AliHLTTPCDigitReaderDecoder");
     fReader = new AliHLTTPCDigitReaderDecoder();
     fClusterFinder->SetReader(fReader);
   }
+  else if(fModeSwitch==kClusterFinder32Bit){
+    HLTDebug("using AliHLTTPCDigitReader32Bit");
+    fReader = new AliHLTTPCDigitReader32Bit();
+    fClusterFinder->SetReader(fReader);
+    fClusterFinder->Set32BitFormat(kTRUE);
+  }
   else{
     HLTFatal("No mode set for clusterfindercomponent");
   }
-  // if pp-run use occupancy limit else set to 1. ==> use all 
-  if ( !fClusterDeconv )
-    fClusterFinder->SetOccupancyLimit(occulimit);
-  else 
+
+  if(fClusterDeconv){
     fClusterFinder->SetOccupancyLimit(1.0);
-      
+  }
   
   fClusterFinder->SetDeconv(fClusterDeconv);
   fClusterFinder->SetDeconvPad(fDeconvPad);
@@ -420,8 +300,6 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
   if ( (fXYClusterError>0) && (fZClusterError>0) ){
     fClusterFinder->SetCalcErr( false );
   }
-  //  fClusterFinder->SetSignalThreshold(sigthresh);
-  //  fClusterFinder->SetNSigmaThreshold(sigmathresh);
 
   if(fFirstTimeBin>0){
     fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
@@ -430,7 +308,7 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
     fClusterFinder->SetLastTimeBin(fLastTimeBin);
   }
 
-  return 0;
+  return iResult;
 }
 
 int AliHLTTPCClusterFinderComponent::DoDeinit()
@@ -455,6 +333,13 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
                                              vector<AliHLTComponentBlockData>& outputBlocks )
 {
   // see header file for class documentation
+  int iResult=0;
+
+  if(fReader == NULL){
+    HLTFatal("Digit reader not initialized, skipping HLT TPC cluster reconstruction.");
+    size=0;
+    return 0;    
+  }
 
   if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )){
     size=0;
@@ -474,7 +359,7 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
   outBPtr = outputPtr;
   outPtr = (AliHLTTPCClusterData*)outBPtr;
 
-  Int_t slice, patch, row[2];
+  Int_t slice, patch;
   unsigned long maxPoints, realPoints = 0;
 
   for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
@@ -483,8 +368,17 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
       mysize = 0;
       offset = tSize;
 
+      // Kenneth 16. July 2009
+      // 32 byte is the size of the common data header (CDH)
+      // this is introduced as a protection of empty files
+      // normally when running with file publisher where 
+      // Timms script is used to create the missing files
+      if(iter->fSize <= 32){
+       continue;
+      }
+
 
-      if (fModeSwitch==0 || fModeSwitch==2) {
+      if (fModeSwitch==0 || fModeSwitch==2 || fModeSwitch==3) {
        HLTDebug("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
                 evtData.fEventID, evtData.fEventID, 
                 DataType2Text( iter->fDataType).c_str(), 
@@ -510,12 +404,9 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
        if ( iter->fDataType != AliHLTTPCDefinitions::fgkUnpackedRawDataType ) continue;
 
       }
-       
+
       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
       patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
-      row[0] = AliHLTTPCTransform::GetFirstRow( patch );
-      row[1] = AliHLTTPCTransform::GetLastRow( patch );
-
 
       if(fUnsorted){
        fClusterFinder->SetUnsorted(fUnsorted);
@@ -526,14 +417,13 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
 
       maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
 
-      fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
+      fClusterFinder->InitSlice( slice, patch, maxPoints );
       fClusterFinder->SetOutputArray( (AliHLTTPCSpacePointData*)outPtr->fSpacePoints );
        
       if(fUnsorted){
        if(fGetActivePads){
          fClusterFinder->SetDoPadSelection(kTRUE);
-       }
-       
+       }       
        if(fDeconvTime){
          fClusterFinder->ReadDataUnsortedDeconvoluteTime(iter->fPtr, iter->fSize);
        }
@@ -547,6 +437,8 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
        fClusterFinder->Read(iter->fPtr, iter->fSize );
        fClusterFinder->ProcessDigits();
       }
+      fReader->Reset();
+
       realPoints = fClusterFinder->GetNumberOfClusters();
        
       outPtr->fSpacePointCnt = realPoints;
@@ -555,14 +447,13 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
 
       Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints", 
               "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
-              realPoints, slice, patch, row[0], row[1] );
+              realPoints, slice, patch,AliHLTTPCTransform::GetFirstRow( patch ) , AliHLTTPCTransform::GetLastRow( patch ) );
       AliHLTComponentBlockData bd;
       FillBlockData( bd );
       bd.fOffset = offset;
       bd.fSize = mysize;
       bd.fSpecification = iter->fSpecification;
       bd.fDataType = AliHLTTPCDefinitions::fgkClustersDataType;
-      //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
       outputBlocks.push_back( bd );
        
       tSize += mysize;
@@ -575,7 +466,8 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
          Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data", 
                   "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
                   tSize, size );
-         return EMSGSIZE;
+         iResult=-ENOSPC;
+         break;
        }
        
       if(fUnsorted && fGetActivePads){
@@ -583,10 +475,6 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
        AliHLTUInt16_t* outputHWPtr= (AliHLTUInt16_t*)(outputPtr+tSize);
        Int_t nHWAdd = fClusterFinder->FillHWAddressList(outputHWPtr, maxNumberOfHW);
       
-       //cout<<"Number of hardwareaddresses: "<<nHWAdd<<endl;
-       for(AliHLTUInt16_t test=0;test<nHWAdd;test++){
-        //cout<<"The HW address is: "<<(AliHLTUInt16_t)outputHWPtr[test]<<endl;
-       }
        AliHLTComponentBlockData bdHW;
        FillBlockData( bdHW );
        bdHW.fOffset = tSize ;
@@ -597,25 +485,217 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponentEventData& ev
        
        tSize+=nHWAdd*sizeof(AliHLTUInt16_t);
       }
+
+      if(fDoMC){
+       Int_t maxNumberOfClusterMCInfo = (Int_t)((size-tSize)/sizeof(AliHLTTPCClusterFinder::ClusterMCInfo)-1);
+       AliHLTTPCClusterFinder::ClusterMCInfo* outputMCInfo= (AliHLTTPCClusterFinder::ClusterMCInfo*)(outputPtr+tSize);
+       Int_t nMCInfo = fClusterFinder->FillOutputMCInfo(outputMCInfo, maxNumberOfClusterMCInfo);
+       
+       AliHLTComponentBlockData bdMCInfo;
+       FillBlockData( bdMCInfo );
+       bdMCInfo.fOffset = tSize ;
+       bdMCInfo.fSize = nMCInfo*sizeof(AliHLTTPCClusterFinder::ClusterMCInfo);
+       bdMCInfo.fSpecification = iter->fSpecification;
+       bdMCInfo.fDataType = AliHLTTPCDefinitions::fgkAliHLTDataTypeClusterMCInfo;
+       outputBlocks.push_back( bdMCInfo );
+       
+       tSize+=nMCInfo*sizeof(AliHLTTPCClusterFinder::ClusterMCInfo);
+
+      }
     }
-    
-  size = tSize;
 
-  return 0;
+  if (iResult>=0)
+    size = tSize;
+
+  return iResult;
 }
 
-int AliHLTTPCClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* chainId)
-{
+int AliHLTTPCClusterFinderComponent::ScanConfigurationArgument(int argc, const char** argv){
+
   // see header file for class documentation
-  const char* path="HLT/ConfigTPC";
+
+  if (argc<=0) return 0;
+  int i=0;
+  TString argument=argv[i];
+
+  if (argument.CompareTo("-update-calibdb")==0 || argument.CompareTo("-update-transform")==0 ){
+    if(fClusterFinder->UpdateCalibDB()){
+      HLTDebug("CalibDB and offline transform successfully updated.");
+    }
+    else{
+      HLTError("CalibDB could not be updated.");
+    }
+    return 1;
+  }
+
+  if (argument.CompareTo("-deconvolute-time")==0){
+    HLTDebug("Switching on deconvolution in time direction.");
+    fDeconvTime = kTRUE;
+    fClusterFinder->SetDeconvTime(fDeconvTime);
+    return 1;
+  }
+
+  if (argument.CompareTo("-deconvolute-pad")==0){
+    HLTDebug("Switching on deconvolution in pad direction.");
+    fDeconvPad = kTRUE;
+    fClusterFinder->SetDeconvPad(fDeconvPad);
+    return 1;
+  }
+
+  if (argument.CompareTo("-timebins")==0 || argument.CompareTo("timebins" )==0){
+    HLTWarning("Argument %s is depreciated after moving to the offline AliTPCTransform class for xyz calculations.",argument.Data());
+    /*
+      if (++i>=argc) return -EPROTO;
+      argument=argv[i];
+      AliHLTTPCTransform::SetNTimeBins(argument.Atoi());
+      fClusterFinder->UpdateLastTimeBin();
+      HLTInfo("number of timebins set to %d, zbin=%f", AliHLTTPCTransform::GetNTimeBins(), AliHLTTPCTransform::GetZWidth());
+      return 2;
+    */
+    if(argument.CompareTo("timebins")==0){
+      HLTWarning("Argument 'timebins' is old, please switch to new argument naming convention (-timebins). The timebins argument will still work, but please change anyway.");
+    }
+    return 2;
+  }
+  
+  if (argument.CompareTo("-first-timebin")==0){
+    if (++i>=argc) return -EPROTO;
+    argument=argv[i];
+    fFirstTimeBin = argument.Atoi();
+    if(fFirstTimeBin>=0){
+      HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
+      fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
+    }
+    else{
+      HLTError("-first-timebin specifier is negative: %d",fFirstTimeBin);
+    }
+    return 2;
+  }
+
+  if (argument.CompareTo("-last-timebin")==0){
+    if (++i>=argc) return -EPROTO;
+    argument=argv[i];
+    fLastTimeBin = argument.Atoi();
+    if(fLastTimeBin<AliHLTTPCTransform::GetNTimeBins()){
+      HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
+    }
+    else{
+      HLTError("fLastTimeBins is too big: %d. Maximum: %d",fLastTimeBin,AliHLTTPCTransform::GetNTimeBins());
+    }
+    return 2;
+  }
+  if (argument.CompareTo("-sorted")==0) {
+    fUnsorted=0;
+    HLTDebug("Swithching unsorted off.");
+    fClusterFinder->SetUnsorted(0);
+    return 1;
+  } 
+  
+  if (argument.CompareTo("-do-mc")==0) {
+    fDoMC=kTRUE;
+    fClusterFinder->SetDoMC(fDoMC);
+    HLTDebug("Setting fDoMC to true.");
+    return 1;
+  }
+
+  if (argument.CompareTo("-active-pads")==0 || argument.CompareTo("activepads")==0){
+    if(argument.CompareTo("activepads" )==0){
+      HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'activepads'");
+    }
+    HLTDebug("Switching on ActivePads");
+    fGetActivePads = 1;
+    fClusterFinder->SetDoPadSelection(kTRUE);
+    return 1;
+  }
+
+  if (argument.CompareTo("-occupancy-limit")==0 || argument.CompareTo("occupancy-limit")==0){
+    if(argument.CompareTo("occupancy-limit" )==0){
+      HLTWarning("Please switch to new component argument naming convention, use '-occupancy-limit' instead of 'occupancy-limit'");
+    }
+    if (++i>=argc) return -EPROTO;
+    argument=argv[i];
+    fClusterFinder->SetOccupancyLimit(argument.Atof());
+    HLTDebug("Occupancy limit set to occulimit %f", argument.Atof());
+    return 2;
+  }
+
+  if (argument.CompareTo("rawreadermode")==0){
+    if (++i>=argc) return -EPROTO;
+    HLTWarning("Argument 'rawreadermode' is deprecated");
+    return 2;
+  }
+  
+  if (argument.CompareTo("pp-run")==0){
+    HLTWarning("Argument 'pp-run' is obsolete, deconvolution is swiched off in both time and pad directions by default.");
+    fClusterDeconv = false;
+    return 1;
+  }
+
+  if (argument.CompareTo("adc-threshold" )==0){
+    if (++i>=argc) return -EPROTO;
+    HLTWarning("'adc-threshold' is no longer a valid argument, please use TPCZeroSuppression component if you want to zerosuppress data.");
+    return 2;
+  } 
+  
+  if (argument.CompareTo("oldrcuformat" )==0){
+    if (++i>=argc) return -EPROTO;
+    HLTWarning("Argument 'oldrcuformat' is deprecated.");
+    return 2;
+  }
+  
+  if (argument.CompareTo("unsorted" )==0 || argument.CompareTo("-unsorted" )==0){
+    HLTWarning("Argument is obsolete, unsorted reading is default.");
+    //    fClusterFinder->SetUnsorted(1);
+    return 1;
+  }
+  if (argument.CompareTo("nsigma-threshold")==0){
+    if (++i>=argc) return -EPROTO;
+    HLTWarning("Argument 'nsigma-threshold' argument is obsolete.");
+    return 2;
+  }
+
+  // unknown argument
+  return -EINVAL;
+}
+
+int AliHLTTPCClusterFinderComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
+{  
+  // see header file for class documentation
+
+  const char* entry=cdbEntry;
+  if (!entry || entry[0]==0){
+    switch(fModeSwitch){
+    case kClusterFinderPacked:
+      entry=fgkOCDBEntryPacked;
+      break;
+    case kClusterFinderUnpacked:        
+      entry=fgkOCDBEntryUnpacked;
+      break;
+    case kClusterFinderDecoder:
+      entry=fgkOCDBEntryDecoder;
+      break;
+    case kClusterFinder32Bit:
+      entry=fgkOCDBEntry32Bit;
+      break;
+    }
+  }
+
+  return ConfigureFromCDBTObjString(entry);
+
+  /*
+  int iResult=0;
+  
+  const char* path="HLT/ConfigTPC/ClusterFinderComponent";
   if (cdbEntry) path=cdbEntry;
   if (path) {
     HLTInfo("reconfigure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
-    AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+    AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path);//,GetRunNo());
     if (pEntry) {
       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
       if (pString) {
        HLTInfo("received configuration object: %s", pString->GetString().Data());
+       iResult = Configure(pString->GetString().Data());
       } else {
        HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
       }
@@ -623,5 +703,138 @@ int AliHLTTPCClusterFinderComponent::Reconfigure(const char* cdbEntry, const cha
       HLTError("can not fetch object \"%s\" from CDB", path);
     }
   }
-  return 0;
+  return iResult;
+  */
 }
+
+int AliHLTTPCClusterFinderComponent::Configure(const char* arguments){
+  // see header file for class documentation
+  int iResult=0;
+  if (!arguments) return iResult;
+  
+  TString allArgs=arguments;
+  TString argument;
+  int bMissingParam=0;
+
+  TObjArray* pTokens=allArgs.Tokenize(" ");
+  if (pTokens) {
+    
+    for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
+      argument=((TObjString*)pTokens->At(i))->GetString();
+
+      if (argument.IsNull()) continue;
+      
+      // -- deconvolute-time option
+      if (argument.CompareTo("-deconvolute-time")==0){
+       HLTDebug("Switching on deconvolution in time direction.");
+       fDeconvTime = kTRUE;
+       fClusterFinder->SetDeconvTime(fDeconvTime);
+      }
+      else if (argument.CompareTo("-deconvolute-pad")==0){
+       HLTDebug("Switching on deconvolution in pad direction.");
+       fDeconvPad = kTRUE;
+       fClusterFinder->SetDeconvPad(fDeconvPad);
+      }
+      else if (argument.CompareTo("-timebins")==0 || argument.CompareTo("timebins" )==0){
+       HLTWarning("Argument %s is depreciated after moving to the offline AliTPCTransform class for xyz calculations.",argument.Data());
+       /*
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       AliHLTTPCTransform::SetNTimeBins(((TObjString*)pTokens->At(i))->GetString().Atoi());
+       fClusterFinder->UpdateLastTimeBin();
+       HLTInfo("number of timebins set to %d, zbin=%f", AliHLTTPCTransform::GetNTimeBins(), AliHLTTPCTransform::GetZWidth());
+       */
+       if(argument.CompareTo("timebins")==0){
+         HLTWarning("Argument 'timebins' is old, please switch to new argument naming convention (-timebins). The timebins argument will still work, but please change anyway.");
+       }
+       
+      }
+      else if (argument.CompareTo("-first-timebin")==0){
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       fFirstTimeBin = ((TObjString*)pTokens->At(i))->GetString().Atoi();
+       if(fFirstTimeBin>=0){
+         HLTDebug("fFirstTimeBin set to %d",fFirstTimeBin);
+         fClusterFinder->SetFirstTimeBin(fFirstTimeBin);
+       }
+       else{
+         HLTError("-first-timebin specifier is negative: %d",fFirstTimeBin);
+       }
+      }
+      else if (argument.CompareTo("-last-timebin")==0){
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       fLastTimeBin = ((TObjString*)pTokens->At(i))->GetString().Atoi();
+       if(fLastTimeBin<AliHLTTPCTransform::GetNTimeBins()){
+         HLTDebug("fLastTimeBin set to %d",fLastTimeBin);
+       }
+       else{
+         HLTError("fLastTimeBins is too big: %d. Maximum: %d",fLastTimeBin,AliHLTTPCTransform::GetNTimeBins());
+       }
+      }
+      else if (argument.CompareTo("-sorted")==0) {
+       fUnsorted=0;
+       HLTDebug("Swithching unsorted off.");
+       fClusterFinder->SetUnsorted(0);
+      }
+      else if (argument.CompareTo("-do-mc")==0) {
+       fDoMC=kTRUE;
+       fClusterFinder->SetDoMC(fDoMC);
+       HLTInfo("Setting fDoMC to true.");
+      }
+      else if (argument.CompareTo("-active-pads")==0 || argument.CompareTo("activepads")==0){
+       if(argument.CompareTo("activepads" )==0){
+         HLTWarning("Please change to new component argument naming scheme and use '-active-pads' instead of 'activepads'");
+       }
+       HLTDebug("Switching on ActivePads");
+       fGetActivePads = 1;
+       fClusterFinder->SetDoPadSelection(kTRUE);
+      }
+      else if (argument.CompareTo("-occupancy-limit")==0 || argument.CompareTo("occupancy-limit")==0){
+       if(argument.CompareTo("occupancy-limit" )==0){
+         HLTWarning("Please switch to new component argument naming convention, use '-occupancy-limit' instead of 'occupancy-limit'");
+       }
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       fClusterFinder->SetOccupancyLimit(((TObjString*)pTokens->At(i))->GetString().Atof());
+       HLTDebug("Occupancy limit set to occulimit %f", ((TObjString*)pTokens->At(i))->GetString().Atof());
+      }
+      else if (argument.CompareTo("rawreadermode")==0){
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTWarning("Argument 'rawreadermode' is deprecated");      
+      }
+      else if (argument.CompareTo("pp-run")==0){
+       HLTWarning("Argument 'pp-run' is obsolete, deconvolution is swiched off in both time and pad directions by default.");
+       fClusterDeconv = false;
+      }
+      else if (argument.CompareTo("adc-threshold" )==0){
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTWarning("'adc-threshold' is no longer a valid argument, please use TPCZeroSuppression component if you want to zerosuppress data.");
+      }
+      else if (argument.CompareTo("oldrcuformat" )==0){
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTWarning("Argument 'oldrcuformat' is deprecated.");
+      }
+      else if (argument.CompareTo("unsorted" )==0){
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTDebug("Using unsorted reading.");
+       fClusterFinder->SetUnsorted(1);
+      }
+      else if (argument.CompareTo("nsigma-threshold")==0){
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTWarning("Argument 'nsigma-threshold' argument is obsolete.");
+      }
+      else if (argument.CompareTo("-update-calibdb")==0){
+       fClusterFinder->UpdateCalibDB();
+      }
+      else {
+       HLTError("unknown argument %s", argument.Data());
+       iResult=-EINVAL;
+       break;
+      }
+    }
+    delete pTokens;
+  }
+  if (bMissingParam) {
+    HLTError("missing parameter for argument %s", argument.Data());
+    iResult=-EINVAL;
+  }
+  return iResult;
+}
+