6#ifndef HEPMC3_CROSS_SECTION_H
7#define HEPMC3_CROSS_SECTION_H
36#include "HepMC3/Attribute.h"
50 long attempted_events;
52 std::vector<double> cross_sections;
53 std::vector<double> cross_section_errors;
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);
81 const std::vector<double>&
xsecs()
const {
return cross_sections; }
85 const std::vector<double>&
xsec_errs()
const {
return cross_section_errors; }
91 accepted_events=n_acc;
97 attempted_events=n_att;
103 return accepted_events;
109 return attempted_events;
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");}
126 cross_sections[index] = xs;
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");}
143 cross_section_errors[index] = xs_err;
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 {
159 if ( index < cross_sections.size() ) {
return cross_sections.at(index); }
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 {
177 if ( index < cross_section_errors.size() ) {
return cross_section_errors.at(index);}
178 else {
throw std::runtime_error(
"GenCrossSection::xsec_err(const unsigned long&): index outside of range");}
189 int windx(
const std::string& wName)
const;
Attribute()
Default constructor.
Stores additional information about cross-section.
const std::vector< double > & xsec_errs() const
Get the cross-section errors.
void set_xsec(const unsigned long &index, const double &xs)
Set the cross section corresponding to the weight with index indx.
void set_attempted_events(const long &n_att)
Set the number of attempted events.
double xsec_err(const unsigned long &index=0) const
Get the cross section error corresponding to the weight with index indx.
bool is_valid() const
Verify that the instance contains non-zero information.
bool operator==(const GenCrossSection &) const
Operator ==.
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.
bool from_string(const std::string &att) override
Implementation of Attribute::from_string.
void set_accepted_events(const long &n_acc)
Set the number of accepted events.
bool operator!=(const GenCrossSection &) const
Operator !=.
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)
Set all fields.
double xsec_err(const std::string &wName) const
Get the cross section error 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_cross_section(const double &xs, const double &xs_err, const long &n_acc=-1, const long &n_att=-1)
Set all fields.
double xsec(const std::string &wName) const
Get the cross section corresponding to the weight named wName.
const std::vector< double > & xsecs() const
Get the cross-sections.
bool to_string(std::string &att) const override
Implementation of Attribute::to_string.
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.
void set_xsec_err(const unsigned long &index, const double &xs_err)
Set the cross section error corresponding to the weight with index indx.