]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/AliHLTTPCSliceTrackerComponent.cxx
Coding violations
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCSliceTrackerComponent.cxx
index e4b2aed66488df89fa78c0416b0faeb3ef69fe0b..00abc77b047bc6db432d92b1928a7c2359d7f7c7 100644 (file)
@@ -1,21 +1,21 @@
 // $Id$
 
-/**************************************************************************
- * This file is property of and copyright by the ALICE HLT Project        * 
- * ALICE Experiment at CERN, All rights reserved.                         *
- *                                                                        *
- * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
- *                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
- *                  for The ALICE HLT Project.                            *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
 
 /** @file   AliHLTTPCSliceTrackerComponent.cxx
     @author Timm Steinbeck, Matthias Richter
     @brief  The TPC conformal mapping tracker component.
 */
 
-// 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 __GNUC__>= 3
 using namespace std;
 #endif
 
+#include <climits>
 #include "AliHLTTPCSliceTrackerComponent.h"
 #include "AliHLTTPCTransform.h"
 #include "AliHLTTPCConfMapper.h"
@@ -46,13 +41,18 @@ using namespace std;
 #include "AliHLTTPCInterMerger.h"
 #include "AliHLTTPCMemHandler.h"
 #include "AliHLTTPCDefinitions.h"
+#include "AliHLTCommonCDBEntries.h"
+#include "TString.h"
+#include "TObjString.h"
+#include "TObjArray.h"
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "TGeoGlobalMagField.h"
 //#include "AliHLTTPC.h"
 //#include <stdlib.h>
 //#include <cerrno>
 
-// this is a global object used for automatic component registration, do not use this
-AliHLTTPCSliceTrackerComponent gAliHLTTPCSliceTrackerComponent;
-
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTTPCSliceTrackerComponent)
 
@@ -62,10 +62,26 @@ AliHLTTPCSliceTrackerComponent::AliHLTTPCSliceTrackerComponent()
   fVertex(NULL),
   fDoNonVertex(false),
   fDoPP(false),
+  fDoPbPb(false),
   fMultiplicity(4000),
-  fBField(0.4),
+  fBField(0.5),
   fnonvertextracking(kFALSE),
   fmainvertextracking(kTRUE),
+  fPhisegment(50),
+  fEtasegment(100),
+  fTrackletlength(3),
+  fTracklength(60),
+  fRowscopetracklet(6),
+  fRowscopetrack(6),
+  fMinPtFit(0),
+  fMaxangle(0.1745),
+  fGoodDist(5),
+  fHitChi2Cut(100),
+  fGoodHitChi2(5),
+  fTrackChi2Cut(50),
+  fMaxdist(50),
+  fMaxphi(0.1),
+  fMaxeta(0.1),
   fpInterMerger(NULL)
 {
   // see header file for class documentation
@@ -92,7 +108,7 @@ const char* AliHLTTPCSliceTrackerComponent::GetComponentID()
   return "TPCSliceTracker";
 }
 
-void AliHLTTPCSliceTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+void AliHLTTPCSliceTrackerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
 {
   // see header file for class documentation
   list.clear();
@@ -111,7 +127,7 @@ void AliHLTTPCSliceTrackerComponent::GetOutputDataSize( unsigned long& constBase
   // see header file for class documentation
   // XXX TODO: Find more realistic values.
   constBase = 0;
-  inputMultiplier = 0.2;
+  inputMultiplier = 1;
 }
 
 AliHLTComponent* AliHLTTPCSliceTrackerComponent::Spawn()
@@ -126,8 +142,8 @@ void AliHLTTPCSliceTrackerComponent::SetTrackerParam(Int_t phiSegments, Int_t et
                                   Double_t minPtFit, Double_t maxangle,
                                   Double_t goodDist, Double_t hitChi2Cut,
                                   Double_t goodHitChi2, Double_t trackChi2Cut,
-                                  Int_t maxdist, Double_t maxphi,Double_t maxeta, bool vertexConstraints )
-    {
+                                  Int_t maxdist, Double_t maxphi,Double_t maxeta)
+{
   // see header file for class documentation
     //fTracker->SetClusterFinderParam( fXYClusterError, fZClusterError, kTRUE ); // ??
     //Set parameters input to the tracker
@@ -179,163 +195,154 @@ void AliHLTTPCSliceTrackerComponent::SetTrackerParam(Int_t phiSegments, Int_t et
     fTracker->InitVolumes();
     }
 
-void AliHLTTPCSliceTrackerComponent::SetTrackerParam( bool doPP, int multiplicity, double bField )
-    {
-  // see header file for class documentation
-    AliHLTTPCTransform::SetBField( bField );
-    Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f T\n", bField );
 
-    if ( doPP )
+void AliHLTTPCSliceTrackerComponent::SetTrackerParam( Bool_t doPP, Bool_t doPbPb, Int_t multiplicity, 
+                                                     Double_t bField, Int_t etasegment, Double_t hitchi2cut, 
+                                                     Int_t rowscopetracklet, Int_t rowscopetrack, 
+                                                     Int_t trackletlength, Int_t tracklength )
+{
+  // see header file for class documentation
+  AliHLTTPCTransform::SetBField( bField );
+  Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f T\n", bField );
+  
+  if ( doPP )
+    {
+      //tracker->SetClusterFinderParam(xyerror,zerror,kTRUE); // ??
+      
+      SetTrackerParam( 50, 100, 3, 60,
+                      6, 6,
+                      0, 0.1745, 5, 100,
+                      5, 50, 50, 0.1, 0.1);
+    }
+  else if(doPbPb)
+    {
+      int mults[] = { 1000, 2000, 4000, 8000 };
+      int multCount = 4;
+      int closestMult = 0;
+      int i;
+      int multDist, tmpMultDist;
+      if ( multiplicity>mults[closestMult] )
+       multDist = multiplicity-mults[closestMult];
+      else
+       multDist = mults[closestMult]-multiplicity;
+      for ( i = 1; i < multCount; i++ )
        {
-       //tracker->SetClusterFinderParam(xyerror,zerror,kTRUE); // ??
-       /* the old setup used during TPC
-       SetTrackerParam( 50, 100, 3, 10,
-                        2, 2,
-                        0, 0.1745, 5, 100,
-                        5, 50, 50, 0.1, 0.1, kTRUE);
-       */
-         SetTrackerParam( 50,        // phi_segments:     Devide the space into phi_segments                                      
-                          100,       // ets_segments:     Devide the space into eta_segments                                       
-                          3,         // trackletlength:   Number of hits a tracklet has to have                                   
-                          50,         // tracklength:      Number of hits a track has to have                                      
-                          6,         // rowscopetracklet: Search range of rows for a tracklet                                     
-                          6,         // rowscopetrack:    Search range of rows for a track                                       
-                          0,         // min_pt_fit:       Cut for moment fit, use:SetMaxDca(min_pt_fit)                           
-                          AliHLTTPCTransform::Deg2Rad(10),
-                          // maxangle:         AliHLTTPCTransform::Deg2Rad(10), max angle for the three point look aheand         
-                          5,         // goodDist:         Threshold distancs between two hits when building tracklets             
-                          100,        // hitChi2Cut:       Max chi2 of added hit to track                                         
-                          5,         // goodHitChi2:      Stop looking for next hit to add if chi2 is less then goodHitChi2       
-                          50,        // trackChi2Cut:     Max chi2 for track after final fit                                      
-                          50,        // maxdist:          Maximum distance between two clusters when forming segments             
-                          0.1,       // maxphi:           Max phi difference for neighboring hits                                
-                          0.1,       // maxeta:           Max eta difference for neighboring hits                                 
-                          kTRUE);    // vertexConstrain:  False if one want to look for secondary vertex track           
+         if ( multiplicity>mults[i] )
+           tmpMultDist = multiplicity-mults[i];
+         else
+           tmpMultDist = mults[i]-multiplicity;
+         if ( tmpMultDist < multDist )
+           {
+             closestMult = i;
+             multDist = tmpMultDist;
+           }
        }
-    else
+      
+      double bfs[] = { 0.2, 0.4 };
+      int bfCount = 2;
+      int closestBf = 0;
+      double bfDist, tmpBFDist;
+      if ( bField>bfs[closestBf] )
+       bfDist = bField-bfs[closestBf];
+      else
+       bfDist = bfs[closestBf]-bField;
+      for ( i = 1; i < bfCount; i++ )
        {
-       int mults[] = { 1000, 2000, 4000, 8000 };
-       int multCount = 4;
-       int closestMult = 0;
-       int i;
-       int multDist, tmpMultDist;
-       if ( multiplicity>mults[closestMult] )
-           multDist = multiplicity-mults[closestMult];
-       else
-           multDist = mults[closestMult]-multiplicity;
-       for ( i = 1; i < multCount; i++ )
+         if ( bField>bfs[i] )
+           tmpBFDist = bField-bfs[i];
+         else
+           tmpBFDist = bfs[i]-bField;
+         if ( tmpBFDist < bfDist )
            {
-           if ( multiplicity>mults[i] )
-               tmpMultDist = multiplicity-mults[i];
-           else
-               tmpMultDist = mults[i]-multiplicity;
-           if ( tmpMultDist < multDist )
-               {
-               closestMult = i;
-               multDist = tmpMultDist;
-               }
+             closestBf = i;
+             bfDist = tmpBFDist;
            }
-       
-       double bfs[] = { 0.2, 0.4 };
-       int bfCount = 2;
-       int closestBf = 0;
-       double bfDist, tmpBFDist;
-       if ( bField>bfs[closestBf] )
-           bfDist = bField-bfs[closestBf];
-       else
-           bfDist = bfs[closestBf]-bField;
-       for ( i = 1; i < bfCount; i++ )
+       }
+      
+      switch ( closestMult )
+       {
+       case 0: // 1000
+         switch ( closestBf )
            {
-           if ( bField>bfs[i] )
-               tmpBFDist = bField-bfs[i];
-           else
-               tmpBFDist = bfs[i]-bField;
-           if ( tmpBFDist < bfDist )
-               {
-               closestBf = i;
-               bfDist = tmpBFDist;
-               }
+           case 0: // 0.2
+             SetTrackerParam( 50, 100, 3, 10,
+                              2, 4,
+                              0, 0.1745, 5, 100,
+                              5, 50, 50, 0.1, 0.1);
+             break;
+           case 1: // 0.4
+             SetTrackerParam( 50, 100, 3, 10,
+                              2, 4,
+                              0, 0.1745, 5, 100,
+                              5, 50, 50, 0.1, 0.1);
+             break;
            }
-
-       switch ( closestMult )
+         break;
+       case 1: // 2000
+         switch ( closestBf )
            {
-           case 0: // 1000
-               switch ( closestBf )
-                   {
-                   case 0: // 0.2
-                       SetTrackerParam( 50, 100, 3, 10,
-                                       2, 4,
-                                       0, 0.1745, 5, 100,
-                                       5, 50, 50, 0.1, 0.1, kTRUE );
-                       break;
-                   case 1: // 0.4
-                       SetTrackerParam( 50, 100, 3, 10,
-                                        2, 4,
-                                        0, 0.1745, 5, 100,
-                                        5, 50, 50, 0.1, 0.1, kTRUE );
-                       break;
-                   }
-               break;
-           case 1: // 2000
-               switch ( closestBf )
-                   {
-                   case 0: // 0.2
-                       SetTrackerParam( 50, 100, 3, 10,
-                                        2, 4,
-                                        0, 0.1745, 5, 30,
-                                        5, 20, 50, 0.1, 0.1, kTRUE );
-                       break;
-                   case 1: // 0.4
-                       SetTrackerParam( 50, 100, 3, 10,
-                                        2, 5,
-                                        0, 0.1745, 5, 30,
-                                        5, 20, 50, 0.1, 0.1, kTRUE );
-                       break;
-                   }
-               break;
-           case 2: // 4000
-               switch ( closestBf )
-                   {
-                   case 0: // 0.2
-                       SetTrackerParam( 50, 100, 3, 10,
-                                        2 , 10,
-                                        0, 0.1745, 5, 20,
-                                        5, 10 , 50, 0.1, 0.1, kTRUE );
-                       break;
-                   case 1: // 0.4
-                       SetTrackerParam( 50, 100, 3, 10,
-                                        2, 10,
-                                        0, 0.1745, 5, 20,
-                                        5, 10, 50, 0.1, 0.1, kTRUE );
-                       break;
-                   }
-               break;
-           case 3: // 8000
-               switch ( closestBf )
-                   {
-                   case 0: // 0.2
-                       SetTrackerParam( 50, 100, 3, 10,
-                                        3, 15,
-                                        0, 0.1745, 5, 10,
-                                        5, 5, 50, 0.1, 0.1, kTRUE );
-                       break;
-                   case 1: // 0.4
-                       SetTrackerParam( 50, 100, 3, 10,
-                                        2, 15,
-                                        0, 0.1745, 5, 15,
-                                        5, 5, 50, 0.1, 0.1, kTRUE );
-                       break;
-                   }
-               break;
+           case 0: // 0.2
+             SetTrackerParam( 50, 100, 3, 10,
+                              2, 4,
+                              0, 0.1745, 5, 30,
+                              5, 20, 50, 0.1, 0.1);
+             break;
+           case 1: // 0.4
+             SetTrackerParam( 50, 100, 3, 10,
+                              2, 5,
+                              0, 0.1745, 5, 30,
+                              5, 20, 50, 0.1, 0.1);
+             break;
+           }
+         break;
+       case 2: // 4000
+         switch ( closestBf )
+           {
+           case 0: // 0.2
+             SetTrackerParam( 50, 100, 3, 10,
+                              2 , 10,
+                              0, 0.1745, 5, 20,
+                              5, 10 , 50, 0.1, 0.1);
+             break;
+           case 1: // 0.4
+             SetTrackerParam( 50, 100, 3, 10,
+                              2, 10,
+                              0, 0.1745, 5, 20,
+                              5, 10, 50, 0.1, 0.1);
+             break;
+           }
+         break;
+       case 3: // 8000
+         switch ( closestBf )
+           {
+           case 0: // 0.2
+             SetTrackerParam( 50, 100, 3, 10,
+                              3, 15,
+                              0, 0.1745, 5, 10,
+                              5, 5, 50, 0.1, 0.1);
+             break;
+           case 1: // 0.4
+             SetTrackerParam( 50, 100, 3, 10,
+                              2, 15,
+                              0, 0.1745, 5, 15,
+                              5, 5, 50, 0.1, 0.1);
+             break;
            }
-//     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bfs[closestBf] );
-//     AliHLTTPCTransform::SetBField( bfs[closestBf] );
-//     AliHLTTPCTransform::SetBField( bField );
-//     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bField );
+         break;
        }
+      //       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bfs[closestBf] );
+      //       AliHLTTPCTransform::SetBField( bfs[closestBf] );
+      //       AliHLTTPCTransform::SetBField( bField );
+      //       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bField );
     }
-
-
+  else
+    {
+      SetTrackerParam( 50, etasegment, trackletlength, tracklength,
+                      rowscopetracklet, rowscopetrack,
+                      0, 0.1745, 5, hitchi2cut,
+                      5, 50, 50, 0.1, 0.1);
+    }
+}
        
 int AliHLTTPCSliceTrackerComponent::DoInit( int argc, const char** argv )
     {
@@ -349,101 +356,42 @@ int AliHLTTPCSliceTrackerComponent::DoInit( int argc, const char** argv )
     fEta[0] = 0.;
     fEta[1] = 1.1;
     fDoNonVertex = false;
-    Bool_t bDoMerger=kTRUE;
     fMultiplicity = 4000;
-    fBField = 0.4;
+    fBField = 0.5;
     fDoPP = false;
-
-    int i = 0;
-    char* cpErr;
-    while ( i < argc )
-       {
-       if ( !strcmp( argv[i], "disable-merger" ) ){
-           bDoMerger = kFALSE;
-           i++;
-           continue;       
-       }
-
-       if ( !strcmp( argv[i], "pp-run" ) )
-           {
-           fDoPP = true;
-           i++;
-           continue;
-           }
-       if ( !strcmp( argv[i], "multiplicity" ) )
-           {
-           if ( argc <= i+1 )
-               {
-               Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Missing event multiplicity specifier." );
-               return ENOTSUP;
-               }
-           fMultiplicity = strtoul( argv[i+1], &cpErr, 0 );
-           if ( *cpErr )
-               {
-               Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Cannot convert event multiplicity specifier '%s'.", argv[i+1] );
-               return EINVAL;
-               }
-           i += 2;
-           continue;
-           }
-       if ( !strcmp( argv[i], "bfield" ) )
-           {
-           if ( argc <= i+1 )
-               {
-               Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing B-field", "Missing B-field specifier." );
-               return ENOTSUP;
-               }
-           fBField = strtod( argv[i+1], &cpErr );
-           if ( *cpErr )
-               {
-               Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing multiplicity", "Cannot convert B-field specifier '%s'.", argv[i+1] );
-               return EINVAL;
-               }
-           i += 2;
-           continue;
-           }
-
-       if ( !strcmp( argv[i], "nonvertextracking" ) ){
-         fnonvertextracking = kTRUE;
-         i++;
-         continue;         
-       }
-       
-       if ( !strcmp( argv[i], "mainvertextrackingoff" ) ){     
-         fmainvertextracking = kFALSE;
-         i++;
-         continue;         
-       }
-       
-       if ( !strcmp( argv[i], "etarange" ) ){  
-         if ( argc <= i+1 ){
-           Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing Eta range", "Missing Eta-range specifiers." );
-           return ENOTSUP;
-         }
-         fEta[1] = strtod( argv[i+1], &cpErr );
-         if ( *cpErr ){
-           Logging( kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Missing Eta range", "Cannot convert Eta-range specifier '%s'.", argv[i+1] );
-           return EINVAL;
-         }
-         
-         i += 2;
-         continue;
-       }
-       Logging(kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
-       return EINVAL;
-       }
-    if (fBField == 0.){
-      // parameter for B=0 T 
-      fDoPP = kTRUE;
-      fnonvertextracking = kTRUE;
-      fmainvertextracking = kFALSE;
-    }
+    fDoPbPb = false;
+    fPhisegment=50;
+    fEtasegment=100;
+    fTrackletlength=3;
+    fTracklength=60;
+    fRowscopetracklet=6;
+    fRowscopetrack=6;
+    fMinPtFit=0;
+    fMaxangle=0.1745;
+    fGoodDist=5;
+    fHitChi2Cut=100;
+    fGoodHitChi2=5;
+    fTrackChi2Cut=50;
+    fMaxdist=50;
+    fMaxphi=0.1;
+    fMaxeta=0.1;
+    int iResult=0;
         
-    if (bDoMerger)
-      fpInterMerger = new AliHLTTPCInterMerger();
+    TString configuration="";
+    TString argument="";
+    for (int i=0; i<argc && iResult>=0; i++) {
+      argument=argv[i];
+      if (!configuration.IsNull()) configuration+=" ";
+      configuration+=argument;
+    }
 
-    SetTrackerParam( fDoPP, fMultiplicity, fBField );
-    return 0;
+    if (!configuration.IsNull()) {
+      iResult=Configure(configuration.Data());
+    } else {
+      iResult=Reconfigure(NULL, NULL);
+    }
+    
+    return iResult;
     }
 
 int AliHLTTPCSliceTrackerComponent::DoDeinit()
@@ -463,11 +411,16 @@ int AliHLTTPCSliceTrackerComponent::DoDeinit()
 }
 
 int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
-                                             AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
-                                             AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
-    {
+                                             AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, 
+                                             AliHLTUInt32_t& size, AliHLTComponentBlockDataList& outputBlocks )
+{
   // see header file for class documentation
-    Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "DoEvent()" );
+  int iResult=0;
+  AliHLTUInt32_t capacity=size;
+  size=0;
+
+  if (!IsDataEvent()) return 0;
+
     if ( evtData.fBlockCnt<=0 )
       {
        Logging( kHLTLogWarning, "HLT::TPCSliceTracker::DoEvent", "DoEvent", "no blocks in event" );
@@ -502,12 +455,28 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
        {
        iter = blocks+ndx;
 
-       if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType){
-         HLTDebug("Data block type is not of type AliHLTTPCDefinitions::fgkClustersDataType");
+       bool bIsClusterDataBlock=false;
+       bool bIsVertexDataBlock=false;
+       if(!(bIsClusterDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkClustersDataType)) &&
+          !(bIsVertexDataBlock=(iter->fDataType==AliHLTTPCDefinitions::fgkVertexDataType))){
          continue;
        }
 
        slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+       if (slice<0 || slice>=AliHLTTPCTransform::GetNSlice()) {
+         HLTError("invalid slice number %d extracted from specification 0x%08lx,  skipping block of type %s",
+                  slice, iter->fSpecification, DataType2Text(iter->fDataType).c_str());
+         // just remember the error, if there are other valid blocks ignore the
+         // error, return code otherwise
+         iResult=-EBADF;
+         continue;
+       }
+       if (slice!=AliHLTTPCDefinitions::GetMaxSliceNr( *iter )) {
+         // the code was not written for/ never used with multiple slices
+         // in one data block/ specification
+         HLTWarning("specification 0x%08lx indicates multiple slices in data block %s: never used before, please audit the code",
+                    iter->fSpecification, DataType2Text(iter->fDataType).c_str());
+       }
        found = false;
        slIter = slices.begin();
        slEnd = slices.end();
@@ -530,7 +499,7 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
        else
            *slCntIter++;
 
-       if ( iter->fDataType == AliHLTTPCDefinitions::fgkVertexDataType )
+       if (bIsVertexDataBlock)
            {
            inPtrV = (AliHLTTPCVertexData*)(iter->fPtr);
            vertexIter = iter;
@@ -538,7 +507,7 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
            fVertex->Read( inPtrV );
            vertexSlice = slice;
            }
-       if ( iter->fDataType == AliHLTTPCDefinitions::fgkClustersDataType )
+       if (bIsClusterDataBlock)
            {
            patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
            if ( minPatch>patch )
@@ -585,9 +554,13 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
       }
     else
       {
-       slice = -1;
+       // there is no sense in running the tracker without input, do not send an
+       // empty output block
+       return iResult;
       }
     
+    iResult=0;
+
     if ( vertexSlice != slice )
        {
        // multiple vertex blocks in event and we used the wrong one...
@@ -638,11 +611,11 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
            
        Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Reading hits",
                 "Reading hits for slice %d - patch %d", slice, patch );
-       fTracker->ReadHits( inPtrSP->fSpacePointCnt, inPtrSP->fSpacePoints );
+       //fTracker->ReadHits( inPtrSP->fSpacePointCnt, inPtrSP->fSpacePoints );
+       fTracker->ReadHitsChecked(inPtrSP->fSpacePointCnt, inPtrSP->fSpacePoints,iter->fSize );
        pIter++;
        }
 
-    outPtr = (AliHLTTPCTrackletData*)(outBPtr);
 
     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){        
       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracking", " ---MAINVERTEXTRACKING---");
@@ -677,23 +650,42 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
     } 
     ntracks0=0;
     AliHLTTPCTrackArray* pArray=fTracker->GetTracks();
+    if (pArray->GetOutSize()+sizeof(AliHLTTPCTrackletData)<=capacity) {
+    outPtr = (AliHLTTPCTrackletData*)(outBPtr);
     mysize = pArray->WriteTracks( ntracks0, outPtr->fTracklets );
     outPtr->fTrackletCnt = ntracks0;
 
+    // Matthias 2009-05-22
+    // Somehow the ConfMapFit uses a different sign convention for the magnetic field.
+    // In order to avoid conversions further upstream we change the sign here.
+    // The CM tracker is not the first priority any more as the CA tracker is
+    // going to be used for online TPC reconstruction. But CM tracker has to
+    // remain functional.
+    // Further investigation is ongoing
+    AliHLTTPCTrackSegmentData* segment=outPtr->fTracklets;
+    for (unsigned int trackno=0; trackno<ntracks0; trackno++, segment++) {
+      segment->fCharge*=-1;
+    }
+
     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoEvent", "Tracks",
             "Input: Number of tracks: %lu Slice/MinPatch/MaxPatch/RowMin/RowMax: %lu/%lu/%lu/%lu/%lu.", 
             ntracks0, slice, minPatch, maxPatch, row[0], row[1] );
 
-    tSize += mysize+sizeof(AliHLTTPCTrackletData);
-    outBPtr += mysize+sizeof(AliHLTTPCTrackletData);
-    
+    fTracker->Reset();
+
     AliHLTComponentBlockData bd;
     FillBlockData( bd );
     bd.fOffset = offset;
-    bd.fSize = tSize;
+    bd.fSize = mysize+sizeof(AliHLTTPCTrackletData);
     bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
     outputBlocks.push_back( bd );
 
+    tSize += bd.fSize;
+    outBPtr += bd.fSize;
+    } else {
+      iResult=-ENOSPC;
+    }
+
 #ifdef FORWARD_VERTEX_BLOCK
     if ( vertexIter )
        {
@@ -704,16 +696,245 @@ int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponentEventData& evt
 #endif // FORWARD_VERTEX_BLOCK
 
     size = tSize;
-    return 0;
+    return iResult;
     }
 
+int AliHLTTPCSliceTrackerComponent::Configure(const char* arguments)
+{
+  // see header file for class documentation
+  int iResult=0;
+  if (!arguments) return iResult;
+  
+  // Check field
+  if (!TGeoGlobalMagField::Instance()) {
+    HLTError("magnetic field not initialized, please set up TGeoGlobalMagField and AliMagF");
+    return -ENODEV;
+  }
+
+  TString allArgs=arguments;
+  TString argument;
+  int bMissingParam=0;
+  Bool_t bDoMerger=kTRUE;
+
+  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;
+      
+      if (argument.CompareTo("-disable-merger")==0) {
+       HLTInfo("Disabled Inter Merger");
+       bDoMerger = kFALSE;
+       continue;
+      }
+      else if (argument.CompareTo("-pp-run")==0) {
+       HLTInfo("Using Trackparameters for pp-run");
+       fDoPP = true;
+       continue;
+      }
+      else if (argument.CompareTo("-PbPb-run")==0) {
+       HLTInfo("Using Trackparameters for Pb-Pb-run");
+       fDoPbPb = true;
+       continue;
+      }
+      else if (argument.CompareTo("-nonvertextracking")==0) {
+       HLTInfo("Doing Nonvertex Tracking");
+       fnonvertextracking = kTRUE;
+       continue;
+      }     
+      else if (argument.CompareTo("-mainvertextrackingoff")==0) {
+       HLTInfo("Mainvertex Tracking off");
+       fmainvertextracking = kFALSE;
+       continue;
+      }
+      else if (argument.CompareTo("-multiplicity")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("Multiplicity set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fMultiplicity=((TObjString*)pTokens->At(i))->GetString().Atoi();
+       continue;
+      } 
+      else if (argument.CompareTo("-solenoidBz")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTWarning("parameter -solenoidBz deprecated, magnetic field handled by global AliMagF object and TGeoGlobalMagField");
+       continue;
+      } 
+      else if (argument.CompareTo("-bfield")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTWarning("parameter -bfield deprecated, magnetic field handled by global AliMagF object and TGeoGlobalMagField");
+       continue;
+      } 
+      else if (argument.CompareTo("-etarange")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("Etarange set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fEta[1]=((TObjString*)pTokens->At(i))->GetString().Atof();
+       continue;
+      }
+      else if (argument.CompareTo("-etasegment")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("Number of Etasegment: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fEtasegment=((TObjString*)pTokens->At(i))->GetString().Atoi();
+       continue;
+      }
+      else if (argument.CompareTo("-chi2cut")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("chi2cut set to: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fHitChi2Cut=((TObjString*)pTokens->At(i))->GetString().Atof();
+       continue;
+      }
+      else if (argument.CompareTo("-rowscopetracklet")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("Number of row to look for next cluster for tracklet: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fRowscopetracklet=((TObjString*)pTokens->At(i))->GetString().Atoi();
+       continue;
+      }
+      else if (argument.CompareTo("-rowscopetrack")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("Number of row to look for next cluster for track: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fRowscopetrack=((TObjString*)pTokens->At(i))->GetString().Atoi();
+       continue;
+      }
+      else if (argument.CompareTo("-trackletlength")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("Minimum number of clusters on a Tracklet: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fTrackletlength=((TObjString*)pTokens->At(i))->GetString().Atoi();
+       continue;
+      }
+      else if (argument.CompareTo("-tracklength")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("Minimum number of clusters on a Track: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fTracklength=((TObjString*)pTokens->At(i))->GetString().Atoi();
+       continue;
+      }
+      else if (argument.CompareTo("-clusterZ")==0) {
+       if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
+       HLTInfo("Minimum number of clusters on a Track: %s", ((TObjString*)pTokens->At(i))->GetString().Data());
+       fTracker->SetClusterCutZ(((TObjString*)pTokens->At(i))->GetString().Atoi());
+       continue;
+      }
+      else {
+       HLTError("unknown argument %s", argument.Data());
+       iResult=-EINVAL;
+       break;
+      }
+    }
+    delete pTokens;
+  }
+  if (bMissingParam) {
+    HLTError("missing parameter for argument %s", argument.Data());
+    iResult=-EINVAL;
+  }
+  fBField=GetBz()/10.0;
+  if (fBField == 0.){
+    // parameter for B=0 T 
+    fDoPP = kTRUE;
+    fnonvertextracking = kTRUE;
+    fmainvertextracking = kFALSE;
+  }
+  if (bDoMerger)
+    fpInterMerger = new AliHLTTPCInterMerger();
+  else
+    fpInterMerger = NULL;
+
+  SetTrackerParam(fDoPP,fDoPbPb,fMultiplicity,fBField,fEtasegment,fHitChi2Cut,fRowscopetracklet,fRowscopetrack,fTrackletlength,fTracklength);
+  
+  return iResult;
+}
+
+int AliHLTTPCSliceTrackerComponent::ReadPreprocessorValues(const char* modules)
+{
+  // see header file for class documentation
+  
+  int iResult = 0;
+  TString str(modules);
+  if(str.Contains("HLT") || str.Contains("TPC") || str.Contains("GRP")){
+  
+    const char* pathBField=NULL;
+    if (pathBField) {
+
+      HLTInfo("reconfigure B-Field from entry %s, modules %s", pathBField,(modules!=NULL && modules[0]!=0)?modules:"<none>");
+      //AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(pathBField/*,GetRunNo()*/);
+      
+      AliCDBPath path(pathBField);
+      
+      AliCDBStorage *stor = AliCDBManager::Instance()->GetDefaultStorage();
+      Int_t version    = stor->GetLatestVersion(pathBField, GetRunNo());
+      Int_t subVersion = stor->GetLatestSubVersion(pathBField, GetRunNo(), version);
+      AliCDBEntry *pEntry = stor->Get(path,GetRunNo(), version, subVersion);
+      
+      HLTImportant("RunNo %d, Version %d, subversion %d", GetRunNo(), version, subVersion);
+      
+      if (pEntry) {
+       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
+       if (pString) {
+         HLTImportant("received configuration object string: \'%s\'", pString->GetString().Data());
+         iResult=Configure(pString->GetString().Data());
+       } else {
+         HLTError("configuration object \"%s\" has wrong type, required TObjString", pathBField);
+       }
+      } else {
+       HLTError("cannot fetch object \"%s\" from CDB", pathBField);
+      }
+    }
+  }  
+  return iResult;
+}
+
+int AliHLTTPCSliceTrackerComponent::Reconfigure(const char* cdbEntry, const char* chainId)
+{
+  // see header file for class documentation
+
+  int iResult=0;
+  const char* path="HLT/ConfigTPC/SliceTrackerComponent";
+  const char* defaultNotify="";
+  if (cdbEntry) {
+    path=cdbEntry;
+    defaultNotify=" (default)";
+  }
+  if (path) {
+    HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
+    AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
+    if (pEntry) {
+      TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
+      if (pString) {
+       HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
+       iResult=Configure(pString->GetString().Data());
+      } else {
+       HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
+      }
+    } else {
+      HLTError("cannot fetch object \"%s\" from CDB", path);
+    }
+  }
+
+  const char* pathBField=NULL;
+
+  if (pathBField) {
+    HLTInfo("reconfigure B-Field from entry %s, chain id %s", path,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
+    AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(pathBField/*,GetRunNo()*/);
+    if (pEntry) {
+      TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
+      if (pString) {
+       HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
+       iResult=Configure(pString->GetString().Data());
+      } else {
+       HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
+      }
+    } else {
+      HLTError("cannot fetch object \"%s\" from CDB", path);
+    }
+  }
+  
+  return iResult;
+
+}
+
 void AliHLTTPCSliceTrackerComponent::SetTrackerParam1()
 {
   // see header file for class documentation
   SetTrackerParam( 10, 20, 5, 10, 2,2,
                   0, 1.31, 5, 100,
-                  50, 100, 50, 0.1, 0.1,
-                  true );
+                  50, 100, 50, 0.1, 0.1);
 }