]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Adding the hit reconstructor and tracking components for dHLT, which use the AliHLTPr...
authorszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 28 May 2007 11:36:31 +0000 (11:36 +0000)
committerszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 28 May 2007 11:36:31 +0000 (11:36 +0000)
HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.cxx [new file with mode: 0644]
HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.h [new file with mode: 0644]
HLT/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerComponent.cxx [new file with mode: 0644]
HLT/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerComponent.h [new file with mode: 0644]

diff --git a/HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.cxx b/HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.cxx
new file mode 100644 (file)
index 0000000..98a7003
--- /dev/null
@@ -0,0 +1,373 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+/*
+
+  The HitRec Component is designed to deal the rawdata inputfiles to findout the 
+  the reconstructed hits. The output is send to the output block for further 
+  processing.
+
+  Author : Indranil Das ( indra.das@saha.ac.in || indra.ehep@gmail.com )
+*/
+
+#if __GNUC__>= 3
+using namespace std;
+#endif
+
+#include "AliHLTMUONHitReconstructorComponent.h"
+#include "AliHLTLogging.h"
+#include "AliHLTSystem.h"
+#include "AliHLTDefinitions.h"
+#include <stdlib.h>
+#include <errno.h>
+
+namespace
+{
+       // The global object used for automatic component registration, 
+       // Note DO NOT use this component for calculation!
+       AliHLTMUONHitReconstructorComponent gAliHLTMUONHitReconstructorComponent;
+}
+
+
+ClassImp(AliHLTMUONHitReconstructorComponent)
+
+
+AliHLTMUONHitReconstructorComponent::AliHLTMUONHitReconstructorComponent()
+  : 
+  fHitRec(NULL)
+{
+  // see header file for class documentation
+}
+
+AliHLTMUONHitReconstructorComponent::~AliHLTMUONHitReconstructorComponent()
+{
+  // see header file for class documentation
+
+}
+
+int AliHLTMUONHitReconstructorComponent::DoInit( int argc, const char** argv ){
+  // see header file for class documentation
+
+  fHitRec = new AliHLTMUONHitRec();
+
+  HLTInfo("dHLT hitrec");
+  if (argc==0 && argv==NULL) {
+    Logging( kHLTLogError, "AliHLTMUONHitReconstructorComponent::DoInit", "Arguments missing", " no arguments" );
+    // this is just to get rid of the warning "unused parameter"
+  }
+
+  Int_t i = 0;
+  char lutFileName[500],buspatchFileName[500];
+  int iDDL;
+  while(i<argc){
+    if ( !strcmp( argv[i], "lut" ) ) {
+      if ( argc <= i+1 ) {
+       Logging( kHLTLogError, "AliHLTMUONHitReconstructorComponent::DoInit", "Missing LookupTable filename", "LookupTable filename not specified" );
+       return EINVAL; /* Invalid argument */ 
+      }
+      
+      sprintf(lutFileName,"%s",argv[i+1]);
+
+      i += 2;
+      continue;
+    }// lut argument
+
+    if ( !strcmp( argv[i], "ddl" ) ) {
+      if ( argc <= i+1 ) {
+       Logging( kHLTLogError, "AliHLTMUONHitReconstructorComponent::DoInit", "Missing DDL argument", "DDL number not specified" );
+       HLTError("AliHLTMUONHitReconstructorComponent::DoInit : DDL number is not specified ");
+       return EINVAL;  /* Invalid argument */
+      }
+
+      iDDL = atoi(argv[i+1]);
+
+      i += 2;
+      continue;
+    }// ddl argument
+
+    if ( !strcmp( argv[i], "buspatchmap" ) ) {
+      if ( argc <= i+1 ) {
+       Logging( kHLTLogError, "AliHLTMUONHitReconstructorComponent::DoInit", "Missing buspatch filename", "buspatch filename not specified" );
+       return EINVAL; /* Invalid argument */
+      }
+      
+      sprintf(buspatchFileName,"%s",argv[i+1]);
+
+      i += 2;
+      continue;
+    }// buspatch argument
+
+
+
+  }// end of while loop
+
+  int lutline = fHitRec->GetLutLine(iDDL);
+  DHLTLut* lookupTable = new DHLTLut[lutline];
+  if(!ReadLookUpTable(lookupTable,lutFileName,iDDL)){
+    Logging(kHLTLogInfo, "AliHLTMUONHitReconstructorComponent::DoInit", "Failed to read lut", "lut cannot be read, DoInit");
+    return ENOENT ; /* No such file or directory */
+  }else{
+    for(int i = 0;i<lutline; i++){
+      //#ifdef MY_DEBUG
+//       printf("%d\t%d\t%d\t%f\t%f\t%f\t%d\t\n",
+//          lookupTable[i].fIdManuChannel,
+//          lookupTable[i].fIX,
+//          lookupTable[i].fIY,
+//          lookupTable[i].fRealX,
+//          lookupTable[i].fRealY,
+//          lookupTable[i].fRealZ,
+//          lookupTable[i].fPcbZone,
+//          lookupTable[i].fPlane
+//          );
+      //#endif
+    }
+
+    BusToDetElem busToDetElem;
+    if(!ReadBusPatchToDetElemFile(busToDetElem,buspatchFileName)){
+      Logging(kHLTLogInfo, "AliHLTMUONHitReconstructorComponent::DoInit", "Failed to read buspatchmap", "buspatchmap cannot be read, DoInit");
+      return ENOENT ; /* No such file or directory */
+    }
+
+    fHitRec->SetBusToDetMap(busToDetElem);
+    fHitRec->LoadLookUpTable(lookupTable,iDDL);
+
+  }// reading lut
+
+  return 0;
+}
+
+int AliHLTMUONHitReconstructorComponent::DoDeinit(){
+  // see header file for class documentation
+  if(fHitRec)
+    delete fHitRec;
+  HLTInfo("dHLT hitrec");
+  return 0;
+}
+
+int AliHLTMUONHitReconstructorComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
+                                     AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                     AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) {
+  // see header file for class documentation
+  HLTInfo("dHLT hitrec");
+
+//   if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0 &&
+//       outputPtr==0 && size==0)
+//   {
+//     outputBlocks.clear();
+//     // this is just to get rid of the warning "unused parameter"
+//  }
+
+  unsigned long totalSize = 0;
+  unsigned long mySize;
+  //cout<<"Block Count : "<<evtData.fBlockCnt<<endl;
+  for(Int_t i=0;i<evtData.fBlockCnt;i++){
+
+    cout<<"0: totalsize : "<<totalSize<<"\tkAliHLTBlockAlignment :"<<kAliHLTBlockAlignment<<"\t size :"<<size<<endl;
+
+    // Align the beginning of this  block to the required value.
+    //           if ( totalSize % kAliHLTBlockAlignment ){
+    //             totalSize += kAliHLTBlockAlignment-(totalSize % kAliHLTBlockAlignment);
+    //           }
+
+    if ( totalSize > size )
+      break;
+    
+    cout<<"1: totalsize : "<<totalSize<<"\tkAliHLTBlockAlignment :"<<kAliHLTBlockAlignment<<endl;
+    // Determine the size we should use for the output for this block (the input block's size times the relative output size)
+    
+
+    int totalDDLSize = blocks[i].fSize/4;
+    int ddlRawDataSize = totalDDLSize - AliHLTMUONHitRec::fgkDDLHeaderSize;
+    int ddlHeader[8];
+    memcpy((char *) & ddlHeader,blocks[i].fPtr,(size_t)4*(AliHLTMUONHitRec::fgkDDLHeaderSize));
+
+//     for(int j=0;j<8;j++)
+//       HLTDebug("ddlHeader[%d] : %d\n",j,ddlHeader[j]);
+
+    int* buffer = new int[ddlRawDataSize];
+    memcpy((int*)buffer,((int*)blocks[i].fPtr + AliHLTMUONHitRec::fgkDDLHeaderSize),(sizeof(int)*ddlRawDataSize));
+
+//     for(int j=0;j<ddlRawDataSize;j++)
+//       HLTDebug("buffer[%d] : %x\n",j,buffer[j]);
+
+    
+    AliHLTMUONRecPoint recHit[300];
+    int nofHit = 300;
+   
+    if(! (fHitRec->Run(buffer,&ddlRawDataSize,recHit,&nofHit))){
+      cerr <<"AliHLTMUONHitReconstructorComponent::DoEvent : ERROR In Processing of HitRec Algo "<< endl;
+      return EIO;
+    }
+
+    mySize = sizeof(AliHLTMUONRecPoint)*nofHit;
+    
+    HLTInfo("mySize set (1) mySize == %lu B - blocks[%lu].fSize == %lu", 
+            mySize, i, blocks[i].fSize);
+    
+    // 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[i].fSize <= mySize )
+      {
+       Logging( kHLTLogInfo, "0 : HLT::Dummy::DoEvent", "Copying", "Copying %lu B - Copied: %lu B - totalSize: %lu B", 
+                blocks[i].fSize, copied, totalSize );
+       memcpy( outputPtr+totalSize+copied, blocks[i].fPtr, blocks[i].fSize );
+       copied += blocks[i].fSize;
+      }
+    // And the copy the remaining fragment of the block
+    Logging( kHLTLogInfo, "1 : HLT::Dummy::DoEvent", "Copying", "Copying %lu B - Copied: %lu B - totalSize: %lu B", 
+            mySize-copied, copied, totalSize );
+    memcpy( outputPtr+totalSize+copied, blocks[i].fPtr, mySize-copied );
+    Logging( kHLTLogInfo, "HLT::Dummy::DoEvent", "Copied", "Copied: %lu B - totalSize: %lu B", 
+            copied, totalSize );
+    
+
+    
+    AliHLTComponentBlockData bd;
+    FillBlockData( bd );
+    bd.fOffset = totalSize;;
+    bd.fSize = mySize;
+    //bd.fPtr = (AliHLTUInt8_t*)(&recHit[0]);
+    bd.fSpecification = blocks[i].fSpecification;
+    outputBlocks.push_back( bd );
+    
+    totalSize += mySize;
+
+    //    for(int j=0; j<nofHit; j++){
+//       printf("%d\t\t%d\t\t%f\t%f\t%f\n",
+//          i,outPtr->fRecPoint[j].fDetElemId,outPtr->fRecPoint[j].fX,
+//          outPtr->fRecPoint[j].fY,outPtr->fRecPoint[j].fZ);
+//       printf("1 : %d\t\t%d\t\t%f\t%f\t%f\n",
+//          i,(((AliHLTMUONRecPoint*)bd.fPtr) + j)->fDetElemId,
+//          (((AliHLTMUONRecPoint*)bd.fPtr) + j)->fX,
+//          (((AliHLTMUONRecPoint*)bd.fPtr) + j)->fY,
+//          (((AliHLTMUONRecPoint*)bd.fPtr) + j)->fZ);
+//    }// nof RecHits
+
+
+    if(totalSize > size){
+      cout<<"size : "<<size<<"\t  totalSize: "<<totalSize<<"\t mySize :"<<mySize<<endl; 
+      Logging( kHLTLogError, "AliHLTMUONHitReconstructorComponent::DoEvent", "Size exceeds the quota", "Size Exceeds the maximum quota" );
+      return EMSGSIZE;
+    }
+
+  }// block loop
+
+  size = totalSize;
+  
+  return 0;
+}
+
+
+bool AliHLTMUONHitReconstructorComponent::ReadLookUpTable(
+               DHLTLut* lookupTable, const char* lutpath, int iDDL
+       )
+{
+       if (iDDL < AliHLTMUONHitRec::fgkDDLOffSet ||
+               iDDL >= AliHLTMUONHitRec::fgkDDLOffSet + AliHLTMUONHitRec::fgkNofDDL)
+       {
+//             Logging(kHLTLogError, "AliHLTMUONHitReconstructorComponent::ReadLookUpTable", "Invalid DDL")
+//                     << "DDL number is out of range (must be " << AliHLTLog::kDec << HLTMUONHitRec::fgkDDLOffSet
+//                     << " <= iDDL < " << AliHLTLog::kDec
+//                     << HLTMUONHitRec::fgkDDLOffSet + HLTMUONHitRec::fgkNofDDL
+//                     << ENDLOG;
+               return false;
+       }
+
+       int lutLine = fHitRec->GetLutLine(iDDL);
+//     cout<<"LutLine :"<<lutLine<<endl;
+       FILE* fin = fopen(lutpath, "r");
+       if (fin == NULL)
+       {
+//             LOG(kHLTLogError, "AliHLTMUONHitReconstructorComponent::ReadLookUpTable", "I/O error")
+//                     << "Failed to open file: " << lutpath << ENDLOG;
+               return false;
+       }
+
+#      ifdef DEBUG
+//     Logging(kHLTLogError, "AliHLTMUONHitReconstructorComponent::ReadLookUpTable", "Trace")
+//             << "Reading LUT file: " << lutpath << ENDLOG;
+#      endif
+
+       for(int i=0;i<lutLine;i++)
+       {
+               fscanf(
+                       fin,
+                       "%d\t%d\t%d\t%f\t%f\t%f\t%d\t%d\n",
+                       &lookupTable[i].fIdManuChannel,
+                       &lookupTable[i].fIX,
+                       &lookupTable[i].fIY,
+                       &lookupTable[i].fRealX,
+                       &lookupTable[i].fRealY,
+                       &lookupTable[i].fRealZ,
+                       &lookupTable[i].fPcbZone,
+                       &lookupTable[i].fPlane
+               );
+       }
+
+       fclose(fin);
+       return true;
+}
+
+// implement this as well.
+
+bool AliHLTMUONHitReconstructorComponent::ReadBusPatchToDetElemFile(
+               BusToDetElem& busToDetElem, const char* buspatchmappath
+       )
+{
+       char getLine[80];
+       char temp;
+       int detElem, minBusPatch, maxBusPatch;
+
+       FILE* fin = fopen(buspatchmappath, "r");
+       if (fin == NULL)
+       {
+//             Logging(kHLTLogError, "AliHLTMUONHitReconstructorComponent::ReadBusPatchToDetElemFile", "I/O error")
+//                     << "Failed to open file: " << buspatchmappath << ENDLOG;
+               return false;
+       }
+
+#      ifdef DEBUG
+//     Logging(kHLTLogError, "AliHLTMUONHitReconstructorComponent::ReadBusPatchToDetElemFile", "Trace")
+//             << "Reading bus patch mapping file: " << buspatchmappath << ENDLOG;
+#      endif
+
+       while (feof(fin)==0)
+       {
+               fgets(getLine,80,fin);
+               sscanf(getLine, "%d\t%d %c %d", &detElem, &minBusPatch, &temp, &maxBusPatch);
+               if (detElem >= 700 && detElem <= 1025)
+               {
+                       for(int i = minBusPatch; i <= maxBusPatch; i++)
+                               busToDetElem[i] = detElem;
+               } // detElem condn
+       } // while loop for file
+
+       fclose(fin);
+       return true;
+}
diff --git a/HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.h b/HLT/MUON/OnlineAnalysis/AliHLTMUONHitReconstructorComponent.h
new file mode 100644 (file)
index 0000000..9e05f04
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef ALIHLTMUONHITRECONSTRUCTORCOMPONENT_H
+#define ALIHLTMUONHITRECONSTRUCTORCOMPONENT_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+/*  @file   AliHLTMUONHitReconstructorComponent.h
+ *  @author Indranil Das <indra.das@saha.ac.in> | <indra.ehep@gmail.com>
+ *  @date   
+ *  @brief  Hit Reconstruction processing component for the dimuon HLT. 
+ */
+
+#include "AliHLTProcessor.h"
+#include "HitRec/AliHLTMUONHitRec.h"
+#include "Util/AliHLTMUONHitData.h"
+#include "Util/AliHLTMUONDefinitions.h"
+
+class AliHLTMUONHitReconstructorComponent : public AliHLTProcessor {
+
+public:
+  AliHLTMUONHitReconstructorComponent();
+  virtual ~AliHLTMUONHitReconstructorComponent();
+
+  const char* GetComponentID() { return "MUONHitRec";}
+
+  void GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
+    list.clear();
+    list.push_back( AliHLTMUONDefinitions::fgkDDLPackedRawDataType );
+  }
+  
+  AliHLTComponentDataType GetOutputDataType() {return AliHLTMUONDefinitions::fgkHitRecDataType;}
+  virtual void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {constBase = 0;inputMultiplier = 0;};
+
+  // Spawn function, return new class instance
+  AliHLTComponent* Spawn() {return new AliHLTMUONHitReconstructorComponent;};
+
+ protected:
+  
+  int DoInit( int argc, const char** argv );
+  int DoDeinit();
+  int DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
+                      AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                      AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks );
+
+private:
+  /** array of input data types */
+
+  AliHLTMUONHitRec* fHitRec;
+  bool ReadLookUpTable(DHLTLut* lookupTable, const char* lutpath, int iDDL);
+  bool ReadBusPatchToDetElemFile(BusToDetElem& busToDetElem, const char* buspatchmappath);
+
+
+  ClassDef(AliHLTMUONHitReconstructorComponent, 0)
+};
+
+#endif // ALIHLTMUONHITRECONSTRUCTORCOMPONENT_H
diff --git a/HLT/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerComponent.cxx b/HLT/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerComponent.cxx
new file mode 100644 (file)
index 0000000..8b01ee5
--- /dev/null
@@ -0,0 +1,271 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+/**
+ *  @file   AliHLTMUONMansoTrackerComponent.cxx
+ *  @author Artur Szostak <artursz@iafrica.com>,
+ *          Indranil Das <indra.das@saha.ac.in>
+ *  @date   
+ *  @brief  Implementation of AliHLTMUONMansoTrackerComponent class.
+ */
+
+#include "AliHLTMUONMansoTrackerComponent.h"
+#include "Util/AliHLTMUONRecPoint.h"
+#include <stdlib.h>
+#include <errno.h>
+
+namespace
+{
+       // this is a global object used for automatic component registration, do not use this
+       AliHLTMUONMansoTrackerComponent gAliHLTMUONMansoTrackerComponent;
+}
+
+
+ClassImp(AliHLTMUONMansoTrackerComponent);
+
+
+AliHLTMUONMansoTrackerComponent::AliHLTMUONMansoTrackerComponent()
+  :
+    fOutputPercentage(100) // By default we copy to the output exactly what we got as input
+    {
+    }
+
+AliHLTMUONMansoTrackerComponent::~AliHLTMUONMansoTrackerComponent()
+    {
+    }
+
+const char* AliHLTMUONMansoTrackerComponent::GetComponentID()
+    {
+    return "tracking"; // The ID of this component
+    }
+
+void AliHLTMUONMansoTrackerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
+    {
+      /* in order to be backward compatible we have to keep the old code, at
+       * least for a while. Remember to use the new const kAliHLTVoidDataType
+       * if you are using a more recent AliRoot version (from Jan 07)
+       list.push_back(kAliHLTAnyDataType); // We do not have any requirements for our input data type(s).
+      */
+
+      AliHLTComponentDataType dt = 
+       { sizeof(AliHLTComponentDataType),
+         {'*','*','*','*','*','*','*','\0'},
+         {'*','*','*','\0'}};
+       list.push_back(dt);
+    }
+
+AliHLTComponentDataType AliHLTMUONMansoTrackerComponent::GetOutputDataType()
+    {
+      /* in order to be backward compatible we have to keep the old code, at
+       * least for a while. Remember to use the new const kAliHLTVoidDataType
+       * if you are using a more recent AliRoot version (from Jan 07)
+      return kAliHLTVoidDataType;
+      */
+      AliHLTComponentDataType dt = 
+       { sizeof(AliHLTComponentDataType),
+         {'\0','\0','\0','0','\0','\0','\0','\0'},
+         {'\0','\0','\0','\0'}};
+      return dt;
+    }
+
+void AliHLTMUONMansoTrackerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
+    {
+    constBase = 0;
+    inputMultiplier = ((double)fOutputPercentage)/100.0;
+    }
+
+
+
+// Spawn function, return new instance of this class
+AliHLTComponent* AliHLTMUONMansoTrackerComponent::Spawn()
+    {
+    return new AliHLTMUONMansoTrackerComponent;
+    }
+
+int AliHLTMUONMansoTrackerComponent::DoInit( int argc, const char** argv )
+    {
+    // perform initialization. We check whether our relative output size is specified in the arguments.
+    fOutputPercentage = 100;
+                                               
+    fTracker = new AliHLTMUONMansoTracker();
+
+    Logging(kHLTLogInfo, "dHLT", "Tracking", "hitrec, DoInit");
+    if (argc==0 && argv==NULL) {
+      // this is just to get rid of the warning "unused parameter"
+    }
+
+    int i = 0;
+    char* cpErr;
+    while ( i < argc )
+      {
+       Logging( kHLTLogDebug, "AliHLTMUONMansoTrackerComponent::DoInit", "Arguments", "argv[%d] == %s", i, argv[i] );
+       if ( !strcmp( argv[i], "output_percentage" ) )
+           {
+           if ( i+1>=argc )
+               {
+               Logging(kHLTLogError, "AliHLTMUONMansoTrackerComponent::DoInit", "Missing Argument", "Missing output_percentage parameter");
+               return ENOTSUP;
+               }
+           Logging( kHLTLogDebug, "AliHLTMUONMansoTrackerComponent::DoInit", "Arguments", "argv[%d+1] == %s", i, argv[i+1] );
+           fOutputPercentage = strtoul( argv[i+1], &cpErr, 0 );
+           if ( *cpErr )
+               {
+                 Logging(kHLTLogError, "AliHLTMUONMansoTrackerComponent::DoInit", "Wrong Argument", "Cannot convert output_percentage parameter '%s'", argv[i+1] );
+                 return EINVAL;
+               }
+           Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoInit", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
+           i += 2;
+           continue;
+           }
+       Logging(kHLTLogError, "AliHLTMUONMansoTrackerComponent::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+       return EINVAL;
+      }// while loop
+    return 0;
+    }
+
+int AliHLTMUONMansoTrackerComponent::DoDeinit()
+{
+  if(fTracker)
+    delete fTracker;
+  return 0;
+}
+
+int AliHLTMUONMansoTrackerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
+                                     AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                                     AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
+{
+  Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::DoEvent", "Output percentage set", "Output percentage set to %lu %%", fOutputPercentage );
+  // Process an event
+  unsigned long totalSize = 0;
+  AliHLTUInt32_t maxTracksPerEvent = 1024;
+
+  fTracker->Reset();
+  fTracker->SetTrackOutputBuffer((AliHLTMUONTrackPoints*)outputPtr,maxTracksPerEvent);
+  
+//  cout<<"BlockSize :"<<evtData.fBlockCnt<<" size :"<<outputBlocks.size()<<endl;
+  // 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, "AliHLTMUONMansoTrackerComponent::DoEvent", "mySize set (1)", "mySize == %lu B - blocks[%lu].fSize == %lu - fOutputPercentage == %lu - totalSize == %lu", 
+              mySize, n, blocks[n].fSize, fOutputPercentage, totalSize );
+
+      Int_t noftrigData,nofhitData;
+      if(n== (evtData.fBlockCnt - 1)){// for trigger
+       UInt_t trigDataSize;
+       memcpy(&trigDataSize,blocks[n].fPtr,sizeof(UInt_t));
+//     cout<<"trigDataSize :"<<trigDataSize<<endl;
+       UInt_t trigOffSet;
+       memcpy(&trigOffSet,(UInt_t*)blocks[n].fPtr + 1,sizeof(UInt_t));
+//     cout<<"trigOffSet :"<<trigOffSet<<endl;
+       noftrigData = (trigDataSize -  sizeof(UInt_t))*sizeof(AliHLTUInt32_t)/sizeof(AliHLTMUONCoreTriggerRecord) ;
+       fTrigData = new AliHLTMUONCoreTriggerRecord[noftrigData];
+
+       for(Int_t i=0;i<noftrigData;i++){
+         AliHLTMUONCoreTriggerRecord record;
+         memcpy(&record,(UInt_t*)blocks[n].fPtr + 2 + i*(sizeof(AliHLTMUONCoreTriggerRecord))/4,sizeof(AliHLTMUONCoreTriggerRecord));
+         fTrigData[i] = record;
+
+//       cout<<" Sign : "<<fTrigData[i].fSign
+//           <<" Pt : "<<fTrigData[i].fPt
+//           <<"\t X1:"<<fTrigData[i].fStation1impact.X()<<" Y1 :"<<fTrigData[i].fStation1impact.Y()
+//           <<"\t X2:"<<fTrigData[i].fStation2impact.X()<<" Y2 :"<<fTrigData[i].fStation2impact.Y()
+//           << endl;
+       }// for
+       
+       fTracker->FindTracks(fTrigData,noftrigData);
+//     cout<<"Nof tracks found :"<<fTracker->TrackCount()<<endl;
+//     cout<<"Z7 : "<<AliHLTMUONCoreMansoTracker::GetZ7()<<endl;
+
+      }else{ // for hitrec
+       UInt_t hitDataSize;
+       memcpy(&hitDataSize,blocks[n].fPtr,sizeof(UInt_t));
+//     cout<<"hitDataSize :"<<hitDataSize<<endl;
+       nofhitData = hitDataSize*sizeof(AliHLTUInt32_t)/sizeof(AliHLTMUONCorePoint) ;
+       
+       Int_t chamber = n + 6;
+       AliHLTMUONRecPoint *recHit = new AliHLTMUONRecPoint[nofhitData];
+       for(Int_t i=0;i<nofhitData;i++){
+         AliHLTMUONCorePoint point;
+         memcpy(&point,(UInt_t*)blocks[n].fPtr + 1 + i*(sizeof(AliHLTMUONCorePoint))/4,sizeof(AliHLTMUONCorePoint));
+//       cout <<"chamber :"<<chamber<<"\tX : "<<point.X()<<"\t Y : "<<point.Y()<< endl;
+         recHit[i].fX = point.X();
+         recHit[i].fY = point.Y();
+       }// for
+       
+       fTracker->AddRecHits(chamber,recHit,nofhitData);
+
+      }// hit or trig condn
+      
+
+      //for(Int_t itrig = 0 ; itrig < nofTrigData ; itrig++){
+      
+      //}
+
+
+       // Check how much space we have left and adapt this output block's size accordingly.
+//     if ( totalSize + mySize > size )
+//         mySize = size-totalSize;
+//     Logging( kHLTLogInfo, "AliHLTMUONMansoTrackerComponent::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, "AliHLTMUONMansoTrackerComponent::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, "AliHLTMUONMansoTrackerComponent::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, "AliHLTMUONMansoTrackerComponent::DoEvent", "Copied", "Copied: %lu B - totalSize: %lu B", 
+//              copied, totalSize );
+//     // Fill a block data structure for our output block.
+//     AliHLTComponentBlockData 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/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerComponent.h b/HLT/MUON/OnlineAnalysis/AliHLTMUONMansoTrackerComponent.h
new file mode 100644 (file)
index 0000000..ad8976e
--- /dev/null
@@ -0,0 +1,74 @@
+#ifndef AliHLTMUONMANSOTRACKERCOMPONENT_H
+#define AliHLTMUONMANSOTRACKERCOMPONENT_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+/**
+ *  @file   AliHLTMUONMansoTrackerComponent.h
+ *  @author Artur Szostak <artursz@iafrica.com>,
+ *          Indranil Das <indra.das@saha.ac.in>
+ *  @date   
+ *  @brief  Tracker component implementing the Manso algorithm for the dimuon HLT.
+ */
+
+#include "AliHLTProcessor.h"
+#include "Tracking/AliHLTMUONMansoTracker.h"
+#include "Util/AliHLTMUONCoreTriggerRecord.h"
+
+/**
+ * @class AliHLTMUONMansoTrackerComponent
+ * @brief Manso tracker component
+ */
+class AliHLTMUONMansoTrackerComponent : public AliHLTProcessor
+    {
+    public:
+       AliHLTMUONMansoTrackerComponent();
+       virtual ~AliHLTMUONMansoTrackerComponent();
+
+       // Public functions to implement AliHLTComponent's interface.
+       // These functions are required for the registration process
+
+       const char* GetComponentID();
+       void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
+       AliHLTComponentDataType 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 AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
+                    AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
+                    AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& 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;
+
+       // For Tracking
+
+       //TrackerCallback callback;
+       AliHLTMUONMansoTracker* fTracker;
+
+/*     struct TriggerBlock */
+/*     { */
+/*       const AliHLTMUONCoreTriggerRecord *data; */
+/*     }; */
+
+       AliHLTMUONCoreTriggerRecord *fTrigData;
+       //std::vector<TriggerBlock> fTriggerBlocks;  // array of trigger record blocks
+       
+       ClassDef(AliHLTMUONMansoTrackerComponent, 0);
+
+    };
+
+#endif // AliHLTMUONMANSOTRACKERCOMPONENT_H