MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
HepMC3::GenCrossSection Class Reference

Stores additional information about cross-section. More...

#include <GenCrossSection.h>

Inheritance diagram for HepMC3::GenCrossSection:
HepMC3::Attribute

Public Member Functions

bool from_string (const std::string &att) override
 Implementation of Attribute::from_string.
 
long get_accepted_events () const
 Get the number of accepted events.
 
long get_attempted_events () const
 Get the number of attempted events.
 
bool is_valid () const
 Verify that the instance contains non-zero information.
 
bool operator!= (const GenCrossSection &) const
 Operator !=.
 
bool operator== (const GenCrossSection &) const
 Operator ==.
 
void set_accepted_events (const long &n_acc)
 Set the number of accepted events.
 
void set_attempted_events (const long &n_att)
 Set the number of attempted events.
 
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.
 
void set_xsec (const std::string &wName, const double &xs)
 Set the cross section 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.
 
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_err (const unsigned long &index, const double &xs_err)
 Set the cross section error corresponding to the weight with index indx.
 
bool to_string (std::string &att) const override
 Implementation of Attribute::to_string.
 
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.
 
double xsec_err (const std::string &wName) const
 Get the cross section error corresponding to the weight named wName.
 
double xsec_err (const unsigned long &index=0) const
 Get the cross section error corresponding to the weight with index indx.
 
const std::vector< double > & xsec_errs () const
 Get the cross-section errors.
 
const std::vector< double > & xsecs () const
 Get the cross-sections.
 
Deprecated functionality
void set_cross_section (const double &xs, const double &xs_err, const long &n_acc=-1, const long &n_att=-1)
 Set all fields.
 
- Public Member Functions inherited from HepMC3::Attribute
 Attribute ()
 Default constructor.
 
virtual ~Attribute ()
 Virtual destructor.
 
const GenEventevent () const
 
virtual bool init ()
 Optionally initialize the attribute after from_string.
 
virtual bool init (const GenRunInfo &)
 Optionally initialize the attribute after from_string.
 
bool is_parsed () const
 Check if this attribute is parsed.
 
GenParticlePtr particle ()
 
ConstGenParticlePtr particle () const
 
const std::string & unparsed_string () const
 Get unparsed string.
 
GenVertexPtr vertex ()
 
ConstGenVertexPtr vertex () const
 

Additional Inherited Members

- Protected Member Functions inherited from HepMC3::Attribute
 Attribute (const std::string &st)
 Protected constructor that allows to set string.
 
void set_is_parsed (bool flag)
 Set is_parsed flag.
 
void set_unparsed_string (const std::string &st)
 Set unparsed string.
 

Detailed Description

Stores additional information about cross-section.

This is an example of event attribute used to store cross-section information

This class is meant to be used to pass, on an event by event basis, the current best guess of the total cross section. It is expected that the final cross section will be stored elsewhere.

  • double cross_section; // cross section in pb.
  • double cross_section_error; // error associated with this cross section.
  • long accepted_events; ///< The number of events generated so far.
  • long attempted_events; ///< The number of events attempted so far.

In addition, several cross sections and related info can be included in case of runs with mulltiple weights.

The units of cross_section and cross_section_error are expected to be pb.

Definition at line 42 of file GenCrossSection.h.

Member Function Documentation

◆ from_string()

bool HepMC3::GenCrossSection::from_string ( const std::string & att)
overridevirtual

Implementation of Attribute::from_string.

Implements HepMC3::Attribute.

◆ get_accepted_events()

long HepMC3::GenCrossSection::get_accepted_events ( ) const
inline

Get the number of accepted events.

Definition at line 102 of file GenCrossSection.h.

102 {
103 return accepted_events;
104 }

◆ get_attempted_events()

long HepMC3::GenCrossSection::get_attempted_events ( ) const
inline

Get the number of attempted events.

Definition at line 108 of file GenCrossSection.h.

108 {
109 return attempted_events;
110 }

◆ set_accepted_events()

void HepMC3::GenCrossSection::set_accepted_events ( const long & n_acc)
inline

Set the number of accepted events.

Definition at line 90 of file GenCrossSection.h.

90 {
91 accepted_events=n_acc;
92 }

◆ set_attempted_events()

void HepMC3::GenCrossSection::set_attempted_events ( const long & n_att)
inline

Set the number of attempted events.

Definition at line 96 of file GenCrossSection.h.

96 {
97 attempted_events=n_att;
98 }

◆ set_cross_section()

void HepMC3::GenCrossSection::set_cross_section ( const double & xs,
const double & xs_err,
const long & n_acc = -1,
const long & n_att = -1 )

Set all fields.

Deprecated
Use set_cross_section(const std::vector<double>& xs, const std::vector<double>& xs_err instead
Parameters
xsCross section
xs_errUncertainty on cross-section
n_accNumber of accepted events
n_attNumber of attempted events

◆ set_xsec() [1/2]

void HepMC3::GenCrossSection::set_xsec ( const std::string & wName,
const double & xs )
inline

Set the cross section corresponding to the weight named wName.

Definition at line 115 of file GenCrossSection.h.

115 {
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");
118 set_xsec(pos, xs);
119 }
void set_xsec(const std::string &wName, const double &xs)
Set the cross section corresponding to the weight named wName.

References set_xsec().

Referenced by set_xsec().

◆ set_xsec() [2/2]

void HepMC3::GenCrossSection::set_xsec ( const unsigned long & index,
const double & xs )
inline

Set the cross section corresponding to the weight with index indx.

Definition at line 124 of file GenCrossSection.h.

124 {
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;
127 }

◆ set_xsec_err() [1/2]

void HepMC3::GenCrossSection::set_xsec_err ( const std::string & wName,
const double & xs_err )
inline

Set the cross section error corresponding to the weight named wName.

Definition at line 132 of file GenCrossSection.h.

132 {
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");
135 set_xsec_err(pos, xs_err);
136 }
void set_xsec_err(const std::string &wName, const double &xs_err)
Set the cross section error corresponding to the weight named wName.

References set_xsec_err().

Referenced by set_xsec_err().

◆ set_xsec_err() [2/2]

void HepMC3::GenCrossSection::set_xsec_err ( const unsigned long & index,
const double & xs_err )
inline

Set the cross section error corresponding to the weight with index indx.

Definition at line 141 of file GenCrossSection.h.

141 {
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;
144 }

◆ to_string()

bool HepMC3::GenCrossSection::to_string ( std::string & att) const
overridevirtual

Implementation of Attribute::to_string.

Implements HepMC3::Attribute.

◆ xsec() [1/2]

double HepMC3::GenCrossSection::xsec ( const std::string & wName) const
inline

Get the cross section corresponding to the weight named wName.

Definition at line 149 of file GenCrossSection.h.

149 {
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");
152 return xsec(pos);
153 }
double xsec(const std::string &wName) const
Get the cross section corresponding to the weight named wName.

References xsec().

Referenced by xsec().

◆ xsec() [2/2]

double HepMC3::GenCrossSection::xsec ( const unsigned long & index = 0) const
inline

Get the cross section corresponding to the weight with index indx.

Definition at line 158 of file GenCrossSection.h.

158 {
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");}
161 return 0.0;
162 }

◆ xsec_err() [1/2]

double HepMC3::GenCrossSection::xsec_err ( const std::string & wName) const
inline

Get the cross section error corresponding to the weight named wName.

Definition at line 167 of file GenCrossSection.h.

167 {
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");
170 return xsec_err(pos);
171 }
double xsec_err(const std::string &wName) const
Get the cross section error corresponding to the weight named wName.

References xsec_err().

Referenced by xsec_err().

◆ xsec_err() [2/2]

double HepMC3::GenCrossSection::xsec_err ( const unsigned long & index = 0) const
inline

Get the cross section error corresponding to the weight with index indx.

Definition at line 176 of file GenCrossSection.h.

176 {
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");}
179 return 0.0;
180 }

◆ xsec_errs()

const std::vector< double > & HepMC3::GenCrossSection::xsec_errs ( ) const
inline

Get the cross-section errors.

Definition at line 85 of file GenCrossSection.h.

85{ return cross_section_errors; }

◆ xsecs()

const std::vector< double > & HepMC3::GenCrossSection::xsecs ( ) const
inline

Get the cross-sections.

Definition at line 81 of file GenCrossSection.h.

81{ return cross_sections; }

The documentation for this class was generated from the following file: