18 #include "HepMC/WeightContainer.h"
23 : m_weights(n,value), m_names()
24 { set_default_names(n); }
27 : m_weights(wgts), m_names()
28 { set_default_names(
size()); }
30 void WeightContainer::set_default_names( size_type n )
33 std::ostringstream name;
34 for (
size_type count = 0; count<n; ++count )
36 name.str(std::string());
38 m_names[name.str()] = count;
45 m_weights.push_back(value);
46 std::ostringstream name;
48 m_names[name.str()] = count;
56 for ( map_iterator m = m_names.begin(); m != m_names.end(); ++m )
58 if( m->second == vit ) {
59 m_names.erase(m->first);
68 const_map_iterator m = m_names.find(s);
69 if( m != m_names.end() ) {
70 return m_weights[m->second];
74 m_weights.push_back(0);
76 return m_weights.back();
82 const_map_iterator m = m_names.find(s);
83 if( m != m_names.end() ) {
84 return m_weights[m->second];
89 throw std::out_of_range(
"const WeightContainer::operator[] ERROR: string "+s+
" not found in WeightContainer" );
94 if(
size() != other.
size() ) {
return false; }
95 if( m_names != other.m_names ) {
return false; }
96 if( m_weights != other.m_weights ) {
return false; }
102 return !(*
this == other );
108 return m_names.find(s) != m_names.end();
114 for ( const_map_iterator m = map_begin(); m != map_end(); ++m )
116 ostr <<
"(" << m->first <<
"," << m_weights[m->second] <<
") ";
127 for ( const_map_iterator m = map_begin(); m != map_end(); ++m )
129 if( m->second == count ) name = m->first;
131 ostr <<
"Weight " << std::setw(4) << count
132 <<
" with name " << std::setw(10) << name
133 <<
" is " << *w << std::endl;
void print(std::ostream &ostr=std::cout) const
print weights
double & operator[](size_type n)
access the weight container
bool operator!=(const WeightContainer &) const
inequality
std::vector< double >::const_iterator const_iterator
const iterator for the weight container
void pop_back()
pop from weight container
void push_back(const double &)
push onto weight container
iterator begin()
begining of the weight container
bool has_key(const std::string &s) const
check to see if a name exists in the map
void write(std::ostream &ostr=std::cout) const
write weights in a readable table
WeightContainer(size_type n=0, double value=0.)
default constructor
std::size_t size_type
defining the size type used by vector and map
iterator end()
end of the weight container
Container for the Weights associated with an event or vertex.
bool operator==(const WeightContainer &) const
equality
size_type size() const
size of weight container