6#ifndef HEPMC3_CROSS_SECTION_H
7#define HEPMC3_CROSS_SECTION_H
62 bool to_string(std::string &att)
const override;
67 void set_cross_section(
const double& xs,
const double& xs_err,
const long& n_acc = -1,
const long& n_att = -1);
71 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);
109 void set_xsec(
const std::string& wName,
const double& xs) {
110 int pos =
windx(wName);
111 if ( pos < 0 )
throw std::runtime_error(
"GenCrossSection::set_xsec(const std::string&,const double&): no weight with given name in this run");
118 void set_xsec(
const unsigned long& index,
const double& xs) {
119 if ( index >=
cross_sections.size() ) {
throw std::runtime_error(
"GenCrossSection::set_xsec(const unsigned long&): index outside of range");}
127 int pos =
windx(wName);
128 if ( pos < 0 )
throw std::runtime_error(
"GenCrossSection::set_xsec_err(const std::string&,const double&): no weight with given name in this run");
136 if ( index >=
cross_section_errors.size() ) {
throw std::runtime_error(
"GenCrossSection::set_xsec_err(const unsigned long&): index outside of range");}
143 double xsec(
const std::string& wName)
const {
144 int pos =
windx(wName);
145 if ( pos < 0 )
throw std::runtime_error(
"GenCrossSection::xsec(const std::string&): no weight with given name in this run");
152 double xsec(
const unsigned long& index = 0)
const {
154 else {
throw std::runtime_error(
"GenCrossSection::xsec(const unsigned long&): index outside of range");}
162 int pos =
windx(wName);
163 if ( pos < 0 )
throw std::runtime_error(
"GenCrossSection::xsec_err(const std::string&): no weight with given name in this run");
170 double xsec_err(
const unsigned long& index = 0)
const {
172 else {
throw std::runtime_error(
"GenCrossSection::xsec_err(const unsigned long&): index outside of range");}
183 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_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.