From: richterm Date: Tue, 17 Apr 2007 16:39:33 +0000 (+0000) Subject: HLT sample applications X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=90ebac254452087aac5949b630ca6e42949503d4 HLT sample applications - publisher for AliLoader trees added - sample analysis chain added tp sample lib - tutorial and documentation - benchmark functionality added to AliHLTSystem --- diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx index 9ab55b5c4b4..7995190e0bc 100644 --- a/HLT/BASE/AliHLTComponent.cxx +++ b/HLT/BASE/AliHLTComponent.cxx @@ -32,9 +32,19 @@ using namespace std; #include "TString.h" #include "TObjArray.h" #include "TClass.h" +#include "TStopwatch.h" /** ROOT macro for the implementation of ROOT specific class methods */ -ClassImp(AliHLTComponent) +ClassImp(AliHLTComponent); + +/** stopwatch macro using the stopwatch guard */ +#define ALIHLTCOMPONENT_STOPWATCH(type) AliHLTStopwatchGuard swguard(fpStopwatches!=NULL?reinterpret_cast(fpStopwatches->At((int)type)):NULL) +//#define ALIHLTCOMPONENT_STOPWATCH(type) + +/** stopwatch macro for operations of the base class */ +#define ALIHLTCOMPONENT_BASE_STOPWATCH() ALIHLTCOMPONENT_STOPWATCH(kSWBase) +/** stopwatch macro for operations of the detector algorithm (DA) */ +#define ALIHLTCOMPONENT_DA_STOPWATCH() ALIHLTCOMPONENT_STOPWATCH(kSWDA) AliHLTComponent::AliHLTComponent() : @@ -51,7 +61,8 @@ AliHLTComponent::AliHLTComponent() fpOutputBuffer(NULL), fOutputBufferSize(0), fOutputBufferFilled(0), - fOutputBlocks() + fOutputBlocks(), + fpStopwatches(new TObjArray(kSWTypeCount)) { // see header file for class documentation // or @@ -80,7 +91,8 @@ AliHLTComponent::AliHLTComponent(const AliHLTComponent&) fpOutputBuffer(NULL), fOutputBufferSize(0), fOutputBufferFilled(0), - fOutputBlocks() + fOutputBlocks(), + fpStopwatches(NULL) { // see header file for class documentation HLTFatal("copy constructor untested"); @@ -431,6 +443,7 @@ const TObject* AliHLTComponent::GetFirstInputObject(const AliHLTComponentDataTyp int bForce) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); fSearchDataType=dt; if (classname) fClassName=classname; else fClassName.clear(); @@ -452,6 +465,7 @@ const TObject* AliHLTComponent::GetFirstInputObject(const char* dtID, int bForce) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); AliHLTComponentDataType dt; SetDataType(dt, dtID, dtOrigin); return GetFirstInputObject(dt, classname, bForce); @@ -460,6 +474,7 @@ const TObject* AliHLTComponent::GetFirstInputObject(const char* dtID, const TObject* AliHLTComponent::GetNextInputObject(int bForce) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1); //HLTDebug("found block %d when searching for data type %s", idx, DataType2Text(fSearchDataType).c_str()); TObject* pObj=NULL; @@ -550,11 +565,13 @@ int AliHLTComponent::CleanupInputObjects() if (pObj) delete pObj; } delete array; + return 0; } AliHLTComponentDataType AliHLTComponent::GetDataType(const TObject* pObject) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); AliHLTComponentDataType dt=kAliHLTVoidDataType; int idx=fCurrentInputBlock; if (pObject) { @@ -576,6 +593,7 @@ AliHLTComponentDataType AliHLTComponent::GetDataType(const TObject* pObject) AliHLTUInt32_t AliHLTComponent::GetSpecification(const TObject* pObject) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec; int idx=fCurrentInputBlock; if (pObject) { @@ -597,6 +615,7 @@ AliHLTUInt32_t AliHLTComponent::GetSpecification(const TObject* pObject) const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const AliHLTComponentDataType& dt) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); fSearchDataType=dt; fClassName.clear(); int idx=FindInputBlock(fSearchDataType, 0); @@ -612,6 +631,7 @@ const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const char* const char* dtOrigin) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); AliHLTComponentDataType dt; SetDataType(dt, dtID, dtOrigin); return GetFirstInputBlock(dt); @@ -620,6 +640,7 @@ const AliHLTComponentBlockData* AliHLTComponent::GetFirstInputBlock(const char* const AliHLTComponentBlockData* AliHLTComponent::GetNextInputBlock() { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); int idx=FindInputBlock(fSearchDataType, fCurrentInputBlock+1); const AliHLTComponentBlockData* pBlock=NULL; if (idx>=0) { @@ -648,6 +669,7 @@ int AliHLTComponent::FindInputBlock(const AliHLTComponentBlockData* pBlock) AliHLTUInt32_t AliHLTComponent::GetSpecification(const AliHLTComponentBlockData* pBlock) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); AliHLTUInt32_t iSpec=kAliHLTVoidDataSpec; int idx=fCurrentInputBlock; if (pBlock) { @@ -666,6 +688,7 @@ AliHLTUInt32_t AliHLTComponent::GetSpecification(const AliHLTComponentBlockData* int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); int iResult=0; if (pObject) { AliHLTMessage msg(kMESS_OBJECT); @@ -690,6 +713,7 @@ int AliHLTComponent::PushBack(TObject* pObject, const AliHLTComponentDataType& d int AliHLTComponent::PushBack(TObject* pObject, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); AliHLTComponentDataType dt; SetDataType(dt, dtID, dtOrigin); return PushBack(pObject, dt, spec); @@ -698,12 +722,14 @@ int AliHLTComponent::PushBack(TObject* pObject, const char* dtID, const char* dt int AliHLTComponent::PushBack(void* pBuffer, int iSize, const AliHLTComponentDataType& dt, AliHLTUInt32_t spec) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); return InsertOutputBlock(pBuffer, iSize, dt, spec); } int AliHLTComponent::PushBack(void* pBuffer, int iSize, const char* dtID, const char* dtOrigin, AliHLTUInt32_t spec) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); AliHLTComponentDataType dt; SetDataType(dt, dtID, dtOrigin); return PushBack(pBuffer, iSize, dt, spec); @@ -772,6 +798,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, AliHLTComponentEventDoneData*& edd ) { // see header file for function documentation + ALIHLTCOMPONENT_BASE_STOPWATCH(); int iResult=0; fCurrentEvent=evtData.fEventID; fCurrentEventData=evtData; @@ -784,7 +811,10 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, fOutputBlocks.clear(); vector blockData; - iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd); + { // dont delete, sets the scope for the stopwatch guard + ALIHLTCOMPONENT_DA_STOPWATCH(); + iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd); + } // end of the scope of the stopwatch guard if (iResult>=0) { if (fOutputBlocks.size()>0) { //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size()); @@ -811,3 +841,100 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, return iResult; } +AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard() + : + fpStopwatch(NULL), + fpPrec(NULL) +{ + // standard constructor (not for use) +} + +AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(TStopwatch* pStopwatch) + : + fpStopwatch(pStopwatch), + fpPrec(NULL) +{ + // constructor + + // check for already existing guard + if (fgpCurrent) fpPrec=fgpCurrent; + fgpCurrent=this; + + // stop the preceeding guard if it controls a different stopwatch + int bStart=1; + if (fpPrec && fpPrec!=this) bStart=fpPrec->Hold(fpStopwatch); + + // start the stopwatch if the current guard controls a different one + if (fpStopwatch && bStart==1) fpStopwatch->Start(kFALSE); +} + +AliHLTComponent::AliHLTStopwatchGuard::AliHLTStopwatchGuard(AliHLTStopwatchGuard&) + : + fpStopwatch(NULL), + fpPrec(NULL) +{ + // copy constructor (not for use) +} + +AliHLTComponent::AliHLTStopwatchGuard* AliHLTComponent::AliHLTStopwatchGuard::fgpCurrent=NULL; + +AliHLTComponent::AliHLTStopwatchGuard::~AliHLTStopwatchGuard() +{ + // destructor + + // resume the preceeding guard if it controls a different stopwatch + int bStop=1; + if (fpPrec && fpPrec!=this) bStop=fpPrec->Resume(fpStopwatch); + + // stop the stopwatch if the current guard controls a different one + if (fpStopwatch && bStop==1) fpStopwatch->Stop(); + + // resume to the preceeding guard + fgpCurrent=fpPrec; +} + +int AliHLTComponent::AliHLTStopwatchGuard::Hold(TStopwatch* pSucc) +{ + // see header file for function documentation + if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Stop(); + return fpStopwatch!=pSucc?1:0; +} + +int AliHLTComponent::AliHLTStopwatchGuard::Resume(TStopwatch* pSucc) +{ + // see header file for function documentation + if (fpStopwatch!=NULL && fpStopwatch!=pSucc) fpStopwatch->Start(kFALSE); + return fpStopwatch!=pSucc?1:0; +} + +int AliHLTComponent::SetStopwatch(TObject* pSW, AliHLTStopwatchType type) +{ + // see header file for function documentation + int iResult=0; + if (pSW!=NULL && typeAt((int)type); + if (pSW==NULL // explicit reset + || pObj==NULL) { // explicit set + fpStopwatches->AddAt(pSW, (int)type); + } else if (pObj!=pSW) { + HLTWarning("stopwatch %d already set, reset first", (int)type); + iResult=-EBUSY; + } + } + } else { + iResult=-EINVAL; + } + return iResult; +} + +int AliHLTComponent::SetStopwatches(TObjArray* pStopwatches) +{ + // see header file for function documentation + if (pStopwatches==NULL) return -EINVAL; + + int iResult=0; + for (int i=0 ; i<(int)kSWTypeCount && pStopwatches->GetEntries(); i++) + SetStopwatch(pStopwatches->At(i), (AliHLTStopwatchType)i); + return iResult; +} diff --git a/HLT/BASE/AliHLTComponent.h b/HLT/BASE/AliHLTComponent.h index db1f6724d7d..703267e64ec 100644 --- a/HLT/BASE/AliHLTComponent.h +++ b/HLT/BASE/AliHLTComponent.h @@ -39,6 +39,7 @@ typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData; class AliHLTComponentHandler; class TObjArray; +class TStopwatch; /** * @class AliHLTComponent @@ -68,9 +69,9 @@ class TObjArray; * * @subsection alihltcomponent-type Component type * Components can be of type - * - @ref kSource: components which only produce data - * - @ref kProcessor: components which consume and produce data - * - @ref kSink: components which only consume data + * - @ref kSource components which only produce data + * - @ref kProcessor components which consume and produce data + * - @ref kSink components which only consume data * * where data production and consumption refer to the analysis data stream. In * order to indicate the type, a child component can overload the @@ -367,6 +368,87 @@ class AliHLTComponent : public AliHLTLogging { */ void PrintComponentDataTypeInfo(const AliHLTComponentDataType& dt); + /** + * Stopwatch type for benchmarking. + */ + enum AliHLTStopwatchType { + /** total time for event processing */ + kSWBase, + /** detector algorithm w/o interface callbacks */ + kSWDA, + /** data sources */ + kSWInput, + /** data sinks */ + kSWOutput, + /** number of types */ + kSWTypeCount + }; + + /** + * Helper class for starting and stopping a stopwatch. + * The guard can be used by instantiating an object in a function. The + * specified stopwatch is started and the previous stopwatch put on + * hold. When the function is terminated, the object is deleted automatically + * deleted, stopping the stopwatch and starting the one on hold.
+ * \em IMPORTANT: never create dynamic objects from this guard as this violates + * the idea of a guard. + */ + class AliHLTStopwatchGuard { + public: + /** standard constructor (not for use) */ + AliHLTStopwatchGuard(); + /** constructor */ + AliHLTStopwatchGuard(TStopwatch* pStart); + /** copy constructor (not for use) */ + AliHLTStopwatchGuard(AliHLTStopwatchGuard&); + /** destructor */ + ~AliHLTStopwatchGuard(); + + private: + /** + * Hold the previous guard for the existence of this guard. + * Checks whether this guard controls a new stopwatch. In that case, the + * previous guard and its stopwatch are put on hold. + * @param pSucc instance of the stopwatch of the new guard + * @return 1 if pSucc is a different stopwatch which should + * be started
+ * 0 if it controls the same stopwatch + */ + int Hold(TStopwatch* pSucc); + + /** + * Resume the previous guard. + * Checks whether the peceeding guard controls a different stopwatch. In that + * case, the its stopwatch is resumed. + * @param pSucc instance of the stopwatch of the new guard + * @return 1 if pSucc is a different stopwatch which should + * be stopped
+ * 0 if it controls the same stopwatch + */ + int Resume(TStopwatch* pSucc); + + /** the stopwatch controlled by this guard */ + TStopwatch* fpStopwatch; //!transient + + /** previous stopwatch guard, put on hold during existence of the guard */ + AliHLTStopwatchGuard* fpPrec; //!transient + + /** active stopwatch guard */ + static AliHLTStopwatchGuard* fgpCurrent; //!transient + }; + + /** + * Set a stopwatch for a given purpose. + * @param pSW stopwatch object + * @param type type of the stopwatch + */ + int SetStopwatch(TObject* pSW, AliHLTStopwatchType type=kSWBase); + + /** + * Init a set of stopwatches. + * @param pStopwatches object array of stopwatches + */ + int SetStopwatches(TObjArray* pStopwatches); protected: @@ -778,6 +860,9 @@ class AliHLTComponent : public AliHLTLogging { /** list of ouput block data descriptors */ vector fOutputBlocks; // see above - ClassDef(AliHLTComponent, 1) + /** stopwatch array */ + TObjArray* fpStopwatches; //! transient + + ClassDef(AliHLTComponent, 2) }; #endif diff --git a/HLT/BASE/AliHLTDataBuffer.h b/HLT/BASE/AliHLTDataBuffer.h index 7c032430135..5bba4074dbd 100644 --- a/HLT/BASE/AliHLTDataBuffer.h +++ b/HLT/BASE/AliHLTDataBuffer.h @@ -248,7 +248,8 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * of the consumer, neg. error code if failed
* -EINVAL invalid parameter
*/ - int FindMatchingDataSegments(const AliHLTComponent* pConsumer, vector& tgtList); + int FindMatchingDataSegments(const AliHLTComponent* pConsumer, + vector& tgtList); /** * Reset the data buffer. diff --git a/HLT/BASE/AliHLTModuleAgent.cxx b/HLT/BASE/AliHLTModuleAgent.cxx index 333e751d2b8..8101ef52449 100644 --- a/HLT/BASE/AliHLTModuleAgent.cxx +++ b/HLT/BASE/AliHLTModuleAgent.cxx @@ -99,7 +99,16 @@ int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* handler, return 0; } -const char* AliHLTModuleAgent::GetTopConfigurations(AliRunLoader* runloader) const +const char* AliHLTModuleAgent::GetLocalRecConfigurations(AliRunLoader* runloader) const +{ + // default method, nothing to be done, child classes can overload + if (runloader==NULL) { + // get rid of 'unused parameter' warning + } + return NULL; +} + +const char* AliHLTModuleAgent::GetEventRecConfigurations(AliRunLoader* runloader) const { // default method, nothing to be done, child classes can overload if (runloader==NULL) { diff --git a/HLT/BASE/AliHLTModuleAgent.h b/HLT/BASE/AliHLTModuleAgent.h index 87a01f5315b..fddcc96765d 100644 --- a/HLT/BASE/AliHLTModuleAgent.h +++ b/HLT/BASE/AliHLTModuleAgent.h @@ -25,23 +25,49 @@ class AliRunLoader; * @brief Agent helper class for HLT sub modules, e.g. PHOS, TPC, Trigger * * This class implements the agent base class for the HLT sub modules. - * The agent of a library gives information on the features of the module, - * like the configurations to run and other component libraries it depends - * on. - * + * The agent of a library gives information on the features of the library/ + * components, like the configurations to run and other component libraries + * it depends on. + * @note There must not be more than one agent per module/library. + * * All HLT component libraries are loaded on demand through the HLT steering * instance (@ref AliHLTSystem). A library can implement an agent derived * from this base class, and has to define one global object of this agent * in the code. The agent will be registered automatically, and the features * can be queried when required. * - * This is usually done during running the AliRoot Reconstruction (see - * AliReconstruction. The HLT implemets the AliHLTReconstructor which - * holds the HLT steering object. Several flags can be specified as options - * via the SetOption method of AliReconstruction, including the component - * libraries to be loaded. + * This is usually done during running the AliRoot reconstruction (see AliRoot + * documentation on AliReconstruction). The HLT implemets the @ref + * AliHLTReconstructor which holds the HLT steering object. Several flags can + * be specified as options via the SetOption method of + * AliReconstruction, including the component libraries to be loaded. + * + * @section alihltmoduleagent_interface Agent interface + * The child can implement the following functions: + * - @ref CreateConfigurations
+ * create HLT configuration forming an HLT analysis chain. + * + * - @ref GetLocalRecConfigurations
+ * configurations run during local event reconstruction. + * @note Local event reconstruction is the first step of the + * reconstruction chain. All events are processed at once. + *
+ * - @ref GetEventRecConfigurations
+ * configurations run during event reconstruction. + * @note This is the reconstruction on event by event basis. + *
+ * - @ref GetRequiredComponentLibraries
+ * can indicate further libraries which are required for running the + * chains (e.g. if components of another library are used). * - * There must be only one agent per module/library. + * - @ref RegisterComponents
+ * register componens, this can be used to avoid the component + * registration via global objects + * @see @ref alihltcomponent-handling + *
+ * @section alihltmoduleagent_references References + * @see @ref AliHLTReconstructor interface to the AliRoot reconstruction + * @see @ref AliHLTAgentSample agent for the libAliHLTSample library * * @ingroup alihlt_system */ @@ -61,8 +87,8 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { /** * Print status info. - * Short summary on registered agents. This function acts globally on the list - * of agents if no specific agent is specified. + * Short summary on registered agents. This function acts globally on the + * list of agents if no specific agent is specified. */ static void PrintStatus(const char* agent=NULL); @@ -91,7 +117,7 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { AliRunLoader* runloader=NULL) const; /** - * Get the top configurations belonging to this module. + * Get the top configurations for local event reconstruction. * A top configuration describes a processing chain. It can simply be * described by the last configuration(s) in the chain. * The agent can adapt the configurations to be registered to the current @@ -99,7 +125,16 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { * @param runloader [in] AliRoot runloader * @return string containing the top configurations separated by blanks */ - virtual const char* GetTopConfigurations(AliRunLoader* runloader=NULL) const; + virtual const char* GetLocalRecConfigurations(AliRunLoader* runloader=NULL) const; + + /** + * Get the top configurations for event reconstruction. + * The same as for @ref GetLocalRecConfigurations, but for the reconstruction on + * event by event basis. + * @param runloader [in] AliRoot runloader + * @return string containing the top configurations separated by blanks + */ + virtual const char* GetEventRecConfigurations(AliRunLoader* runloader=NULL) const; /** * Component libraries which the configurations of this agent depend on. @@ -117,6 +152,14 @@ class AliHLTModuleAgent : public TObject, public AliHLTLogging { */ virtual int RegisterComponents(AliRunLoader* runloader=NULL) const; + /** + * Old method kept for backward compatibility, redirected to @ref + * GetLocalRecConfigurations. + */ + const char* GetTopConfigurations(AliRunLoader* runloader=NULL) const { + return GetLocalRecConfigurations(runloader); + } + protected: private: diff --git a/HLT/BASE/AliHLTOfflineInterface.cxx b/HLT/BASE/AliHLTOfflineInterface.cxx index 0d1c3c6aee9..59ead57a9c3 100644 --- a/HLT/BASE/AliHLTOfflineInterface.cxx +++ b/HLT/BASE/AliHLTOfflineInterface.cxx @@ -143,8 +143,8 @@ int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRa fgCurrentLnk=fgCurrentLnk->Next(); } if (iResult>=0) { - log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__, - "parameters set to %d offline interface component(s)", count); +// log.LoggingVarargs(kHLTLogInfo, "AliHLTOfflineInterface","SetParamsToComponents", __FILE__, __LINE__, +// "parameters set to %d offline interface component(s)", count); } return iResult; } diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx index 26ce765e535..e316e71970f 100644 --- a/HLT/BASE/AliHLTSystem.cxx +++ b/HLT/BASE/AliHLTSystem.cxx @@ -37,6 +37,7 @@ using namespace std; #include #include #include +#include /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTSystem) @@ -299,7 +300,16 @@ int AliHLTSystem::Run(Int_t iNofEvents) int iResult=0; int iCount=0; SetStatusFlags(kRunning); - if ((iResult=InitTasks())>=0) { + TStopwatch StopwatchBase; StopwatchBase.Reset(); + TStopwatch StopwatchDA; StopwatchDA.Reset(); + TStopwatch StopwatchInput; StopwatchInput.Reset(); + TStopwatch StopwatchOutput; StopwatchOutput.Reset(); + TObjArray Stopwatches; + Stopwatches.AddAt(&StopwatchBase, (int)AliHLTComponent::kSWBase); + Stopwatches.AddAt(&StopwatchDA, (int)AliHLTComponent::kSWDA); + Stopwatches.AddAt(&StopwatchInput, (int)AliHLTComponent::kSWInput); + Stopwatches.AddAt(&StopwatchOutput, (int)AliHLTComponent::kSWOutput); + if ((iResult=InitTasks())>=0 && (iResult=InitBenchmarking(&Stopwatches))>=0) { if ((iResult=StartTasks())>=0) { for (int i=0; i=0; i++) { iResult=ProcessTasks(i); @@ -323,7 +333,18 @@ int AliHLTSystem::Run(Int_t iNofEvents) } else if (iResult!=-ENOENT) { HLTError("can not initialize task list"); } - if (iResult>=0) iResult=iCount; + if (iResult>=0) { + iResult=iCount; + HLTInfo("HLT statistics:\n" + " base: R:%.3fs C:%.3fs\n" + " input: R:%.3fs C:%.3fs\n" + " output: R:%.3fs C:%.3fs\n" + " event processing : R:%.3fs C:%.3fs" + , StopwatchBase.RealTime(),StopwatchBase.CpuTime() + , StopwatchInput.RealTime(),StopwatchInput.CpuTime() + , StopwatchOutput.RealTime(),StopwatchOutput.CpuTime() + , StopwatchDA.RealTime(),StopwatchDA.CpuTime()); + } ClearStatusFlags(kRunning); return iResult; } @@ -351,6 +372,54 @@ int AliHLTSystem::InitTasks() return iResult; } +int AliHLTSystem::InitBenchmarking(TObjArray* pStopwatches) +{ + // see header file for class documentation + if (pStopwatches==NULL) return -EINVAL; + + int iResult=0; + TObjLink *lnk=fTaskList.FirstLink(); + while (lnk && iResult>=0) { + TObject* obj=lnk->GetObject(); + if (obj) { + AliHLTTask* pTask=(AliHLTTask*)obj; + AliHLTComponent* pComp=NULL; + if (iResult>=0 && (pComp=pTask->GetComponent())!=NULL) { + switch (pComp->GetComponentType()) { + case AliHLTComponent::kProcessor: + pComp->SetStopwatches(pStopwatches); + break; + case AliHLTComponent::kSource: + { + // this switch determines whether the time consumption of the + // AliHLTComponent base methods should be counted to the input + // stopwatch or base stopwatch. + //int inputBase=(int)AliHLTComponent::kSWBase; + int inputBase=(int)AliHLTComponent::kSWInput; + pComp->SetStopwatch(pStopwatches->At(inputBase), AliHLTComponent::kSWBase); + pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWInput), AliHLTComponent::kSWDA); + } + break; + case AliHLTComponent::kSink: + { + // this switch determines whether the time consumption of the + // AliHLTComponent base methods should be counted to the output + // stopwatch or base stopwatch. + //int outputBase=(int)AliHLTComponent::kSWBase; + int outputBase=(int)AliHLTComponent::kSWOutput; + pComp->SetStopwatch(pStopwatches->At(outputBase), AliHLTComponent::kSWBase); + pComp->SetStopwatch(pStopwatches->At((int)AliHLTComponent::kSWOutput), AliHLTComponent::kSWDA); + } + break; + } + } + } else { + } + lnk = lnk->Next(); + } + return iResult; +} + int AliHLTSystem::StartTasks() { // see header file for class documentation @@ -575,7 +644,7 @@ int AliHLTSystem::BuildTaskListsFromTopConfigurations(AliRunLoader* runloader) int iResult=0; AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); while (pAgent && iResult>=0) { - TString tops=pAgent->GetTopConfigurations(runloader); + TString tops=pAgent->GetLocalRecConfigurations(runloader); HLTDebug("top configurations for agent %s (%p): %s", pAgent->GetName(), pAgent, tops.Data()); TObjArray* pTokens=tops.Tokenize(" "); if (pTokens) { diff --git a/HLT/BASE/AliHLTSystem.h b/HLT/BASE/AliHLTSystem.h index b97387c28ba..70ca889c9df 100644 --- a/HLT/BASE/AliHLTSystem.h +++ b/HLT/BASE/AliHLTSystem.h @@ -27,6 +27,8 @@ class AliHLTTask; class AliRunLoader; class AliRawReader; class AliESD; +class TObjArray; +class TStopwatch; /** * @class AliHLTSystem @@ -137,6 +139,14 @@ class AliHLTSystem : public AliHLTLogging { */ int InitTasks(); + /** + * Init the stopwatches for all tasks. + * @param pStopwatches object array of stopwatches, for types + * @see AliHLTComponent::AliHLTStopwatchType + * @return neg error code if failed + */ + int InitBenchmarking(TObjArray* pStopwatches); + /** * Start task list. * The @ref AliHLTTask::StartRun method is called for each task, the diff --git a/HLT/BASE/Makefile.am b/HLT/BASE/Makefile.am index 12eb38e65eb..7e7a7dceb72 100644 --- a/HLT/BASE/Makefile.am +++ b/HLT/BASE/Makefile.am @@ -21,7 +21,7 @@ bin_SCRIPTS = setenv.sh setenv.csh lib_LTLIBRARIES = libHLTbase.la # version info for the library -LIBRARY_VERSION = '3:0:0' +LIBRARY_VERSION = '3:1:1' # MODDIR is set by the AliRoot build system and denotes the topdir # of the module, we must set it since the package definition libHLTbase.pkg diff --git a/HLT/BASE/util/AliHLTFilePublisher.h b/HLT/BASE/util/AliHLTFilePublisher.h index 58964ffa3a3..d11debaa1d7 100644 --- a/HLT/BASE/util/AliHLTFilePublisher.h +++ b/HLT/BASE/util/AliHLTFilePublisher.h @@ -22,9 +22,7 @@ * of files.
* * Component ID: \b FilePublisher
- * Library: \b libHLTBase (in order to use the component from the external - * interface, it might be necessary to specify a dummy library with the - * \em -componentlibrary argument). + * Library: \b libAliHLTUtil. * * Mandatory arguments:
* diff --git a/HLT/BASE/util/AliHLTLoaderPublisherComponent.cxx b/HLT/BASE/util/AliHLTLoaderPublisherComponent.cxx new file mode 100644 index 00000000000..d22cd881001 --- /dev/null +++ b/HLT/BASE/util/AliHLTLoaderPublisherComponent.cxx @@ -0,0 +1,211 @@ +// @(#) $Id$ + +/** @file AliHLTLoaderPublisherComponent.cxx + @author Matthias Richter + @date + @brief A general tree publisher component for the AliLoader. +*/ + +#include "AliHLTLoaderPublisherComponent.h" +#include "AliRunLoader.h" +#include "AliLoader.h" +#include "AliLog.h" +#include "TTree.h" + +/** global instance for agent registration */ +AliHLTLoaderPublisherComponent gAliHLTLoaderPublisherComponent; + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTLoaderPublisherComponent) + +AliHLTLoaderPublisherComponent::AliHLTLoaderPublisherComponent() + : + fMaxSize(0), + fLoaderType(), + fTreeType("digits"), + fVerbose(kFALSE), + fDataType(kAliHLTAnyDataType), + fSpecification(0), + fpLoader(NULL) +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTLoaderPublisherComponent::~AliHLTLoaderPublisherComponent() +{ + // see header file for class documentation +} + +const char* AliHLTLoaderPublisherComponent::GetComponentID() +{ + // see header file for class documentation + return "AliLoaderPublisher"; +} + +AliHLTComponentDataType AliHLTLoaderPublisherComponent::GetOutputDataType() +{ + return fDataType; +} + +void AliHLTLoaderPublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) +{ + constBase=fMaxSize; + inputMultiplier=1; +} + +AliHLTComponent* AliHLTLoaderPublisherComponent::Spawn() +{ + // see header file for class documentation + return new AliHLTLoaderPublisherComponent; +} + +int AliHLTLoaderPublisherComponent::DoInit( int argc, const char** argv ) +{ + // see header file for class documentation + int iResult=0; + + // scan arguments + TString argument=""; + int bMissingParam=0; + for (int i=0; i=0; i++) { + argument=argv[i]; + if (argument.IsNull()) continue; + + // -loader + if (argument.CompareTo("-loader")==0) { + if ((bMissingParam=(++i>=argc))) break; + fLoaderType=argv[i]; + + // -tree + } else if (argument.CompareTo("-tree")==0) { + if ((bMissingParam=(++i>=argc))) break; + fTreeType=argv[i]; + + // -verbose + } else if (argument.CompareTo("-verbose")==0) { + fVerbose=kTRUE; + + // -datatype + } else if (argument.CompareTo("-datatype")==0) { + if ((bMissingParam=(++i>=argc))) break; + memcpy(&fDataType.fID, argv[i], TMath::Min(kAliHLTComponentDataTypefIDsize, (Int_t)strlen(argv[i]))); + if ((bMissingParam=(++i>=argc))) break; + memcpy(&fDataType.fOrigin, argv[i], TMath::Min(kAliHLTComponentDataTypefOriginSize, (Int_t)strlen(argv[i]))); + + // -dataspec + } else if (argument.CompareTo("-dataspec")==0) { + if ((bMissingParam=(++i>=argc))) break; + TString parameter(argv[i]); + parameter.Remove(TString::kLeading, ' '); // remove all blanks + if (parameter.IsDigit()) { + fSpecification=(AliHLTUInt32_t)parameter.Atoi(); + } else if (parameter.BeginsWith("0x") && + parameter.Replace(0,2,"",0).IsHex()) { + sscanf(parameter.Data(),"%x", &fSpecification); + } else { + HLTError("wrong parameter for argument %s, number expected", argument.Data()); + iResult=-EINVAL; + } + } else { + HLTError("unknown argument %s", argument.Data()); + iResult=-EINVAL; + } + } + if (bMissingParam) { + HLTError("missing parameter for argument %s", argument.Data()); + iResult=-EINVAL; + } + + if (iResult<0) return iResult; + + if (fLoaderType.IsNull()) { + HLTError("loader type required, use \'-loader\' option"); + return -EINVAL; + } + + // fetch runLoader instance from interface + AliRunLoader* pRunLoader=GetRunLoader(); + if (pRunLoader) { + + // get the TPC loader + fpLoader=pRunLoader->GetLoader(fLoaderType.Data()); + if (fpLoader) { + // prepare the loader + fpLoader->LoadDigits("read"); + + // scan trough all events and estimate the size of the digits + for (int i=0; iGetNumberOfEvents(); i++) { + pRunLoader->GetEvent(i); + TTree* pTree=GetTree(); + if (pTree) { + int size=EstimateObjectSize(pTree); + if (size>fMaxSize) fMaxSize=size; + if (fVerbose) { + AliInfoStream() << "event " << i << " " + << fTreeType <<" size " << size + << " count " << pTree->GetEntries() << endl; + } + } else { + AliWarningStream() << "no " << fTreeType << " tree for event " << i << endl; + } + } + } else { + AliErrorStream() << "can not get loader of type " << fLoaderType << endl; + iResult=-EFAULT; + } + } else { + AliErrorStream() << "can not get runLoader" << endl; + iResult=-EFAULT; + } + return iResult; +} + +int AliHLTLoaderPublisherComponent::DoDeinit() +{ + // see header file for class documentation + int iResult=0; + if (fpLoader) { + fpLoader->UnloadDigits(); + } + fpLoader=NULL; + return iResult; +} + +int AliHLTLoaderPublisherComponent::GetEvent(const AliHLTComponentEventData& evtData, + AliHLTComponentTriggerData& trigData) +{ + // see header file for class documentation + int iResult=0; + // fetch runLoader instance from interface + AliRunLoader* pRunLoader=GetRunLoader(); + if (pRunLoader && fpLoader) { + pRunLoader->GetEvent(GetEventCount()); + TTree* pTree=GetTree(); + if (pTree) { + PushBack(pTree, fDataType); + } else { + AliWarningStream() << "no " << fTreeType << " tree for event " << GetEventCount() << endl; + } + } else { + AliErrorStream() << "component not initialized" << endl; + } + return iResult; +} + +TTree* AliHLTLoaderPublisherComponent::GetTree() +{ + TTree* pTree=NULL; + if (fpLoader) { + if (fTreeType.CompareTo("digits")==0) + pTree=fpLoader->TreeD(); + else if (fTreeType.CompareTo("clusters")==0) { + pTree=fpLoader->TreeR(); + } + } else { + } + return pTree; +} diff --git a/HLT/BASE/util/AliHLTLoaderPublisherComponent.h b/HLT/BASE/util/AliHLTLoaderPublisherComponent.h new file mode 100644 index 00000000000..72b041ec05c --- /dev/null +++ b/HLT/BASE/util/AliHLTLoaderPublisherComponent.h @@ -0,0 +1,135 @@ +//-*- Mode: C++ -*- +// @(#) $Id$ + +#ifndef ALIHLTLOADERPUBLISHERCOMPONENT_H +#define ALIHLTLOADERPUBLISHERCOMPONENT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTLoaderPublisherComponent.h + @author Matthias Richter + @date + @brief A general tree publisher component for the AliLoader. +*/ + +#include "AliHLTOfflineDataSource.h" + +class AliLoader; + +/** + * @class AliHLTLoaderPublisherComponent + * A general tree publisher component for the AliLoader. + * + * Component ID: \b AliLoaderPublisher
+ * Library: \b libAliHLTUtil. + * + * Mandatory arguments:
+ * + * \li -loader loader name + * e.g. -loader TPCLoader + * \li -tree tree name : digits (default), clusters + * e.g. -tree digits + * \li -verbose
+ * print out some more info messages, mainly for the sake of tutorials + * \li -datatype datatype dataorigin
+ * data type ID and origin, e.g. -datatype DIGITS TPC + * \li -dataspec specification
+ * data specification treated as decimal number or hex number if + * prepended by '0x' + * + * Optional arguments:
+ * + * + * @ingroup alihlt_system + */ +class AliHLTLoaderPublisherComponent : public AliHLTOfflineDataSource { + public: + /** standard constructor */ + AliHLTLoaderPublisherComponent(); + /** destructor */ + virtual ~AliHLTLoaderPublisherComponent(); + + /** + * Get the id of the component. + * Each component is identified by a unique id. + * The function is pure virtual and must be implemented by the child class. + * @return component id (string) + */ + const char* GetComponentID(); + + /** + * Get the output data type of the component. + * The function is pure virtual and must be implemented by the child class. + * @return output data type + */ + AliHLTComponentDataType GetOutputDataType(); + + /** + * Get a ratio by how much the data volume is shrinked or enhanced. + * The function is pure virtual and must be implemented by the child class. + * @param constBase return: additive part, independent of the + * input data volume + * @param inputMultiplier return: multiplication ratio + * @return values in the reference variables + */ + void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ); + + /** + * Spawn function. + * Each component must implement a spawn function to create a new instance of + * the class. Basically the function must return new my_class_name. + * @return new class instance + */ + virtual AliHLTComponent* Spawn(); + + protected: + /** + * Init method. + */ + int DoInit( int argc, const char** argv ); + + /** + * Deinit method. + */ + int DoDeinit(); + + /** + * Data source method. + * @param evtData event data structure + * @param trigData trigger data structure + * @return + */ + int GetEvent(const AliHLTComponentEventData& evtData, + AliHLTComponentTriggerData& trigData); + + private: + /** + * Get tree of type specified in fTreeType from loader. + */ + TTree* GetTree(); + + /** max output block size, estimate during DoInit */ + Int_t fMaxSize; //!transient + + /** loader string */ + TString fLoaderType; //!transient + + /** tree string */ + TString fTreeType; //!transient + + /** be verbose: info printouts */ + Bool_t fVerbose; //!transient + + /** data type */ + AliHLTComponentDataType fDataType; //!transient + + /** data specification */ + AliHLTUInt32_t fSpecification; //!transient + + /** instance of the AliLoader */ + AliLoader* fpLoader; //!transient + + ClassDef(AliHLTLoaderPublisherComponent, 0); +}; + +#endif diff --git a/HLT/ChangeLog b/HLT/ChangeLog index eac0faa14dc..54308f38183 100644 --- a/HLT/ChangeLog +++ b/HLT/ChangeLog @@ -1,3 +1,8 @@ +2007-04-17 HLT sample applications + - publisher for AliLoader trees added + - sample analysis chain added tp sample lib + - tutorial and documentation + - benchmark functionality added to AliHLTSystem 2007-03-14 aliroot integration - AliHLTSystem interface methods to AliHLTReconstructor implemeted - AliHLTModuleAgent introduced for each HLT module, sample diff --git a/HLT/Makefile.am b/HLT/Makefile.am index 3e81d52cfe7..b974e21513a 100644 --- a/HLT/Makefile.am +++ b/HLT/Makefile.am @@ -31,6 +31,7 @@ EXTRA_DIST = libHLTbase.pkg \ libAliHLTPHOS.pkg \ libAliHLTTPC.pkg \ libAliHLTTRD.pkg \ + src/AliHLTReconstructor.h \ hlt.conf DIST_SUBDIRS = $(SUBDIRS) diff --git a/HLT/SampleLib/AliHLTAgentSample.cxx b/HLT/SampleLib/AliHLTAgentSample.cxx index 31f319fd301..63fca1251d8 100644 --- a/HLT/SampleLib/AliHLTAgentSample.cxx +++ b/HLT/SampleLib/AliHLTAgentSample.cxx @@ -13,8 +13,8 @@ /** global instance for agent registration */ AliHLTAgentSample gAliHLTAgentSample; -const char* gAliHLTAgentSampleData="/tmp/testdata"; -const char* gAliHLTAgentSampleOut="/tmp/hltout"; +const char* AliHLTAgentSample::fgkAliHLTAgentSampleData="/tmp/testdata"; +const char* AliHLTAgentSample::fgkAliHLTAgentSampleOut="/tmp/hltout"; /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTAgentSample) @@ -33,21 +33,21 @@ AliHLTAgentSample::~AliHLTAgentSample() // see header file for class documentation // delete the test data - ofstream dump(gAliHLTAgentSampleData, ios::in); + ofstream dump(fgkAliHLTAgentSampleData, ios::in); if (dump.good()) { TString arg("rm -f "); - arg+=gAliHLTAgentSampleData; + arg+=fgkAliHLTAgentSampleData; gSystem->Exec(arg.Data()); } } int AliHLTAgentSample::CreateConfigurations(AliHLTConfigurationHandler* handler, - AliRunLoader* runloader) const + AliRunLoader* runloader) const { // see header file for class documentation // create some test data - ofstream dump(gAliHLTAgentSampleData, (ios::openmode)0); + ofstream dump(fgkAliHLTAgentSampleData, (ios::openmode)0); dump << "This is just some test data for the ALICE HLT analysis example"; dump << "---- not copied" << endl; dump.close(); @@ -55,24 +55,30 @@ int AliHLTAgentSample::CreateConfigurations(AliHLTConfigurationHandler* handler, if (handler) { // the publisher configuration for the test data TString arg("-datafile "); - arg+=gAliHLTAgentSampleData; + arg+=fgkAliHLTAgentSampleData; HLTDebug(arg.Data()); - handler->CreateConfiguration("fp1" , "FilePublisher", NULL , arg.Data()); + handler->CreateConfiguration("sample-fp1" , "FilePublisher", NULL , arg.Data()); // the configuration for the dummy component - handler->CreateConfiguration("cp" , "Dummy" , "fp1", "output_percentage 80"); + handler->CreateConfiguration("sample-cp" , "Dummy" , "sample-fp1", "output_percentage 80"); // the writer configuration - arg="-datafile "; arg+=gAliHLTAgentSampleOut; - handler->CreateConfiguration("sink1", "FileWriter" , "cp" , arg.Data()); + arg="-datafile "; arg+=fgkAliHLTAgentSampleOut; + handler->CreateConfiguration("sample-sink1", "FileWriter" , "sample-cp" , arg.Data()); + + // sample offline source + handler->CreateConfiguration("sample-offsrc", "AliLoaderPublisher" , NULL , "-loader TPCLoader -tree digits -verbose"); + + // sample offline sink + handler->CreateConfiguration("sample-offsnk", "SampleOfflineDataSink" , "sample-offsrc" , NULL); } return 0; } -const char* AliHLTAgentSample::GetTopConfigurations(AliRunLoader* runloader) const +const char* AliHLTAgentSample::GetLocalRecConfigurations(AliRunLoader* runloader) const { // see header file for class documentation - return "sink1"; + return "sample-sink1 sample-offsnk"; } const char* AliHLTAgentSample::GetRequiredComponentLibraries() const diff --git a/HLT/SampleLib/AliHLTAgentSample.h b/HLT/SampleLib/AliHLTAgentSample.h index cb5ffabb1f5..6c4879d57c2 100644 --- a/HLT/SampleLib/AliHLTAgentSample.h +++ b/HLT/SampleLib/AliHLTAgentSample.h @@ -15,8 +15,40 @@ /** * @class AliHLTAgentSample - * This is the agent for the AliHLTSample library. + * This is the agent for the AliHLTSample library.
+ * The AliHLTSample library illustrates usage of the HLT framework. The + * agent provides information on the features of the sample components + * and the configuration which should be run during AliRoot reconstruction. * + * The sample agent implements all interface function provided by @ref + * AliHLTModuleAgent : + * - @ref CreateConfigurations
+ * The method gets an instance of the AliHLTConfigurationHanler to add + * configurations, e.g. + *
+ *   handler->CreateConfiguration("my-puplisher"  , "FilePublisher", NULL , "data.bin");
+ *   ...
+ *   handler->CreateConfiguration("my-analysis-chain"  , "FileWriter", "my-processor" , "my arguments");
+ *   
+ * - @ref GetLocalRecConfigurations
+ * returns a string of blank separated configurations to be run during + * local event reconstruction. + *
+ *   return "my-data-sink my-analysis-chain";
+ *   
+ * - @ref GetRequiredComponentLibraries
+ * returns a string of blank separated libraries which have to be loaded + * in addition + *
+ *   return "libAliHLTUtil.so";
+ *   
+ * - not implemented are the in iterface methods + * - @ref AliHLTModuleAgent::GetEventRecConfigurations + * - @ref AliHLTModuleAgent::RegisterComponents + * + * In order to hook the sample library up to the HLT system on global object + * @ref gAliHLTAgentSample of the agent is defined in the source code. + * * @ingroup alihlt_system */ class AliHLTAgentSample : public AliHLTModuleAgent { @@ -30,7 +62,7 @@ class AliHLTAgentSample : public AliHLTModuleAgent { virtual ~AliHLTAgentSample(); /** - * Register all configurations belonging to this module with the + * Register all configurations belonging to the sample library with the * AliHLTConfigurationHandler. The agent can adapt the configurations * to be registered to the current AliRoot setup by checking the * runloader. @@ -42,15 +74,15 @@ class AliHLTAgentSample : public AliHLTModuleAgent { AliRunLoader* runloader=NULL) const; /** - * Get the top configurations belonging to this module. + * Get the top configurations for local event reconstruction. * A top configuration describes a processing chain. It can simply be * described by the last configuration(s) in the chain. * The agent can adapt the configurations to be registered to the current * AliRoot setup by checking the runloader. - * @param runloader AliRoot runloader - * @return number of configurations, neg. error code if failed + * @param runloader [in] AliRoot runloader + * @return string containing the top configurations separated by blanks */ - const char* GetTopConfigurations(AliRunLoader* runloader=NULL) const; + const char* GetLocalRecConfigurations(AliRunLoader* runloader=NULL) const; /** * Component libraries which the configurations of this agent depend on. @@ -61,7 +93,14 @@ class AliHLTAgentSample : public AliHLTModuleAgent { protected: private: - ClassDef(AliHLTAgentSample, 0); + /** file name of the generated test data*/ + static const char* fgkAliHLTAgentSampleData; //!transient + + /** file name of the output file */ + static const char* fgkAliHLTAgentSampleOut; //!transient + + /** ROOT specific member definition */ + ClassDef(AliHLTAgentSample, 1); }; #endif diff --git a/HLT/SampleLib/AliHLTSampleOfflineSinkComponent.cxx b/HLT/SampleLib/AliHLTSampleOfflineSinkComponent.cxx new file mode 100644 index 00000000000..54540e52c32 --- /dev/null +++ b/HLT/SampleLib/AliHLTSampleOfflineSinkComponent.cxx @@ -0,0 +1,88 @@ +// @(#) $Id$ + +/** @file AliHLTSampleOfflineSinkComponent.cxx + @author Matthias Richter + @date + @brief A sample offline sink component. +*/ + +#include "AliHLTSampleOfflineSinkComponent.h" +#include "AliRunLoader.h" +#include "AliLoader.h" +#include "AliLog.h" +#include "TTree.h" + +/** global instance for agent registration */ +AliHLTSampleOfflineSinkComponent gAliHLTSampleOfflineSinkComponent; + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTSampleOfflineSinkComponent) + +AliHLTSampleOfflineSinkComponent::AliHLTSampleOfflineSinkComponent() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTSampleOfflineSinkComponent::~AliHLTSampleOfflineSinkComponent() +{ + // see header file for class documentation +} + +const char* AliHLTSampleOfflineSinkComponent::GetComponentID() +{ + // see header file for class documentation + return "SampleOfflineDataSink"; +} + +void AliHLTSampleOfflineSinkComponent::GetInputDataTypes( vector& list) +{ + // see header file for class documentation + list.clear(); + list.push_back(kAliHLTAnyDataType); +} + +AliHLTComponent* AliHLTSampleOfflineSinkComponent::Spawn() +{ + // see header file for class documentation + return new AliHLTSampleOfflineSinkComponent; +} + +int AliHLTSampleOfflineSinkComponent::DoInit( int argc, const char** argv ) +{ + // see header file for class documentation + int iResult=0; + return iResult; +} + +int AliHLTSampleOfflineSinkComponent::DoDeinit() +{ + // see header file for class documentation + int iResult=0; + return iResult; +} + +int AliHLTSampleOfflineSinkComponent::DumpEvent(const AliHLTComponentEventData& evtData, + AliHLTComponentTriggerData& trigData) +{ + // see header file for class documentation + int iResult=0; + AliInfoStream() << "dump event " << GetEventCount() << endl; + TTree* pTree=(TTree*)GetFirstInputObject(kAliHLTAnyDataType, "TTree"); + while (pTree) { + AliInfoStream() << " got TTree object with " << pTree->GetEntries() << " entries" << endl; + pTree=(TTree*)GetNextInputObject(); + } + return iResult; +} + +int AliHLTSampleOfflineSinkComponent::FillESD(int eventNo, AliRunLoader* runLoader, AliESD* esd) +{ + // see header file for class documentation + int iResult=0; + AliInfoStream() << "event " << eventNo << endl; + return iResult; +} diff --git a/HLT/SampleLib/AliHLTSampleOfflineSinkComponent.h b/HLT/SampleLib/AliHLTSampleOfflineSinkComponent.h new file mode 100644 index 00000000000..459788f4c8a --- /dev/null +++ b/HLT/SampleLib/AliHLTSampleOfflineSinkComponent.h @@ -0,0 +1,94 @@ +//-*- Mode: C++ -*- +// @(#) $Id$ + +#ifndef ALIHLTSAMPLEOFFLINESINKCOMPONENT_H +#define ALIHLTSAMPLEOFFLINESINKCOMPONENT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx sink for full Copyright notice */ + +/** @file AliHLTSampleOfflineSinkComponent.h + @author Matthias Richter + @date + @brief This is a sample offline interface component. +*/ + +#include "AliHLTOfflineDataSink.h" + +class AliLoader; + +/** + * @class AliHLTSampleOfflineSinkComponent + * This is a sample offline interface component. + * + * @ingroup alihlt_system + */ +class AliHLTSampleOfflineSinkComponent : public AliHLTOfflineDataSink { + public: + /** + * standard constructor. The agent is automatically registered in the + * global agent manager + */ + AliHLTSampleOfflineSinkComponent(); + /** destructor */ + virtual ~AliHLTSampleOfflineSinkComponent(); + + /** + * Get the id of the component. + * Each component is identified by a unique id. + * The function is pure virtual and must be implemented by the child class. + * @return component id (string) + */ + const char* GetComponentID(); + + /** + * Get the input data types of the component. + * The function is pure virtual and must be implemented by the child class. + * @return list of data types in the vector reference + */ + virtual void GetInputDataTypes( vector& ); + + /** + * Spawn function. + * Each component must implement a spawn function to create a new instance of + * the class. Basically the function must return new my_class_name. + * @return new class instance + */ + virtual AliHLTComponent* Spawn(); + + /** + * Fill ESD for one event. + * Fill the ESD with the previously reconstructed data. Interface method called by + * the AliHLTOfflineInterface framework. + * @param eventNo event No. \em Note: this is an internal enumeration of the + * processed events. + * @param runLoader the AliRoot runloader + * @param esd an AliESD instance + * @return neg. error code if failed + */ + int FillESD(int eventNo, AliRunLoader* runLoader, AliESD* esd); + + protected: + /** + * Init method. + */ + int DoInit( int argc, const char** argv ); + + /** + * Deinit method. + */ + int DoDeinit(); + + /** + * Data sink method. + * @param evtData event data structure + * @param trigData trigger data structure + * @return + */ + int DumpEvent(const AliHLTComponentEventData& evtData, + AliHLTComponentTriggerData& trigData); + + private: + ClassDef(AliHLTSampleOfflineSinkComponent, 0); +}; + +#endif diff --git a/HLT/SampleLib/Makefile.am b/HLT/SampleLib/Makefile.am index 60ff6cee641..e9c2ca350f7 100644 --- a/HLT/SampleLib/Makefile.am +++ b/HLT/SampleLib/Makefile.am @@ -95,7 +95,7 @@ $(DICTCPP:.cxx=.h): $(DICTCPP) $(DICTCPP): $(DICTHEADERS:%=$(srcdir)/%) $(DICTDEF) if [ -x $(ROOTCINT) ]; then $(ROOTCINT) -f $@ -c $(CPPFLAGS) $(AM_CPPFLAGS) $(DEFS) $(foreach i, $(DICTINCLUDE), $(i)) $^ ; fi -$(DICTDEF): Makefile.am +$(DICTDEF): Makefile.am $(PKGDEF) @echo '//automatically generated ROOT DICT definition' > $@ @echo '//!!! DO NOT EDIT THIS FILE !!!' >> $@ @echo '//add further class definitions to the CLASS_HDRS variable in Makefile.am' >> $@ diff --git a/HLT/SampleLib/tutorial.c b/HLT/SampleLib/tutorial.c index 808465a6e01..76f64f2c926 100644 --- a/HLT/SampleLib/tutorial.c +++ b/HLT/SampleLib/tutorial.c @@ -24,11 +24,181 @@ @date @brief HLT examples and tutorial. */ -/** @defgroup alihlt_tutorial HLT examples and tutorial - @brief HLT examples and tutorial +/** +@defgroup alihlt_tutorial HLT examples and tutorial - A description will follow ... -*/ +-# @ref tut_hltsystem + -# @ref tut_load_libraries + -# @ref tut_dummy_chain + -# @ref tut_tpc_sector +-# @ref tut_reconstruction + -# @ref tut_module_agent + -# @ref tut_reconstruction_sample + +
+
+@section tut_hltsystem Running Components in the HLT System + +@subsection tut_load_libraries Library setup +Component libraries must be loader via the AliHLTComponentHandler +or AliHLTSystem::LoadComponentLibraries. You can run the following +macro from the AliRoot promt. +
+{
+  AliHLTSystem gHLT;
+  gHLT.LoadComponentLibraries("libAliHLTUtil.so");
+}
+
+ +
+@subsection tut_dummy_chain Example: Running a dummy chain +The simplest chain consists of a publisher component, a processor +and a data sink. The AliHLTDummyComponent is a sample component +which just copies a fraction of the input data to the output. +You can run the following macro from the AliRoot promt. +
+{
+  AliHLTSystem gHLT;
+  gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTSample.so");
+  AliHLTConfiguration publisher("fp1", "FilePublisher", NULL, "-datafile some-data.dat");
+  AliHLTConfiguration copy("cp", "Dummy", "fp1", "output_percentage 80");
+  AliHLTConfiguration sink1("sink1", "FileWriter", "cp", NULL);
+  gHLT.BuildTaskList(&sink1);
+  gHLT.Run();
+}
+
+@note You have to specify a real file name instead of \em some-data.dat + +
+@subsection tut_tpc_sector Example: One sector of the TPC +This example builds an analysis chain for TPC sector 0. It works on +simulated data and assumes the ddl files to be present in the current +directory. +
+{
+  AliHLTSystem gHLT;
+  // load the component library
+  gHLT.LoadComponentLibraries("libAliHLTUtil.so libAliHLTTPC.so");
+
+  // data source components
+  AliHLTConfiguration fp0("fp0", "FilePublisher", NULL, "-datafile TPC_768.ddl -datatype DDL_RWPK 'TPC '"
+			                                "-dataspec 0x00000000");
+  AliHLTConfiguration fp1("fp1", "FilePublisher", NULL, "-datafile TPC_769.ddl -datatype DDL_RWPK 'TPC '"
+                                                        "-dataspec 0x00000101");
+  AliHLTConfiguration fp2("fp2", "FilePublisher", NULL, "-datafile TPC_840.ddl -datatype DDL_RWPK 'TPC '"
+                                                        "-dataspec 0x00000202");
+  AliHLTConfiguration fp3("fp3", "FilePublisher", NULL, "-datafile TPC_841.ddl -datatype DDL_RWPK 'TPC '"
+			                                "-dataspec 0x00000303");
+  AliHLTConfiguration fp4("fp4", "FilePublisher", NULL, "-datafile TPC_842.ddl -datatype DDL_RWPK 'TPC '"
+			                                "-dataspec 0x00000404");
+  AliHLTConfiguration fp5("fp5", "FilePublisher", NULL, "-datafile TPC_843.ddl -datatype DDL_RWPK 'TPC '"
+			                                "-dataspec 0x00000505");
+
+  // cluster finders
+  AliHLTConfiguration cf0("cf0", "TPCClusterFinderPacked", "fp0", "pp-run rawreadermode 4 timebins 446");
+  AliHLTConfiguration cf1("cf1", "TPCClusterFinderPacked", "fp1", "pp-run rawreadermode 4 timebins 446");
+  AliHLTConfiguration cf2("cf2", "TPCClusterFinderPacked", "fp2", "pp-run rawreadermode 4 timebins 446");
+  AliHLTConfiguration cf3("cf3", "TPCClusterFinderPacked", "fp3", "pp-run rawreadermode 4 timebins 446");
+  AliHLTConfiguration cf4("cf4", "TPCClusterFinderPacked", "fp4", "pp-run rawreadermode 4 timebins 446");
+  AliHLTConfiguration cf5("cf5", "TPCClusterFinderPacked", "fp5", "pp-run rawreadermode 4 timebins 446");
+
+  // tracker
+  AliHLTConfiguration tracker("tracker", "TPCSliceTracker", "cf0 cf1 cf2 cf3 cf4 cf5", "pp-run bfield 0.5");
+
+  // the data sink component
+  AliHLTConfiguration writer("writer", "TPCEsdWriter", "tracker", "-datafile AliESDs.root");
+
+  gHLT.BuildTaskList(&writer);
+  gHLT.Run();
+}
+
+ +@section tut_reconstruction AliRoot reconstruction +The HLT analysis components can be run either in the AliRoot +reconstruction or the HLT online framework. +The integration into the AliRoot reconstruction works via the +@ref AliHLTReconstructor plugin. The intention is to run HLT analysis +chains in AliRoot in the same way as in the online framework, i.e. +the full components are run also from the offline framework rather +than just the algorithm hooked on by a special interface class. +By this one achieves the highest possible compatibility. + +We think of the HLT as a 'black box' with data input and output. In +addition there is access to calibration data from OCDB (or the local +HLT copy HCDB). All components can only work on the data they get as +input. As the different detector algorithms/components will run in +separated processes and even on different machines, no data exchange +is possible via global data structures and variables possible. + +The AliRoot reconstruction consists mainly of three steps: +-# local event reconstruction: this is usually the place for digit/raw +data conversion to clusters/space points. All the events are processed +at once. If HLT analysis chain are executed in the local event +reconstruction, the chain must contain an output recorder as the ESD +is filled on an event by event basis and the corresponding method called +later. +-# event reconstruction: this is the reconstruction on an event by event +basis. Immediately after the reconstruction, the FillESD method is +called. +-# ESD fill: the reconstructed event is written to the ESD. + +@subsection tut_module_agent The Module Agent +Each component library has to implement a module agent in order to be +hooked up to the AliRoot reconstruction system. The agent defines the +features of the libraries and the configurations to be run during the +different steps of the reconstruction. The agent +- can register all components of the library. This is an + alternative to the component registration via global objects (see + @ref alihltcomponent-handling). +- registers HLT configurations (see @ref AliHLTConfiguration) +- specifies the configurations to be run +- specifies additional component libraries required to run the + configurations. + +Finally, one global object of the module agent has to be specified in +the source code. All registration and integration into the HLT system +is carried out automatically. + +@see + @ref AliHLTModuleAgent for the interface description
+ @ref AliHLTAgentSample for a sample implementation + +@subsection tut_reconstruction_sample The sample library +The libAliHLTSample library provides examples how to implement the +library agent (@ref AliHLTAgentSample), how to add configurations and +define HLT chains for reconstruction. + +The sample library is not part of the default libraries loaded by the +HLT steering during reconstruction. The example can be run by the +following macro in AliRoot (provided you have a simulated event in the +current directory): +
+{
+  AliReconstruction rec;                 // the reconstruction instance
+  rec.SetRunLocalReconstruction("HLT");  // run local rec only for HLT 
+  rec.SetRunTracking("");                // switch off tracking
+  rec.SetOption("HLT", "libAliHLTSample.so");
+  rec.Run();
+}
+
+ +The agent defines the following chains: +-# a simple data copying consisting of a + - @ref AliHLTFilePublisher publishes some data generated before in /tmp + - @ref AliHLTDummyComponent copies a fraction of the incoming data + - @ref AliHLTFileWriter writes the data input to a file +-# digit publishing from the TPCloader
+ This chain illustrates how data can be published from the AliRunLoader + in order to be processed by another component (not in the sample chain). + Finally, the @ref AliHLTSampleOfflineSinkComponent is component which is + the backend and has again the AliRoot structures. + - @ref AliHLTLoaderPublisherComponent + - @ref AliHLTSampleOfflineSinkComponent + +In the same way any other component library can be integrated into the +AliRoot reconstruction. + + */ /* note pad diff --git a/HLT/configure.ac b/HLT/configure.ac index 55479f12e0b..f3f091a42c2 100644 --- a/HLT/configure.ac +++ b/HLT/configure.ac @@ -557,6 +557,13 @@ fi AC_SUBST([HAVE_DOT]) AC_SUBST([DOT_PATH]) +dnl HAVE_SRC_SUBDIR=${abs_top_srcdir}/src +dnl echo $HAVE_SRC_SUBDIR +dnl if ! test -d $HAVE_SRC_SUBDIR; then +dnl HAVE_SRC_SUBDIR= +dnl fi +dnl AC_SUBST([HAVE_SRC_SUBDIR]) + dnl ------------------------------------------------------------------ dnl inatallation directory for libraries dnl diff --git a/HLT/doc/doxygen.conf.in b/HLT/doc/doxygen.conf.in index 47a6a7fe743..06070111636 100644 --- a/HLT/doc/doxygen.conf.in +++ b/HLT/doc/doxygen.conf.in @@ -65,12 +65,32 @@ WARN_LOGFILE = INPUT = @top_srcdir@/doc \ @top_srcdir@/BASE \ @top_srcdir@/TPCLib \ - @top_srcdir@/SampleLib + @top_srcdir@/SampleLib \ + @top_srcdir@/src + FILE_PATTERNS = *.h *.c *.cpp *.hpp *.cxx RECURSIVE = YES EXCLUDE = @top_srcdir@/BASE/HLTbaseLinkDef.h \ @top_srcdir@/TPCLib/AliHLTTPCLinkDef.h \ - @top_srcdir@/TPCLib/AliHLTTPCClustFinderNew.cxx + @top_srcdir@/TPCLib/AliHLTTPCClustFinderNew.cxx \ + @top_srcdir@/src/AliHLTConfMapPoint.cxx \ + @top_srcdir@/src/AliHLTFileHandler.cxx \ + @top_srcdir@/src/AliHLTLogger.cxx \ + @top_srcdir@/src/AliHLTTrackMerger.cxx \ + @top_srcdir@/src/AliHLTTransform.cxx \ + @top_srcdir@/src/AliLevel3.h \ + @top_srcdir@/src/AliLevel3.cxx \ + @top_srcdir@/src/AliHLTLogging.h \ + @top_srcdir@/src/AliHLTDisplay.h \ + @top_srcdir@/src/AliHLTDisplay.cxx \ + @top_srcdir@/src/AliHLTBenchmark.h \ + @top_srcdir@/src/AliHLTBenchmark.cxx \ + @top_srcdir@/src/AliHLTRawDataFileHandler.h \ + @top_srcdir@/src/AliHLTRawDataFileHandler.cxx \ + @top_srcdir@/src/AliHLTClustFinderNew.h \ + @top_srcdir@/src/AliHLTClustFinderNew.cxx \ + @top_srcdir@/src/AliHLTFileHandler.h \ + @top_srcdir@/src/AliHLTFileHandler.cxx EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = @@ -83,7 +103,7 @@ FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- -SOURCE_BROWSER = NO +SOURCE_BROWSER = YES INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES diff --git a/HLT/libAliHLTSample.pkg b/HLT/libAliHLTSample.pkg index fba06100ad0..3f8451bda57 100644 --- a/HLT/libAliHLTSample.pkg +++ b/HLT/libAliHLTSample.pkg @@ -10,6 +10,7 @@ MODULE_SRCS= AliHLTSampleComponent1.cxx \ AliHLTSampleComponent2.cxx \ AliHLTAgentSample.cxx \ + AliHLTSampleOfflineSinkComponent.cxx \ AliHLTDummyComponent.cxx # class header files, the link definition for the root dictionary @@ -17,6 +18,7 @@ MODULE_SRCS= AliHLTSampleComponent1.cxx \ CLASS_HDRS:= AliHLTSampleComponent1.h \ AliHLTSampleComponent2.h \ AliHLTAgentSample.h \ + AliHLTSampleOfflineSinkComponent.h \ AliHLTDummyComponent.h # library headers diff --git a/HLT/libAliHLTUtil.pkg b/HLT/libAliHLTUtil.pkg index ca52e2ee15f..9c60815054e 100644 --- a/HLT/libAliHLTUtil.pkg +++ b/HLT/libAliHLTUtil.pkg @@ -6,11 +6,13 @@ include $(MODDIR)/hlt.conf MODULE_SRCS= AliHLTFilePublisher.cxx \ AliHLTRootFilePublisherComponent.cxx \ AliHLTRootFileWriterComponent.cxx \ + AliHLTLoaderPublisherComponent.cxx \ AliHLTAgentUtil.cxx CLASS_HDRS:= AliHLTFilePublisher.h \ AliHLTRootFilePublisherComponent.h \ AliHLTRootFileWriterComponent.h \ + AliHLTLoaderPublisherComponent.h \ AliHLTAgentUtil.h MODULE_HDRS:= $(CLASS_HDRS) diff --git a/HLT/src/AliHLTReconstructor.cxx b/HLT/src/AliHLTReconstructor.cxx index 194ae0beb3f..649211d8d7f 100644 --- a/HLT/src/AliHLTReconstructor.cxx +++ b/HLT/src/AliHLTReconstructor.cxx @@ -7,9 +7,6 @@ // // /////////////////////////////////////////////////////////////////////////////// -// very ugly but it has to work fast -#ifdef use_reconstruction - #include #include #include @@ -47,6 +44,7 @@ using namespace std; #endif +/** HLT default component libraries */ const char* kHLTDefaultLibs[]= { "libAliHLTUtil.so", "libAliHLTTPC.so", @@ -482,4 +480,3 @@ void AliHLTReconstructor::FillDHLTRecPoint(AliRawReader* rawReader, Int_t nofEve } -#endif diff --git a/HLT/src/AliHLTReconstructor.h b/HLT/src/AliHLTReconstructor.h index ad8e4e012d1..014b2fcb78d 100644 --- a/HLT/src/AliHLTReconstructor.h +++ b/HLT/src/AliHLTReconstructor.h @@ -5,11 +5,39 @@ /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * See cxx source for full Copyright notice */ -#ifdef use_reconstruction #include "AliReconstructor.h" class AliHLTSystem; +/** + * @class AliHLTReconstructor + * AliHLTReconstructor AliRoot event reconstruction plugin for the HLT. + * The AliHLTReconstructor holds an instance of the @ref AliHLTSystem + * steering class. The actual reconstruction depends on the loaded component + * libraries. Each library must implement a module agent (@ref AliHLTModuleAgent) + * in order to provide information on the supported features and the + * configurations to be run. + * + * The default component libraries which are loaded through the initialization + * are determined by the @ref kHLTDefaultLibs array. The library loading can + * be overridden by an option to the AliHLTReconstructor through the + * SetOption method of AliReconstruction, e.g. + *
+ * AliReconstruction rec;
+ * rec.SetOption("HLT", "libAliHLTSample.so");
+ * 
+ * will only load libAliHLTSample.so + * + * Optional arguments:
+ * + * \li loglevel=level
+ * level can be a hex number encoding the @ref AliHLTComponentLogSeverity + * \li alilog=off
+ * disables the logging of HLT log messages through AliLog
+ * + * For further information on the AliRoot reconstruction refer to the AliRoot + * documentation, namely AliReconstruction. + */ class AliHLTReconstructor: public AliReconstructor { public: AliHLTReconstructor(); @@ -74,7 +102,6 @@ private: ClassDef(AliHLTReconstructor, 1) // class for the TPC reconstruction }; -#endif typedef AliHLTReconstructor AliL3Reconstructor; // for backward compatibility