Added a dummy component into the sample library.
authortimms <timms@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Aug 2005 11:20:47 +0000 (11:20 +0000)
committertimms <timms@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Aug 2005 11:20:47 +0000 (11:20 +0000)
Several changes to the BASE module found to be necessary during the
implementation of the dummy component and the TPC components.
Ported existing Pub/Sub TPC components from the framework into the
new system.

32 files changed:
HLT/BASE/AliHLTComponent.h
HLT/BASE/AliHLTDataTypes.h
HLT/BASE/AliHLTDefinitions.h [new file with mode: 0644]
HLT/BASE/AliHLTProcessor.cxx
HLT/BASE/AliHLTProcessor.h
HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx
HLT/BASE/AliHLT_C_Component_WrapperInterface.h
HLT/SampleLib/AliHLTDummyComponent.cxx [new file with mode: 0644]
HLT/SampleLib/AliHLTDummyComponent.h [new file with mode: 0644]
HLT/SampleLib/AliHLTSampleComponent1.cxx
HLT/SampleLib/AliHLTSampleComponent1.h
HLT/SampleLib/AliHLTSampleComponent2.cxx
HLT/SampleLib/AliHLTSampleComponent2.h
HLT/SampleLib/AliHLTSampleLinkDef.h
HLT/SampleLib/Makefile
HLT/TPCLib/AliHLTTPCClusterDataFormat.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCClusterFinderComponent.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCDefinitions.cxx [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCDefinitions.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCGlobalMergerComponent.cxx [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCGlobalMergerComponent.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCLinkDef.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCRawDataFormat.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCRawDataUnpackerComponent.cxx [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCRawDataUnpackerComponent.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCSliceTrackerComponent.cxx [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCSliceTrackerComponent.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCTrackletDataFormat.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCVertexFinderComponent.cxx [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCVertexFinderComponent.h [new file with mode: 0644]
HLT/TPCLib/Makefile [new file with mode: 0644]

index 837430f..1ce466a 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <errno.h>
 #include "AliHLTDataTypes.h"
+#include "AliHLTDefinitions.h"
 #include "TObject.h"
 
 class AliHLTComponentHandler;
@@ -23,17 +24,18 @@ class AliHLTComponent {
   enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
   virtual int Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
   virtual int Deinit();
-  virtual int ProcessEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                           AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr, 
-                           AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt, 
-                           AliHLTComponent_BlockData** outputBlocks,
-                           AliHLTComponent_EventDoneData** edd ) = 0;
+  virtual int ProcessEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                           AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                           AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt, 
+                           AliHLTComponent_BlockData*& outputBlocks,
+                           AliHLTComponent_EventDoneData*& edd ) = 0;
 
   // Information member functions for registration.
   virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
   virtual const char* GetComponentID() = 0;
   virtual void GetInputDataTypes( vector<AliHLTComponent_DataType>& ) = 0;
   virtual AliHLTComponent_DataType GetOutputDataType() = 0;
+  virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) = 0;
 
   // Spawn function, return new class instance
   virtual AliHLTComponent* Spawn() = 0;
@@ -50,6 +52,27 @@ class AliHLTComponent {
     return SetGlobalComponentHandler(NULL,1);
   }
  protected:
+
+  // Fill various structures with default values.
+  void FillBlockData( AliHLTComponent_BlockData& blockData ) {
+    blockData.fStructSize = sizeof(blockData);
+    FillShmData( blockData.fShmKey );
+    blockData.fOffset = ~(AliHLTUInt32_t)0;
+    blockData.fPtr = NULL;
+    blockData.fSize = 0;
+    FillDataType( blockData.fDataType );
+    blockData.fSpecification = ~(AliHLTUInt32_t)0;
+  }
+  void FillShmData( AliHLTComponent_ShmData& shmData ) {
+    shmData.fStructSize = sizeof(shmData);
+    shmData.fShmType = gkAliHLTComponent_InvalidShmType;
+    shmData.fShmID = gkAliHLTComponent_InvalidShmID;
+  }
+  void FillDataType( AliHLTComponent_DataType& dataType ) {
+    dataType.fStructSize = sizeof(dataType);
+    memset( dataType.fID, '*', 8 );
+    memset( dataType.fOrigin, '*', 4 );
+  }
   
   virtual int DoInit( int argc, const char** argv ){
     return 0;
index 3aaea7a..14149b3 100644 (file)
@@ -12,6 +12,8 @@ extern "C" {
 
   typedef unsigned char AliHLTUInt8_t;
 
+  typedef unsigned short AliHLTUInt16_t;
+
   typedef unsigned int AliHLTUInt32_t;
 
   typedef unsigned long long AliHLTUInt64_t;
@@ -35,7 +37,9 @@ extern "C" {
     AliHLTUInt32_t fShmType;
     AliHLTUInt64_t fShmID;
   };
-  
+    const AliHLTUInt32_t gkAliHLTComponent_InvalidShmType = 0;
+    const AliHLTUInt64_t gkAliHLTComponent_InvalidShmID = ~(AliHLTUInt64_t)0;
+
   struct AliHLTComponent_DataType
   {
     AliHLTUInt32_t fStructSize;
@@ -82,4 +86,26 @@ extern "C" {
   };
 }
 
+inline bool operator==( const AliHLTComponent_DataType& dt1, const AliHLTComponent_DataType& dt2 )
+    {
+    for ( unsigned i = 0; i < 8; i++ )
+       if ( dt1.fID[i] != dt2.fID[i] )
+           return false;
+    for ( unsigned i = 0; i < 4; i++ )
+       if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
+           return false;
+    return true;
+    }
+
+inline bool operator!=( const AliHLTComponent_DataType& dt1, const AliHLTComponent_DataType& dt2 )
+    {
+    for ( unsigned i = 0; i < 8; i++ )
+       if ( dt1.fID[i] != dt2.fID[i] )
+           return true;
+    for ( unsigned i = 0; i < 4; i++ )
+       if ( dt1.fOrigin[i] != dt2.fOrigin[i] )
+           return true;
+    return false;
+    }
+
 #endif 
diff --git a/HLT/BASE/AliHLTDefinitions.h b/HLT/BASE/AliHLTDefinitions.h
new file mode 100644 (file)
index 0000000..2df2c75
--- /dev/null
@@ -0,0 +1,12 @@
+// @(#) $Id$
+
+#ifndef ALIHLTDEFINITIONS_H
+#define ALIHLTDEFINITIONS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+#include "AliHLTDataTypes.h"
+
+const AliHLTUInt32_t kAliHLTBlockAlignment = 64;
+
+#endif 
index 53b3863..6b1a778 100644 (file)
@@ -54,18 +54,19 @@ int AliHLTProcessor::Deinit()
   return iResult;
 }
 
-int AliHLTProcessor::ProcessEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                           AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr, 
-                           AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt, 
-                           AliHLTComponent_BlockData** outputBlocks,
-                           AliHLTComponent_EventDoneData** edd )
+int AliHLTProcessor::ProcessEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                           AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                           AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt, 
+                           AliHLTComponent_BlockData*& outputBlocks,
+                           AliHLTComponent_EventDoneData*& edd )
 {
   int iResult=0;
   vector<AliHLTComponent_BlockData> blockData;
   iResult=DoEvent(evtData, blocks, trigData, outputPtr, size, blockData);
   if (iResult>=0) {
-    iResult=MakeOutputDataBlockList(blockData, outputBlockCnt, outputBlocks);
+    iResult=MakeOutputDataBlockList(blockData, &outputBlockCnt, &outputBlocks);
   }
+  edd = NULL;
   return iResult;
 }
 
index a44ba3c..3820976 100644 (file)
@@ -18,11 +18,11 @@ class AliHLTProcessor : public AliHLTComponent {
 
   int Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
   int Deinit();
-  int ProcessEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                   AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr, 
-                   AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt, 
-                   AliHLTComponent_BlockData** outputBlocks,
-                   AliHLTComponent_EventDoneData** edd );
+  int ProcessEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                   AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                   AliHLTUInt32_t& size, AliHLTUInt32_t& outputBlockCnt, 
+                   AliHLTComponent_BlockData*& outputBlocks,
+                   AliHLTComponent_EventDoneData*& edd );
 
   // Information member functions for registration.
   TComponentType GetComponentType() { return AliHLTComponent::kProcessor;}
@@ -35,9 +35,9 @@ class AliHLTProcessor : public AliHLTComponent {
   virtual int DoDeinit(){
     return 0;
   }
-  virtual int DoEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                      AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr, 
-                      AliHLTUInt32_t* size, vector<AliHLTComponent_BlockData>& outputBlocks ) = 0;
+  virtual int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                      AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                      AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks ) = 0;
 
 
   ClassDef(AliHLTProcessor, 0)
index 71a9545..b62bebc 100644 (file)
@@ -89,8 +89,8 @@ void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle )
   delete reinterpret_cast<AliHLTComponent*>( handle );
 }
 
-int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                           AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
+int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponent_EventData* evtData, const AliHLTComponent_BlockData* blocks, 
+                           AliHLTComponent_TriggerData* trigData, AliHLTUInt8_t* outputPtr,
                            AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt, 
                            AliHLTComponent_BlockData** outputBlocks,
                            AliHLTComponent_EventDoneData** edd )
@@ -98,5 +98,23 @@ int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, AliHLTComponent_EventDa
   if ( !handle )
     return ENXIO;
   AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
-  return comp->ProcessEvent( evtData, blocks, trigData, outputPtr, size, outputBlockCnt, outputBlocks, edd );
+  return comp->ProcessEvent( *evtData, blocks, *trigData, outputPtr, *size, *outputBlockCnt, *outputBlocks, *edd );
+}
+
+int AliHLT_C_GetOutputDataType( AliHLTComponentHandle handle, AliHLTComponent_DataType* dataType )
+{
+  if ( !handle )
+    return ENXIO;
+  AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
+  *dataType = comp->GetOutputDataType();
+  return 0;
+}
+
+int AliHLT_C_GetOutputSize( AliHLTComponentHandle handle, unsigned long* constBase, double* inputMultiplier )
+{
+  if ( !handle )
+    return ENXIO;
+  AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
+  comp->GetOutputDataSize( *constBase, *inputMultiplier );
+  return 0;
 }
index 566eeb4..dbc0d30 100644 (file)
@@ -12,7 +12,9 @@
 
 #include <AliHLTDataTypes.h>
 
+#ifdef __cplusplus
 extern "C" {
+#endif
 typedef void* AliHLTComponentHandle;
 
   const AliHLTComponentHandle kEmptyHLTComponentHandle = 0;
@@ -23,12 +25,16 @@ int AliHLT_C_Component_LoadLibrary( const char* libraryPath );
 int AliHLT_C_Component_UnloadLibrary( const char* libraryPath );
 int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, int argc, const char** argv, AliHLTComponentHandle* handle );
 void AliHLT_C_DestroyComponent( AliHLTComponentHandle );
-int AliHLT_C_ProcessEvent( AliHLTComponentHandle, AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                           AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
+int AliHLT_C_ProcessEvent( AliHLTComponentHandle, const AliHLTComponent_EventData* evtData, const AliHLTComponent_BlockData* blocks, 
+                           AliHLTComponent_TriggerData* trigData, AliHLTUInt8_t* outputPtr,
                            AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt, 
                            AliHLTComponent_BlockData** outputBlocks,
                            AliHLTComponent_EventDoneData** edd );
+int AliHLT_C_GetOutputDataType( AliHLTComponentHandle, AliHLTComponent_DataType* dataType );
+int AliHLT_C_GetOutputSize( AliHLTComponentHandle, unsigned long* constBase, double* inputMultiplier );
 
+#ifdef __cplusplus
 }
+#endif
 
 #endif //ALIHLT_C_COMPONENT_WARAPPERINTERFACE_H 
diff --git a/HLT/SampleLib/AliHLTDummyComponent.cxx b/HLT/SampleLib/AliHLTDummyComponent.cxx
new file mode 100644 (file)
index 0000000..988a818
--- /dev/null
@@ -0,0 +1,177 @@
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
+ *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
+ *          for The ALICE Off-line 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// a dummy processing component for the HLT                                 //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__ >= 3
+using namespace std;
+#endif
+
+#include "AliHLTDummyComponent.h"
+#include <stdlib.h>
+#include <errno.h>
+
+// this is a global object used for automatic component registration, do not use this
+AliHLTDummyComponent gAliHLTDummyComponent;
+
+ClassImp(AliHLTDummyComponent)
+    
+AliHLTDummyComponent::AliHLTDummyComponent()
+    {
+    fOutputPercentage = 100; // By default we copy to the output exactly what we got as input
+    }
+
+AliHLTDummyComponent::~AliHLTDummyComponent()
+    {
+    }
+
+const char* AliHLTDummyComponent::GetComponentID()
+    {
+    return "Dummy"; // The ID of this component
+    }
+
+void AliHLTDummyComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
+    {
+    list.clear(); // We do not have any requirements for our input data type(s).
+    }
+
+AliHLTComponent_DataType AliHLTDummyComponent::GetOutputDataType()
+    {
+    return (AliHLTComponent_DataType){ sizeof(AliHLTComponent_DataType), {'D','U','M','M','Y',' ',' ',' '},{'D','U','M','Y'}};
+    }
+
+void AliHLTDummyComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+    {
+    constBase = 0;
+    inputMultiplier = ((double)fOutputPercentage)/100.0;
+    }
+
+
+
+// Spawn function, return new instance of this class
+AliHLTComponent* AliHLTDummyComponent::Spawn()
+    {
+    return new AliHLTDummyComponent;
+    };
+
+int AliHLTDummyComponent::DoInit( int argc, const char** argv )
+    {
+    // perform initialization. We check whether our relative output size is specified in the arguments.
+    fOutputPercentage = 100;
+    int i = 0;
+    char* cpErr;
+    while ( i < argc )
+       {
+       Logging( kHLTLogDebug, "HLT::Dummy::DoInit", "Arguments", "argv[%d] == %s", i, argv[i] );
+       if ( !strcmp( argv[i], "output_percentage" ) )
+           {
+           if ( i+1>=argc )
+               {
+               Logging(kHLTLogError, "HLT::Dummy::DoInit", "Missing Argument", "Missing output_percentage parameter");
+               return ENOTSUP;
+               }
+           Logging( kHLTLogDebug, "HLT::Dummy::DoInit", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
+           fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
+           if ( *cpErr )
+               {
+               Logging(kHLTLogError, "HLT::Dummy::DoInit", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
+               return EINVAL;
+               }
+           Logging( kHLTLogInfo, "HLT::Dummy::DoInit", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
+           i += 2;
+           continue;
+           }
+       Logging(kHLTLogError, "HLT::Dummy::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+       return EINVAL;
+       }
+    return 0;
+    }
+
+int AliHLTDummyComponent::DoDeinit()
+    {
+    return 0;
+    }
+
+int AliHLTDummyComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                                     AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                     AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
+    {
+    Logging( kHLTLogInfo, "HLT::Dummy::DoEvent", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
+    // Process an event
+    unsigned long totalSize = 0;
+    // Loop over all input blocks in the event
+    for ( unsigned long n = 0; n < evtData.fBlockCnt; n++ )
+       {
+       // Align the beginning of this  block to the required value.
+       if ( totalSize % kAliHLTBlockAlignment )
+           totalSize += kAliHLTBlockAlignment-(totalSize % kAliHLTBlockAlignment);
+       if ( totalSize > size )
+           break;
+       // Determine the size we should use for the output for this block (the input block's size times the relative output size)
+       unsigned long mySize = (blocks[n].fSize * fOutputPercentage) / 100;
+       Logging( kHLTLogInfo, "HLT::Dummy::DoEvent", "mySize set (1)", "mySize == %lu B - blocks[%lu].fSize == %lu - fOutputPercentage == %lu", 
+                mySize, n, blocks[n].fSize, fOutputPercentage );
+       // Check how much space we have left and adapt this output block's size accordingly.
+       if ( totalSize + mySize > size )
+           mySize = size-totalSize;
+       Logging( kHLTLogInfo, "HLT::Dummy::DoEvent", "mySize set (2)", "mySize == %lu B - totalSize == %lu - size == %lu", 
+                mySize, totalSize, size );
+       if ( mySize<=0 )
+           continue; // No room left to write a further block.
+       // Now copy the input block
+       unsigned long copied = 0;
+       // First copy all full multiples of the input block
+       while ( copied+blocks[n].fSize <= mySize )
+           {
+           Logging( kHLTLogInfo, "HLT::Dummy::DoEvent", "Copying", "Copying %lu B - Copied: %lu B - totalSize: %lu B", 
+                    blocks[n].fSize, copied, totalSize );
+           memcpy( outputPtr+totalSize+copied, blocks[n].fPtr, blocks[n].fSize );
+           copied += blocks[n].fSize;
+           }
+       // And the copy the remaining fragment of the block
+       Logging( kHLTLogInfo, "HLT::Dummy::DoEvent", "Copying", "Copying %lu B - Copied: %lu B - totalSize: %lu B", 
+                mySize-copied, copied, totalSize );
+       memcpy( outputPtr+totalSize+copied, blocks[n].fPtr, mySize-copied );
+       Logging( kHLTLogInfo, "HLT::Dummy::DoEvent", "Copied", "Copied: %lu B - totalSize: %lu B", 
+                copied, totalSize );
+       // Fill a block data structure for our output block.
+       AliHLTComponent_BlockData ob;
+       // Let the structure be filled with the default values.
+       // This takes care of setting the shared memory and data type values to default values,
+       // so that they can be filled in by the calling code.
+       FillBlockData( ob );
+       // This block's start (offset) is after all other blocks written so far
+       ob.fOffset = totalSize;
+       // the size of this block's data.
+       ob.fSize = mySize;
+       // The specification of the data is copied from the input block.
+       ob.fSpecification = blocks[n].fSpecification;
+       // The data type is set automatically to the component's specified output data type.
+       // Place this block into the list of output blocks
+       outputBlocks.push_back( ob );
+       // Increase the total amount of data written so far to our output memory
+       totalSize += mySize;
+       }
+    // Finally we set the total size of output memory we consumed.
+    size = totalSize;
+    return 0;
+    }
diff --git a/HLT/SampleLib/AliHLTDummyComponent.h b/HLT/SampleLib/AliHLTDummyComponent.h
new file mode 100644 (file)
index 0000000..bd85682
--- /dev/null
@@ -0,0 +1,52 @@
+// XEMacs -*-C++-*-
+// @(#) $Id$
+
+#ifndef ALIHLTDUMMYCOMPONENT_H
+#define ALIHLTDUMMYCOMPONENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTDummyComponent
+** An implementiation of a dummy component that just copies its input data
+** as a test, demonstration, and example of the new HLT component system.
+ */
+
+#include "AliHLTProcessor.h"
+
+class AliHLTDummyComponent : public AliHLTProcessor
+    {
+    public:
+       AliHLTDummyComponent();
+       virtual ~AliHLTDummyComponent();
+
+       // Public functions to implement AliHLTComponent's interface.
+       // These functions are required for the registration process
+
+       const char* GetComponentID();
+       void GetInputDataTypes( vector<AliHLTComponent_DataType>& list);
+       AliHLTComponent_DataType GetOutputDataType();
+       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       AliHLTComponent* Spawn();
+       
+    protected:
+       
+       // Protected functions to implement AliHLTComponent's interface.
+       // These functions provide initialization as well as the actual processing
+       // capabilities of the component. 
+
+       int DoInit( int argc, const char** argv );
+       int DoDeinit();
+       int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                    AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                    AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
+       
+    private:
+
+       // The size of the output data produced, as a percentage of the input data's size.
+       // Can be greater than 100 (%)
+       unsigned fOutputPercentage;
+       
+       ClassDef(AliHLTDummyComponent, 0)
+
+    };
+#endif
index 0dc6765..bf64c61 100644 (file)
@@ -55,9 +55,9 @@ int AliHLTSampleComponent1::DoDeinit(){
   return 0;
 }
 
-int AliHLTSampleComponent1::DoEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                                     AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr, 
-                                     AliHLTUInt32_t* size, vector<AliHLTComponent_BlockData>& outputBlocks ) {
+int AliHLTSampleComponent1::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                                     AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                     AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks ) {
   Logging(kHLTLogInfo, "HLT", "Sample", "Sample component1, DoEvent");
   return 0;
 }
index e55c935..be21566 100644 (file)
@@ -24,6 +24,7 @@ public:
     }
   }
   AliHLTComponent_DataType GetOutputDataType() {return outputDataType;}
+  virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {constBase = 0;inputMultiplier = 0;};
 
   // Spawn function, return new class instance
   AliHLTComponent* Spawn() {return new AliHLTSampleComponent1;};
@@ -32,9 +33,9 @@ public:
   
   int DoInit( int argc, const char** argv );
   int DoDeinit();
-  int DoEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                      AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr, 
-                      AliHLTUInt32_t* size, vector<AliHLTComponent_BlockData>& outputBlocks );
+  int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                      AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                      AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
 
 private:
   static const AliHLTComponent_DataType inputDataTypes[];
index 8e07c40..a31716a 100644 (file)
@@ -55,9 +55,9 @@ int AliHLTSampleComponent2::DoDeinit(){
   return 0;
 }
 
-int AliHLTSampleComponent2::DoEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                                     AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr, 
-                                     AliHLTUInt32_t* size, vector<AliHLTComponent_BlockData>& outputBlocks ) {
+int AliHLTSampleComponent2::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                                     AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                     AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks ) {
   Logging(kHLTLogInfo, "HLT", "Sample", "Sample component2, DoEvent");
   return 0;
 }
index ef5e612..b87dda7 100644 (file)
@@ -24,6 +24,7 @@ public:
     }
   }
   AliHLTComponent_DataType GetOutputDataType() {return outputDataType;}
+  virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {constBase = 0;inputMultiplier = 0;};
 
   // Spawn function, return new class instance
   AliHLTComponent* Spawn() {return new AliHLTSampleComponent2;};
@@ -32,9 +33,9 @@ public:
   
   int DoInit( int argc, const char** argv );
   int DoDeinit();
-  int DoEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks, 
-                      AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr, 
-                      AliHLTUInt32_t* size, vector<AliHLTComponent_BlockData>& outputBlocks );
+  int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                      AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                      AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
 
 private:
   static const AliHLTComponent_DataType inputDataTypes[];
index 0f623bf..e474000 100644 (file)
@@ -8,6 +8,7 @@
 
 #pragma link C++ class AliHLTSampleComponent1;
 #pragma link C++ class AliHLTSampleComponent2;
+#pragma link C++ class AliHLTDummyComponent;
 
 #endif
 
index 162983b..1f0d883 100644 (file)
@@ -13,7 +13,7 @@ endif
 
 include $(ALIHLT_TOPDIR)/Makefile.conf
 
-SRCS   = AliHLTSampleComponent1.cxx AliHLTSampleComponent2.cxx 
+SRCS   = AliHLTSampleComponent1.cxx AliHLTSampleComponent2.cxx AliHLTDummyComponent.cxx
 
 SRCS += $(EXTRA_SRCS)
 
diff --git a/HLT/TPCLib/AliHLTTPCClusterDataFormat.h b/HLT/TPCLib/AliHLTTPCClusterDataFormat.h
new file mode 100644 (file)
index 0000000..1a4ccc6
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _ALIHLTTPCCLUSTERFORMAT_H_
+#define _ALIHLTTPCCLUSTERFORMAT_H_
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCClusterData
+ */
+
+struct AliHLTTPCClusterData
+    {
+       AliHLTUInt32_t fSpacePointCnt;
+       AliL3SpacePointData fSpacePoints[];
+    };
+
+#endif // _ALIHLTTPCCLUSTERFORMAT_H_
diff --git a/HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx b/HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx
new file mode 100644 (file)
index 0000000..ed9e08d
--- /dev/null
@@ -0,0 +1,203 @@
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
+ *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
+ *          for The ALICE Off-line 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// a TPC cluster finder processing component for the HLT                     //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTTPCClusterFinderComponent.h"
+#include "AliL3ClustFinderNew.h"
+#include "AliL3SpacePointData.h"
+#include "AliHLTTPCRawDataFormat.h"
+#include "AliHLTTPCClusterDataFormat.h"
+#include "AliL3Transform.h"
+#include <stdlib.h>
+#include <errno.h>
+
+// this is a global object used for automatic component registration, do not use this
+AliHLTTPCClusterFinderComponent gAliHLTTPCClusterFinderComponent;
+
+ClassImp(AliHLTTPCClusterFinderComponent)
+
+AliHLTTPCClusterFinderComponent::AliHLTTPCClusterFinderComponent()
+    {
+    fClusterFinder = NULL;
+    fClusterDeconv = true;
+    fXYClusterError = -1;
+    fZClusterError = -1;
+    }
+
+AliHLTTPCClusterFinderComponent::~AliHLTTPCClusterFinderComponent()
+    {
+    }
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+
+const char* AliHLTTPCClusterFinderComponent::GetComponentID()
+    {
+    return "TPCClusterFinder";
+    }
+
+void AliHLTTPCClusterFinderComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
+    {
+    list.clear();
+    list.push_back( AliHLTTPCDefinitions::gkUnpackedRawDataType );
+    }
+
+AliHLTComponent_DataType AliHLTTPCClusterFinderComponent::GetOutputDataType()
+    {
+    return AliHLTTPCDefinitions::gkClustersDataType;
+    }
+
+void AliHLTTPCClusterFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+    {
+    // XXX TODO: Find more realistic values.
+    constBase = 0;
+    inputMultiplier = 0.4;
+    }
+
+AliHLTComponent* AliHLTTPCClusterFinderComponent::Spawn()
+    {
+    return new AliHLTTPCClusterFinderComponent;
+    }
+       
+int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
+    {
+    if ( fClusterFinder )
+       return EINPROGRESS;
+    fClusterFinder = new AliL3ClustFinderNew();
+    fClusterDeconv = true;
+    fXYClusterError = -1;
+    fZClusterError = -1;
+    int i = 0;
+    while ( i < argc )
+       {
+       if ( !strcmp( argv[i], "-pp-run" ) )
+           {
+           fClusterDeconv = false;
+           i++;
+           continue;
+           }
+       Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+       return EINVAL;
+       }
+    return 0;
+    }
+
+int AliHLTTPCClusterFinderComponent::DoDeinit()
+    {
+    if ( !fClusterFinder )
+       return ECANCELED;
+    if ( fClusterFinder )
+       delete fClusterFinder;
+    fClusterFinder = NULL;
+    return 0;
+    }
+
+int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                                             AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                             AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
+    {
+    const AliHLTComponent_BlockData* iter = NULL;
+    unsigned long ndx;
+    AliHLTTPCUnpackedRawData* inPtr;
+    AliHLTTPCClusterData* outPtr;
+    AliHLTUInt8_t* outBPtr;
+    UInt_t offset, mysize, nSize, tSize = 0;
+    outBPtr = outputPtr;
+    outPtr = (AliHLTTPCClusterData*)outBPtr;
+    Int_t slice, patch, row[2];
+    unsigned long maxPoints, realPoints = 0;
+    for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+       {
+       iter = blocks+ndx;
+       mysize = 0;
+       offset = tSize;
+       if ( iter->fDataType != AliHLTTPCDefinitions::gkUnpackedRawDataType )
+           continue;
+       
+       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+       patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
+       row[0] = AliL3Transform::GetFirstRow( patch );
+       row[1] = AliL3Transform::GetLastRow( patch );
+       
+       Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", 
+                "Input: Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
+                realPoints, slice, patch, row[0], row[1] );
+       
+       outPtr = (AliHLTTPCClusterData*)outBPtr;
+       
+       inPtr = (AliHLTTPCUnpackedRawData*)iter->fPtr;
+       maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliL3SpacePointData);
+       
+       fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
+       fClusterFinder->SetDeconv( fClusterDeconv );
+       fClusterFinder->SetXYError( fXYClusterError );
+       fClusterFinder->SetZError( fZClusterError );
+       if ( (fXYClusterError>0) && (fZClusterError>0) )
+           fClusterFinder->SetCalcErr( false );
+       fClusterFinder->SetOutputArray( outPtr->fSpacePoints );
+       fClusterFinder->Read( maxPoints, inPtr->fDigits );
+       fClusterFinder->ProcessDigits();
+       realPoints = fClusterFinder->GetNumberOfClusters();
+       
+       Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Spacepoints", 
+                "Number of spacepoints found: %lu.", realPoints );
+       
+       outPtr->fSpacePointCnt = realPoints;
+       nSize = sizeof(AliL3SpacePointData)*realPoints;
+       mysize += nSize+sizeof(AliHLTTPCClusterData);
+       
+       Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", 
+                "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
+                realPoints, slice, patch, row[0], row[1] );
+       
+       
+       AliHLTComponent_BlockData bd;
+       FillBlockData( bd );
+       bd.fOffset = offset;
+       bd.fSize = mysize;
+       bd.fSpecification = iter->fSpecification;
+       //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
+       outputBlocks.push_back( bd );
+       
+       tSize += mysize;
+       outBPtr += mysize;
+       outPtr = (AliHLTTPCClusterData*)outBPtr;
+       
+       if ( tSize > size )
+           {
+           Logging( kHLTLogFatal, "HLT::TPCClusterFinder::DoEvent", "Too much data", 
+                    "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",
+                    tSize, size );
+           return EMSGSIZE;
+           }
+       }
+    
+    size = tSize;
+    return 0;
+    }
+
+       
diff --git a/HLT/TPCLib/AliHLTTPCClusterFinderComponent.h b/HLT/TPCLib/AliHLTTPCClusterFinderComponent.h
new file mode 100644 (file)
index 0000000..f7b7ab1
--- /dev/null
@@ -0,0 +1,55 @@
+// XEmacs -*-C++-*-
+// @(#) $Id$
+
+#ifndef ALIHLTTPCCLUSTERFINDERCOMPONENT_H
+#define ALIHLTTPCCLUSTERFINDERCOMPONENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCClusterFinderComponent
+ */
+
+#include "AliHLTProcessor.h"
+#include "AliHLTTPCDefinitions.h"
+
+class AliL3ClustFinderNew;
+
+class AliHLTTPCClusterFinderComponent : public AliHLTProcessor
+    {
+    public:
+       AliHLTTPCClusterFinderComponent();
+       virtual ~AliHLTTPCClusterFinderComponent();
+
+       // Public functions to implement AliHLTComponent's interface.
+       // These functions are required for the registration process
+
+       const char* GetComponentID();
+       void GetInputDataTypes( vector<AliHLTComponent_DataType>& list);
+       AliHLTComponent_DataType GetOutputDataType();
+       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       AliHLTComponent* Spawn();
+       
+    protected:
+       
+       // Protected functions to implement AliHLTComponent's interface.
+       // These functions provide initialization as well as the actual processing
+       // capabilities of the component. 
+
+       int DoInit( int argc, const char** argv );
+       int DoDeinit();
+       int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                    AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                    AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
+       
+    private:
+
+       AliL3ClustFinderNew* fClusterFinder;
+
+       bool fClusterDeconv;
+       float fXYClusterError;
+       float fZClusterError;
+       
+       ClassDef(AliHLTTPCClusterFinderComponent, 0)
+
+    };
+#endif
diff --git a/HLT/TPCLib/AliHLTTPCDefinitions.cxx b/HLT/TPCLib/AliHLTTPCDefinitions.cxx
new file mode 100644 (file)
index 0000000..e80fb63
--- /dev/null
@@ -0,0 +1,37 @@
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
+ *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
+ *          for The ALICE Off-line 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// Definitions for the HLT TPC components                                    //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliHLTTPCDefinitions.h"
+
+
+ClassImp(AliHLTTPCDefinitions)
+
+const AliHLTComponent_DataType AliHLTTPCDefinitions::gkDDLPackedRawDataType = { sizeof(AliHLTComponent_DataType), {'D','D','L','_','R','W','P','K'},{'T','P','C',' '}};;
+const AliHLTComponent_DataType AliHLTTPCDefinitions::gkPackedRawDataType = { sizeof(AliHLTComponent_DataType), {'R','A','W','P','A','K','E','D'},{'T','P','C',' '}};;
+const AliHLTComponent_DataType AliHLTTPCDefinitions::gkUnpackedRawDataType = { sizeof(AliHLTComponent_DataType), {'R','A','W','U','N','P','A','K'},{'T','P','C',' '}};;
+const AliHLTComponent_DataType AliHLTTPCDefinitions::gkClustersDataType = { sizeof(AliHLTComponent_DataType), {'C','L','U','S','T','E','R','S'},{'T','P','C',' '}};;
+const AliHLTComponent_DataType AliHLTTPCDefinitions::gkVertexDataType = { sizeof(AliHLTComponent_DataType), {'V','E','R','T','E','X',' ',' '},{'T','P','C',' '}};;
+const AliHLTComponent_DataType AliHLTTPCDefinitions::gkTrackSegmentsDataType = { sizeof(AliHLTComponent_DataType), {'T','R','A','K','S','E','G','S'},{'T','P','C',' '}};;
+
+    
diff --git a/HLT/TPCLib/AliHLTTPCDefinitions.h b/HLT/TPCLib/AliHLTTPCDefinitions.h
new file mode 100644 (file)
index 0000000..96d3261
--- /dev/null
@@ -0,0 +1,55 @@
+// XEmacs -*-C++-*-
+// @(#) $Id$
+
+#ifndef ALIHLTTPCDEFINITIONS_H
+#define ALIHLTTPCDEFINITIONS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCDefinitions
+ */
+
+#include "AliHLTDataTypes.h"
+#include "TObject.h"
+
+class AliHLTTPCDefinitions
+    {
+    public:
+
+       static AliHLTUInt8_t GetMinSliceNr( const AliHLTComponent_BlockData& block )
+               {
+               return (AliHLTUInt8_t)( (block.fSpecification & 0x00FF0000) >> 16 );
+               }
+       static AliHLTUInt8_t GetMaxSliceNr( const AliHLTComponent_BlockData& block )
+               {
+               return (AliHLTUInt8_t)( (block.fSpecification & 0xFF000000) >> 24 );
+               }
+       static AliHLTUInt8_t GetMinPatchNr( const AliHLTComponent_BlockData& block )
+               {
+               return (AliHLTUInt8_t)( (block.fSpecification & 0x000000FF) );
+               }
+       static AliHLTUInt8_t GetMaxPatchNr( const AliHLTComponent_BlockData& block )
+               {
+               return (AliHLTUInt8_t)( (block.fSpecification & 0x0000FF00) >> 8 );
+               }
+       
+       static AliHLTUInt32_t EncodeDataSpecification( AliHLTUInt8_t minSliceNr, 
+                                               AliHLTUInt8_t maxSliceNr,
+                                               AliHLTUInt8_t minPatchNr,
+                                               AliHLTUInt8_t maxPatchNr )
+               {
+               return ((maxSliceNr & 0xFF) << 24) | ((minSliceNr & 0xFF) << 16) | ((maxPatchNr & 0xFF) << 8) | ((minPatchNr & 0xFF));
+               }
+
+       static const AliHLTComponent_DataType gkDDLPackedRawDataType;
+       static const AliHLTComponent_DataType gkPackedRawDataType;
+       static const AliHLTComponent_DataType gkUnpackedRawDataType;
+       static const AliHLTComponent_DataType gkClustersDataType;
+       static const AliHLTComponent_DataType gkTrackSegmentsDataType;
+       static const AliHLTComponent_DataType gkVertexDataType;
+
+       ClassDef(AliHLTTPCDefinitions, 0)
+
+    };
+
+#endif
diff --git a/HLT/TPCLib/AliHLTTPCGlobalMergerComponent.cxx b/HLT/TPCLib/AliHLTTPCGlobalMergerComponent.cxx
new file mode 100644 (file)
index 0000000..d25266a
--- /dev/null
@@ -0,0 +1,253 @@
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
+ *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
+ *          for The ALICE Off-line 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// a TPC sector tracker processing component for the HLT                     //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTTPCGlobalMergerComponent.h"
+#include "AliL3Transform.h"
+#include "AliL3GlobalMerger.h"
+#include "AliL3Vertex.h"
+#include "AliL3VertexData.h"
+#include "AliL3TrackSegmentData.h"
+#include "AliL3TrackArray.h"
+#include "AliHLTTPCTrackletDataFormat.h"
+#include "AliL3SpacePointData.h"
+#include "AliHLTTPCClusterDataFormat.h"
+#include <stdlib.h>
+#include <errno.h>
+
+// this is a global object used for automatic component registration, do not use this
+AliHLTTPCGlobalMergerComponent gAliHLTTPCGlobalMergerComponent;
+
+ClassImp(AliHLTTPCGlobalMergerComponent)
+
+AliHLTTPCGlobalMergerComponent::AliHLTTPCGlobalMergerComponent()
+    {
+    fGlobalMerger = NULL;
+    fVertex = NULL;
+    }
+
+AliHLTTPCGlobalMergerComponent::~AliHLTTPCGlobalMergerComponent()
+    {
+    }
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+
+const char* AliHLTTPCGlobalMergerComponent::GetComponentID()
+    {
+    return "TPCGlobalMerger";
+    }
+
+void AliHLTTPCGlobalMergerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
+    {
+    list.clear();
+    list.push_back( AliHLTTPCDefinitions::gkTrackSegmentsDataType );
+    list.push_back( AliHLTTPCDefinitions::gkVertexDataType );
+    }
+
+AliHLTComponent_DataType AliHLTTPCGlobalMergerComponent::GetOutputDataType()
+    {
+    return AliHLTTPCDefinitions::gkTrackSegmentsDataType;
+    }
+
+void AliHLTTPCGlobalMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+    {
+    // XXX TODO: Find more realistic values.
+    constBase = 0;
+    inputMultiplier = 1.0;
+    }
+
+AliHLTComponent* AliHLTTPCGlobalMergerComponent::Spawn()
+    {
+    return new AliHLTTPCGlobalMergerComponent;
+    }
+
+void AliHLTTPCGlobalMergerComponent::SetMergerParameters(Double_t maxy,Double_t maxz,Double_t maxkappa,Double_t maxpsi,Double_t maxtgl)
+    {
+    fGlobalMerger->SetParameter( maxy, maxz, maxkappa, maxpsi, maxtgl );
+    }
+
+int AliHLTTPCGlobalMergerComponent::DoInit( int argc, const char** argv )
+    {
+    if ( fGlobalMerger || fVertex )
+       return EINPROGRESS;
+    fGlobalMerger = new AliL3GlobalMerger();
+    fVertex = new AliL3Vertex();
+    SetMergerParameters();
+    return 0;
+    }
+
+int AliHLTTPCGlobalMergerComponent::DoDeinit()
+    {
+    if ( fGlobalMerger )
+       delete fGlobalMerger;
+    fGlobalMerger = NULL;
+    if ( fVertex )
+       delete fVertex;
+    fVertex = NULL;
+    return 0;
+    }
+
+int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                                             AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                             AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
+    {
+    const AliHLTComponent_BlockData* iter = NULL;
+    const AliHLTComponent_BlockData* lastVertexBlock = NULL;
+    unsigned long ndx;
+
+    std::vector<SliceData> slices;
+    std::vector<SliceData>::iterator sdIter, sdEnd;
+    int minSlice = INT_MAX, maxSlice = 0;
+    bool found;
+    AliHLTTPCTrackletData* inPtr;
+    AliHLTTPCTrackletData* outPtr;
+    UInt_t tSize = 0;
+    Int_t slice=0;
+
+    // Create sorted (by slice number) list of data (tracks and vertex) for each slice present.
+    // also note the min and max slice numbers
+    for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+       {
+       iter = blocks+ndx;
+       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+       found=false;
+       sdIter = slices.begin();
+       sdEnd = slices.end();
+       while ( sdIter != sdEnd )
+           {
+           if ( sdIter->fSlice > slice || sdIter->fSlice == slice )
+               break;
+           sdIter++;
+           }
+       if ( sdIter->fSlice>slice || sdIter==sdEnd )
+           {
+           if ( sdIter == sdEnd )
+               maxSlice = slice;
+           if ( sdIter==slices.begin() )
+               minSlice = slice;
+           SliceData sd;
+           sd.fSlice = slice;
+           sd.fVertexBlock = NULL;
+           sd.fVertexBlockIndex = 0;
+           sd.fTrackletBlock = NULL;
+           sd.fTrackletBlockIndex = 0;
+           sdIter = slices.insert( sdIter, sd );
+           }
+       if ( sdIter->fSlice == slice )
+           {
+           if ( iter->fDataType == AliHLTTPCDefinitions::gkTrackSegmentsDataType )
+               {
+               if ( !sdIter->fTrackletBlock )
+                   {
+                   sdIter->fTrackletBlock = iter;
+                   sdIter->fTrackletBlockIndex = ndx;
+                   }
+               else
+                   {
+                   Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "Duplicate track data block",
+                            "Duplicate track data block for slice %lu in event 0x%08lX (%lu) - previous block: %lu - new block: %lu.",
+                            slice, evtData.fEventID, evtData.fEventID, sdIter->fTrackletBlockIndex, ndx );
+                   }
+               }
+           if ( iter->fDataType == AliHLTTPCDefinitions::gkVertexDataType )
+               {
+               lastVertexBlock = iter;
+               if ( !sdIter->fVertexBlock )
+                   {
+                   sdIter->fVertexBlock = iter;
+                   sdIter->fVertexBlockIndex = ndx;
+                   }
+               else
+                   {
+                   Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "Duplicate vertex data block",
+                            "Duplicate vertex data block for slice %lu in event 0x%08lX (%lu) - previous block: %lu - new block: %lu.",
+                            slice, evtData.fEventID, evtData.fEventID, sdIter->fVertexBlockIndex, ndx );
+                   }
+               }
+           }
+       }
+
+    fGlobalMerger->Setup( minSlice, maxSlice );
+
+    if ( !lastVertexBlock )
+       {
+       Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "No vertex data block",
+                "No vertex data block found  for event  0x%08lX (%lu).", evtData.fEventID, evtData.fEventID );
+       fVertex->SetZero();
+       }
+    else
+       fVertex->Read( (AliL3VertexData*)( lastVertexBlock->fPtr ) );
+
+    // Add all tracks into the merger
+    sdIter = slices.begin();
+    sdEnd = slices.end();
+    while ( sdIter != sdEnd )
+       {
+       if ( sdIter->fVertexBlock )
+           {
+           fVertex->Read( (AliL3VertexData*)( sdIter->fVertexBlock->fPtr ) );
+           fGlobalMerger->SetVertex( fVertex );
+           }
+       inPtr = (AliHLTTPCTrackletData*)( sdIter->fTrackletBlock->fPtr );
+       if ( !inPtr )
+           {
+           Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "No track data block",
+                    "No track data block found  for event  0x%08lX (%lu).", evtData.fEventID, evtData.fEventID );
+           }
+       else
+           {
+           fGlobalMerger->InitSlice( sdIter->fSlice );
+           fGlobalMerger->FillTracks( inPtr->fTrackletCnt, inPtr->fTracklets );
+           }
+       
+       sdIter++;
+       }
+
+    // Now we can really merge
+    fGlobalMerger->Merge();
+
+    UInt_t ntracks0=0;
+    outPtr = (AliHLTTPCTrackletData*)(outputPtr);
+
+    tSize = fGlobalMerger->GetOutTracks()->WriteTracks( ntracks0, outPtr->fTracklets );
+    outPtr->fTrackletCnt = ntracks0;
+
+    tSize += sizeof(AliHLTTPCTrackletData);
+
+    AliHLTComponent_BlockData bd;
+    FillBlockData( bd );
+    bd.fOffset = 0;
+    bd.fSize = tSize;
+    bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( minSlice, maxSlice, 0, 5 );
+    outputBlocks.push_back( bd );
+
+    size = tSize;
+    return 0;
+    }
+
+       
diff --git a/HLT/TPCLib/AliHLTTPCGlobalMergerComponent.h b/HLT/TPCLib/AliHLTTPCGlobalMergerComponent.h
new file mode 100644 (file)
index 0000000..79f13f5
--- /dev/null
@@ -0,0 +1,65 @@
+// XEmacs -*-C++-*-
+// @(#) $Id$
+
+#ifndef ALIHLTTPCGLOBALMERGERCOMPONENT_H
+#define ALIHLTTPCGLOBALMERGERCOMPONENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCGlobalMergerComponent
+ */
+
+#include "AliHLTProcessor.h"
+#include "AliHLTTPCDefinitions.h"
+
+class AliL3GlobalMerger;
+class AliL3Vertex;
+
+class AliHLTTPCGlobalMergerComponent : public AliHLTProcessor
+    {
+    public:
+       AliHLTTPCGlobalMergerComponent();
+       virtual ~AliHLTTPCGlobalMergerComponent();
+
+       // Public functions to implement AliHLTComponent's interface.
+       // These functions are required for the registration process
+
+       const char* GetComponentID();
+       void GetInputDataTypes( vector<AliHLTComponent_DataType>& list);
+       AliHLTComponent_DataType GetOutputDataType();
+       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       AliHLTComponent* Spawn();
+       
+    protected:
+       
+       void SetMergerParameters(Double_t maxy=2.0,Double_t maxz=3.0,Double_t maxkappa=0.003,
+                                Double_t maxpsi=0.1,Double_t maxtgl=0.05);
+
+       // Protected functions to implement AliHLTComponent's interface.
+       // These functions provide initialization as well as the actual processing
+       // capabilities of the component. 
+
+       int DoInit( int argc, const char** argv );
+       int DoDeinit();
+       int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                    AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                    AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
+       
+    private:
+
+       AliL3GlobalMerger* fGlobalMerger;
+       AliL3Vertex* fVertex;
+
+       struct SliceData
+           {
+               int fSlice;
+               const AliHLTComponent_BlockData* fVertexBlock;
+               unsigned fVertexBlockIndex;
+               const AliHLTComponent_BlockData* fTrackletBlock;
+               unsigned fTrackletBlockIndex;
+           };
+
+       ClassDef(AliHLTTPCGlobalMergerComponent, 0)
+
+    };
+#endif
diff --git a/HLT/TPCLib/AliHLTTPCLinkDef.h b/HLT/TPCLib/AliHLTTPCLinkDef.h
new file mode 100644 (file)
index 0000000..943d634
--- /dev/null
@@ -0,0 +1,18 @@
+// @(#) $Id$
+
+#ifdef __CINT__
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliHLTTPCDefinitions;
+#pragma link C++ class AliHLTTPCRawDataUnpackerComponent;
+#pragma link C++ class AliHLTTPCClusterFinderComponent;
+#pragma link C++ class AliHLTTPCVertexFinderComponent;
+#pragma link C++ class AliHLTTPCSliceTrackerComponent;
+#pragma link C++ class AliHLTTPCGlobalMergerComponent;
+#pragma link C++ class AliRawReaderMemory;
+
+#endif
+
diff --git a/HLT/TPCLib/AliHLTTPCRawDataFormat.h b/HLT/TPCLib/AliHLTTPCRawDataFormat.h
new file mode 100644 (file)
index 0000000..a34cd5f
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef _ALIHLTTPCRAWDATAFORMAT_HPP_
+#define _ALIHLTTPCRAWDATAFORMAT_HPP_
+
+#include "Rtypes.h"
+#include "AliL3DigitData.h"
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCRawData
+ */
+
+struct AliHLTTPCPackedRawData
+    {
+       UInt_t fPackedDigits[];
+    };
+
+struct AliHLTTPCUnpackedRawData
+    {
+       AliL3DigitRowData fDigits[];
+    };
+
+#endif // _ALIHLTTPCRAWDATAFORMAT_HPP_
diff --git a/HLT/TPCLib/AliHLTTPCRawDataUnpackerComponent.cxx b/HLT/TPCLib/AliHLTTPCRawDataUnpackerComponent.cxx
new file mode 100644 (file)
index 0000000..c4298bb
--- /dev/null
@@ -0,0 +1,241 @@
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
+ *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
+ *          for The ALICE Off-line 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// a TPC cluster finder processing component for the HLT                     //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTTPCRawDataUnpackerComponent.h"
+#include "AliTPCRawStream.h"
+#include "AliRawDataHeader.h"
+#include "AliRawReaderMemory.h"
+#include "AliHLTTPCRawDataFormat.h"
+#include "AliL3DigitData.h"
+#include "AliL3Transform.h"
+#include <stdlib.h>
+#include <errno.h>
+
+// this is a global object used for automatic component registration, do not use this
+AliHLTTPCRawDataUnpackerComponent gAliHLTTPCRawDataUnpackerComponent;
+
+ClassImp(AliHLTTPCRawDataUnpackerComponent)
+
+AliHLTTPCRawDataUnpackerComponent::AliHLTTPCRawDataUnpackerComponent()
+    {
+    fRawMemoryReader = NULL;
+    fTPCRawStream = NULL;
+    }
+
+AliHLTTPCRawDataUnpackerComponent::~AliHLTTPCRawDataUnpackerComponent()
+    {
+    }
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+
+const char* AliHLTTPCRawDataUnpackerComponent::GetComponentID()
+    {
+    return "TPCRawDataUnpacker";
+    }
+
+void AliHLTTPCRawDataUnpackerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
+    {
+    list.clear();
+    list.push_back( AliHLTTPCDefinitions::gkPackedRawDataType );
+    }
+
+AliHLTComponent_DataType AliHLTTPCRawDataUnpackerComponent::GetOutputDataType()
+    {
+    return AliHLTTPCDefinitions::gkUnpackedRawDataType;
+    }
+
+void AliHLTTPCRawDataUnpackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+    {
+    // XXX TODO: Find more realistic values.
+    constBase = 0;
+    inputMultiplier = 3.0;
+    }
+
+AliHLTComponent* AliHLTTPCRawDataUnpackerComponent::Spawn()
+    {
+    return new AliHLTTPCRawDataUnpackerComponent;
+    }
+       
+int AliHLTTPCRawDataUnpackerComponent::DoInit( int argc, const char** argv )
+    {
+    if ( fRawMemoryReader || fTPCRawStream )
+       return EINPROGRESS;
+
+    int i = 0;
+    const char* tableFileBaseDir = NULL;
+    while ( i < argc )
+       {
+       if ( !strcmp( argv[i], "-table-dir" ) )
+           {
+           if ( i+1>=argc )
+               {
+               Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Missing Argument", "Missing -table-dir parameter");
+               return ENOTSUP;
+               }
+           tableFileBaseDir = argv[i+1];
+           i += 2;
+           continue;
+           }
+       Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+       return EINVAL;
+       }
+
+    if ( !tableFileBaseDir )
+       {
+       Logging(kHLTLogError, "HLT::TPCRawDataUnpacker::DoInit", "Table file directory missing ", 
+               "Table file base directory has to be set using the -table-dir component parameter." );
+       return EINVAL;
+       }
+
+    fRawMemoryReader = new AliRawReaderMemory;
+    //fTPCRawStream = new AliTPCRawStream( fRawMemoryReader, tableFileBaseDir );
+    fTPCRawStream = new AliTPCRawStream( fRawMemoryReader );
+    
+    return 0;
+    }
+
+int AliHLTTPCRawDataUnpackerComponent::DoDeinit()
+    {
+    if ( fRawMemoryReader )
+       delete fRawMemoryReader;
+    fRawMemoryReader = NULL;
+    if ( fTPCRawStream )
+       delete fTPCRawStream;
+    fTPCRawStream = NULL;
+    return 0;
+    }
+
+int AliHLTTPCRawDataUnpackerComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                                             AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                             AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
+    {
+    const AliHLTComponent_BlockData* iter = NULL;
+    unsigned long ndx;
+
+    AliHLTUInt8_t* outBPtr;
+    AliHLTTPCUnpackedRawData* outPtr;
+    AliL3DigitRowData* currentRow;
+    AliL3DigitData* currentDigit;
+    unsigned long long outputSize = 0;
+    unsigned long blockOutputSize = 0;
+    unsigned long rowSize = 0;
+    Int_t slice, patch, row[2];
+    outBPtr = outputPtr;
+    outPtr = (AliHLTTPCUnpackedRawData*)outputPtr;
+    currentRow = outPtr->fDigits;
+    currentDigit = currentRow->fDigitData;
+
+    for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+       {
+       iter = blocks+ndx;
+       if ( iter->fDataType != AliHLTTPCDefinitions::gkDDLPackedRawDataType )
+           {
+           continue;
+           }
+       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+       patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
+       row[0] = AliL3Transform::GetFirstRow( patch );
+       row[1] = AliL3Transform::GetLastRow( patch );
+       blockOutputSize = 0;
+
+       fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
+       bool readValue = true;
+       readValue = fTPCRawStream->Next();
+       int row = -1, oldRow = -1;
+       Int_t rowOffset = 0;
+       if ( patch >= 2 ) // Outer sector, patches 2, 3, 4, 5
+           rowOffset = AliL3Transform::GetFirstRow( 2 );
+
+       while ( readValue )
+           {
+           row = fTPCRawStream->GetRow();
+           if ( row != oldRow )
+               {
+               if ( oldRow!=-1 && rowSize != sizeof(AliL3DigitRowData)+currentRow->fNDigit*sizeof(AliL3DigitData) )
+                   {
+                   Logging( kHLTLogFatal, "TPCRawDataUnpackerSubscriber::ProcessEvent", "Size inconsistency", 
+                            "Size inconsistency for row %d data: %lu != %lu (%lu digits).", oldRow, rowSize, 
+                            sizeof(AliL3DigitRowData)+currentRow->fNDigit*sizeof(AliL3DigitData), currentRow->fNDigit );
+                   }
+               rowSize = 0;
+               if ( size < outputSize+sizeof(AliL3DigitRowData) )
+                   {
+                   Logging( kHLTLogFatal, "TPCRawDataUnpackerSubscriber::ProcessEvent", "Too much data", 
+                            "Output data too big, output memory full. Aborting event 0x%08lX (%lu)" , 
+                            evtData.fEventID, evtData.fEventID );
+                   return 0;
+                   }
+               currentRow = (AliL3DigitRowData*)(outBPtr+outputSize);
+               currentDigit = currentRow->fDigitData;
+               currentRow->fRow = row+rowOffset;
+               currentRow->fNDigit = 0;
+               oldRow = row;
+               outputSize += sizeof(AliL3DigitRowData);
+               blockOutputSize += sizeof(AliL3DigitRowData);
+               rowSize += sizeof(AliL3DigitRowData);
+               }
+           if ( size < outputSize+sizeof(AliL3DigitData) )
+               {
+               Logging( kHLTLogFatal, "TPCRawDataUnpackerSubscriber::ProcessEvent", "Too much data", 
+                        "Output data too big, output memory full. Aborting event 0x%08lX (%lu)" , 
+                        evtData.fEventID, evtData.fEventID );
+               return 0;
+               }
+           currentDigit->fCharge = fTPCRawStream->GetSignal();
+           currentDigit->fPad = fTPCRawStream->GetPad();
+           currentDigit->fTime = fTPCRawStream->GetTime();
+           currentRow->fNDigit++;
+           currentDigit++;
+           outputSize += sizeof(AliL3DigitData);
+           blockOutputSize += sizeof(AliL3DigitData);
+           rowSize += sizeof(AliL3DigitData);
+           readValue = fTPCRawStream->Next();
+           }
+       if ( oldRow!=-1 && rowSize != sizeof(AliL3DigitRowData)+currentRow->fNDigit*sizeof(AliL3DigitData) )
+           {
+           Logging( kHLTLogFatal, "TPCRawDataUnpackerSubscriber::ProcessEvent", "Size inconsistency", 
+                    "Size inconsistency for row %d data: %lu != %lu (%lu digits).", oldRow, rowSize, 
+                    sizeof(AliL3DigitRowData)+currentRow->fNDigit*sizeof(AliL3DigitData), currentRow->fNDigit );
+           }
+
+       AliHLTComponent_BlockData bd;
+       FillBlockData( bd );
+       bd.fOffset = outputSize-blockOutputSize;
+       bd.fSize = blockOutputSize;
+       bd.fSpecification = iter->fSpecification;
+       //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
+       outputBlocks.push_back( bd );
+       }
+
+    
+    size = outputSize;
+    return 0;
+    }
+
+       
diff --git a/HLT/TPCLib/AliHLTTPCRawDataUnpackerComponent.h b/HLT/TPCLib/AliHLTTPCRawDataUnpackerComponent.h
new file mode 100644 (file)
index 0000000..cd0ac25
--- /dev/null
@@ -0,0 +1,54 @@
+// XEmacs -*-C++-*-
+// @(#) $Id$
+
+#ifndef ALIHLTTPCRAWDATAUNPACKERCOMPONENT_H
+#define ALIHLTTPCRAWDATAUNPACKERCOMPONENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCRawDataUnpackerComponent
+ */
+
+#include "AliHLTProcessor.h"
+#include "AliHLTTPCDefinitions.h"
+
+class AliRawReaderMemory;
+class AliTPCRawStream;
+
+class AliHLTTPCRawDataUnpackerComponent : public AliHLTProcessor
+    {
+    public:
+       AliHLTTPCRawDataUnpackerComponent();
+       virtual ~AliHLTTPCRawDataUnpackerComponent();
+
+       // Public functions to implement AliHLTComponent's interface.
+       // These functions are required for the registration process
+
+       const char* GetComponentID();
+       void GetInputDataTypes( vector<AliHLTComponent_DataType>& list);
+       AliHLTComponent_DataType GetOutputDataType();
+       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       AliHLTComponent* Spawn();
+       
+    protected:
+       
+       // Protected functions to implement AliHLTComponent's interface.
+       // These functions provide initialization as well as the actual processing
+       // capabilities of the component. 
+
+       int DoInit( int argc, const char** argv );
+       int DoDeinit();
+       int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                    AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                    AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
+       
+    private:
+
+       // Initialize AliROOT TPC raw stream parsing class
+       AliRawReaderMemory *fRawMemoryReader;
+       AliTPCRawStream *fTPCRawStream;
+
+       ClassDef(AliHLTTPCRawDataUnpackerComponent, 0)
+
+    };
+#endif
diff --git a/HLT/TPCLib/AliHLTTPCSliceTrackerComponent.cxx b/HLT/TPCLib/AliHLTTPCSliceTrackerComponent.cxx
new file mode 100644 (file)
index 0000000..6599b41
--- /dev/null
@@ -0,0 +1,506 @@
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
+ *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
+ *          for The ALICE Off-line 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// a TPC sector tracker processing component for the HLT                     //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTTPCSliceTrackerComponent.h"
+#include "AliL3Transform.h"
+#include "AliL3ConfMapper.h"
+#include "AliL3Vertex.h"
+#include "AliL3SpacePointData.h"
+#include "AliL3VertexData.h"
+#include "AliHLTTPCClusterDataFormat.h"
+#include "AliL3Transform.h"
+#include "AliL3TrackSegmentData.h"
+#include "AliL3TrackArray.h"
+#include "AliHLTTPCTrackletDataFormat.h"
+#include <stdlib.h>
+#include <errno.h>
+
+// this is a global object used for automatic component registration, do not use this
+AliHLTTPCSliceTrackerComponent gAliHLTTPCSliceTrackerComponent;
+
+ClassImp(AliHLTTPCSliceTrackerComponent)
+
+AliHLTTPCSliceTrackerComponent::AliHLTTPCSliceTrackerComponent()
+    {
+    fTracker = NULL;
+    fVertex = NULL;
+    fEta[0] = 0.;
+    fEta[1] = 1.1;
+    fDoNonVertex = false;
+    }
+
+AliHLTTPCSliceTrackerComponent::~AliHLTTPCSliceTrackerComponent()
+    {
+    }
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+
+const char* AliHLTTPCSliceTrackerComponent::GetComponentID()
+    {
+    return "TPCSliceTracker";
+    }
+
+void AliHLTTPCSliceTrackerComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
+    {
+    list.clear();
+    list.push_back( AliHLTTPCDefinitions::gkClustersDataType );
+    list.push_back( AliHLTTPCDefinitions::gkVertexDataType );
+    }
+
+AliHLTComponent_DataType AliHLTTPCSliceTrackerComponent::GetOutputDataType()
+    {
+    return AliHLTTPCDefinitions::gkTrackSegmentsDataType;
+    }
+
+void AliHLTTPCSliceTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+    {
+    // XXX TODO: Find more realistic values.
+    constBase = 0;
+    inputMultiplier = 0.2;
+    }
+
+AliHLTComponent* AliHLTTPCSliceTrackerComponent::Spawn()
+    {
+    return new AliHLTTPCSliceTrackerComponent;
+    }
+
+void AliHLTTPCSliceTrackerComponent::SetTrackerParam(Int_t phi_segments, Int_t eta_segments,
+                                  Int_t trackletlength, Int_t tracklength,
+                                  Int_t rowscopetracklet, Int_t rowscopetrack,
+                                  Double_t min_pt_fit, 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 )
+    {
+    //fTracker->SetClusterFinderParam( fXYClusterError, fZClusterError, kTRUE ); // ??
+    //Set parameters input to the tracker
+    //If no arguments are given, default parameters will be used
+    
+    fTracker->SetNSegments(phi_segments,eta_segments);
+    fTracker->SetMaxDca(min_pt_fit);
+    //   fTracker->MainVertexSettings(trackletlength,tracklength,rowscopetracklet,rowscopetrack);
+    fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,vertexConstraints);
+    fTracker->SetTrackletCuts(maxangle,goodDist,vertexConstraints);
+    
+    if( vertexConstraints )
+       fTracker->MainVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack, maxphi, maxeta);
+    else
+       fTracker->NonVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack);
+    //fTracker->SetParamDone(true);
+    
+    fTracker->InitVolumes();
+    }
+
+void AliHLTTPCSliceTrackerComponent::SetTrackerParam( bool doPP, int multiplicity, double bField )
+    {
+    if ( doPP )
+       {
+       //tracker->SetClusterFinderParam(xyerror,zerror,kTRUE); // ??
+       SetTrackerParam( 50, 100, 3, 10,
+                        2, 2,
+                        0, 0.1745, 5, 100,
+                        5, 50, 50, 0.1, 0.1, kTRUE);
+       }
+    else
+       {
+       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 ( multiplicity>mults[i] )
+               tmpMultDist = multiplicity-mults[i];
+           else
+               tmpMultDist = mults[i]-multiplicity;
+           if ( tmpMultDist < multDist )
+               {
+               closestMult = i;
+               multDist = tmpMultDist;
+               }
+           }
+       
+       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++ )
+           {
+           if ( bField>bfs[i] )
+               tmpBFDist = bField-bfs[i];
+           else
+               tmpBFDist = bfs[i]-bField;
+           if ( tmpBFDist < bfDist )
+               {
+               closestBf = i;
+               bfDist = tmpBFDist;
+               }
+           }
+
+       switch ( closestMult )
+           {
+           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;
+           }
+
+       }
+    }
+
+
+       
+int AliHLTTPCSliceTrackerComponent::DoInit( int argc, const char** argv )
+    {
+    if ( fTracker || fVertex )
+       return EINPROGRESS;
+    fTracker = new AliL3ConfMapper();
+    fVertex = new AliL3Vertex();
+    fEta[0] = 0.;
+    fEta[1] = 1.1;
+    fDoNonVertex = false;
+
+    int i = 0;
+    char* cpErr;
+    while ( i < argc )
+       {
+       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;
+           }
+       Logging(kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+       return EINVAL;
+       }
+    SetTrackerParam( fDoPP, fMultiplicity, fBField );
+    return 0;
+    }
+
+int AliHLTTPCSliceTrackerComponent::DoDeinit()
+    {
+    if ( fTracker )
+       delete fTracker;
+    fTracker = NULL;
+    if ( fVertex )
+       delete fVertex;
+    fVertex = NULL;
+    return 0;
+    }
+
+int AliHLTTPCSliceTrackerComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                                             AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                             AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
+    {
+    const AliHLTComponent_BlockData* iter = NULL;
+    unsigned long ndx;
+    AliHLTTPCClusterData* inPtrSP;
+    AliL3VertexData* inPtrV = NULL;
+    const AliHLTComponent_BlockData* vertexIter=NULL;
+    AliHLTTPCTrackletData* outPtr;
+    AliHLTUInt8_t* outBPtr;
+    AliHLTUInt32_t vSize = 0;
+    UInt_t offset=0, mysize, tSize = 0;
+    outBPtr = outputPtr;
+    Int_t slice, patch, row[2];
+    Int_t minPatch=INT_MAX, maxPatch = 0;
+    offset = 0;
+    std::vector<Int_t> slices;
+    std::vector<Int_t>::iterator slIter, slEnd;
+    std::vector<unsigned> sliceCnts;
+    std::vector<unsigned>::iterator slCntIter;
+    Int_t vertexSlice=0;
+
+    // Find min/max rows used in total and find and read out vertex if it is present
+    // also determine correct slice number, if multiple slice numbers are present in event
+    // (which should not happen in the first place) we use the one that occurs the most times
+    row[0] = 0;
+    row[1] = 0;
+    bool found;
+    for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+       {
+       iter = blocks+ndx;
+
+       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+       found = false;
+       slIter = slices.begin();
+       slEnd = slices.end();
+       slCntIter = sliceCnts.begin();
+       while ( slIter != slEnd )
+           {
+           if ( *slIter == slice )
+               {
+               found = true;
+               break;
+               }
+           slIter++;
+           slCntIter++;
+           }
+       if ( !found )
+           {
+           slices.insert( slices.end(), slice );
+           sliceCnts.insert( sliceCnts.end(), 1 );
+           }
+       else
+           *slCntIter++;
+
+       if ( iter->fDataType == AliHLTTPCDefinitions::gkVertexDataType )
+           {
+           inPtrV = (AliL3VertexData*)(iter->fPtr);
+           vertexIter = iter;
+           vSize = iter->fSize;
+           fVertex->Read( inPtrV );
+           vertexSlice = slice;
+           }
+       if ( iter->fDataType == AliHLTTPCDefinitions::gkClustersDataType )
+           {
+           patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
+           if ( minPatch>patch )
+               {
+               minPatch = patch;
+               row[0] = AliL3Transform::GetFirstRow( patch );
+               }
+           if ( maxPatch<patch )
+               {
+               maxPatch = patch;
+               row[1] = AliL3Transform::GetLastRow( patch );
+               }
+           }
+       }
+
+    // Determine slice number to really use.
+    if ( slices.size()>1 )
+       {
+       Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
+                "Multiple slice numbers found in event 0x%08lX (%lu). Determining maximum occuring slice number...",
+                evtData.fEventID, evtData.fEventID );
+       unsigned maxCntSlice=0;
+       slIter = slices.begin();
+       slEnd = slices.end();
+       slCntIter = sliceCnts.begin();
+       while ( slIter != slEnd )
+           {
+           Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
+                    "Slice %lu found %lu times.", *slIter, *slCntIter );
+           if ( maxCntSlice<*slCntIter )
+               {
+               maxCntSlice = *slCntIter;
+               slice = *slIter;
+               }
+           slIter++;
+           slCntIter++;
+           }
+       Logging( kHLTLogError, "HLT::TPCSliceTracker::DoEvent", "Multiple slices found in event",
+                "Using slice %lu.", slice );
+       }
+    else
+       slice = *(slices.begin());
+    
+    if ( vertexSlice != slice )
+       {
+       // multiple vertex blocks in event and we used the wrong one...
+       found = false;
+       for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+           {
+           iter = blocks+ndx;
+           if ( iter->fDataType == AliHLTTPCDefinitions::gkVertexDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
+               {
+               inPtrV = (AliL3VertexData*)(iter->fPtr);
+               vertexIter = iter;
+               vSize = iter->fSize;
+               fVertex->Read( inPtrV );
+               break;
+               }
+           }
+       }
+
+    fTracker->InitSector( slice, row, fEta );
+    fTracker->SetVertex(fVertex);
+    mysize = 0;
+    // read in all hits
+    for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+       {
+       iter = blocks+ndx;
+
+       if ( iter->fDataType == AliHLTTPCDefinitions::gkClustersDataType && slice==AliHLTTPCDefinitions::GetMinSliceNr( *iter ) )
+           {
+           patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
+           inPtrSP = (AliHLTTPCClusterData*)(iter->fPtr);
+           
+           fTracker->ReadHits( inPtrSP->fSpacePointCnt, inPtrSP->fSpacePoints );
+           }
+       }
+
+    outPtr = (AliHLTTPCTrackletData*)(outBPtr);
+    fTracker->MainVertexTracking_a();
+    fTracker->MainVertexTracking_b();
+    fTracker->FillTracks();
+    
+    if ( fDoNonVertex )
+       fTracker->NonVertexTracking();//Do a second pass for nonvertex tracks
+    
+    // XXX Do track merging??
+    
+    UInt_t ntracks0=0;
+    mysize = fTracker->GetTracks()->WriteTracks( ntracks0, outPtr->fTracklets );
+    outPtr->fTrackletCnt = ntracks0;
+    
+    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);
+    
+    AliHLTComponent_BlockData bd;
+    FillBlockData( bd );
+    bd.fOffset = offset;
+    bd.fSize = tSize;
+    bd.fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification( slice, slice, minPatch, maxPatch );
+    outputBlocks.push_back( bd );
+
+#ifdef FORWARD_VERTEX_BLOCK
+    if ( vertexIter )
+       {
+       // Copy the descriptor block for the vertex information.
+       bd = *vertexIter;
+       outputBlocks.push_back( bd );
+       }
+#endif // FORWARD_VERTEX_BLOCK
+
+    size = tSize;
+    return 0;
+    }
+
+       
diff --git a/HLT/TPCLib/AliHLTTPCSliceTrackerComponent.h b/HLT/TPCLib/AliHLTTPCSliceTrackerComponent.h
new file mode 100644 (file)
index 0000000..4b08c7f
--- /dev/null
@@ -0,0 +1,75 @@
+// XEmacs -*-C++-*-
+// @(#) $Id$
+
+#ifndef ALIHLTTPCSLICETRACKERCOMPONENT_H
+#define ALIHLTTPCSLICETRACKERCOMPONENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCSliceTrackerComponent
+ */
+
+#include "AliHLTProcessor.h"
+#include "AliHLTTPCDefinitions.h"
+
+class AliL3ConfMapper;
+class AliL3Vertex;
+
+class AliHLTTPCSliceTrackerComponent : public AliHLTProcessor
+    {
+    public:
+       AliHLTTPCSliceTrackerComponent();
+       virtual ~AliHLTTPCSliceTrackerComponent();
+
+       // Public functions to implement AliHLTComponent's interface.
+       // These functions are required for the registration process
+
+       const char* GetComponentID();
+       void GetInputDataTypes( vector<AliHLTComponent_DataType>& list);
+       AliHLTComponent_DataType GetOutputDataType();
+       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       AliHLTComponent* Spawn();
+       
+    protected:
+       
+       void SetTrackerParam(Int_t phi_segments=50,Int_t eta_segments=100,
+                            Int_t trackletlength=3,Int_t tracklength=5,
+                            Int_t rowscopetracklet=2,Int_t rowscopetrack=3,
+                            Double_t min_pt_fit=0,Double_t maxangle=1.31,
+                            Double_t goodDist=5,Double_t hitChi2Cut=10,
+                            Double_t goodHitChi2=20,Double_t trackChi2Cut=50,
+                            Int_t maxdist=50,Double_t maxphi=0.1,Double_t maxeta=0.1,
+                            bool vertexconstraint=true);
+       void SetTrackerParam( bool doPP, int multiplicity, double bField );
+       void SetTrackerParam1()
+               {
+               SetTrackerParam( 10, 20, 5, 10, 2,2,
+                                0, 1.31, 5, 100,
+                                50, 100, 50, 0.1, 0.1,
+                                true );
+               }
+
+       // Protected functions to implement AliHLTComponent's interface.
+       // These functions provide initialization as well as the actual processing
+       // capabilities of the component. 
+
+       int DoInit( int argc, const char** argv );
+       int DoDeinit();
+       int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                    AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                    AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
+       
+    private:
+
+       AliL3ConfMapper* fTracker;
+       AliL3Vertex* fVertex;
+       float fEta[2];
+       bool fDoNonVertex;
+       bool fDoPP;
+       int fMultiplicity;
+       double fBField;
+
+       ClassDef(AliHLTTPCSliceTrackerComponent, 0)
+
+    };
+#endif
diff --git a/HLT/TPCLib/AliHLTTPCTrackletDataFormat.h b/HLT/TPCLib/AliHLTTPCTrackletDataFormat.h
new file mode 100644 (file)
index 0000000..1ff283a
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef _ALIHLTTPCTRACKLETFORMAT_HPP_
+#define _ALIHLTTPCTRACKLETFORMAT_HPP_
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCTrackletData
+ */
+
+#include "AliHLTDataTypes.h"
+#include "AliL3TrackSegmentData.h"
+
+struct AliHLTTPCTrackletData
+    {
+       AliHLTUInt32_t fTrackletCnt;
+       AliL3TrackSegmentData fTracklets[];
+       //AliL3SpacePointData fSpacePoints[];
+    };
+
+
+#endif // _ALIHLTTPCTRACKLETFORMAT_HPP_
diff --git a/HLT/TPCLib/AliHLTTPCVertexFinderComponent.cxx b/HLT/TPCLib/AliHLTTPCVertexFinderComponent.cxx
new file mode 100644 (file)
index 0000000..fbdd612
--- /dev/null
@@ -0,0 +1,173 @@
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
+ *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
+ *          for The ALICE Off-line 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// a TPC vertex finder processing component for the HLT                     //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTTPCVertexFinderComponent.h"
+#include "AliL3VertexFinder.h"
+#include "AliL3SpacePointData.h"
+#include "AliL3VertexData.h"
+#include "AliHLTTPCClusterDataFormat.h"
+#include "AliL3Transform.h"
+#include <stdlib.h>
+#include <errno.h>
+
+// this is a global object used for automatic component registration, do not use this
+AliHLTTPCVertexFinderComponent gAliHLTTPCVertexFinderComponent;
+
+ClassImp(AliHLTTPCVertexFinderComponent)
+
+AliHLTTPCVertexFinderComponent::AliHLTTPCVertexFinderComponent()
+    {
+    fVertexFinder = NULL;
+    }
+
+AliHLTTPCVertexFinderComponent::~AliHLTTPCVertexFinderComponent()
+    {
+    }
+
+// Public functions to implement AliHLTComponent's interface.
+// These functions are required for the registration process
+
+const char* AliHLTTPCVertexFinderComponent::GetComponentID()
+    {
+    return "TPCVertexFinder";
+    }
+
+void AliHLTTPCVertexFinderComponent::GetInputDataTypes( vector<AliHLTComponent_DataType>& list)
+    {
+    list.clear();
+    list.push_back( AliHLTTPCDefinitions::gkClustersDataType );
+    }
+
+AliHLTComponent_DataType AliHLTTPCVertexFinderComponent::GetOutputDataType()
+    {
+    return AliHLTTPCDefinitions::gkVertexDataType;
+    }
+
+void AliHLTTPCVertexFinderComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+    {
+    // XXX TODO: Find more realistic values.
+    constBase = sizeof(AliL3VertexData);
+    inputMultiplier = 0;
+    }
+
+AliHLTComponent* AliHLTTPCVertexFinderComponent::Spawn()
+    {
+    return new AliHLTTPCVertexFinderComponent;
+    }
+       
+int AliHLTTPCVertexFinderComponent::DoInit( int argc, const char** argv )
+    {
+    if ( fVertexFinder )
+       return EINPROGRESS;
+    fVertexFinder = new AliL3VertexFinder();
+    return 0;
+    }
+
+int AliHLTTPCVertexFinderComponent::DoDeinit()
+    {
+    if ( !fVertexFinder )
+       return ECANCELED;
+    if ( fVertexFinder )
+       delete fVertexFinder;
+    fVertexFinder = NULL;
+    return 0;
+    }
+
+int AliHLTTPCVertexFinderComponent::DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                                             AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                             AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks )
+    {
+    const AliHLTComponent_BlockData* iter = NULL;
+    unsigned long ndx;
+
+    AliHLTTPCClusterData* inPtr;
+    AliL3VertexData* outPtr;
+    AliHLTUInt8_t* outBPtr;
+    UInt_t offset, mysize, tSize = 0;
+    outBPtr = outputPtr;
+    Int_t slice, patch, row[2];
+    AliHLTUInt32_t realPoints;
+
+    for ( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
+       {
+       iter = blocks+ndx;
+       mysize = 0;
+       offset = tSize;
+       if ( iter->fDataType != AliHLTTPCDefinitions::gkClustersDataType )
+           {
+           continue;
+           }
+       
+       inPtr = (AliHLTTPCClusterData*)(iter->fPtr);
+       slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
+       patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
+       row[0] = AliL3Transform::GetFirstRow( patch );
+       row[1] = AliL3Transform::GetLastRow( patch );
+       realPoints = inPtr->fSpacePointCnt;
+
+       Logging( kHLTLogDebug, "HLT::TPCVertexFinder::DoEvent", "Spacepoint count",
+                "realpoints: %lu.", realPoints );
+       
+       outPtr = (AliL3VertexData*)outBPtr;
+
+       fVertexFinder->Reset();
+       
+        fVertexFinder->Read( realPoints, inPtr->fSpacePoints );
+        fVertexFinder->Analyze();
+
+        //publish Vertex
+        fVertexFinder->Write( outPtr );
+
+
+       mysize += sizeof(AliL3VertexData);
+       
+       AliHLTComponent_BlockData bd;
+       FillBlockData( bd );
+       bd.fOffset = offset;
+       bd.fSize = mysize;
+       bd.fSpecification = iter->fSpecification;
+       //AliHLTSubEventDescriptor::FillBlockAttributes( bd.fAttributes );
+       outputBlocks.push_back( bd );
+
+       tSize += mysize;
+       outBPtr += mysize;
+
+       if ( tSize > size )
+           {
+           Logging( kHLTLogFatal, "HLT::TPCVertexFinder::DoEvent", "Too much data",
+                    "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
+                    , tSize, size );
+           return EMSGSIZE;
+           }
+       }
+    
+    size = tSize;
+    return 0;
+    }
+
+       
diff --git a/HLT/TPCLib/AliHLTTPCVertexFinderComponent.h b/HLT/TPCLib/AliHLTTPCVertexFinderComponent.h
new file mode 100644 (file)
index 0000000..5ebe5d4
--- /dev/null
@@ -0,0 +1,51 @@
+// XEmacs -*-C++-*-
+// @(#) $Id$
+
+#ifndef ALIHLTTPCVERTEXFINDERCOMPONENT_H
+#define ALIHLTTPCVERTEXFINDERCOMPONENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCVertexFinderComponent
+ */
+
+#include "AliHLTProcessor.h"
+#include "AliHLTTPCDefinitions.h"
+
+class AliL3VertexFinder;
+
+class AliHLTTPCVertexFinderComponent : public AliHLTProcessor
+    {
+    public:
+       AliHLTTPCVertexFinderComponent();
+       virtual ~AliHLTTPCVertexFinderComponent();
+
+       // Public functions to implement AliHLTComponent's interface.
+       // These functions are required for the registration process
+
+       const char* GetComponentID();
+       void GetInputDataTypes( vector<AliHLTComponent_DataType>& list);
+       AliHLTComponent_DataType GetOutputDataType();
+       virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
+       AliHLTComponent* Spawn();
+       
+    protected:
+       
+       // Protected functions to implement AliHLTComponent's interface.
+       // These functions provide initialization as well as the actual processing
+       // capabilities of the component. 
+
+       int DoInit( int argc, const char** argv );
+       int DoDeinit();
+       int DoEvent( const AliHLTComponent_EventData& evtData, const AliHLTComponent_BlockData* blocks, 
+                    AliHLTComponent_TriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                    AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
+       
+    private:
+
+       AliL3VertexFinder* fVertexFinder;
+
+       ClassDef(AliHLTTPCVertexFinderComponent, 0)
+
+    };
+#endif
diff --git a/HLT/TPCLib/Makefile b/HLT/TPCLib/Makefile
new file mode 100644 (file)
index 0000000..62a5ff8
--- /dev/null
@@ -0,0 +1,29 @@
+#$Id$
+##########################################
+# Makefile for AliRoot HLT Sample        #
+#                                        #
+# Author: Matthias Richter,              #                     
+##########################################
+
+MODNAME = AliHLTTPC
+
+ifndef ALIHLT_TOPDIR
+ALIHLT_TOPDIR = $(shell pwd)/..
+endif
+
+USENEWIO=1
+
+include $(ALIHLT_TOPDIR)/Makefile.conf
+
+SRCS   = AliHLTTPCDefinitions.cxx \
+          AliHLTTPCRawDataUnpackerComponent.cxx \
+          AliHLTTPCClusterFinderComponent.cxx \
+          AliHLTTPCVertexFinderComponent.cxx \
+          AliHLTTPCSliceTrackerComponent.cxx \
+          AliHLTTPCGlobalMergerComponent.cxx \
+          AliRawReaderMemory.cxx
+
+SRCS += $(EXTRA_SRCS)
+
+
+include $(ALIHLT_TOPDIR)/Makefile.rules