From 032c5e5ecea91b14e7788a95c666f2613ce218e2 Mon Sep 17 00:00:00 2001 From: richterm Date: Mon, 21 Apr 2008 05:52:35 +0000 Subject: [PATCH] - AliHLTReconstructor: added helper functions to run HLTOUT processing stand alone - AliHLTSystem: enable benchmark printout again - AliHLTConfiguration: additional parameter for the output buffer size --- HLT/BASE/AliHLTConfiguration.cxx | 46 +++++++++++++-- HLT/BASE/AliHLTConfiguration.h | 20 ++++++- HLT/BASE/AliHLTSystem.cxx | 34 +++++++++-- HLT/BASE/AliHLTSystem.h | 18 +++++- HLT/BASE/AliHLTTask.cxx | 11 +++- HLT/RCU/AliHLTAltroGenerator.h | 1 + HLT/doc/doxygen.conf.in | 1 + HLT/rec/AliHLTOUTDigitReader.cxx | 5 +- HLT/rec/AliHLTOUTDigitReader.h | 8 ++- HLT/rec/AliHLTReconstructor.cxx | 96 ++++++++++++++++++++++++++++++++ HLT/rec/AliHLTReconstructor.h | 33 +++++++++++ 11 files changed, 256 insertions(+), 17 deletions(-) diff --git a/HLT/BASE/AliHLTConfiguration.cxx b/HLT/BASE/AliHLTConfiguration.cxx index 03b291de852..91a47228af6 100644 --- a/HLT/BASE/AliHLTConfiguration.cxx +++ b/HLT/BASE/AliHLTConfiguration.cxx @@ -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& argList) +int AliHLTConfiguration::InterpreteString(const char* arg, vector& argList) const { // see header file for function documentation int iResult=0; @@ -402,6 +408,36 @@ int AliHLTConfiguration::InterpreteString(const char* arg, vector& 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 diff --git a/HLT/BASE/AliHLTConfiguration.h b/HLT/BASE/AliHLTConfiguration.h index 5a0d4e459f4..6bf284b48d2 100644 --- a/HLT/BASE/AliHLTConfiguration.h +++ b/HLT/BASE/AliHLTConfiguration.h @@ -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& argList); + int InterpreteString(const char* arg, vector& 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 diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx index 7939458e72c..d3923726002 100644 --- a/HLT/BASE/AliHLTSystem.cxx +++ b/HLT/BASE/AliHLTSystem.cxx @@ -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=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(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(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" diff --git a/HLT/BASE/AliHLTSystem.h b/HLT/BASE/AliHLTSystem.h index cf1caa692b7..a5bbfdd5660 100644 --- a/HLT/BASE/AliHLTSystem.h +++ b/HLT/BASE/AliHLTSystem.h @@ -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. diff --git a/HLT/BASE/AliHLTTask.cxx b/HLT/BASE/AliHLTTask.cxx index 384c4edbbda..b0f8caf73a4 100644 --- a/HLT/BASE/AliHLTTask.cxx +++ b/HLT/BASE/AliHLTTask.cxx @@ -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; diff --git a/HLT/RCU/AliHLTAltroGenerator.h b/HLT/RCU/AliHLTAltroGenerator.h index 261090fad8c..e34599b376d 100644 --- a/HLT/RCU/AliHLTAltroGenerator.h +++ b/HLT/RCU/AliHLTAltroGenerator.h @@ -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); diff --git a/HLT/doc/doxygen.conf.in b/HLT/doc/doxygen.conf.in index 4be1a0d7588..ebe67867659 100644 --- a/HLT/doc/doxygen.conf.in +++ b/HLT/doc/doxygen.conf.in @@ -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 \ diff --git a/HLT/rec/AliHLTOUTDigitReader.cxx b/HLT/rec/AliHLTOUTDigitReader.cxx index b5323c95cd7..2b6d0a048c4 100644 --- a/HLT/rec/AliHLTOUTDigitReader.cxx +++ b/HLT/rec/AliHLTOUTDigitReader.cxx @@ -35,9 +35,10 @@ /** 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; diff --git a/HLT/rec/AliHLTOUTDigitReader.h b/HLT/rec/AliHLTOUTDigitReader.h index 0d5756e7e3d..59197d10059 100644 --- a/HLT/rec/AliHLTOUTDigitReader.h +++ b/HLT/rec/AliHLTOUTDigitReader.h @@ -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 diff --git a/HLT/rec/AliHLTReconstructor.cxx b/HLT/rec/AliHLTReconstructor.cxx index a8648cdbfcb..90552504f2e 100644 --- a/HLT/rec/AliHLTReconstructor.cxx +++ b/HLT/rec/AliHLTReconstructor.cxx @@ -23,8 +23,11 @@ #include #include +#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; eventRewindEvents(); + 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)); + } +} diff --git a/HLT/rec/AliHLTReconstructor.h b/HLT/rec/AliHLTReconstructor.h index 3fad1a6fb32..725ca6abe97 100644 --- a/HLT/rec/AliHLTReconstructor.h +++ b/HLT/rec/AliHLTReconstructor.h @@ -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); -- 2.43.0