PSEnv/include/Env.h

Go to the documentation of this file.
00001 #ifndef PSENV_ENV_H
00002 #define PSENV_ENV_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: Env.h 9877 2015-04-08 21:15:19Z davidsch@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Class Env.
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 #include <string>
00017 #include <boost/scoped_ptr.hpp>
00018 #include <boost/enable_shared_from_this.hpp>
00019 
00020 //----------------------
00021 // Base Class Headers --
00022 //----------------------
00023 
00024 //-------------------------------
00025 // Collaborating Class Headers --
00026 //-------------------------------
00027 #include "PSEnv/EnvObjectStore.h"
00028 #include "PSEnv/EpicsStore.h"
00029 #include "PSEnv/IExpNameProvider.h"
00030 #include "PSHist/HManager.h"
00031 //------------------------------------
00032 // Collaborating Class Declarations --
00033 //------------------------------------
00034 
00035 //              ---------------------
00036 //              -- Class Interface --
00037 //              ---------------------
00038 
00039 
00040 /**
00041  *  @defgroup PSEnv  PSEnv package
00042  *  
00043  *  @brief PSEnv package contains classes which provide storage and 
00044  *  access to non-event data in the context of psana framework.
00045  *  
00046  *  The core of the package is the Env class which stores other
00047  *  types of objects such as configuration data, EPICS data, etc. 
00048  */
00049 
00050 namespace PSEnv {
00051 
00052 /**
00053  *  @ingroup PSEnv
00054  *  
00055  *  @brief Class representing an environment object for psana jobs.
00056  *  
00057  *  Environment object stores non-event data such as configuration objects, 
00058  *  EPICS data, histogram manager, plus some job-specific information
00059  *  which does not change from event to event.
00060  *
00061  *  This software was developed for the LCLS project.  If you use all or 
00062  *  part of it, please give an appropriate acknowledgment.
00063  *
00064  *  @version \$Id: Env.h 9877 2015-04-08 21:15:19Z davidsch@SLAC.STANFORD.EDU $
00065  *
00066  *  @author Andrei Salnikov
00067  */
00068 
00069 class Env : public boost::enable_shared_from_this<Env>, boost::noncopyable {
00070 public:
00071 
00072   /**
00073    *  @brief Constructor
00074    *
00075    *  @param[in] jobName    Name of the psana job.
00076    *  @param[in] expNameProvider  Object which provides experiment/instrument names.
00077    *  @param[in] calibDir  Name of the calibration directory, can include "{exp}"
00078    *                       and "{instr}" strings which will be replaced with experiment
00079    *                       and instrument names.
00080    *  @param[in] aliasMap  Optional instance of the alias map.
00081    *  @param[in] subproc   Subprocess number.
00082    */
00083   Env (const std::string& jobName,
00084       const boost::shared_ptr<IExpNameProvider>& expNameProvider,
00085       const std::string& calibDir,
00086       const boost::shared_ptr<PSEvt::AliasMap>& aliasMap,
00087       int subproc) ;
00088 
00089   // Destructor
00090   ~Env () ;
00091 
00092   /** 
00093    *  @brief Returns name of the framework. 
00094    *  
00095    *  This method is supposed to be defined across different frameworks. 
00096    *  It returns the name of the current framework, e.g. when client code runs 
00097    *  inside pyana framework it will return string "pyana", inside  psana framework 
00098    *  it will return "psana". This method should be used as a primary mechanism for 
00099    *  distinguishing between different frameworks in cases when client needs to 
00100    *  execute framework-specific code. This method is not very useful in C++ as
00101    *  we have only one C++ framework, but is more useful in Python code which 
00102    *  needs to run inside both pyana and psana.
00103    */
00104   const std::string& fwkName() const { return m_fwkName; }
00105   
00106   /// Returns job name.
00107   const std::string& jobName() const { return m_jobName; }
00108   
00109   /// Returns combination of job name and subprocess index as a string
00110   /// which is unique for all subprocesses in a job..
00111   const std::string& jobNameSub() const { return m_jobNameSub; }
00112 
00113   /// Returns instrument name
00114   const std::string& instrument() const { return m_expNameProvider->instrument(); }
00115 
00116   /// Returns experiment name
00117   const std::string& experiment() const { return m_expNameProvider->experiment(); }
00118 
00119   /// Returns experiment number or 0
00120   unsigned expNum() const { return m_expNameProvider->expNum(); }
00121 
00122   /// Returns sub-process number. In case of multi-processing job it will be a non-negative number
00123   /// ranging from 0 to a total number of sub-processes. In case of single-process job it will return -1.
00124   int subprocess() const { return m_subproc; }
00125 
00126   /// Returns that name of the calibration directory for current
00127   /// instrument/experiment.
00128   const std::string& calibDir() const;
00129 
00130   /// Access to Configuration Store object.
00131   EnvObjectStore& configStore() { return *m_cfgStore; }
00132 
00133   /// Access to Calibration Store object.
00134   EnvObjectStore& calibStore() { return *m_calibStore; }
00135 
00136   /// Access to EPICS Store object.
00137   EpicsStore& epicsStore() { return *m_epicsStore; }
00138 
00139   /// Access to alias map.
00140   boost::shared_ptr<PSEvt::AliasMap> aliasMap() { return m_aliasMap; }
00141 
00142   /// Access to histogram manager.
00143   boost::shared_ptr<PSHist::HManager> hmgr();
00144 
00145 protected:
00146 
00147 private:
00148 
00149   // Data members
00150   std::string m_fwkName;   ///< Framework name
00151   std::string m_jobName;   ///< Job name
00152   std::string m_jobNameSub;   ///< Job name with sub-process index
00153   boost::shared_ptr<PSEvt::AliasMap> m_aliasMap;  ///< Alias map instance
00154   boost::shared_ptr<EnvObjectStore> m_cfgStore;   ///< Pointer to Configuration Store
00155   boost::shared_ptr<EnvObjectStore> m_calibStore;   ///< Pointer to Calibration Store
00156   boost::shared_ptr<EpicsStore> m_epicsStore;  ///< Pointer to EPICS Store
00157   boost::shared_ptr<PSHist::HManager> m_hmgr;  ///< Pointer to histogram manager
00158   bool m_firstHmgrCall;
00159   boost::shared_ptr<IExpNameProvider> m_expNameProvider; ///< Object which provides experiment and instrument names
00160   mutable std::string m_calibDir;              ///< Name of the calibration directory
00161   mutable bool m_calibDirSetup;                ///< Flag set to true after calibration directory name is fixed
00162   int m_subproc;
00163 };
00164 
00165 } // namespace PSEnv
00166 
00167 #endif // PSENV_ENV_H

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7