6#ifndef HEPMC3_CROSS_SECTION_H
7#define HEPMC3_CROSS_SECTION_H
62 bool to_string(std::string &att)
const override;
73 void set_cross_section(
const double& xs,
const double& xs_err,
const long& n_acc = -1,
const long& n_att = -1);
77 void set_cross_section(
const std::vector<double>& xs,
const std::vector<double>& xs_err,
const long& n_acc = -1,
const long& n_att = -1);
115 void set_xsec(
const std::string& wName,
const double& xs) {
116 int pos =
windx(wName);
117 if ( pos < 0 )
throw std::runtime_error(
"GenCrossSection::set_xsec(const std::string&,const double&): no weight with given name in this run");
124 void set_xsec(
const unsigned long& index,
const double& xs) {
125 if ( index >=
cross_sections.size() ) {
throw std::runtime_error(
"GenCrossSection::set_xsec(const unsigned long&): index outside of range");}
133 int pos =
windx(wName);
134 if ( pos < 0 )
throw std::runtime_error(
"GenCrossSection::set_xsec_err(const std::string&,const double&): no weight with given name in this run");
142 if ( index >=
cross_section_errors.size() ) {
throw std::runtime_error(
"GenCrossSection::set_xsec_err(const unsigned long&): index outside of range");}
149 double xsec(
const std::string& wName)
const {
150 int pos =
windx(wName);
151 if ( pos < 0 )
throw std::runtime_error(
"GenCrossSection::xsec(const std::string&): no weight with given name in this run");
158 double xsec(
const unsigned long& index = 0)
const {
160 else {
throw std::runtime_error(
"GenCrossSection::xsec(const unsigned long&): index outside of range");}
168 int pos =
windx(wName);
169 if ( pos < 0 )
throw std::runtime_error(
"GenCrossSection::xsec_err(const std::string&): no weight with given name in this run");
176 double xsec_err(
const unsigned long& index = 0)
const {
178 else {
throw std::runtime_error(
"GenCrossSection::xsec_err(const unsigned long&): index outside of range");}
189 int windx(
const std::string& wName)
const;
Definition of class Attribute, class IntAttribute and class StringAttribute.
Attribute()
Default constructor.
Stores additional information about cross-section.
double xsec(const std::string &wName) const
Get the cross section corresponding to the weight named wName.
double xsec(const unsigned long &index=0) const
Get the cross section corresponding to the weight with index indx.
long get_accepted_events() const
Get the number of accepted events.
long attempted_events
The number of events attempted so far.
void set_xsec_err(const unsigned long &index, const double &xs_err)
Set the cross section error corresponding to the weight with index indx.
std::vector< double > cross_section_errors
Per-weight errors.
void set_attempted_events(const long &n_att)
Set the number of attempted events.
void set_cross_section(const double &xs, const double &xs_err, const long &n_acc=-1, const long &n_att=-1)
Set all fields.
void set_accepted_events(const long &n_acc)
Set the number of accepted events.
const std::vector< double > & xsecs() const
Get the cross-sections.
std::vector< double > cross_sections
Per-weight cross-section.
bool is_valid() const
Verify that the instance contains non-zero information.
const std::vector< double > & xsec_errs() const
Get the cross-section errors.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
double xsec_err(const std::string &wName) const
Get the cross section error corresponding to the weight named wName.
bool operator==(const GenCrossSection &) const
Operator ==.
bool operator!=(const GenCrossSection &) const
Operator !=.
int windx(const std::string &wName) const
get the weight index given a weight name.
double xsec_err(const unsigned long &index=0) const
Get the cross section error corresponding to the weight with index indx.
long get_attempted_events() const
Get the number of attempted events.
void set_xsec(const std::string &wName, const double &xs)
Set the cross section corresponding to the weight named wName.
void set_xsec_err(const std::string &wName, const double &xs_err)
Set the cross section error corresponding to the weight named wName.
void set_xsec(const unsigned long &index, const double &xs)
Set the cross section corresponding to the weight with index indx.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
long accepted_events
The number of events generated so far.