]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- AliHLTReconstructor: added helper functions to run HLTOUT processing stand alone
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Apr 2008 05:52:35 +0000 (05:52 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Apr 2008 05:52:35 +0000 (05:52 +0000)
- AliHLTSystem: enable benchmark printout again
- AliHLTConfiguration: additional parameter for the output buffer size

HLT/BASE/AliHLTConfiguration.cxx
HLT/BASE/AliHLTConfiguration.h
HLT/BASE/AliHLTSystem.cxx
HLT/BASE/AliHLTSystem.h
HLT/BASE/AliHLTTask.cxx
HLT/RCU/AliHLTAltroGenerator.h
HLT/doc/doxygen.conf.in
HLT/rec/AliHLTOUTDigitReader.cxx
HLT/rec/AliHLTOUTDigitReader.h
HLT/rec/AliHLTReconstructor.cxx
HLT/rec/AliHLTReconstructor.h

index 03b291de852cc55441f3cfb4bee2ee0fb0033e6a..91a47228af6700500e9d181c44b8b49713b01cb9 100644 (file)
@@ -55,7 +55,8 @@ AliHLTConfiguration::AliHLTConfiguration()
   fListSrcElement(),
   fArguments(""),
   fArgc(-1),
-  fArgv(NULL)
+  fArgv(NULL),
+  fBufferSize(-1)
 { 
   // see header file for class documentation
   // or
@@ -66,7 +67,8 @@ AliHLTConfiguration::AliHLTConfiguration()
   fListSrcElement=fListSources.begin();
 }
 
-AliHLTConfiguration::AliHLTConfiguration(const char* id, const char* component, const char* sources, const char* arguments)
+AliHLTConfiguration::AliHLTConfiguration(const char* id, const char* component, const char* sources,
+                                        const char* arguments, const char* bufsize)
   :
   fID(id),
   fComponent(component),
@@ -76,9 +78,11 @@ AliHLTConfiguration::AliHLTConfiguration(const char* id, const char* component,
   fListSrcElement(),
   fArguments(arguments),
   fArgc(-1),
-  fArgv(NULL)
+  fArgv(NULL),
+  fBufferSize(-1)
 {
   // see header file for function documentation
+  if (bufsize) fBufferSize=ConvertSizeString(bufsize);
   fListSrcElement=fListSources.begin();
   if (id && component) {
     if (fgConfigurationHandler) {
@@ -101,7 +105,8 @@ AliHLTConfiguration::AliHLTConfiguration(const AliHLTConfiguration& src)
   fListSrcElement(),
   fArguments(src.fArguments),
   fArgc(-1),
-  fArgv(NULL)
+  fArgv(NULL),
+  fBufferSize(src.fBufferSize)
 { 
   // see header file for function documentation
   fListSrcElement=fListSources.begin();
@@ -117,6 +122,7 @@ AliHLTConfiguration& AliHLTConfiguration::operator=(const AliHLTConfiguration& s
   fArguments=src.fArguments;
   fArgc=-1;
   fArgv=NULL;
+  fBufferSize=src.fBufferSize;
   return *this;
 }
 
@@ -366,7 +372,7 @@ int AliHLTConfiguration::ExtractArguments()
   return iResult;
 }
 
-int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argList)
+int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argList) const
 {
   // see header file for function documentation
   int iResult=0;
@@ -402,6 +408,36 @@ int AliHLTConfiguration::InterpreteString(const char* arg, vector<char*>& argLis
   return iResult;
 }
 
+int AliHLTConfiguration::ConvertSizeString(const char* strSize) const
+{
+  // see header file for function documentation
+  int size=0;
+  if (!strSize) return -1;
+
+  char* endptr=NULL;
+  size=strtol(strSize, &endptr, 10);
+  if (size>=0) {
+    if (endptr) {
+      if (endptr==strSize) {
+       HLTWarning("ignoring unrecognized buffer size '%s'", strSize);
+       size=-1;
+      } else if (*endptr==0) {
+       // no unit specifier
+      } else if (*endptr=='k') {
+       size*=1014;
+      } else if (*endptr=='M') {
+       size*=1024*1024;
+      } else {
+       HLTWarning("ignoring buffer size of unknown unit '%c'", endptr[0]);
+      }
+    } else {
+      HLTWarning("ignoring negative buffer size specifier '%s'", strSize);
+      size=-1;
+    }
+  }
+  return size;
+}
+
 int AliHLTConfiguration::FollowDependency(const char* id, TList* pTgtList)
 {
   // see header file for function documentation
index 5a0d4e459f4b26ff82a1072bd7e5bb0adc3c7f09..6bf284b48d2508f04ea96d56be1eff71073815c5 100644 (file)
@@ -67,9 +67,12 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
    * @param component  component id
    * @param sources    blank separated list of source configuration ids
    * @param arguments  argument string passed to the component at initialization
+   * @param bufsize    size of the output buffer in byte, the string can contain a
+   *                   number prepended by a unit, e.g. 1M, allowed units 'k' and 'M'
    */
   AliHLTConfiguration(const char* id, const char* component,
-                     const char* sources, const char* arguments);
+                     const char* sources, const char* arguments,
+                     const char* bufsize=NULL);
   /** copy constructor */
   AliHLTConfiguration(const AliHLTConfiguration& src);
   /** assignment op */
@@ -177,6 +180,11 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
    */
   int GetArguments(const char*** pArgv);
 
+  /**
+   * Get output buffer size.
+   * @return size in byte or -1 if not specified
+   */
+  int GetOutputBufferSize() const {return fBufferSize;}
  protected:
   
 
@@ -194,7 +202,12 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
    * @param arg       pointer to argument string
    * @param argList   target to receive the argument list
    */
-  int InterpreteString(const char* arg, vector<char*>& argList);
+  int InterpreteString(const char* arg, vector<char*>& argList) const;
+
+  /**
+   * Convert buffer size string to number
+   */
+  int ConvertSizeString(const char* strSize) const;
 
   /** id of this configuration */
   TString fID;                                                     // see above
@@ -222,6 +235,9 @@ class AliHLTConfiguration : public TObject, public AliHLTLogging {
   /** argument array */
   char** fArgv;                                                    // see above
 
+  /** size of the output buffer */
+  int fBufferSize;                                                 // see above
+
   /** the instance of the global configuration handler */
   static AliHLTConfigurationHandler* fgConfigurationHandler;       //! transient
 
index 7939458e72ca8ac7400357c3b6ab846ba73f5d47..d3923726002f996713433664ada5519eb1862d77 100644 (file)
@@ -351,7 +351,7 @@ int AliHLTSystem::Run(Int_t iNofEvents, int bStop)
       if (fEventCount==0) {
        InitBenchmarking(fStopwatches);
       } else {
-       //ResumeBenchmarking(fStopwatches);    
+       ResumeBenchmarking(fStopwatches);    
       }
       for (int i=fEventCount; i<fEventCount+iNofEvents && iResult>=0; i++) {
        if ((iResult=ProcessTasks(i))>=0) {
@@ -366,7 +366,7 @@ int AliHLTSystem::Run(Int_t iNofEvents, int bStop)
       }
       fEventCount+=iNofEvents;
       if (bStop) StopTasks();
-      //else PauseBenchmarking(fStopwatches);
+      else PauseBenchmarking(fStopwatches);
     }
     if (bStop) DeinitTasks();
   }
@@ -469,7 +469,33 @@ int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches)
   return iResult;
 }
 
-int AliHLTSystem::PrintBenchmarking(TObjArray* pStopwatches, int bClean)
+int AliHLTSystem::PauseBenchmarking(TObjArray* pStopwatches) const
+{
+  // see header file for class documentation
+  if (pStopwatches==NULL) return 0;
+
+  for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
+    if (!pStopwatches->At(i)) continue;
+    TStopwatch* pSw=dynamic_cast<TStopwatch*>(pStopwatches->At(i));
+    if (pSw) pSw->Stop();
+  }
+  return 0;
+}
+
+int AliHLTSystem::ResumeBenchmarking(TObjArray* pStopwatches) const
+{
+  // see header file for class documentation
+  if (pStopwatches==NULL) return 0;
+
+  for (int i=0; i<(int)AliHLTComponent::kSWTypeCount; i++) {
+    if (!pStopwatches->At(i)) continue;
+    TStopwatch* pSw=dynamic_cast<TStopwatch*>(pStopwatches->At(i));
+    if (pSw) pSw->Continue();
+  }
+  return 0;
+}
+
+int AliHLTSystem::PrintBenchmarking(TObjArray* pStopwatches, int bClean) const
 {
   // see header file for class documentation
   int iInitialized=1;
@@ -483,7 +509,7 @@ int AliHLTSystem::PrintBenchmarking(TObjArray* pStopwatches, int bClean)
   }
 
   if (iInitialized!=0) {
-    HLTInfo("HLT statistics:\n"
+    HLTImportant("HLT statistics:\n"
            "    base:              R:%.3fs C:%.3fs\n"
            "    input:             R:%.3fs C:%.3fs\n"
            "    output:            R:%.3fs C:%.3fs\n"
index cf1caa692b76e4f5af457c99d684e1c73dcddfbc..a5bbfdd5660f24098449bbcc73ae42f890f3a5af 100644 (file)
@@ -159,6 +159,22 @@ class AliHLTSystem : public AliHLTLogging {
    */
   int InitBenchmarking(TObjArray* pStopwatches);
 
+  /**
+   * Stop the stopwatches for all tasks.
+   * @param pStopwatches    object array of stopwatches, for types
+   *                        @see AliHLTComponent::AliHLTStopwatchType
+   * @return neg error code if failed
+   */
+  int PauseBenchmarking(TObjArray* pStopwatches) const;
+
+  /**
+   * Continue the stopwatches for all tasks.
+   * @param pStopwatches    object array of stopwatches, for types
+   *                        @see AliHLTComponent::AliHLTStopwatchType
+   * @return neg error code if failed
+   */
+  int ResumeBenchmarking(TObjArray* pStopwatches) const;
+
   /**
    * Print benchmarking summary.
    * Optionak: clean up stop watches.
@@ -166,7 +182,7 @@ class AliHLTSystem : public AliHLTLogging {
    * @param bClean          delete stop watches if 1
    * @return neg error code if failed
    */
-  int PrintBenchmarking(TObjArray* pStopwatches, int bClean=0);
+  int PrintBenchmarking(TObjArray* pStopwatches, int bClean=0) const;
 
   /**
    * Start task list.
index 384c4edbbda0fc1e6f9b65d5b3569273a49bccc0..b0f8caf73a4a723421f5c0b9c1ac84a6e4ad948f 100644 (file)
@@ -496,6 +496,14 @@ int AliHLTTask::ProcessTask(Int_t eventNo)
     AliHLTUInt32_t size=0;
     if (iResult>=0) {
     do {
+      long unsigned int iOutputDataSize=0;
+      AliHLTConfiguration* pConf=GetConf();
+      assert(pConf);
+      // check if there was a buffer size specified, query output size
+      // estimator from component otherwize
+      if (pConf && pConf->GetOutputBufferSize()>=0) {
+       iOutputDataSize=pConf->GetOutputBufferSize();
+      } else {
       long unsigned int iConstBase=0;
       double fInputMultiplier=0;
       if (pComponent->GetComponentType()!=AliHLTComponent::kSink)
@@ -504,8 +512,9 @@ int AliHLTTask::ProcessTask(Int_t eventNo)
        HLTWarning("ignoring negative input multiplier");
        fInputMultiplier=0;
       }
-      long unsigned int iOutputDataSize=int(fInputMultiplier*iInputDataVolume) + iConstBase;
+      iOutputDataSize=int(fInputMultiplier*iInputDataVolume) + iConstBase;
       //HLTDebug("task %s: reqired output size %d", GetName(), iOutputDataSize);
+      }
       if (iNofTrial>0) {
        // dont process again if the buffer size is the same
        if (size==iOutputDataSize) break;
index 261090fad8cf8bfcb383d78cfcbbd3460dd656be..e34599b376df07cb5625d91d610a683a575af7dd 100644 (file)
@@ -79,6 +79,7 @@ class AliHLTAltroGenerator : AliHLTLogging {
    * The provided buffer is filled with the encoded data from the
    * previous simulation.
    * @param pBuffer     target variable to receive the pointer
+   * @param size        size of the target buffer
    * @return size in byte, neg. error if failed
    */
   int GetData(AliHLTUInt8_t* pBuffer, int size);
index 4be1a0d7588893ed3ac01e1151c3312259a5b0f8..ebe6786765941c63b03abd2dcd22eeef263ce3fb 100644 (file)
@@ -68,6 +68,7 @@ INPUT                  = @top_srcdir@/doc     \
                         @top_srcdir@/BASE      \
                         @top_srcdir@/TPCLib    \
                         @top_srcdir@/SampleLib \
+                        @top_srcdir@/RCU       \
                         @top_srcdir@/rec       \
                         @top_srcdir@/exa       \
                         @top_srcdir@/sim       \
index b5323c95cd7ad95821e376019529e0b8cf1f3cb6..2b6d0a048c403ded9fada2cbb000dfc4fff47e2b 100644 (file)
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTOUTDigitReader)
 
-AliHLTOUTDigitReader::AliHLTOUTDigitReader(int event, AliHLTEsdManager* pEsdManager)
+AliHLTOUTDigitReader::AliHLTOUTDigitReader(int event, AliHLTEsdManager* pEsdManager, const char* digitFile)
   :
   AliHLTOUTHomerCollection(event, pEsdManager),
+  fDigitFileName(digitFile),
   fpDigitFile(NULL),
   fpDigitTree(NULL),
   fMinDDL(-1),
@@ -139,7 +140,7 @@ bool AliHLTOUTDigitReader::ReadArrays()
   }
 
   if (!fpDigitFile) {
-    fpDigitFile=new TFile("HLT.Digits.root");
+    fpDigitFile=new TFile(fDigitFileName);
   }
   if (!fpDigitFile) return false;
   if (fpDigitFile->IsZombie()) return false;
index 0d5756e7e3df2ff4e08b3f7f673de8d3f5aa0707..59197d10059b7ce0d928d6ad813e97e33a4866cb 100644 (file)
@@ -14,6 +14,7 @@
 */
 
 #include "AliHLTOUTHomerCollection.h"
+#include "TString.h"
 
 class AliRawReader;
 class AliHLTHOMERReader;
@@ -27,8 +28,8 @@ class TArrayC;
  */
 class AliHLTOUTDigitReader : public AliHLTOUTHomerCollection {
  public:
-  /** standard constructor */
-  AliHLTOUTDigitReader(int event=-1, AliHLTEsdManager* pEsdManager=NULL);
+  /** constructor */
+  AliHLTOUTDigitReader(int event=-1, AliHLTEsdManager* pEsdManager=NULL, const char* digitFile="HLT.Digits.root");
   /** destructor */
   virtual ~AliHLTOUTDigitReader();
 
@@ -60,6 +61,9 @@ class AliHLTOUTDigitReader : public AliHLTOUTHomerCollection {
    */
   int CloseTree();
 
+  /** name of the digit file */
+  TString fDigitFileName; //! transient
+
   /** the root file for the HLT 'digit' output */
   TFile* fpDigitFile; //!transient
 
index a8648cdbfcba8f4db33cc5e01989f71da9246a1e..90552504f2e2b0c1c4deee76ccab42c749c17cfa 100644 (file)
 
 #include <TSystem.h>
 #include <TObjString.h>
+#include "TFile.h"
+#include "TTree.h"
 #include "AliHLTReconstructor.h"
 #include "AliLog.h"
+#include "AliRawReader.h"
 #include "AliESDEvent.h"
 #include "AliHLTSystem.h"
 #include "AliHLTOUTRawReader.h"
@@ -43,6 +46,17 @@ AliHLTReconstructor::AliHLTReconstructor()
   //constructor
 }
 
+AliHLTReconstructor::AliHLTReconstructor(const char* options)
+  : 
+  AliReconstructor(),
+  AliHLTReconstructorBase(),
+  fFctProcessHLTOUT(NULL),
+  fpEsdManager(NULL)
+{ 
+  //constructor
+  if (options) Init(options);
+}
+
 AliHLTReconstructor::~AliHLTReconstructor()
 { 
   //destructor
@@ -60,6 +74,13 @@ AliHLTReconstructor::~AliHLTReconstructor()
   fpEsdManager=NULL;
 }
 
+void AliHLTReconstructor::Init(const char* options)
+{
+  // init the reconstructor
+  SetOption(options);
+  Init();
+}
+
 void AliHLTReconstructor::Init()
 {
   // init the reconstructor
@@ -148,6 +169,7 @@ void AliHLTReconstructor::Reconstruct(AliRawReader* /*rawReader*/, TTree* /*clus
   // added to the existing HLTOUT data
   // The HLTOUT data is finally processed in FillESD
   AliHLTSystem* pSystem=GetInstance();
+  AliInfo("running raw data reconstruction");
 }
 
 void AliHLTReconstructor::FillESD(AliRawReader* rawReader, TTree* /*clustersTree*/, 
@@ -204,6 +226,7 @@ void AliHLTReconstructor::Reconstruct(TTree* /*digitsTree*/, TTree* /*clustersTr
 
   // all reconstruction has been moved to FillESD
   //AliReconstructor::Reconstruct(digitsTree,clustersTree);
+  AliInfo("running digit data reconstruction");
 }
 
 void AliHLTReconstructor::FillESD(TTree* /*digitsTree*/, TTree* /*clustersTree*/, AliESDEvent* esd) const
@@ -271,3 +294,76 @@ void AliHLTReconstructor::ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd) co
     }
   }
 }
+
+void AliHLTReconstructor::ProcessHLTOUT(const char* digitFile, AliESDEvent* pEsd) const
+{
+  // debugging/helper function to examine simulated data
+  if (!digitFile) return;
+
+  // read the number of events
+  TFile f(digitFile);
+  if (f.IsZombie()) return;
+  TTree* pTree=NULL;
+  f.GetObject("rawhltout", pTree);
+  if (!pTree) {
+    AliWarning(Form("can not find tree rawhltout in file %s", digitFile));
+    return ;
+  }
+  int nofEvents=pTree->GetEntries();
+  f.Close();
+  //delete pTree; OF COURSE NOT! its an object in the file
+  pTree=NULL;
+
+  for (int event=0; event<nofEvents; event++) {
+    AliHLTOUTDigitReader* pHLTOUT=new AliHLTOUTDigitReader(event, fpEsdManager, digitFile);
+    if (pHLTOUT) {
+      AliInfo(Form("event %d", event));
+      ProcessHLTOUT(pHLTOUT, pEsd);
+      PrintHLTOUTContent(pHLTOUT);
+      delete pHLTOUT;
+    } else {
+      AliError("error creating HLTOUT handler");
+    }
+  }
+}
+
+void AliHLTReconstructor::ProcessHLTOUT(AliRawReader* pRawReader, AliESDEvent* pEsd) const
+{
+  // debugging/helper function to examine simulated or real HLTOUT data
+  if (!pRawReader) return;
+
+  pRawReader->RewindEvents();
+  for (int event=0; pRawReader->NextEvent(); event++) {
+    AliHLTOUTRawReader* pHLTOUT=new AliHLTOUTRawReader(pRawReader, event, fpEsdManager);
+    if (pHLTOUT) {
+      AliInfo(Form("event %d", event));
+      ProcessHLTOUT(pHLTOUT, pEsd);
+      PrintHLTOUTContent(pHLTOUT);
+      delete pHLTOUT;
+    } else {
+      AliError("error creating HLTOUT handler");
+    }
+  }
+}
+
+void AliHLTReconstructor::PrintHLTOUTContent(AliHLTOUT* pHLTOUT) const
+{
+  // print the block specifications of the HLTOUT data blocks
+  if (!pHLTOUT) return;
+  int iResult=0;
+
+  for (iResult=pHLTOUT->SelectFirstDataBlock();
+       iResult>=0;
+       iResult=pHLTOUT->SelectNextDataBlock()) {
+    AliHLTComponentDataType dt=kAliHLTVoidDataType;
+    AliHLTUInt32_t spec=kAliHLTVoidDataSpec;
+    pHLTOUT->GetDataBlockDescription(dt, spec);
+    const AliHLTUInt8_t* pBuffer=NULL;
+    AliHLTUInt32_t size=0;
+    if (pHLTOUT->GetDataBuffer(pBuffer, size)>=0) {
+      pHLTOUT->ReleaseDataBuffer(pBuffer);
+      pBuffer=NULL; // just a dummy
+    }
+    AliInfo(Form("   %s  0x%x: size %d", AliHLTComponent::DataType2Text(dt).c_str(), spec, size));
+  }
+}
index 3fad1a6fb32e32092116da5a3cdeddcda7f762f0..725ca6abe97af35568d0938497da8b96f5f11469 100644 (file)
@@ -52,13 +52,19 @@ class AliHLTEsdManager;
  */
 class AliHLTReconstructor: public AliReconstructor, public AliHLTReconstructorBase {
 public:
+  /** standard constructor */
   AliHLTReconstructor();
+  /** constructor */
+  AliHLTReconstructor(const char* options);
   /** destructor */
   virtual ~AliHLTReconstructor();
 
   /** init the reconstructor */
   void Init();
 
+  /** init the reconstructor */
+  void Init(const char* options);
+
   /**
    * This Reconstructor function is not applicable for the AliHLTReconstructor
    * as it gets a detector specific digits tree. But HLT processes all detectors.
@@ -103,6 +109,33 @@ public:
    */
   void ProcessHLTOUT(AliHLTOUT* pHLTOUT, AliESDEvent* esd) const;
 
+  /**
+   * Process HLTOUT data.
+   * Open digit file and process the HLTOUT digit data.
+   * This function is mostly intended for debugging purposes and stand-alone
+   * processing of the output from the simulation. Loops over all events.
+   * @param digitFile        path of the digit file
+   * @param pEsd             optional ESD to be filled
+   */
+  void ProcessHLTOUT(const char* digitFile="HLT.Digits.root", AliESDEvent* pEsd=NULL) const;
+
+  /**
+   * Process HLTOUT data.
+   * Process the HLTOUT from the raw reader.
+   * This function is mostly intended for debugging purposes and stand-alone
+   * processing of simulated or real raw data. 
+   * \em Note: Loops over all events, i.e. the current event of the the raw
+   * reader will change. Not to be called inside the normal AliRoot processsing.
+   * @param pRawReader       raw reader instance
+   * @param pEsd             optional ESD to be filled
+   */
+  void ProcessHLTOUT(AliRawReader* pRawReader, AliESDEvent* pEsd=NULL) const;
+
+  /**
+   * Print a short info about the HLTOUT content.
+   */
+  void PrintHLTOUTContent(AliHLTOUT* pHLTOUT) const;
+
 private:
   /** copy constructor prohibited */
   AliHLTReconstructor(const AliHLTReconstructor& src);