cspad_mod/include/CalibDataProxy.h

Go to the documentation of this file.
00001 #ifndef CSPAD_MOD_CALIBDATAPROXY_H
00002 #define CSPAD_MOD_CALIBDATAPROXY_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: CalibDataProxy.h 2904 2012-02-08 22:19:48Z salnikov@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Class CalibDataProxy.
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 #include <string>
00017 #include <map>
00018 
00019 //----------------------
00020 // Base Class Headers --
00021 //----------------------
00022 #include "PSEvt/Proxy.h"
00023 
00024 //-------------------------------
00025 // Collaborating Class Headers --
00026 //-------------------------------
00027 
00028 //------------------------------------
00029 // Collaborating Class Declarations --
00030 //------------------------------------
00031 
00032 //              ---------------------
00033 //              -- Class Interface --
00034 //              ---------------------
00035 
00036 namespace cspad_mod {
00037 
00038 /// @addtogroup cspad_mod
00039 
00040 /**
00041  *  @ingroup cspad_mod
00042  *
00043  *  @brief Proxy class for calibration data
00044  *
00045  *
00046  *
00047  *  This software was developed for the LCLS project.  If you use all or 
00048  *  part of it, please give an appropriate acknowledgment.
00049  *
00050  *  @see AdditionalClass
00051  *
00052  *  @version $Id: CalibDataProxy.h 2904 2012-02-08 22:19:48Z salnikov@SLAC.STANFORD.EDU $
00053  *
00054  *  @author Andy Salnikov
00055  */
00056 
00057 template <typename T>
00058 class CalibDataProxy : public PSEvt::Proxy<T> {
00059 public:
00060 
00061   /**
00062    *   Make new proxy instance
00063    *
00064    *   @param[in] calibDir   Experiment calibration directory
00065    *   @param[in] calibType  Type of object such as "pedestals" or "common_mode"
00066    *   @param[in] run        Run number
00067    */
00068   CalibDataProxy (const std::string& calibDir, const std::string& calibType, int run);
00069 
00070   virtual ~CalibDataProxy ();
00071 
00072   /**
00073    *  @brief Get the correctly-typed object from the proxy.
00074    *
00075    *  @param[in] dict    Proxy dictionary containing this proxy.
00076    *  @param[in] source Detector address information
00077    *  @param[in] key     String key, additional key supplied by user.
00078    *  @return Shared pointer of the correct type.
00079    */
00080   virtual boost::shared_ptr<T> getTypedImpl(PSEvt::ProxyDictI* dict,
00081                                             const Pds::Src& source,
00082                                             const std::string& key);
00083 
00084 protected:
00085 
00086 private:
00087 
00088   // helper class to make Pds::Src usable as a key
00089   struct _Src {
00090     _Src(const Pds::Src& asrc) : src(asrc) {}
00091 
00092     bool operator<(const _Src rhs) const {
00093       // ignore PID in comparison
00094       if (src.level() == rhs.src.level()) {
00095         return src.phy() < rhs.src.phy();
00096       }
00097       return src.level() < rhs.src.level();
00098     }
00099 
00100     Pds::Src src;
00101   };
00102 
00103   typedef std::map<_Src, boost::shared_ptr<T> > Src2Data;
00104 
00105   // Data members
00106   const std::string m_calibDir;
00107   const std::string m_calibType;
00108   int m_run;
00109   Src2Data m_data;
00110 
00111 };
00112 
00113 } // namespace cspad_mod
00114 
00115 #endif // CSPAD_MOD_CALIBDATAPROXY_H

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7