Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:15:18

0001 /**
0002  *  @file   PandoraSDK/include/Managers/AlgorithmManager.h
0003  * 
0004  *  @brief  Header file for the algorithm manager class.
0005  * 
0006  *  $Log: $
0007  */
0008 #ifndef PANDORA_ALGORITHM_MANAGER_H
0009 #define PANDORA_ALGORITHM_MANAGER_H 1
0010 
0011 #include "Pandora/PandoraInternal.h"
0012 #include "Pandora/StatusCodes.h"
0013 
0014 namespace pandora
0015 {
0016 
0017 class Algorithm;
0018 class AlgorithmTool;
0019 class AlgorithmFactory;
0020 class AlgorithmToolFactory;
0021 class Pandora;
0022 class TiXmlElement;
0023 class TiXmlHandle;
0024 
0025 //------------------------------------------------------------------------------------------------------------------------------------------
0026 
0027 /**
0028  *  @brief AlgorithmManager class
0029  */
0030 class AlgorithmManager
0031 {
0032 public:
0033     /**
0034      *  @brief  Constructor
0035      * 
0036      *  @param  pPandora address of the associated pandora object
0037      */
0038     AlgorithmManager(const Pandora *const pPandora);
0039 
0040     /**
0041      *  @brief  Destructor
0042      */
0043     ~AlgorithmManager();
0044 
0045     /**
0046      *  @brief  Get the list of algorithms to be run by pandora
0047      *
0048      *  @return address of the list pandora algorithms
0049      */
0050     const StringVector &GetPandoraAlgorithms() const;
0051 
0052 private:
0053     /**
0054      *  @brief  Register an algorithm factory
0055      * 
0056      *  @param  algorithmType the type of algorithm that the factory will create
0057      *  @param  pAlgorithmFactory the address of an algorithm factory instance
0058      */
0059     StatusCode RegisterAlgorithmFactory(const std::string &algorithmType, AlgorithmFactory *const pAlgorithmFactory);
0060 
0061     /**
0062      *  @brief  Register an algorithm tool factory
0063      * 
0064      *  @param  algorithmToolType the type of algorithm tool that the factory will create
0065      *  @param  pAlgorithmToolFactory the address of an algorithm tool factory instance
0066      */
0067     StatusCode RegisterAlgorithmToolFactory(const std::string &algorithmToolType, AlgorithmToolFactory *const pAlgorithmToolFactory);
0068 
0069     /**
0070      *  @brief  Initialize algorithms
0071      * 
0072      *  @param  pXmlHandle address of the relevant xml handle
0073      */
0074     StatusCode InitializeAlgorithms(const TiXmlHandle *const pXmlHandle);
0075 
0076     /**
0077      *  @brief  Create an algorithm, via one of the algorithm factories registered with pandora
0078      * 
0079      *  @param  pXmlElement address of the xml element describing the algorithm type and settings
0080      *  @param  algorithmName to receive the name of the algorithm instance
0081      */
0082     StatusCode CreateAlgorithm(TiXmlElement *const pXmlElement, std::string &algorithmName);
0083 
0084     /**
0085      *  @brief  Create an algorithm tool, via one of the algorithm tool factories registered with pandora
0086      * 
0087      *  @param  pXmlElement address of the xml element describing the algorithm tool type and settings
0088      *  @param  pAlgorithmTool to receive the address of the algorithm tool instance
0089      */
0090     StatusCode CreateAlgorithmTool(TiXmlElement *const pXmlElement, AlgorithmTool *&pAlgorithmTool);
0091 
0092     /**
0093      *  @brief  Find the name of a specific algorithm instance, so that it can be re-used
0094      * 
0095      *  @param  pXmlElement address of the xml element describing the algorithm type and settings
0096      *  @param  algorithmName to receive the name of the algorithm instance
0097      *  @param  xmlInstanceLabel to receive the xml label referring to a specific algorithm instance
0098      */
0099     StatusCode FindSpecificAlgorithmInstance(TiXmlElement *const pXmlElement, std::string &algorithmName, std::string &xmlInstanceLabel) const;
0100 
0101     /**
0102      *  @brief  Call the reset callback in all managed algorithms and algorithm tools
0103      */
0104     StatusCode ResetForNextEvent();
0105 
0106     typedef std::map<const std::string, Algorithm *const> AlgorithmMap;
0107     typedef std::map<const std::string, AlgorithmFactory *const> AlgorithmFactoryMap;
0108     typedef std::map<const std::string, const std::string> SpecificAlgorithmInstanceMap;
0109 
0110     AlgorithmMap                    m_algorithmMap;                     ///< The algorithm map
0111     AlgorithmFactoryMap             m_algorithmFactoryMap;              ///< The algorithm factory map
0112     SpecificAlgorithmInstanceMap    m_specificAlgorithmInstanceMap;     ///< The specific algorithm instance map
0113     StringVector                    m_pandoraAlgorithms;                ///< The ordered list of names of top-level algorithms, to be run by pandora
0114 
0115     typedef std::map<const std::string, AlgorithmToolFactory *const> AlgorithmToolFactoryMap;
0116 
0117     AlgorithmToolVector             m_algorithmToolVector;              ///< The algorithm tool vector
0118     AlgorithmToolFactoryMap         m_algorithmToolFactoryMap;          ///< The algorithm tool factory map
0119 
0120     const Pandora *const            m_pPandora;                         ///< The pandora instance that will run the algorithms
0121 
0122     friend class PandoraApiImpl;
0123     friend class PandoraContentApiImpl;
0124     friend class PandoraImpl;
0125 };
0126 
0127 //------------------------------------------------------------------------------------------------------------------------------------------
0128 
0129 inline const StringVector &AlgorithmManager::GetPandoraAlgorithms() const
0130 {
0131     return m_pandoraAlgorithms;
0132 }
0133 
0134 } // namespace pandora
0135 
0136 #endif // #ifndef PANDORA_ALGORITHM_MANAGER_H