00001
00002 #ifndef HEPMC_WEIGHT_CONTAINER_H
00003 #define HEPMC_WEIGHT_CONTAINER_H
00004
00006
00007
00008
00009
00010
00011
00013
00014 #include "CLHEP/config/CLHEP.h"
00015 #include "CLHEP/config/iostream.h"
00016 #include <vector>
00017
00018 namespace HepMC {
00019
00024 class WeightContainer {
00025
00026 public:
00027 WeightContainer( unsigned int n = 0, const double& value = 0. );
00028 WeightContainer( const std::vector<double>& weights );
00029 WeightContainer( const WeightContainer& in );
00030 virtual ~WeightContainer();
00031
00032 WeightContainer& operator=( const WeightContainer& );
00033 WeightContainer& operator=( const std::vector<double>& in );
00034
00035 void print( std::ostream& ostr = std::cout ) const;
00036
00037 int size() const;
00038 bool empty() const;
00039 void push_back( const double& );
00040 void pop_back();
00041 void clear();
00042
00043 double& operator[]( unsigned int n );
00044 const double& operator[]( unsigned int n ) const;
00045
00046 double& front();
00047 const double& front() const;
00048 double& back();
00049 const double& back() const;
00050
00051 typedef std::vector<double>::iterator iterator;
00052 typedef std::vector<double>::const_iterator const_iterator;
00053 iterator begin();
00054 iterator end();
00055 const_iterator begin() const;
00056 const_iterator end() const;
00057
00058 private:
00059 std::vector<double> m_weights;
00060 };
00061
00063
00065
00066 inline WeightContainer::WeightContainer( unsigned int n,
00067 const double& value )
00068 : m_weights(n,value)
00069 {}
00070
00071 inline WeightContainer::WeightContainer( const std::vector<double>& wgts )
00072 : m_weights(wgts)
00073 {}
00074
00075 inline WeightContainer::WeightContainer( const WeightContainer& in )
00076 : m_weights(in.m_weights)
00077 {}
00078
00079 inline WeightContainer::~WeightContainer() {}
00080
00081 inline WeightContainer& WeightContainer::operator=
00082 ( const WeightContainer& in ) {
00083 m_weights = in.m_weights;
00084 return *this;
00085 }
00086
00087 inline WeightContainer& WeightContainer::operator=
00088 ( const std::vector<double>& in ) {
00089 m_weights = in;
00090 return *this;
00091 }
00092
00093 inline void WeightContainer::print( std::ostream& ostr ) const
00094 {
00095 for ( const_iterator w = begin(); w != end(); ++w )
00096 {
00097 ostr << *w << " ";
00098 }
00099 ostr << std::endl;
00100 }
00101
00102 inline int WeightContainer::size() const { return m_weights.size(); }
00103
00104 inline bool WeightContainer::empty() const { return m_weights.empty(); }
00105
00106 inline void WeightContainer::push_back( const double& value)
00107 { m_weights.push_back(value); }
00108
00109 inline void WeightContainer::pop_back() { m_weights.pop_back(); }
00110
00111 inline void WeightContainer::clear() { m_weights.clear(); }
00112
00113 inline double& WeightContainer::operator[]( unsigned int n )
00114 { return m_weights[(int)n]; }
00115
00116 inline const double& WeightContainer::operator[]( unsigned int n ) const
00117 { return m_weights[(int)n]; }
00118
00119 inline double& WeightContainer::front() { return m_weights.front(); }
00120
00121 inline const double& WeightContainer::front() const
00122 { return m_weights.front(); }
00123
00124 inline double& WeightContainer::back() { return m_weights.back(); }
00125
00126 inline const double& WeightContainer::back() const
00127 { return m_weights.back(); }
00128
00129 inline WeightContainer::iterator WeightContainer::begin()
00130 { return m_weights.begin(); }
00131
00132 inline WeightContainer::iterator WeightContainer::end()
00133 { return m_weights.end(); }
00134
00135 inline WeightContainer::const_iterator WeightContainer::begin() const
00136 { return m_weights.begin(); }
00137
00138 inline WeightContainer::const_iterator WeightContainer::end() const
00139 { return m_weights.end(); }
00140
00141 }
00142
00143 #endif // HEPMC_WEIGHT_CONTAINER_H
00144
00145
00146
00147