psddl_hdf2psana/include/acqiris.h

Go to the documentation of this file.
00001 #ifndef PSDDL_HDF2PSANA_ACQIRIS_H
00002 #define PSDDL_HDF2PSANA_ACQIRIS_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: acqiris.h 7035 2013-10-31 19:57:40Z salnikov@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Hand-written supporting types for DDL-HDF5 mapping.
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 
00017 //----------------------
00018 // Base Class Headers --
00019 //----------------------
00020 
00021 //-------------------------------
00022 // Collaborating Class Headers --
00023 //-------------------------------
00024 #include "hdf5pp/Group.h"
00025 #include "hdf5pp/Type.h"
00026 #include "psddl_psana/acqiris.ddl.h"
00027 #include "psddl_hdf2psana/acqiris.ddl.h"
00028 #include "psddl_hdf2psana/ChunkPolicy.h"
00029 
00030 namespace psddl_hdf2psana {
00031 namespace Acqiris {
00032 
00033 
00034 template <typename Config>
00035 class DataDescV1Elem_v0 : public Psana::Acqiris::DataDescV1Elem {
00036 public:
00037   typedef Psana::Acqiris::DataDescV1Elem PsanaType;
00038 
00039   DataDescV1Elem_v0() {}
00040   DataDescV1Elem_v0(const ndarray<const Psana::Acqiris::TimestampV1, 1>& ds_timestamp,
00041       const ndarray<const int16_t, 2>& ds_waveforms,
00042       const boost::shared_ptr<Config>& cfg)
00043     : m_cfg(cfg), m_ds_timestamp(ds_timestamp), m_ds_waveforms(ds_waveforms) {}
00044 
00045   virtual ~DataDescV1Elem_v0() {}
00046 
00047   virtual uint32_t nbrSamplesInSeg() const { return m_cfg->horiz().nbrSamples(); }
00048   virtual uint32_t indexFirstPoint() const { return 0; }
00049   virtual uint32_t nbrSegments() const { return m_cfg->horiz().nbrSegments(); }
00050   virtual ndarray<const Psana::Acqiris::TimestampV1, 1> timestamp() const { return m_ds_timestamp; }
00051   virtual ndarray<const int16_t, 2> waveforms() const { return m_ds_waveforms; }
00052 
00053 private:
00054 
00055   boost::shared_ptr<Config> m_cfg;
00056   mutable ndarray<const Psana::Acqiris::TimestampV1, 1> m_ds_timestamp;
00057   mutable ndarray<const int16_t, 2> m_ds_waveforms;
00058 };
00059 
00060 
00061 
00062 template <typename Config>
00063 class DataDescV1_v0 : public Psana::Acqiris::DataDescV1 {
00064 public:
00065   typedef Psana::Acqiris::DataDescV1 PsanaType;
00066 
00067   DataDescV1_v0() {}
00068   DataDescV1_v0(hdf5pp::Group group, hsize_t idx, const boost::shared_ptr<Config>& cfg)
00069     : m_group(group), m_idx(idx), m_cfg(cfg) {}
00070 
00071   virtual ~DataDescV1_v0() {}
00072 
00073   /** Waveform data, one object per channel. */
00074   virtual const Psana::Acqiris::DataDescV1Elem& data(uint32_t i0) const;
00075   /** Method which returns the shape (dimensions) of the data returned by data() method. */
00076   virtual std::vector<int> data_shape() const;
00077 
00078 private:
00079 
00080   mutable hdf5pp::Group m_group;
00081   hsize_t m_idx;
00082   boost::shared_ptr<Config> m_cfg;
00083 
00084   mutable ndarray<DataDescV1Elem_v0<Config>, 1> m_ds_data;
00085   void read_ds_data() const;
00086 
00087 };
00088 
00089 void make_datasets_DataDescV1_v0(const Psana::Acqiris::DataDescV1& obj,
00090       hdf5pp::Group group, const ChunkPolicy& chunkPolicy, int deflate, bool shuffle);
00091 void store_DataDescV1_v0(const Psana::Acqiris::DataDescV1* obj, hdf5pp::Group group, long index, bool append);
00092 
00093 
00094 namespace ns_DataDescV1Elem_v1 {
00095 struct dataset_data {
00096 
00097   static hdf5pp::Type native_type();
00098   static hdf5pp::Type stored_type();
00099   
00100   dataset_data() {}
00101   dataset_data(const Psana::Acqiris::DataDescV1Elem& psanaobj);
00102 
00103   uint32_t nbrSamplesInSeg;
00104   uint32_t indexFirstPoint;
00105   uint32_t nbrSegments;
00106 
00107 };
00108 }
00109 
00110 template <typename Config>
00111 class DataDescV1Elem_v1 : public Psana::Acqiris::DataDescV1Elem {
00112 public:
00113   typedef Psana::Acqiris::DataDescV1Elem PsanaType;
00114 
00115   DataDescV1Elem_v1() {}
00116   DataDescV1Elem_v1(const ndarray<const Psana::Acqiris::TimestampV1, 1>& ds_timestamp,
00117       const ndarray<const int16_t, 2>& ds_waveforms,
00118       const ns_DataDescV1Elem_v1::dataset_data& ds_data)
00119     : m_ds_data(ds_data), m_ds_timestamp(ds_timestamp), m_ds_waveforms(ds_waveforms) {}
00120 
00121   virtual ~DataDescV1Elem_v1() {}
00122 
00123   virtual uint32_t nbrSamplesInSeg() const { return m_ds_data.nbrSamplesInSeg; }
00124   virtual uint32_t indexFirstPoint() const { return m_ds_data.indexFirstPoint; }
00125   virtual uint32_t nbrSegments() const { return m_ds_data.nbrSegments; }
00126   virtual ndarray<const Psana::Acqiris::TimestampV1, 1> timestamp() const { return m_ds_timestamp; }
00127   virtual ndarray<const int16_t, 2> waveforms() const { return m_ds_waveforms; }
00128 
00129 private:
00130 
00131   ns_DataDescV1Elem_v1::dataset_data m_ds_data;
00132   mutable ndarray<const Psana::Acqiris::TimestampV1, 1> m_ds_timestamp;
00133   mutable ndarray<const int16_t, 2> m_ds_waveforms;
00134 };
00135 
00136 
00137 
00138 template <typename Config>
00139 class DataDescV1_v1 : public Psana::Acqiris::DataDescV1 {
00140 public:
00141   typedef Psana::Acqiris::DataDescV1 PsanaType;
00142 
00143   DataDescV1_v1() {}
00144   DataDescV1_v1(hdf5pp::Group group, hsize_t idx, const boost::shared_ptr<Config>& cfg)
00145     : m_group(group), m_idx(idx), m_cfg(cfg) {}
00146 
00147   virtual ~DataDescV1_v1() {}
00148 
00149   /** Waveform data, one object per channel. */
00150   virtual const Psana::Acqiris::DataDescV1Elem& data(uint32_t i0) const;
00151 
00152   /** Method which returns the shape (dimensions) of the data returned by data() method. */
00153   virtual std::vector<int> data_shape() const;
00154 
00155 private:
00156 
00157   mutable hdf5pp::Group m_group;
00158   hsize_t m_idx;
00159   boost::shared_ptr<Config> m_cfg;
00160 
00161   mutable ndarray<DataDescV1Elem_v1<Config>, 1> m_ds_data;
00162   void read_ds_data() const;
00163 
00164 };
00165 
00166 void make_datasets_DataDescV1_v1(const Psana::Acqiris::DataDescV1& obj,
00167       hdf5pp::Group group, const ChunkPolicy& chunkPolicy, int deflate, bool shuffle);
00168 void store_DataDescV1_v1(const Psana::Acqiris::DataDescV1* obj, hdf5pp::Group group, long index, bool append);
00169 
00170 
00171 } // namespace Acqiris
00172 } // namespace psddl_hdf2psana
00173 
00174 #endif // PSDDL_HDF2PSANA_ACQIRIS_H

Generated on 19 Dec 2016 for PSDMSoftware by  doxygen 1.4.7