From 242bb79445186571fd170bb8134f46ca80aa7263 Mon Sep 17 00:00:00 2001 From: richterm Date: Wed, 14 Mar 2007 11:38:29 +0000 Subject: [PATCH] aliroot integration - AliHLTSystem interface methods to AliHLTReconstructor implemeted - AliHLTModuleAgent introduced for each HLT module, sample agent added to libAliHLTSample - AliHLTOfflineInterface base classes added - AliHLTFilePublisher, AliHLTRootFileWriter/Publisher moved to libAliHLTUtil (AliHLTFileWriter will follow when dep. to PHOS are cleared) --- HLT/BASE/AliHLTComponentHandler.cxx | 12 +- HLT/BASE/AliHLTFilePublisher.cxx | 292 ------------------ HLT/BASE/AliHLTFilePublisher.h | 137 -------- HLT/BASE/AliHLTModuleAgent.cxx | 160 ++++++++++ HLT/BASE/AliHLTModuleAgent.h | 129 ++++++++ HLT/BASE/AliHLTOfflineDataSink.cxx | 59 ++++ HLT/BASE/AliHLTOfflineDataSink.h | 53 ++++ HLT/BASE/AliHLTOfflineDataSource.cxx | 59 ++++ HLT/BASE/AliHLTOfflineDataSource.h | 63 ++++ HLT/BASE/AliHLTOfflineInterface.cxx | 192 ++++++++++++ HLT/BASE/AliHLTOfflineInterface.h | 158 ++++++++++ HLT/BASE/AliHLTRootFilePublisherComponent.cxx | 138 --------- HLT/BASE/AliHLTRootFilePublisherComponent.h | 96 ------ HLT/BASE/AliHLTRootFileWriterComponent.cxx | 138 --------- HLT/BASE/AliHLTRootFileWriterComponent.h | 108 ------- HLT/BASE/AliHLTSystem.cxx | 202 +++++++++++- HLT/BASE/AliHLTSystem.h | 117 ++++++- HLT/BASE/HLTbaseLinkDef.h | 10 +- HLT/BASE/Makefile.am | 4 +- HLT/BASE/util/AliHLTAgentUtil.cxx | 51 +++ HLT/BASE/util/AliHLTAgentUtil.h | 66 ++++ HLT/BASE/util/Makefile.am | 56 ++++ HLT/ChangeLog | 8 + HLT/Makefile.am | 2 + HLT/SampleLib/AliHLTAgentSample.cxx | 82 +++++ HLT/SampleLib/AliHLTAgentSample.h | 66 ++++ HLT/SampleLib/Makefile.am | 2 + HLT/TPCLib/Makefile.am | 4 +- HLT/configure.ac | 1 + HLT/libAliHLTSample.pkg | 6 +- HLT/libAliHLTTPC.pkg | 2 +- HLT/libAliHLTUtil.pkg | 30 ++ HLT/libHLTbase.pkg | 14 +- 33 files changed, 1584 insertions(+), 933 deletions(-) delete mode 100644 HLT/BASE/AliHLTFilePublisher.cxx delete mode 100644 HLT/BASE/AliHLTFilePublisher.h create mode 100644 HLT/BASE/AliHLTModuleAgent.cxx create mode 100644 HLT/BASE/AliHLTModuleAgent.h create mode 100644 HLT/BASE/AliHLTOfflineDataSink.cxx create mode 100644 HLT/BASE/AliHLTOfflineDataSink.h create mode 100644 HLT/BASE/AliHLTOfflineDataSource.cxx create mode 100644 HLT/BASE/AliHLTOfflineDataSource.h create mode 100644 HLT/BASE/AliHLTOfflineInterface.cxx create mode 100644 HLT/BASE/AliHLTOfflineInterface.h delete mode 100644 HLT/BASE/AliHLTRootFilePublisherComponent.cxx delete mode 100644 HLT/BASE/AliHLTRootFilePublisherComponent.h delete mode 100644 HLT/BASE/AliHLTRootFileWriterComponent.cxx delete mode 100644 HLT/BASE/AliHLTRootFileWriterComponent.h create mode 100644 HLT/BASE/util/AliHLTAgentUtil.cxx create mode 100644 HLT/BASE/util/AliHLTAgentUtil.h create mode 100644 HLT/BASE/util/Makefile.am create mode 100644 HLT/SampleLib/AliHLTAgentSample.cxx create mode 100644 HLT/SampleLib/AliHLTAgentSample.h create mode 100644 HLT/libAliHLTUtil.pkg diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx index 45b26b2628f..26f42f4a8ab 100644 --- a/HLT/BASE/AliHLTComponentHandler.cxx +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -38,10 +38,10 @@ using namespace std; #include "AliHLTSystem.h" // the standard components -#include "AliHLTFilePublisher.h" +// #include "AliHLTFilePublisher.h" #include "AliHLTFileWriter.h" -#include "AliHLTRootFilePublisherComponent.h" -#include "AliHLTRootFileWriterComponent.h" +// #include "AliHLTRootFilePublisherComponent.h" +// #include "AliHLTRootFileWriterComponent.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTComponentHandler) @@ -325,10 +325,10 @@ int AliHLTComponentHandler::AddStandardComponents() // see header file for class documentation int iResult=0; AliHLTComponent::SetGlobalComponentHandler(this); - fStandardList.push_back(new AliHLTFilePublisher); +// fStandardList.push_back(new AliHLTFilePublisher); fStandardList.push_back(new AliHLTFileWriter); - fStandardList.push_back(new AliHLTRootFilePublisherComponent); - fStandardList.push_back(new AliHLTRootFileWriterComponent); +// fStandardList.push_back(new AliHLTRootFilePublisherComponent); +// fStandardList.push_back(new AliHLTRootFileWriterComponent); AliHLTComponent::UnsetGlobalComponentHandler(); iResult=RegisterScheduledComponents(); return iResult; diff --git a/HLT/BASE/AliHLTFilePublisher.cxx b/HLT/BASE/AliHLTFilePublisher.cxx deleted file mode 100644 index bd81e574419..00000000000 --- a/HLT/BASE/AliHLTFilePublisher.cxx +++ /dev/null @@ -1,292 +0,0 @@ -// $Id$ - -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Authors: Matthias Richter * - * for The ALICE Off-line Project. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/** @file AliHLTFilePublisher.cxx - @author Matthias Richter - @date - @brief HLT file publisher component implementation. */ - -#if __GNUC__>= 3 -using namespace std; -#endif - -#include "AliHLTFilePublisher.h" -#include -#include -#include - -/** the global object for component registration */ -AliHLTFilePublisher gAliHLTFilePublisher; - -/** ROOT macro for the implementation of ROOT specific class methods */ -ClassImp(AliHLTFilePublisher) - -AliHLTFilePublisher::AliHLTFilePublisher() - : - AliHLTDataSource(), - fFileNames(), - fFiles(), - fpCurrent(NULL), - fDataType(kAliHLTVoidDataType), - fSpecification(~(AliHLTUInt32_t)0), - fMaxSize(0) -{ - // see header file for class documentation - // or - // refer to README to build package - // or - // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt - - // make the lists owners of their objects in order to automatically - // de-allocate the objects - fFileNames.SetOwner(); - fFiles.SetOwner(); -} - -AliHLTFilePublisher::AliHLTFilePublisher(const AliHLTFilePublisher&) - : - AliHLTDataSource(), - fFileNames(), - fFiles(), - fpCurrent(NULL), - fDataType(kAliHLTVoidDataType), - fSpecification(0), - fMaxSize(0) -{ - // see header file for class documentation - HLTFatal("copy constructor untested"); -} - -AliHLTFilePublisher& AliHLTFilePublisher::operator=(const AliHLTFilePublisher&) -{ - // see header file for class documentation - HLTFatal("assignment operator untested"); - return *this; -} - -AliHLTFilePublisher::~AliHLTFilePublisher() -{ - // see header file for class documentation - - // file list and file name list are owner of their objects and - // delete all the objects -} - -const char* AliHLTFilePublisher::GetComponentID() -{ - // see header file for class documentation - return "FilePublisher"; -} - -AliHLTComponentDataType AliHLTFilePublisher::GetOutputDataType() -{ - // see header file for class documentation - return fDataType; -} - -void AliHLTFilePublisher::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) -{ - // see header file for class documentation - constBase=fMaxSize; - inputMultiplier=1.0; -} - -AliHLTComponent* AliHLTFilePublisher::Spawn() -{ - // see header file for class documentation - return new AliHLTFilePublisher; -} - -int AliHLTFilePublisher::DoInit( int argc, const char** argv ) -{ - // see header file for class documentation - - //HLTDebug("%d %s", argc, argv[0]); - int iResult=0; - TString argument=""; - int bMissingParam=0; - for (int i=0; i=0; i++) { - argument=argv[i]; - if (argument.IsNull()) continue; - - // -datafile - if (argument.CompareTo("-datafile")==0) { - if ((bMissingParam=(++i>=argc))) break; - TObjString* parameter=new TObjString(argv[i]); - if (parameter) { - fFileNames.Add(parameter); - } else { - iResult=-ENOMEM; - } - - // -datafilelist - } else if (argument.CompareTo("-datafilelist")==0) { - if ((bMissingParam=(++i>=argc))) break; - HLTWarning("-datafilelist option not yet implemented"); - - // -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 { - if ((iResult=ScanArgument(argc-i, &argv[i]))==-EINVAL) { - HLTError("unknown argument %s", argument.Data()); - break; - } else if (iResult==-EPROTO) { - bMissingParam=1; - break; - } else if (iResult>=0) { - i+=iResult; - iResult=0; - } - } - } - if (bMissingParam) { - HLTError("missing parameter for argument %s", argument.Data()); - iResult=-EINVAL; - } - if (fFileNames.GetSize()==0) { - HLTError("the publisher needs at least one file argument"); - iResult=-EINVAL; - } - if (iResult>=0) iResult=OpenFiles(); - if (iResult<0) { - fFileNames.Clear(); - } - return iResult; -} - -int AliHLTFilePublisher::ScanArgument(int argc, const char** argv) -{ - // see header file for class documentation - - // there are no other arguments than the standard ones - if (argc==0 && argv==NULL) { - // this is just to get rid of the warning "unused parameter" - } - return -EPROTO; -} - -int AliHLTFilePublisher::OpenFiles() -{ - // see header file for class documentation - int iResult=0; - TObjLink *lnk=fFileNames.FirstLink(); - while (lnk && iResult>=0) { - TObjString* pFileName=(TObjString*)lnk->GetObject(); - if (pFileName) { - TString fullFN= pFileName->GetString() + "?filetype=raw"; - TFile* pFile = new TFile(fullFN); - if (pFile) { - if (pFile->IsZombie()==0) { - fFiles.Add(pFile); - if (pFile->GetSize()>fMaxSize) fMaxSize=pFile->GetSize(); - } else { - HLTError("can not open file %s", (pFileName->GetString()).Data()); - fFiles.Clear(); - iResult=-ENOENT; - } - } - } - lnk = lnk->Next(); - } - - return iResult; -} - -int AliHLTFilePublisher::DoDeinit() -{ - // see header file for class documentation - int iResult=0; - fFileNames.Clear(); - fFiles.Clear(); - return iResult; -} - -int AliHLTFilePublisher::GetEvent( const AliHLTComponentEventData& evtData, - AliHLTComponentTriggerData& trigData, - AliHLTUInt8_t* outputPtr, - AliHLTUInt32_t& size, - vector& outputBlocks ) -{ - int iResult=0; - TObjLink *lnk=NULL; - if (fpCurrent) lnk=fpCurrent->Next(); - if (lnk==NULL) lnk=fFiles.FirstLink(); - fpCurrent=lnk; - if (lnk) { - TFile* pFile=(TFile*)lnk->GetObject(); - if (pFile) { - int iCopy=pFile->GetSize(); - pFile->Seek(0); - if (iCopy>(int)size) { - iCopy=size; - HLTWarning("buffer to small, data of file %s truncated", pFile->GetName()); - } - if (pFile->ReadBuffer((char*)outputPtr, iCopy)!=0) { - // ReadBuffer returns 1 in case of failure and 0 in case of success - iResult=-EIO; - } else { - AliHLTComponentBlockData bd; - FillBlockData(bd); - bd.fPtr=outputPtr; - bd.fOffset=0; - bd.fSize=iCopy; - bd.fDataType=fDataType; - bd.fSpecification=fSpecification; - outputBlocks.push_back(bd); - size=iCopy; - } - } else { - HLTError("no file available"); - iResult=-EFAULT; - } - } else { - iResult=-ENOENT; - } - if (evtData.fStructSize==0 && trigData.fStructSize==0) { - // this is just to get rid of the warning "unused parameter" - } - return iResult; -} - -AliHLTComponentDataType AliHLTFilePublisher::GetCurrentDataType() const -{ - return fDataType; -} - -AliHLTUInt32_t AliHLTFilePublisher::GetCurrentSpecification() const -{ - return fSpecification; -} diff --git a/HLT/BASE/AliHLTFilePublisher.h b/HLT/BASE/AliHLTFilePublisher.h deleted file mode 100644 index ee2a4b28518..00000000000 --- a/HLT/BASE/AliHLTFilePublisher.h +++ /dev/null @@ -1,137 +0,0 @@ -// @(#) $Id$ - -#ifndef ALIHLTFILEPUBLISHER_H -#define ALIHLTFILEPUBLISHER_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/** @file AliHLTFilePublisher.h - @author Matthias Richter - @date - @brief An HLT file publishing (data source) component. - @note The class is used in Offline (AliRoot) context -*/ - -#include "AliHLTDataSource.h" -#include - -/** - * @class AliHLTFilePublisher - * An HLT data source component which publishes data from one or a sequence - * 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). - * - * Mandatory arguments:
- * - * \li -datafile filename - * \li -datafilelist file pattern
- * not yet implemented - * \li -datatype datatype dataorigin
- * data type ID and origin, e.g. -datatype CLUSTERS TPC - * \li -dataspec specification
- * data specification treated as decimal number or hex number if - * prepended by '0x' - * - * Optional arguments:
- * - * The component needs at least one argument \em -datafile or \em -datafilelist. - * Both can occur multiple times. The \em -datatype and \em -dataspec - * parameters are valid for all files until the next occurrence of - * \em -datatype/spec - * @ingroup alihlt_component - */ -class AliHLTFilePublisher : public AliHLTDataSource { - public: - /** standard constructor */ - AliHLTFilePublisher(); - /** not a valid copy constructor, defined according to effective C++ style */ - AliHLTFilePublisher(const AliHLTFilePublisher&); - /** not a valid assignment op, but defined according to effective C++ style */ - AliHLTFilePublisher& operator=(const AliHLTFilePublisher&); - /** destructor */ - virtual ~AliHLTFilePublisher(); - - const char* GetComponentID(); - AliHLTComponentDataType GetOutputDataType(); - void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ); - AliHLTComponent* Spawn(); - - /** - * Open all files. - * Opens all files from the file name list @ref fFileNames and adds TFile - * opjects to the TFiles list. - */ - int OpenFiles(); - - protected: - /** - * Init method. - */ - int DoInit( int argc, const char** argv ); - - /** - * Deinit method. - */ - int DoDeinit(); - - /** - * Data processing method for the component. - * @param evtData event data structure - * @param trigData trigger data structure - * @param outputPtr pointer to target buffer - * @param size input: size of target buffer - * output:size of produced data - * @param outputBlocks list to receive output block descriptors - * @return - */ - int GetEvent( const AliHLTComponentEventData& evtData, - AliHLTComponentTriggerData& trigData, - AliHLTUInt8_t* outputPtr, - AliHLTUInt32_t& size, - vector& outputBlocks ); - - /** - * Scan one argument and adjacent parameters. - * Can be overloaded by child classes in order to add additional arguments - * beyond the standard arguments of the file publisher. The method is called - * whenever a non-standard argument is recognized. - * @param argc size of the argument array - * @param argv agument array for component initialization - * @return number of processed members of the argv
- * -EINVAL unknown argument
- * -EPROTO parameter for argument missing
- */ - virtual int ScanArgument(int argc, const char** argv); - - protected: - /** - * Get the data type which is set for the current file - */ - AliHLTComponentDataType GetCurrentDataType() const; - - /** - * Get the data specification which is set for the current file - */ - AliHLTUInt32_t GetCurrentSpecification() const; - - private: - /** list of file names */ - TList fFileNames; // see above - /** list of opened files */ - TList fFiles; // see above - /** current positions in the file list */ - TObjLink* fpCurrent; //! transient - /** data type */ - AliHLTComponentDataType fDataType; // see above - /** data specification */ - AliHLTUInt32_t fSpecification; // see above - /** the maximum buffer size i.e. size of the biggest file */ - Int_t fMaxSize; // see above - - ClassDef(AliHLTFilePublisher, 0) -}; -#endif diff --git a/HLT/BASE/AliHLTModuleAgent.cxx b/HLT/BASE/AliHLTModuleAgent.cxx new file mode 100644 index 00000000000..c881cdae649 --- /dev/null +++ b/HLT/BASE/AliHLTModuleAgent.cxx @@ -0,0 +1,160 @@ +// @(#) $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * for The ALICE Off-line Project. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/** @file AliHLTModuleAgent.cxx + @author Matthias Richter + @date + @brief Agent helper class for component libraries. + @note The class is used in Offline (AliRoot) context +*/ + +#include "AliHLTModuleAgent.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTModuleAgent) + +AliHLTModuleAgent::AliHLTModuleAgent() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + Register(this); +} + +AliHLTModuleAgent::AliHLTModuleAgent(const AliHLTModuleAgent&) + : + TObject(), + AliHLTLogging() +{ + // see header file for function documentation +} + +AliHLTModuleAgent& AliHLTModuleAgent::operator=(const AliHLTModuleAgent&) +{ + // see header file for function documentation + return *this; +} + +TList AliHLTModuleAgent::fgAgentList; +TObjLink* AliHLTModuleAgent::fgCurrentLnk=NULL; + +AliHLTModuleAgent::~AliHLTModuleAgent() +{ + // see header file for function documentation + Unregister(this); +} + +void AliHLTModuleAgent::PrintStatus(const char* agent) +{ + // see header file for function documentation + AliHLTLogging log; + if (agent) { + TObject* pAgent=fgAgentList.FindObject(agent); + if (pAgent) { + log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", + "agent %s available", pAgent->GetName()); + } else { + log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", + "agent %s not found", agent); + } + } else { + TObjLink* lnk=fgAgentList.FirstLink(); + while (lnk) { + log.Logging(kHLTLogInfo, "AliHLTModuleAgent::PrintStatus", "module agents", + ((AliHLTModuleAgent*)lnk->GetObject())->GetName()); + lnk=lnk->Next(); + } + } +} + +int AliHLTModuleAgent::CreateConfigurations(AliHLTConfigurationHandler* handler, + AliRunLoader* runloader) const +{ + // default method, nothing to be done, child classes can overload + if (handler==NULL && runloader==NULL) { + // get rid of 'unused parameter' warning + } + return 0; +} + +const char* AliHLTModuleAgent::GetTopConfigurations(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::GetRequiredComponentLibraries() const +{ + // default method, nothing to be done, child classes can overload + return NULL; +} + +int AliHLTModuleAgent::RegisterComponents(AliRunLoader* runloader) const +{ + if (runloader==NULL) { + // get rid of 'unused parameter' warning + } + // default method, nothing to be done, child classes can overload + return 0; +} + +AliHLTModuleAgent* AliHLTModuleAgent::GetFirstAgent() +{ + // see header file for function documentation + fgCurrentLnk=fgAgentList.FirstLink(); + if (fgCurrentLnk==NULL) return NULL; + return (AliHLTModuleAgent*)fgCurrentLnk->GetObject(); +} + +AliHLTModuleAgent* AliHLTModuleAgent::GetNextAgent() +{ + // see header file for function documentation + if (fgCurrentLnk==NULL) return NULL; + fgCurrentLnk=fgCurrentLnk->Next(); + if (fgCurrentLnk==NULL) return NULL; + return (AliHLTModuleAgent*)fgCurrentLnk->GetObject(); +} + +int AliHLTModuleAgent::Register(AliHLTModuleAgent* pAgent) +{ + // see header file for function documentation + AliHLTLogging log; + if (!pAgent) return -EINVAL; + if (fgAgentList.FindObject(pAgent)==NULL) { + log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Register", "", "module agent %p registered", pAgent); + fgAgentList.Add(pAgent); + } + return 0; +} + +int AliHLTModuleAgent::Unregister(AliHLTModuleAgent* pAgent) +{ + // see header file for function documentation + AliHLTLogging log; + if (!pAgent) return -EINVAL; + if (fgAgentList.FindObject(pAgent)!=NULL) { + log.Logging(kHLTLogDebug, "AliHLTModuleAgent::Unregister", "", "module agent %s (%p) unregistered", pAgent->GetName(), pAgent); + fgAgentList.Remove(pAgent); + } else { + } + return 0; +} diff --git a/HLT/BASE/AliHLTModuleAgent.h b/HLT/BASE/AliHLTModuleAgent.h new file mode 100644 index 00000000000..4e08e5f5660 --- /dev/null +++ b/HLT/BASE/AliHLTModuleAgent.h @@ -0,0 +1,129 @@ +// @(#) $Id$ + +#ifndef ALIHLTMODULEAGENT_H +#define ALIHLTMODULEAGENT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTModuleAgent.h + @author Matthias Richter + @date + @brief Agent helper class for component libraries. + @note The class is used in Offline (AliRoot) context +*/ + +#include +#include +#include "AliHLTLogging.h" +#include "AliHLTConfiguration.h" +#include "AliHLTConfigurationHandler.h" + +class AliRunLoader; + +/** + * @class AliHLTModuleAgent + * @brief Agent helper class for HLT sub modules, e.g. PHOS, TPC, Trigger + * + * This class describes + * + * There must be only one agent per module/library. + * + * @ingroup alihlt_system + */ +class AliHLTModuleAgent : public TObject, public AliHLTLogging { + public: + /** + * standard constructor. The agent is automatically registered in the + * global agent manager + */ + AliHLTModuleAgent(); + /** not a valid copy constructor, defined according to effective C++ style */ + AliHLTModuleAgent(const AliHLTModuleAgent&); + /** not a valid assignment op, but defined according to effective C++ style */ + AliHLTModuleAgent& operator=(const AliHLTModuleAgent&); + /** destructor */ + virtual ~AliHLTModuleAgent(); + + /** + * Print status info. + * 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); + + /** + * Get the first agent in the list + * @return pointer to first agent in the list, NULL if empty + */ + static AliHLTModuleAgent* GetFirstAgent(); + + /** + * Get the next agent in the list + * @return pointer to next agent in the list, NULL if end of list + */ + static AliHLTModuleAgent* GetNextAgent(); + + /** + * Register all configurations belonging to this module with the + * AliHLTConfigurationHandler. The agent can adapt the configurations + * to be registered to the current AliRoot setup by checking the + * runloader. + * @param handler[in] the configuration handler + * @param runloader[in] AliRoot runloader + * @return neg. error code if failed + */ + virtual int CreateConfigurations(AliHLTConfigurationHandler* handler, + AliRunLoader* runloader=NULL) const; + + /** + * Get the top configurations belonging to this module. + * 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[in] AliRoot runloader + * @return string containing the top configurations separated by blanks + */ + virtual const char* GetTopConfigurations(AliRunLoader* runloader=NULL) const; + + /** + * Component libraries which the configurations of this agent depend on. + * @return list of component libraries as a blank-separated string. + */ + virtual const char* GetRequiredComponentLibraries() const; + + /** + * Register componets. + * This method can be used to register components for the module instead + * of the 'static object approach'. Registration is don by passing a + * sample object to @ref AliHLTComponentHandler::RegisterComponent
+ * \em Note: The sample object is owned by the agent, make sure to delete + * it. + */ + virtual int RegisterComponents(AliRunLoader* runloader=NULL) const; + + protected: + + private: + /** + * Register agent in the global list. + * @return neg. error code if failed + */ + static int Register(AliHLTModuleAgent* pAgent); + + /** + * Unregister agent in the global list. + * @return neg. error code if failed + */ + static int Unregister(AliHLTModuleAgent* pAgent); + + /** the list of active agents */ + static TList fgAgentList; + + /** the current object link (list position) */ + static TObjLink* fgCurrentLnk; + + ClassDef(AliHLTModuleAgent, 0); +}; + +#endif diff --git a/HLT/BASE/AliHLTOfflineDataSink.cxx b/HLT/BASE/AliHLTOfflineDataSink.cxx new file mode 100644 index 00000000000..950dddf80d7 --- /dev/null +++ b/HLT/BASE/AliHLTOfflineDataSink.cxx @@ -0,0 +1,59 @@ +// $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * for The ALICE Off-line Project. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/** @file AliHLTOfflineDataSink.cxx + @author Matthias Richter + @date + @brief AliRoot data sink component base class. +*/ + +#include "AliHLTOfflineDataSink.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTOfflineDataSink) + +AliHLTOfflineDataSink::AliHLTOfflineDataSink() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTOfflineDataSink::AliHLTOfflineDataSink(const AliHLTOfflineDataSink&) + : + AliHLTDataSink(), + AliHLTOfflineInterface() +{ + // see header file for class documentation + HLTFatal("copy constructor untested"); + Register(this); +} + +AliHLTOfflineDataSink& AliHLTOfflineDataSink::operator=(const AliHLTOfflineDataSink&) +{ + // see header file for class documentation + HLTFatal("assignment operator untested"); + return *this; +} + +AliHLTOfflineDataSink::~AliHLTOfflineDataSink() +{ + // see header file for class documentation + Unregister(this); +} diff --git a/HLT/BASE/AliHLTOfflineDataSink.h b/HLT/BASE/AliHLTOfflineDataSink.h new file mode 100644 index 00000000000..b70d058293f --- /dev/null +++ b/HLT/BASE/AliHLTOfflineDataSink.h @@ -0,0 +1,53 @@ +// -*- Mode: C++ -*- +// $Id$ + +#ifndef ALIHLTOFFLINEDATASINK_H +#define ALIHLTOFFLINEDATASINK_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx sink for full Copyright notice */ + +/** @file AliHLTOfflineDataSink.h + @author Matthias Richter + @date + @brief AliRoot data sink component base class. +*/ + +#include "AliHLTDataSink.h" +#include "AliHLTOfflineInterface.h" + +/******************************************************************************/ + +/** + * @class AliHLTOfflineDataSink + * The class implements a AliRoot data sink component base class. + * The child class must implement the functions: + * - @ref DoInit (optional) + * - @ref DoDeinit (optional) + * - @ref DumpEvent + * - @ref GetComponentID + * - @ref GetInputDataTypes + * - @ref Spawn + * - @ref FillESD + * + * @note This class is only used for the @ref alihlt_system. + * + * @ingroup alihlt_system + */ +class AliHLTOfflineDataSink +: public AliHLTDataSink, public AliHLTOfflineInterface +{ + public: + /** standard constructor */ + AliHLTOfflineDataSink(); + /** not a valid copy constructor, defined according to effective C++ style */ + AliHLTOfflineDataSink(const AliHLTOfflineDataSink&); + /** not a valid assignment op, but defined according to effective C++ style */ + AliHLTOfflineDataSink& operator=(const AliHLTOfflineDataSink&); + /** destructor */ + virtual ~AliHLTOfflineDataSink(); + + private: + ClassDef(AliHLTOfflineDataSink, 1); +}; + +#endif diff --git a/HLT/BASE/AliHLTOfflineDataSource.cxx b/HLT/BASE/AliHLTOfflineDataSource.cxx new file mode 100644 index 00000000000..5b1fdcdf674 --- /dev/null +++ b/HLT/BASE/AliHLTOfflineDataSource.cxx @@ -0,0 +1,59 @@ +// $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * for The ALICE Off-line Project. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/** @file AliHLTOfflineDataSource.cxx + @author Matthias Richter + @date + @brief AliRoot data source component base class. +*/ + +#include "AliHLTOfflineDataSource.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTOfflineDataSource) + +AliHLTOfflineDataSource::AliHLTOfflineDataSource() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + Register(this); +} + +AliHLTOfflineDataSource::AliHLTOfflineDataSource(const AliHLTOfflineDataSource&) + : + AliHLTDataSource(), + AliHLTOfflineInterface() +{ + // see header file for class documentation + HLTFatal("copy constructor untested"); +} + +AliHLTOfflineDataSource& AliHLTOfflineDataSource::operator=(const AliHLTOfflineDataSource&) +{ + // see header file for class documentation + HLTFatal("assignment operator untested"); + return *this; +} + +AliHLTOfflineDataSource::~AliHLTOfflineDataSource() +{ + // see header file for class documentation + Unregister(this); +} diff --git a/HLT/BASE/AliHLTOfflineDataSource.h b/HLT/BASE/AliHLTOfflineDataSource.h new file mode 100644 index 00000000000..42b4ce04a53 --- /dev/null +++ b/HLT/BASE/AliHLTOfflineDataSource.h @@ -0,0 +1,63 @@ +// -*- Mode: C++ -*- +// $Id$ + +#ifndef ALIHLTOFFLINEDATASOURCE_H +#define ALIHLTOFFLINEDATASOURCE_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTOfflineDataSource.h + @author Matthias Richter + @date + @brief AliRoot data sink component base class. +*/ + +#include "AliHLTDataSource.h" +#include "AliHLTOfflineInterface.h" + +/******************************************************************************/ + +/** + * @class AliHLTOfflineDataSource + * The class implements a AliRoot data source component base class. + * The child class must implement the functions: + * - @ref DoInit (optional) + * - @ref DoDeinit (optional) + * - @ref GetEvent + * - @ref GetComponentID + * - @ref GetOutputDataType + * - @ref GetOutputDataSize + * - @ref Spawn + * + * @note This class is only used for the @ref alihlt_system. + * + * @ingroup alihlt_system + */ +class AliHLTOfflineDataSource +: public AliHLTDataSource, public AliHLTOfflineInterface { + public: + /** standard constructor */ + AliHLTOfflineDataSource(); + /** not a valid copy constructor, defined according to effective C++ style */ + AliHLTOfflineDataSource(const AliHLTOfflineDataSource&); + /** not a valid assignment op, but defined according to effective C++ style */ + AliHLTOfflineDataSource& operator=(const AliHLTOfflineDataSource&); + /** destructor */ + virtual ~AliHLTOfflineDataSource(); + + /** + * Default implementation as sources do not have a real FillESD method. + */ + int FillESD(AliRunLoader* runLoader, AliESD* esd) { + if (esd==NULL && runLoader==NULL) { + // get rid of 'unused parameter' warning + } + return 0; + } + + private: + + ClassDef(AliHLTOfflineDataSource, 1); +}; + +#endif diff --git a/HLT/BASE/AliHLTOfflineInterface.cxx b/HLT/BASE/AliHLTOfflineInterface.cxx new file mode 100644 index 00000000000..f16196fefa7 --- /dev/null +++ b/HLT/BASE/AliHLTOfflineInterface.cxx @@ -0,0 +1,192 @@ +// $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * for The ALICE Off-line Project. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/** @file AliHLTOfflineInterface.cxx + @author Matthias Richter + @date + @brief the HLT interface to AliRoot +*/ + +#include "AliHLTOfflineInterface.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTOfflineInterface) + +AliHLTOfflineInterface::AliHLTOfflineInterface() + : + fpRunLoader(NULL), + fpRawReader(NULL), + fpESD(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 +} + +TList AliHLTOfflineInterface::fgList; +TObjLink* AliHLTOfflineInterface::fgCurrentLnk=NULL; + +AliHLTOfflineInterface::AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader) + : + fpRunLoader(pRunLoader), + fpRawReader(pRawReader), + fpESD(NULL) +{ +} + +AliHLTOfflineInterface::AliHLTOfflineInterface(const AliHLTOfflineInterface&) + : + TObject(), + fpRunLoader(NULL), + fpRawReader(NULL), + fpESD(NULL) +{ + // see header file for class documentation + //HLTFatal("copy constructor untested"); +} + +AliHLTOfflineInterface& AliHLTOfflineInterface::operator=(const AliHLTOfflineInterface&) +{ + // see header file for class documentation + //HLTFatal("assignment operator untested"); + return *this; +} + +AliHLTOfflineInterface::~AliHLTOfflineInterface() +{ +} + +const AliRunLoader* AliHLTOfflineInterface::GetRunLoader() const +{ + return fpRunLoader; +} + +const AliRawReader* AliHLTOfflineInterface::GetRawReader() const +{ + return fpRawReader; +} + +int AliHLTOfflineInterface::SetESD(Int_t eventNo, AliESD* pESD) +{ + fpESD=pESD; + return 0; +} + +AliESD* AliHLTOfflineInterface::GetESD() const +{ + return fpESD; +} + +int AliHLTOfflineInterface::SetParams(AliRunLoader* runLoader, AliRawReader* rawReader) +{ + // see header file for class documentation + int iResult=0; + if (fpRunLoader!=NULL && fpRunLoader!=runLoader) { + //HLTWarning("overriding previous instance of Run Loader %p with %p", fpRunLoader, runLoader); + } + fpRunLoader=runLoader; + if (fpRawReader!=NULL && fpRawReader!=rawReader) { + //HLTWarning("overriding previous instance of RawReader %p with %p", fpRawReader, rawReader); + } + fpRawReader=rawReader; + return iResult; +} + +int AliHLTOfflineInterface::Reset() +{ + // see header file for class documentation + int iResult=0; + fpRunLoader=NULL; + fpRawReader=NULL; + fpESD=NULL; + return iResult; +} + +int AliHLTOfflineInterface::SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader) +{ + // see header file for class documentation + int iResult=0; + fgCurrentLnk=fgList.FirstLink(); + while (fgCurrentLnk!=NULL) { + AliHLTOfflineInterface* pComponent=reinterpret_cast(fgCurrentLnk->GetObject()); + int iLocal=0; + if (pComponent) iLocal=pComponent->SetParams(runLoader, rawReader); + if (iLocal<0) { + if (iResult>=0) iResult=iLocal; + } + fgCurrentLnk=fgCurrentLnk->Next(); + } + return iResult; +} + +int AliHLTOfflineInterface::ResetComponents() +{ + // see header file for class documentation + int iResult=0; + fgCurrentLnk=fgList.FirstLink(); + while (fgCurrentLnk!=NULL) { + AliHLTOfflineInterface* pComponent=reinterpret_cast(fgCurrentLnk->GetObject()); + int iLocal=0; + if (pComponent) iLocal=pComponent->Reset(); + if (iLocal<0) { + if (iResult>=0) iResult=iLocal; + } + fgCurrentLnk=fgCurrentLnk->Next(); + } + return iResult; +} + +int AliHLTOfflineInterface::FillComponentESDs(AliRunLoader* runLoader, AliESD* esd) +{ + // see header file for class documentation + int iResult=0; + fgCurrentLnk=fgList.FirstLink(); + while (fgCurrentLnk!=NULL) { + AliHLTOfflineInterface* pComponent=reinterpret_cast(fgCurrentLnk->GetObject()); + int iLocal=0; + if (pComponent) iLocal=pComponent->FillESD(runLoader, esd); + if (iLocal<0) { + if (iResult>=0) iResult=iLocal; + } + fgCurrentLnk=fgCurrentLnk->Next(); + } + return iResult; +} + +int AliHLTOfflineInterface::Register(AliHLTOfflineInterface* me) +{ + // see header file for function documentation + int iResult=0; + if (fgList.FindObject(me->GetName())==NULL) { + fgList.Add(me); + } else { + } + return iResult; +} + +int AliHLTOfflineInterface::Unregister(AliHLTOfflineInterface* me) +{ + // see header file for function documentation + int iResult=0; + if (fgList.FindObject(me)!=NULL) { + fgList.Remove(me); + } else { + } + return iResult; +} diff --git a/HLT/BASE/AliHLTOfflineInterface.h b/HLT/BASE/AliHLTOfflineInterface.h new file mode 100644 index 00000000000..cac9ba89ff0 --- /dev/null +++ b/HLT/BASE/AliHLTOfflineInterface.h @@ -0,0 +1,158 @@ +// -*- Mode: C++ -*- +// $Id$ + +#ifndef ALIHLTOFFLINEINTERFACE_H +#define ALIHLTOFFLINEINTERFACE_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTOfflineInterface.h + @author Matthias Richter + @date + @brief the HLT interface to AliRoot +*/ + +#include +#include + +class AliRunLoader; +class AliRawReader; +class AliESD; +class TTree; + +/******************************************************************************/ + +/** + * @class AliHLTOfflineInterface + * The class implements the basic interface to the AliRoot objects during + * reconstructions. + * It serves as a base class for offline source and sink interface components + * and provides access methods for the AliRunLoader, AliRawReader and AliESD + * objects. The AliRunLoader and the AliRawReader are fixed during one run, + * while the AliESD object will be changed from event to event.
+ * \em Note: The digits and clusters trees are not available through this + * interface class as they are completetly detector (AliLoader) dependend. + * + * @note This class is only used for the @ref alihlt_system. + * + * @ingroup alihlt_system + */ +class AliHLTOfflineInterface : public TObject { + public: + /** standard constructor */ + AliHLTOfflineInterface(); + /** constructor + * @param pRunLoader pointer to AliRoot run loader + * @param pRawReader pointer to AliRoot raw reader + */ + AliHLTOfflineInterface(AliRunLoader* pRunLoader, AliRawReader* pRawReader); + /** not a valid copy constructor, defined according to effective C++ style */ + AliHLTOfflineInterface(const AliHLTOfflineInterface&); + /** not a valid assignment op, but defined according to effective C++ style */ + AliHLTOfflineInterface& operator=(const AliHLTOfflineInterface&); + /** destructor */ + virtual ~AliHLTOfflineInterface(); + + /** + * Get the AliRoot run loader. + */ + const AliRunLoader* GetRunLoader() const; + + /** + * Get the AliRoot raw reader + */ + const AliRawReader* GetRawReader() const; + + /** + * Set AliRoot ESD for the current event. + */ + int SetESD(Int_t eventNo, AliESD* pESD); + + /** + * Get the AliRoot ESD + */ + AliESD* GetESD() const; + + /** + * Set AliRoot external params. + * + * @param runLoader the AliRoot runloader + * @param rawReader the AliRoot RawReader + * @return neg. error code if failed + */ + int SetParams(AliRunLoader* runLoader, AliRawReader* rawReader); + + /** + * Reset AliRoot internal params. + */ + int Reset(); + + /** + * Set AliRoot external params. + * This method works on the global list. + * @param runLoader the AliRoot runloader + * @param rawReader the AliRoot RawReader + * @return neg. error code if failed + */ + static int SetParamsToComponents(AliRunLoader* runLoader, AliRawReader* rawReader); + + /** + * Fill ESD for one event. + * Fill the ESD with the previously reconstructed data. It must be implmented + * by the child class. + * @param runLoader the AliRoot runloader + * @param esd an AliESD instance + * @return neg. error code if failed + */ + virtual int FillESD(AliRunLoader* runLoader, AliESD* esd)=0; + + /** + * Fill ESD for one event. + * The FillESD method of all active AliHLTOfflineDataSink's is called in + * order to fill the ESD with the previously reconstructed data. This method + * works on the global list. + * @param runLoader the AliRoot runloader + * @param esd an AliESD instance + * @return neg. error code if failed + */ + static int FillComponentESDs(AliRunLoader* runLoader, AliESD* esd); + + /** + * Reset AliRoot internal params of all active components. + * This method works on the global list. + */ + static int ResetComponents(); + +protected: + /** + * Register an OfflineInterface. + * @param me instance of AliHLTOfflineInterface + * @return neg. error code if failed + */ + static int Register(AliHLTOfflineInterface* me); + + /** + * Unregister an OfflineInterface. + * @param me instance of AliHLTOfflineInterface + * @return neg. error code if failed + */ + static int Unregister(AliHLTOfflineInterface* me); + + private: + /** the list of active interfaces */ + static TList fgList; // see above + + /** the current object link (list position) */ + static TObjLink* fgCurrentLnk; // see above + + /** AliRoot run loader instance */ + AliRunLoader* fpRunLoader; //! transient + /** AliRoot raw reader instance */ + AliRawReader* fpRawReader; //! transient + /** AliRoot HLT ESD instance */ + AliESD* fpESD; //! transient + + ClassDef(AliHLTOfflineInterface, 1); +}; + +#endif diff --git a/HLT/BASE/AliHLTRootFilePublisherComponent.cxx b/HLT/BASE/AliHLTRootFilePublisherComponent.cxx deleted file mode 100644 index 612373647c1..00000000000 --- a/HLT/BASE/AliHLTRootFilePublisherComponent.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// $Id$ - -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Authors: Matthias Richter * - * for The ALICE Off-line Project. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/** @file AliHLTRootFilePublisherComponent.cxx - @author Matthias Richter - @date - @brief HLT file publisher component implementation. */ - -#include "AliHLTRootFilePublisherComponent.h" -//#include -//#include -//#include - -// temporary -#include "TH1F.h" - -/** the global object for component registration */ -AliHLTRootFilePublisherComponent gAliHLTRootFilePublisherComponent; - -/** ROOT macro for the implementation of ROOT specific class methods */ -ClassImp(AliHLTRootFilePublisherComponent) - -AliHLTRootFilePublisherComponent::AliHLTRootFilePublisherComponent() - : - AliHLTFilePublisher() -{ - // see header file for class documentation - // or - // refer to README to build package - // or - // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt - -} - -AliHLTRootFilePublisherComponent::AliHLTRootFilePublisherComponent(const AliHLTRootFilePublisherComponent&) - : - AliHLTFilePublisher() -{ - // see header file for class documentation - HLTFatal("copy constructor untested"); -} - -AliHLTRootFilePublisherComponent& AliHLTRootFilePublisherComponent::operator=(const AliHLTRootFilePublisherComponent&) -{ - // see header file for class documentation - HLTFatal("assignment operator untested"); - return *this; -} - -AliHLTRootFilePublisherComponent::~AliHLTRootFilePublisherComponent() -{ - // see header file for class documentation - - // file list and file name list are owner of their objects and - // delete all the objects -} - -const char* AliHLTRootFilePublisherComponent::GetComponentID() -{ - // see header file for class documentation - return "ROOTFilePublisher"; -} - -AliHLTComponentDataType AliHLTRootFilePublisherComponent::GetOutputDataType() -{ - // see header file for class documentation - AliHLTComponentDataType dt = - {sizeof(AliHLTComponentDataType), - kAliHLTVoidDataTypeID, - kAliHLTVoidDataOrigin}; - return dt; -} - -void AliHLTRootFilePublisherComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) -{ - // see header file for class documentation - constBase=10000; - inputMultiplier=1.0; -} - -AliHLTComponent* AliHLTRootFilePublisherComponent::Spawn() -{ - // see header file for class documentation - return new AliHLTRootFilePublisherComponent; -} - -int AliHLTRootFilePublisherComponent::ScanArgument(int argc, const char** argv) -{ - // see header file for class documentation - - // there are no other arguments than the standard ones - if (argc==0 && argv==NULL) { - // this is just to get rid of the warning "unused parameter" - } - int iResult=-EPROTO; - return iResult; -} - -int AliHLTRootFilePublisherComponent::OpenFiles() -{ - // see header file for class documentation - int iResult=0; - return iResult; -} - -int AliHLTRootFilePublisherComponent::GetEvent( const AliHLTComponentEventData& evtData, - AliHLTComponentTriggerData& trigData, - AliHLTUInt8_t* outputPtr, - AliHLTUInt32_t& size, - vector& outputBlocks ) -{ - int iResult=0; - if (GetCurrentSpecification()==0) { - TH1F *hpx = new TH1F("hpx","px distribution",100,-4,4); - hpx->FillRandom("gaus",1000); - PushBack(hpx, "TH1F", "ROOT"); - } else { - TH1F *hpy = new TH1F("hpy","py distribution",100,-10,10); - hpy->FillRandom("gaus",10000); - PushBack(hpy, "TH1F", "ROOT"); - } - - return iResult; -} diff --git a/HLT/BASE/AliHLTRootFilePublisherComponent.h b/HLT/BASE/AliHLTRootFilePublisherComponent.h deleted file mode 100644 index 94241978a54..00000000000 --- a/HLT/BASE/AliHLTRootFilePublisherComponent.h +++ /dev/null @@ -1,96 +0,0 @@ -// @(#) $Id$ - -#ifndef ALIHLTROOTFILEPUBLISHERCOMPONENT_H -#define ALIHLTROOTFILEPUBLISHERCOMPONENT_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/** @file AliHLTRootFilePublisherComponent.h - @author Matthias Richter - @date - @brief component for publishing of Root objects from a root file. - @note The class is used in Offline (AliRoot) context -*/ - -#include "AliHLTFilePublisher.h" -#include - -/** - * @class AliHLTRootFilePublisherComponent - * An HLT data source component which publishes data from one or a sequence - * of files.
- * - * Component ID: \b RootFilePublisherComponent
- * 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). - * - * Mandatory arguments:
- * - * Optional arguments:
- * - * @see AliHLTFilePublisher for default arguments - * @ingroup alihlt_component - */ -class AliHLTRootFilePublisherComponent : public AliHLTFilePublisher { - public: - /** standard constructor */ - AliHLTRootFilePublisherComponent(); - /** not a valid copy constructor, defined according to effective C++ style */ - AliHLTRootFilePublisherComponent(const AliHLTRootFilePublisherComponent&); - /** not a valid assignment op, but defined according to effective C++ style */ - AliHLTRootFilePublisherComponent& operator=(const AliHLTRootFilePublisherComponent&); - /** destructor */ - virtual ~AliHLTRootFilePublisherComponent(); - - const char* GetComponentID(); - AliHLTComponentDataType GetOutputDataType(); - void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ); - AliHLTComponent* Spawn(); - - /** - * Open all files. - * Opens all files from the file name list @ref fFileNames and adds TFile - * opjects to the TFiles list. - */ - int OpenFiles(); - - protected: - /** - * Data processing method for the component. - * The component uses the @ref alihltcomponent-high-level-interface - * to put serialized Root object into the output stream. Despite of that it - * implements the lox-level DumpEvent method in order to allow child classes - * to use the low-level method. - * @param evtData event data structure - * @param trigData trigger data structure - * @param outputPtr pointer to target buffer - * @param size input: size of target buffer - * output:size of produced data - * @param outputBlocks list to receive output block descriptors - * @return - */ - int GetEvent( const AliHLTComponentEventData& evtData, - AliHLTComponentTriggerData& trigData, - AliHLTUInt8_t* outputPtr, - AliHLTUInt32_t& size, - vector& outputBlocks ); - - /** - * Scan one argument and adjacent parameters. - * Can be overloaded by child classes in order to add additional arguments - * beyond the standard arguments of the file publisher. The method is called - * whenever a non-standard argument is recognized. - * @param argc size of the argument array - * @param argv agument array for component initialization - * @return number of processed members of the argv
- * -EINVAL unknown argument
- * -EPROTO parameter for argument missing
- */ - virtual int ScanArgument(int argc, const char** argv); - - private: - - ClassDef(AliHLTRootFilePublisherComponent, 0) -}; -#endif diff --git a/HLT/BASE/AliHLTRootFileWriterComponent.cxx b/HLT/BASE/AliHLTRootFileWriterComponent.cxx deleted file mode 100644 index 87146df317a..00000000000 --- a/HLT/BASE/AliHLTRootFileWriterComponent.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// @(#) $Id$ - -/** @file AliHLTRootFileWriterComponent.cxx - @author Matthias Richter - @date - @brief Base class for writer components to store data in a ROOT file - - */ - -#include "AliHLTRootFileWriterComponent.h" -#include "TFile.h" -#include "TString.h" - -/** the global object for component registration */ -AliHLTRootFileWriterComponent gAliHLTRootFileWriterComponent; - -/** ROOT macro for the implementation of ROOT specific class methods */ -ClassImp(AliHLTRootFileWriterComponent) - -AliHLTRootFileWriterComponent::AliHLTRootFileWriterComponent() - : - AliHLTFileWriter(), - fEventID(kAliHLTVoidEventID), - fCurrentFile(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 - - // all blocks of one event go into the same file - SetMode(kConcatenateBlocks); -} - -AliHLTRootFileWriterComponent::AliHLTRootFileWriterComponent(const AliHLTRootFileWriterComponent&) - : - AliHLTFileWriter(), - fEventID(kAliHLTVoidEventID), - fCurrentFile(NULL) -{ - // see header file for class documentation - HLTFatal("copy constructor untested"); -} - -AliHLTRootFileWriterComponent& AliHLTRootFileWriterComponent::operator=(const AliHLTRootFileWriterComponent&) -{ - // see header file for class documentation - HLTFatal("assignment operator untested"); - return *this; -} - -AliHLTRootFileWriterComponent::~AliHLTRootFileWriterComponent() -{ - // see header file for class documentation -} - -int AliHLTRootFileWriterComponent::DumpEvent( const AliHLTComponentEventData& evtData, - const AliHLTComponentBlockData* blocks, - AliHLTComponentTriggerData& trigData ) -{ - // see header file for class documentation - int iResult=0; - if (evtData.fStructSize==0 && blocks==NULL && trigData.fStructSize==0) { - // this is just to get rid of the warning "unused parameter" - } - const TObject* pObj=GetFirstInputObject(kAliHLTAnyDataType); - HLTDebug("got first object %p", pObj); - int count=0; - while (pObj && iResult>=0) { - iResult=WriteObject(evtData.fEventID, pObj); - if (iResult) { - count++; - HLTDebug("wrote object of class %s, data type %s", pObj->ClassName(), (DataType2Text(GetDataType(pObj)).c_str())); - } - pObj=GetNextInputObject(); - } - HLTDebug("wrote %d of %d object(s) to file", count, GetNumberOfInputBlocks()); - return iResult; -} - -int AliHLTRootFileWriterComponent::ScanArgument(int argc, const char** argv) -{ - // see header file for class documentation - // no other arguments known - if (argc==0 && argv==NULL) { - // this is just to get rid of the warning "unused parameter" - } - int iResult=-EPROTO; - return iResult; -} - -int AliHLTRootFileWriterComponent::WriteObject(const AliHLTEventID_t eventID, const TObject *pOb) -{ - // see header file for class documentation - int iResult=0; - if (pOb) { - HLTDebug("write object %p (%s)", pOb, pOb->GetName()); - if (CheckMode(kConcatenateEvents) && eventID != fEventID && - fCurrentFile!=NULL && eventID!=kAliHLTVoidEventID) { - TFile* pFile=fCurrentFile; fCurrentFile=NULL; - pFile->Close(); delete pFile; - } - if (fCurrentFile==NULL) { - fCurrentFile=OpenFile(eventID, 0); - if (fCurrentFile) fEventID=eventID; - } - if (fCurrentFile) { - fCurrentFile->cd(); - pOb->Write(); - } else { - iResult=-EBADF; - } - } - return iResult; -} - -TFile* AliHLTRootFileWriterComponent::OpenFile(const AliHLTEventID_t eventID, const int blockID, const char* option) -{ - // see header file for class documentation - TFile* pFile=NULL; - TString filename(""); - if ((BuildFileName(eventID, blockID, kAliHLTVoidDataType, filename))>=0 && filename.IsNull()==0) { - pFile=new TFile(filename, option); - if (pFile) { - if (pFile->IsZombie()) { - delete pFile; - pFile=NULL; - HLTError("can not open ROOT file %s", filename.Data()); - } - } else { - HLTFatal("memory allocation failed"); - } - } else { - HLTError("failed to build a new file name for event %#8x", eventID); - } - return pFile; -} diff --git a/HLT/BASE/AliHLTRootFileWriterComponent.h b/HLT/BASE/AliHLTRootFileWriterComponent.h deleted file mode 100644 index 05eb08f5610..00000000000 --- a/HLT/BASE/AliHLTRootFileWriterComponent.h +++ /dev/null @@ -1,108 +0,0 @@ -// @(#) $Id$ - -#ifndef ALIHLTROOTFILEWRITERCOMPONENT_H -#define ALIHLTROOTFILEWRITERCOMPONENT_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/** @file AliHLTRootFileWriterComponent.h - @author Matthias Richter - @date - @brief Base class for writer components to store data in a ROOT file - - */ -#include "AliHLTFileWriter.h" -#include "TObject.h" - -class TFile; - -/** - * @class AliHLTRootFileWriterComponent - * The RootFileWriter provides a stand alone component to write incoming - * TObject like structures into a Root file. Furthermore it functions as - * base class for customized writers. - * @see AliHLTFileWriter for parameters - */ -class AliHLTRootFileWriterComponent : public AliHLTFileWriter -{ - public: - /** standard constructor */ - AliHLTRootFileWriterComponent(); - /** not a valid copy constructor, defined according to effective C++ style */ - AliHLTRootFileWriterComponent(const AliHLTRootFileWriterComponent&); - /** not a valid assignment op, but defined according to effective C++ style */ - AliHLTRootFileWriterComponent& operator=(const AliHLTRootFileWriterComponent&); - /** destructor */ - ~AliHLTRootFileWriterComponent(); - - /** - * The id of the component. - * @return component id (string) - */ - virtual const char* GetComponentID() {return "ROOTFileWriter";}; - - /** - * Spawn function. - * @return new class instance - */ - virtual AliHLTComponent* Spawn() {return new AliHLTRootFileWriterComponent;} - - protected: - /** - * Data processing method for the component. - * The function can be overloaded by specific ROOT file writer - * components. The RootFileWriter processes only TObject like data - * structures of the input blocks and uses the - * @ref alihltcomponent-high-level-interface. Despite of that it implements - * the lox-level DumpEvent method in order to allow child classes to use the - * low-level method. - * @param evtData event data structure - * @param blocks input data block descriptors - * @param trigData trigger data structure - */ - virtual int DumpEvent( const AliHLTComponentEventData& evtData, - const AliHLTComponentBlockData* blocks, - AliHLTComponentTriggerData& trigData ); - - /** - * Scan one argument and adjacent parameters. - * \b IMPORTANT: if overloaded by child class, call this function - * as the default from the cutomized switch, e.g. - *
-   * 
- * @param argc size of the argument array - * @param argv agument array for component initialization - * @return number of processed members of the argv
- * -EINVAL unknown argument
- * -EPROTO parameter for argument missing
- */ - virtual int ScanArgument(int argc, const char** argv); - - /** - * Write ROOT object to current file. - * @param eventID ID of the current event - * @param pOb pointer to ROOT object - * @return neg. error code if failed - */ - int WriteObject(const AliHLTEventID_t eventID, const TObject *pOb); - - /** - * Open a ROOT file. - * The function calls @ref AliHLTFileWriter::BuildFileName in order to - * create a file name and opens it as a root file. - * @param eventID ID of the current event - * @param blockID ID of the current block - * @param option option as specified in TFile - * @return pointer to TFile object, the called has to clean-up the object after use. - */ - TFile* OpenFile(const AliHLTEventID_t eventID, const int blockID=-1, const char* option="recreate"); - - /** the event ID associated with the current file */ - AliHLTEventID_t fEventID; // see above - - /** the name of the current file */ - TFile* fCurrentFile; //! transient value - - ClassDef(AliHLTRootFileWriterComponent, 0) -}; -#endif diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx index be5e2b0bf62..178e00e26fe 100644 --- a/HLT/BASE/AliHLTSystem.cxx +++ b/HLT/BASE/AliHLTSystem.cxx @@ -32,7 +32,10 @@ using namespace std; #include "AliHLTConfiguration.h" #include "AliHLTConfigurationHandler.h" #include "AliHLTTask.h" -#include "TString.h" +#include "AliHLTModuleAgent.h" +#include +#include +#include /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTSystem) @@ -41,7 +44,8 @@ AliHLTSystem::AliHLTSystem() : fpComponentHandler(new AliHLTComponentHandler()), fpConfigurationHandler(new AliHLTConfigurationHandler()), - fTaskList() + fTaskList(), + fState(0) { // see header file for class documentation // or @@ -74,7 +78,8 @@ AliHLTSystem::AliHLTSystem(const AliHLTSystem&) AliHLTLogging(), fpComponentHandler(NULL), fpConfigurationHandler(NULL), - fTaskList() + fTaskList(), + fState(0) { // see header file for class documentation if (fgNofInstances++>0) @@ -291,6 +296,8 @@ int AliHLTSystem::Run(Int_t iNofEvents) { // see header file for class documentation int iResult=0; + int iCount=0; + SetStatusFlags(kRunning); if ((iResult=InitTasks())>=0) { if ((iResult=StartTasks())>=0) { for (int i=0; i=0; i++) { @@ -298,6 +305,7 @@ int AliHLTSystem::Run(Int_t iNofEvents) if (iResult>=0) { HLTInfo("Event %d successfully finished (%d)", i, iResult); iResult=0; + iCount++; } else { HLTError("Processing of event %d failed (%d)", i, iResult); // TODO: define different running modes to either ignore errors in @@ -314,6 +322,8 @@ int AliHLTSystem::Run(Int_t iNofEvents) } else if (iResult!=-ENOENT) { HLTError("can not initialize task list"); } + if (iResult>=0) iResult=iCount; + ClearStatusFlags(kRunning); return iResult; } @@ -415,5 +425,191 @@ int AliHLTSystem::DeinitTasks() void* AliHLTSystem::AllocMemory( void* param, unsigned long size ) { // see header file for class documentation + if (param==NULL) { + // get rid of 'unused parameter' warning + } return (void*)new char[size]; } + +int AliHLTSystem::Reconstruct(int nofEvents, AliRunLoader* runLoader, + AliRawReader* rawReader) +{ + // see header file for class documentation + int iResult=0; + if (runLoader) { + HLTInfo("Run Loader %p, Raw Reader %p , %d events", runLoader, rawReader, nofEvents); + if (CheckStatus(kReady)) { + iResult=Run(nofEvents); + } else { + HLTError("wrong state %#x, required flags %#x", GetStatusFlags(), kReady); + } + } else { + HLTError("missing run loader instance"); + iResult=-EINVAL; + } + return iResult; +} + +int AliHLTSystem::FillESD(int eventNo, AliRunLoader* runLoader, AliESD* esd) +{ + // see header file for class documentation + int iResult=0; + if (runLoader) { + HLTInfo("Event %d: Run Loader %p, ESD %p", eventNo, runLoader, esd); + } else { + HLTError("missing run loader/ESD instance(s)"); + iResult=-EINVAL; + } + return iResult; +} + +int AliHLTSystem::LoadComponentLibraries(const char* libraries) +{ + // see header file for class documentation + int iResult=0; + if (libraries) { + if (fpComponentHandler) { + TString libs(libraries); + TObjArray* pTokens=libs.Tokenize(" "); + if (pTokens) { + int iEntries=pTokens->GetEntries(); + for (int i=0; i=0; i++) { + iResult=fpComponentHandler->LoadLibrary((((TObjString*)pTokens->At(i))->GetString()).Data()); + } + delete pTokens; + } + if (iResult>=0) { + SetStatusFlags(kLibrariesLoaded); + } else { + // lets see if we need this, probably not + //fpComponentHandler->UnloadLibraries(); + ClearStatusFlags(kLibrariesLoaded); + } + } else { + iResult=-EFAULT; + HLTFatal("no component handler available"); + } + } else { + iResult=-EINVAL; + } + return iResult; +} + +int AliHLTSystem::Configure(AliRunLoader* runloader) +{ + // see header file for class documentation + int iResult=0; + if (CheckStatus(kRunning)) { + HLTError("HLT system in running state, can not configure"); + return -EBUSY; + } + ClearStatusFlags(kConfigurationLoaded|kTaskListCreated); + iResult=LoadConfigurations(runloader); + if (iResult>=0) { + SetStatusFlags(kConfigurationLoaded); + iResult=BuildTaskListsFromTopConfigurations(runloader); + if (iResult>=0) { + SetStatusFlags(kTaskListCreated); + } + } + if (iResult<0) SetStatusFlags(kError); + + return iResult; +} + +int AliHLTSystem::Reset(int bForce) +{ + // see header file for class documentation + int iResult=0; + if (!bForce && CheckStatus(kRunning)) { + HLTError("HLT system in running state, can not configure"); + return -EBUSY; + } + CleanTaskList(); + ClearStatusFlags(~kUninitialized); + return iResult; +} + +int AliHLTSystem::LoadConfigurations(AliRunLoader* runloader) +{ + // see header file for class documentation + if (CheckStatus(kRunning)) { + HLTError("HLT system in running state, can not configure"); + return -EBUSY; + } + int iResult=0; + AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); + while (pAgent) { + HLTDebug("load configurations for agent %s (%p)", pAgent->GetName(), pAgent); + pAgent->CreateConfigurations(fpConfigurationHandler, runloader); + pAgent=AliHLTModuleAgent::GetNextAgent(); + } + return iResult; +} + +int AliHLTSystem::BuildTaskListsFromTopConfigurations(AliRunLoader* runloader) +{ + // see header file for class documentation + if (CheckStatus(kRunning)) { + HLTError("HLT system in running state, can not configure"); + return -EBUSY; + } + if (!CheckStatus(kConfigurationLoaded)) { + HLTWarning("configurations not yet loaded"); + return 0; + } + + int iResult=0; + AliHLTModuleAgent* pAgent=AliHLTModuleAgent::GetFirstAgent(); + while (pAgent && iResult>=0) { + TString tops=pAgent->GetTopConfigurations(runloader); + HLTDebug("top configurations for agent %s (%p): %s", pAgent->GetName(), pAgent, tops.Data()); + TObjArray* pTokens=tops.Tokenize(" "); + if (pTokens) { + int iEntries=pTokens->GetEntries(); + for (int i=0; i=0; i++) { + const char* pCID=((TObjString*)pTokens->At(i))->GetString().Data(); + AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(pCID); + if (pConf) { + iResult=BuildTaskList(pConf); + } else { + HLTWarning("can not find top configuration %s", pCID); + } + } + delete pTokens; + } + + pAgent=AliHLTModuleAgent::GetNextAgent(); + } + if (iResult>=0) SetStatusFlags(kTaskListCreated); + + return iResult; +} + +int AliHLTSystem::CheckStatus(int flag) +{ + // see header file for class documentation + if (flag==kUninitialized && flag==fState) return 1; + if ((fState&flag)==flag) return 1; + return 0; +} + +int AliHLTSystem::GetStatusFlags() +{ + // see header file for class documentation + return fState; +} + +int AliHLTSystem::SetStatusFlags(int flags) +{ + // see header file for class documentation + fState|=flags; + return fState; +} + +int AliHLTSystem::ClearStatusFlags(int flags) +{ + // see header file for class documentation + fState&=~flags; + return fState; +} diff --git a/HLT/BASE/AliHLTSystem.h b/HLT/BASE/AliHLTSystem.h index e9a5579946b..7257be9954d 100644 --- a/HLT/BASE/AliHLTSystem.h +++ b/HLT/BASE/AliHLTSystem.h @@ -24,6 +24,9 @@ class AliHLTComponentHandler; class AliHLTConfiguration; class AliHLTConfigurationHandler; class AliHLTTask; +class AliRunLoader; +class AliRawReader; +class AliESD; /** * @class AliHLTSystem @@ -122,7 +125,7 @@ class AliHLTSystem : public AliHLTLogging { * method is scalled * All tasks of the list will be subsequently processed for each event. * @param iNofEvents number of events - * @return neg error code if failed + * @return number of reconstructed events, neg error code if failed */ int Run(Int_t iNofEvents=1); @@ -171,17 +174,129 @@ class AliHLTSystem : public AliHLTLogging { */ static void* AllocMemory( void* param, unsigned long size ); + /** + * Reconstruction inside AliRoot. + * To be called by the AliHLTReconstructor plugin during the + * LocalReconstruction step of the AliRoot reconstruction. The latter means + * that all events are reconstructed at once, the event loop is internally + * implemented. In contrast to that, the FillESD method is called event by + * event. This requires an 'ESD' recorder at the end of the HLT chain, in + * order to have the reconstructed events available for the FillESD loop. + * The 'runLoader' and 'rawReader' parameters are set to all active + * AliHLTOfflineDataSource's and the HLT chain is processed for the given + * number of events. If the rawReader is NULL, reconstruction is done on + * simulated data, from real data if a RawReader is specified. + * @param nofEvents number of events + * @param runLoader the AliRoot runloader + * @param rawReader the AliRoot RawReader + * @return number of reconstructed events, neg. error code if failed + */ + int Reconstruct(int nofEvents, AliRunLoader* runLoader, + AliRawReader* rawReader=NULL); + + /** + * Fill ESD for one event. + * To be called by the AliHLTReconstructor plugin during the event loop + * and FillESD method of the AliRoot reconstruction. + * This method is called on event basis, and thus must copy the previously + * reconstructed data of the event from the 'ESD' recorder. The FillESD + * method of all active AliHLTOfflineDataSink's is called. + * @param eventNo current event no (Note: this event number is just a + * processing counter and is not related to the nature/ + * origin of the event + * @param runLoader the AliRoot runloader + * @param esd an AliESD instance + * @return neg. error code if failed + */ + int FillESD(int eventNo, AliRunLoader* runLoader, AliESD* esd); + + /** + * Load component libraries. + * @param libs string of blank separated library names + * @return neg. error code if failed + */ + int LoadComponentLibraries(const char* libs); + + /** + * Prepare the HLT system for running. + * - module agents are requested to register configurations + * - task lists are built from the top configurations of the modules + * @return neg. error code if failed
+ * -EBUSY system is in kRunning state
+ */ + int Configure(AliRunLoader* runloader=NULL); + + /** + * Reset the HLT system. + * Reset is not possible while the system is in running state. + * @param bForce force the reset + * @return neg. error code if failed
+ * -EBUSY system is in kRunning state
+ */ + int Reset(int bForce=0); + + /** + * Load the configurations specified by the module agents. + * The runLoader is passed to the agent and allows configuration + * selection. + * @return neg. error code if failed + */ + int LoadConfigurations(AliRunLoader* runloader=NULL); + + /** + * Get the top configurations of all agents and build the task lists. + * @return neg. error code if failed + */ + int BuildTaskListsFromTopConfigurations(AliRunLoader* runloader=NULL); + + enum { + kUninitialized = 0x0, + kLibrariesLoaded = 0x1, + kConfigurationLoaded = 0x2, + kTaskListCreated = 0x4, + kReady = 0x7, + kRunning = 0x8, + kError = 0x1000 + } AliHLTSystemState_t ; + + /** + * Check status of the system. + * @param flag AliHLTSystemState_t value to check for + * @return 1 if set, 0 if not + */ + int CheckStatus(int flag); + + /** + * Get the current status. + * @return status flags of @ref AliHLTSystemState_t + */ + int GetStatusFlags(); + protected: private: + /** + * Set status flags. + */ + int SetStatusFlags(int flags); + + /** + * clear status flags. + */ + int ClearStatusFlags(int flags); + /* TList fConfList; */ /* int fbListChanged; */ + /** list of tasks */ TList fTaskList; // see above /** the number of instances of AliHLTSystem */ static int fgNofInstances; // see above + /** state of the object */ + int fState; // see above + private: ClassDef(AliHLTSystem, 2); }; diff --git a/HLT/BASE/HLTbaseLinkDef.h b/HLT/BASE/HLTbaseLinkDef.h index 27e6be8faf5..a0f8e4122ea 100644 --- a/HLT/BASE/HLTbaseLinkDef.h +++ b/HLT/BASE/HLTbaseLinkDef.h @@ -18,11 +18,15 @@ #pragma link C++ class AliHLTConsumerDescriptor; #pragma link C++ class AliHLTDataSource; #pragma link C++ class AliHLTDataSink; -#pragma link C++ class AliHLTFilePublisher; +//#pragma link C++ class AliHLTFilePublisher; #pragma link C++ class AliHLTFileWriter; -#pragma link C++ class AliHLTRootFileWriterComponent; -#pragma link C++ class AliHLTRootFilePublisherComponent; +//#pragma link C++ class AliHLTRootFileWriterComponent; +//#pragma link C++ class AliHLTRootFilePublisherComponent; #pragma link C++ class AliHLTMessage; +#pragma link C++ class AliHLTModuleAgent; +#pragma link C++ class AliHLTOfflineInterface; +#pragma link C++ class AliHLTOfflineDataSource; +#pragma link C++ class AliHLTOfflineDataSink; #endif diff --git a/HLT/BASE/Makefile.am b/HLT/BASE/Makefile.am index d8747e31e9b..12eb38e65eb 100644 --- a/HLT/BASE/Makefile.am +++ b/HLT/BASE/Makefile.am @@ -8,6 +8,8 @@ # e.g. for libHLTbase, MODULE=HLTbase MODULE = HLTbase +SUBDIRS = . util + EXTRA_DIST = HLTbaseLinkDef.h AM_CPPFLAGS = -DMODULE=$(MODULE) \ @@ -19,7 +21,7 @@ bin_SCRIPTS = setenv.sh setenv.csh lib_LTLIBRARIES = libHLTbase.la # version info for the library -LIBRARY_VERSION = '2:0:0' +LIBRARY_VERSION = '3:0:0' # 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/AliHLTAgentUtil.cxx b/HLT/BASE/util/AliHLTAgentUtil.cxx new file mode 100644 index 00000000000..b5e0872caf8 --- /dev/null +++ b/HLT/BASE/util/AliHLTAgentUtil.cxx @@ -0,0 +1,51 @@ +// @(#) $Id$ + +/** @file AliHLTAgentUtil.cxx + @author Matthias Richter + @date + @brief Agent of the libAliHLTUtil library +*/ + +#include "AliHLTAgentUtil.h" +#include "AliHLTConfiguration.h" + +/** global instance for agent registration */ +AliHLTAgentUtil gAliHLTAgentUtil; + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTAgentUtil) + +AliHLTAgentUtil::AliHLTAgentUtil() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTAgentUtil::~AliHLTAgentUtil() +{ + // see header file for class documentation +} + +int AliHLTAgentUtil::CreateConfigurations(AliHLTConfigurationHandler* handler, + AliRunLoader* runloader) const +{ + // see header file for class documentation + if (handler) { + } + return 0; +} + +const char* AliHLTAgentUtil::GetTopConfigurations(AliRunLoader* runloader) const +{ + // see header file for class documentation + return NULL; +} + +const char* AliHLTAgentUtil::GetRequiredComponentLibraries() const +{ + // see header file for class documentation + return "libAliHLTUtil.so"; +} diff --git a/HLT/BASE/util/AliHLTAgentUtil.h b/HLT/BASE/util/AliHLTAgentUtil.h new file mode 100644 index 00000000000..cc98a213e50 --- /dev/null +++ b/HLT/BASE/util/AliHLTAgentUtil.h @@ -0,0 +1,66 @@ +// @(#) $Id$ + +#ifndef ALIHLTAGENTUTIL_H +#define ALIHLTAGENTUTIL_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTAgentUtil.h + @author Matthias Richter + @date + @brief Agent of the libAliHLTUtil library +*/ + +#include "AliHLTModuleAgent.h" + +/** + * @class AliHLTAgentUtil + * This is the agent for the AliHLTUtil library. + * + * @ingroup alihlt_system + */ +class AliHLTAgentUtil : public AliHLTModuleAgent { + public: + /** + * standard constructor. The agent is automatically registered in the + * global agent manager + */ + AliHLTAgentUtil(); + /** destructor */ + virtual ~AliHLTAgentUtil(); + + /** + * Register all configurations belonging to this module with the + * AliHLTConfigurationHandler. The agent can adapt the configurations + * to be registered to the current AliRoot setup by checking the + * runloader. + * @param runloader AliRoot runloader + * @return neg. error code if failed + */ + int CreateConfigurations(AliHLTConfigurationHandler* handler, + AliRunLoader* runloader=NULL) const; + + /** + * Get the top configurations belonging to this module. + * 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 + */ + const char* GetTopConfigurations(AliRunLoader* runloader=NULL) const; + + /** + * Component libraries which the configurations of this agent depend on. + * @return list of component libraries as a blank-separated string. + */ + const char* GetRequiredComponentLibraries() const; + + protected: + + private: + ClassDef(AliHLTAgentUtil, 0); +}; + +#endif diff --git a/HLT/BASE/util/Makefile.am b/HLT/BASE/util/Makefile.am new file mode 100644 index 00000000000..434af5cce40 --- /dev/null +++ b/HLT/BASE/util/Makefile.am @@ -0,0 +1,56 @@ +# $Id$ +# Makefile template for the Alice HLT framework + +# be aware of the two different meanings of 'MODULE' +# 1. AliRoot classifies each detector and main sub-package as a module +# so for all HLT library packages MODULE is equal HLT +# 2. The HLT stand-alone build system knows about sub-modules +# e.g. for libAliHLTUtil, MODULE=AliHLTUtil +MODULE = AliHLTUtil + +EXTRA_DIST = + +AM_CPPFLAGS = @ALIROOT_CPPFLAGS@ \ + -DMODULE=$(MODULE) \ + -I$(top_srcdir)/BASE + +# library definition +lib_LTLIBRARIES = libAliHLTUtil.la + +# version info for the library +LIBRARY_VERSION = '0:0:0' + +# MODDIR is set by the AliRoot build system and denotes the topdir +# of the module, we must set it since the package definition libAliHLTUtil.pkg +# includes another common configuration file +MODDIR = $(top_srcdir) +PKGDEF = $(MODDIR)/libAliHLTUtil.pkg +include $(top_srcdir)/libAliHLTUtil.pkg + +# library sources +libAliHLTUtil_la_SOURCES = $(MODULE_SRCS) + +# library headers +pkginclude_HEADERS = $(MODULE_HDRS) + +# linker flags +libAliHLTUtil_la_LDFLAGS = -version-info $(LIBRARY_VERSION) + +# automatic generation of data and time of library build +COMPILE_INFO = HLTBaseCompileInfo.cxx + +# set the file name for the generated root dictionary +DICTCPP = AliHLTUtil-DICT.cxx +nodist_libAliHLTUtil_la_SOURCES = $(COMPILE_INFO) \ + $(DICTCPP) + +CLEANFILES = $(COMPILE_INFO) + +include $(top_srcdir)/make.dict + +$(COMPILE_INFO): $(libAliHLTUtil_la_SOURCES) $(pkginclude_HEADERS) $(noinst_HEADERS) Makefile.am + @echo '//automatically generated compilation info' > $@ + @echo '//!!! DO NOT EDIT THIS FILE !!!' >> $@ + @echo '//add changes in Makefile.am' >> $@ + @echo 'void $(MODULE)CompileInfo( char*& date, char*& time)' >> $@ + @echo '{date=__DATE__; time=__TIME__; return;}' >> $@ diff --git a/HLT/ChangeLog b/HLT/ChangeLog index 0c92a5e5f27..eac0faa14dc 100644 --- a/HLT/ChangeLog +++ b/HLT/ChangeLog @@ -1,3 +1,11 @@ +2007-03-14 aliroot integration + - AliHLTSystem interface methods to AliHLTReconstructor implemeted + - AliHLTModuleAgent introduced for each HLT module, sample + agent added to libAliHLTSample + - AliHLTOfflineInterface base classes added + - AliHLTFilePublisher, AliHLTRootFileWriter/Publisher moved to + libAliHLTUtil (AliHLTFileWriter will follow when dep. to PHOS are + cleared) 2007-03-09 logging system - adapted to AliRoot logging system, messages printed out via AliRoot message channel diff --git a/HLT/Makefile.am b/HLT/Makefile.am index 72ff1338082..3e81d52cfe7 100644 --- a/HLT/Makefile.am +++ b/HLT/Makefile.am @@ -26,6 +26,7 @@ SUBDIRS = BASE \ doc EXTRA_DIST = libHLTbase.pkg \ + libAliHLTUtil.pkg \ libAliHLTSample.pkg \ libAliHLTPHOS.pkg \ libAliHLTTPC.pkg \ @@ -34,6 +35,7 @@ EXTRA_DIST = libHLTbase.pkg \ DIST_SUBDIRS = $(SUBDIRS) +# this is a special target to create a stand-alone package from the SampleLib SampleLibPkg: Makefile $(top_srcdir)/SampleLib/* @tmpdir=/tmp/$(USER)/$@ ; \ if test -d $@ ; then \ diff --git a/HLT/SampleLib/AliHLTAgentSample.cxx b/HLT/SampleLib/AliHLTAgentSample.cxx new file mode 100644 index 00000000000..31f319fd301 --- /dev/null +++ b/HLT/SampleLib/AliHLTAgentSample.cxx @@ -0,0 +1,82 @@ +// @(#) $Id$ + +/** @file AliHLTAgentSample.cxx + @author Matthias Richter + @date + @brief Agent of the libAliHLTSample library +*/ + +#include "AliHLTAgentSample.h" +#include "AliHLTConfiguration.h" +#include "TSystem.h" + +/** global instance for agent registration */ +AliHLTAgentSample gAliHLTAgentSample; + +const char* gAliHLTAgentSampleData="/tmp/testdata"; +const char* gAliHLTAgentSampleOut="/tmp/hltout"; + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTAgentSample) + +AliHLTAgentSample::AliHLTAgentSample() +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTAgentSample::~AliHLTAgentSample() +{ + // see header file for class documentation + + // delete the test data + ofstream dump(gAliHLTAgentSampleData, ios::in); + if (dump.good()) { + TString arg("rm -f "); + arg+=gAliHLTAgentSampleData; + gSystem->Exec(arg.Data()); + } +} + +int AliHLTAgentSample::CreateConfigurations(AliHLTConfigurationHandler* handler, + AliRunLoader* runloader) const +{ + // see header file for class documentation + + // create some test data + ofstream dump(gAliHLTAgentSampleData, (ios::openmode)0); + dump << "This is just some test data for the ALICE HLT analysis example"; + dump << "---- not copied" << endl; + dump.close(); + + if (handler) { + // the publisher configuration for the test data + TString arg("-datafile "); + arg+=gAliHLTAgentSampleData; + HLTDebug(arg.Data()); + handler->CreateConfiguration("fp1" , "FilePublisher", NULL , arg.Data()); + + // the configuration for the dummy component + handler->CreateConfiguration("cp" , "Dummy" , "fp1", "output_percentage 80"); + + // the writer configuration + arg="-datafile "; arg+=gAliHLTAgentSampleOut; + handler->CreateConfiguration("sink1", "FileWriter" , "cp" , arg.Data()); + } + return 0; +} + +const char* AliHLTAgentSample::GetTopConfigurations(AliRunLoader* runloader) const +{ + // see header file for class documentation + return "sink1"; +} + +const char* AliHLTAgentSample::GetRequiredComponentLibraries() const +{ + // see header file for class documentation + return "libAliHLTUtil.so libAliHLTSample.so"; +} diff --git a/HLT/SampleLib/AliHLTAgentSample.h b/HLT/SampleLib/AliHLTAgentSample.h new file mode 100644 index 00000000000..bc4a3d3423d --- /dev/null +++ b/HLT/SampleLib/AliHLTAgentSample.h @@ -0,0 +1,66 @@ +// @(#) $Id$ + +#ifndef ALIHLTAGENTSAMPLE_H +#define ALIHLTAGENTSAMPLE_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTAgentSample.h + @author Matthias Richter + @date + @brief Agent of the libAliHLTSample library +*/ + +#include "AliHLTModuleAgent.h" + +/** + * @class AliHLTAgentSample + * This is the agent for the AliHLTSample library. + * + * @ingroup alihlt_system + */ +class AliHLTAgentSample : public AliHLTModuleAgent { + public: + /** + * standard constructor. The agent is automatically registered in the + * global agent manager + */ + AliHLTAgentSample(); + /** destructor */ + virtual ~AliHLTAgentSample(); + + /** + * Register all configurations belonging to this module with the + * AliHLTConfigurationHandler. The agent can adapt the configurations + * to be registered to the current AliRoot setup by checking the + * runloader. + * @param runloader AliRoot runloader + * @return neg. error code if failed + */ + int CreateConfigurations(AliHLTConfigurationHandler* handler, + AliRunLoader* runloader=NULL) const; + + /** + * Get the top configurations belonging to this module. + * 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 + */ + const char* GetTopConfigurations(AliRunLoader* runloader=NULL) const; + + /** + * Component libraries which the configurations of this agent depend on. + * @return list of component libraries as a blank-separated string. + */ + const char* GetRequiredComponentLibraries() const; + + protected: + + private: + ClassDef(AliHLTAgentSample, 0); +}; + +#endif diff --git a/HLT/SampleLib/Makefile.am b/HLT/SampleLib/Makefile.am index e2011ce8afb..60ff6cee641 100644 --- a/HLT/SampleLib/Makefile.am +++ b/HLT/SampleLib/Makefile.am @@ -12,6 +12,8 @@ EXTRA_DIST = AliHLTSampleLinkDef.h # include the pkg definition which actually contains the source # file definitions +MODDIR = $(top_srcdir) +PKGDEF = $(MODDIR)/libAliHLTSample.pkg include $(top_srcdir)/libAliHLTSample.pkg # library definition diff --git a/HLT/TPCLib/Makefile.am b/HLT/TPCLib/Makefile.am index 5e4507ccf4c..b0981399b54 100644 --- a/HLT/TPCLib/Makefile.am +++ b/HLT/TPCLib/Makefile.am @@ -6,7 +6,8 @@ MODULE = AliHLTTPC EXTRA_DIST = AliHLTTPCLinkDef.h AM_CPPFLAGS = @ALIROOT_CPPFLAGS@ \ - -I$(top_srcdir)/BASE + -I$(top_srcdir)/BASE \ + -I$(top_srcdir)/BASE/util # generation of the TPC Pad mapping tables for the # AliHLTTPCDigitReaderRaw reader @@ -42,6 +43,7 @@ libAliHLTTPC_la_SOURCES = $(MODULE_SRCS) pkginclude_HEADERS = $(MODULE_HDRS) # linker flags +libAliHLTTPC_la_LIBADD = $(top_builddir)/BASE/util/libAliHLTUtil.la libAliHLTTPC_la_LDFLAGS = -L@ROOTLIBDIR@ \ @ROOTLIBS@ \ @ALIROOT_LDFLAGS@ \ diff --git a/HLT/configure.ac b/HLT/configure.ac index 80fdb1ac806..22ace9d92eb 100644 --- a/HLT/configure.ac +++ b/HLT/configure.ac @@ -564,6 +564,7 @@ AC_CONFIG_FILES([Makefile BASE/Makefile BASE/setenv.sh BASE/setenv.csh + BASE/util/Makefile SampleLib/Makefile TPCLib/Makefile TPCLib/mapping2array.cxx diff --git a/HLT/libAliHLTSample.pkg b/HLT/libAliHLTSample.pkg index 7233b9392c7..fba06100ad0 100644 --- a/HLT/libAliHLTSample.pkg +++ b/HLT/libAliHLTSample.pkg @@ -9,12 +9,14 @@ # library sources MODULE_SRCS= AliHLTSampleComponent1.cxx \ AliHLTSampleComponent2.cxx \ + AliHLTAgentSample.cxx \ AliHLTDummyComponent.cxx # class header files, the link definition for the root dictionary # will be created from the names of the header files CLASS_HDRS:= AliHLTSampleComponent1.h \ AliHLTSampleComponent2.h \ + AliHLTAgentSample.h \ AliHLTDummyComponent.h # library headers @@ -32,8 +34,8 @@ MODULE_HDRS:= $(CLASS_HDRS) # classes. The *LinkDef.h must be added to DHDR in that case. # There might be an extension also in ALIROOT which allows to # generate the LinkDef automatically. -DHDR:= SampleLib/AliHLTSampleLinkDef.h -CINTAUTOLINK:= +#DHDR:= SampleLib/AliHLTSampleLinkDef.h +CINTAUTOLINK:=1 # extra defines and flags for the AliRoot build system. NOTE: include # directories and linking flags/options must be specified in diff --git a/HLT/libAliHLTTPC.pkg b/HLT/libAliHLTTPC.pkg index ef51eda597d..ba46bff6d58 100644 --- a/HLT/libAliHLTTPC.pkg +++ b/HLT/libAliHLTTPC.pkg @@ -103,4 +103,4 @@ PACKCXXFLAGS := ${HLTCXXFLAGS} PACKCFLAGS := ${HLTCLFAGS} PACKDCXXFLAGS:= ${HLTDCXXFLAGS} -EINCLUDE := HLT/TPCLib HLT/BASE TPC RAW +EINCLUDE := HLT/TPCLib HLT/BASE HLT/BASE/util TPC RAW diff --git a/HLT/libAliHLTUtil.pkg b/HLT/libAliHLTUtil.pkg new file mode 100644 index 00000000000..ca52e2ee15f --- /dev/null +++ b/HLT/libAliHLTUtil.pkg @@ -0,0 +1,30 @@ +#-*- Mode: Makefile -*- +# $Id$ + +include $(MODDIR)/hlt.conf + +MODULE_SRCS= AliHLTFilePublisher.cxx \ + AliHLTRootFilePublisherComponent.cxx \ + AliHLTRootFileWriterComponent.cxx \ + AliHLTAgentUtil.cxx + +CLASS_HDRS:= AliHLTFilePublisher.h \ + AliHLTRootFilePublisherComponent.h \ + AliHLTRootFileWriterComponent.h \ + AliHLTAgentUtil.h + +MODULE_HDRS:= $(CLASS_HDRS) + +DHDR:= +CINTAUTOLINK:= 1 + +SRCS:=$(patsubst %,BASE/util/%,$(MODULE_SRCS)) +CINTHDRS:=$(patsubst %,BASE/util/%,$(CLASS_HDRS)) +HDRS:=$(patsubst %,BASE/util/%,$(MODULE_HDRS)) + +EDEFINE := ${HLTDEFS} +PACKCXXFLAGS := ${HLTCXXFLAGS} +PACKCFLAGS := ${HLTCLFAGS} +PACKDCXXFLAGS:= ${HLTDCXXFLAGS} + +EINCLUDE := HLT/BASE HLT/BASE/util STEER RAW diff --git a/HLT/libHLTbase.pkg b/HLT/libHLTbase.pkg index 85fd6c9b4fa..91b07881e3f 100644 --- a/HLT/libHLTbase.pkg +++ b/HLT/libHLTbase.pkg @@ -14,10 +14,11 @@ MODULE_SRCS= AliHLTComponent.cxx \ AliHLTConsumerDescriptor.cxx \ AliHLTDataSource.cxx \ AliHLTDataSink.cxx \ - AliHLTFilePublisher.cxx \ - AliHLTRootFilePublisherComponent.cxx \ - AliHLTRootFileWriterComponent.cxx \ AliHLTFileWriter.cxx \ + AliHLTOfflineInterface.cxx \ + AliHLTOfflineDataSource.cxx \ + AliHLTOfflineDataSink.cxx \ + AliHLTModuleAgent.cxx \ AliHLTMessage.cxx CLASS_HDRS:= AliHLTComponent.h \ @@ -32,10 +33,11 @@ CLASS_HDRS:= AliHLTComponent.h \ AliHLTConsumerDescriptor.h \ AliHLTDataSource.h \ AliHLTDataSink.h \ - AliHLTFilePublisher.h \ - AliHLTRootFilePublisherComponent.h \ - AliHLTRootFileWriterComponent.h \ AliHLTFileWriter.h \ + AliHLTOfflineInterface.h \ + AliHLTOfflineDataSource.h \ + AliHLTOfflineDataSink.h \ + AliHLTModuleAgent.h \ AliHLTMessage.h MODULE_HDRS:= $(CLASS_HDRS) \ -- 2.43.0