HepMC3 event record library
GenCrossSection Class Reference

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.

Examples
HepMC3_fileIO_example.cc, and basic_tree.cc.

Definition at line 42 of file GenCrossSection.h.

#include <GenCrossSection.h>

+ Inheritance diagram for GenCrossSection:
+ Collaboration diagram for GenCrossSection:

Public Member Functions

bool from_string (const std::string &att) override
 Implementation of Attribute::from_string.
 
bool to_string (std::string &att) const override
 Implementation of Attribute::to_string.
 
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.
 
const std::vector< double > & xsecs () const
 Get the cross-sections.
 
const std::vector< double > & xsec_errs () const
 Get the cross-section errors.
 
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.
 
long get_accepted_events () const
 Get the number of accepted events.
 
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 (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.
 
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.
 
bool operator== (const GenCrossSection &) const
 Operator ==.
 
bool operator!= (const GenCrossSection &) const
 Operator !=.
 
bool is_valid () const
 Verify that the instance contains non-zero information.
 
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.
 
const std::string & unparsed_string () const
 Get unparsed string.
 
const GenEventevent () const
 
GenParticlePtr particle ()
 
ConstGenParticlePtr particle () const
 
GenVertexPtr vertex ()
 
ConstGenVertexPtr vertex () const
 
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.
 

Protected Member Functions

void set_is_parsed (bool flag)
 Set is_parsed flag.
 
void set_unparsed_string (const std::string &st)
 Set unparsed string.
 

Private Member Functions

int windx (const std::string &wName) const
 get the weight index given a weight name.
 

Private Attributes

long accepted_events
 The number of events generated so far.
 
long attempted_events
 The number of events attempted so far.
 
std::vector< double > cross_sections
 Per-weight cross-section.
 
std::vector< double > cross_section_errors
 Per-weight errors.
 
bool m_is_parsed
 Is this attribute parsed?
 
std::string m_string
 Raw (unparsed) string.
 
const GenEventm_event
 
GenParticlePtr m_particle
 controlling GenEvent object.
 
GenVertexPtr m_vertex
 Vertex to which assigned.
 

Member Function Documentation

◆ event()

const GenEvent * event ( ) const
inlineinherited

return the GenEvent to which this Attribute belongs, if at all.

Definition at line 108 of file Attribute.h.

References GenEvent, and m_event.

◆ from_string()

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

◆ get_accepted_events()

long get_accepted_events ( ) const
inline

Get the number of accepted events.

Definition at line 102 of file GenCrossSection.h.

References accepted_events.

◆ get_attempted_events()

long get_attempted_events ( ) const
inline

Get the number of attempted events.

Definition at line 108 of file GenCrossSection.h.

References attempted_events.

◆ init() [1/2]

virtual bool init ( )
inlinevirtualinherited

Optionally initialize the attribute after from_string.

Reimplemented in HEPEUPAttribute.

Definition at line 81 of file Attribute.h.

◆ init() [2/2]

virtual bool init ( const GenRunInfo & )
inlinevirtualinherited

Optionally initialize the attribute after from_string.

Is passed a reference to the GenRunInfo object to which the Attribute belongs.

Reimplemented in HEPEUPAttribute.

Definition at line 90 of file Attribute.h.

◆ is_parsed()

bool is_parsed ( ) const
inlineinherited

Check if this attribute is parsed.

Definition at line 102 of file Attribute.h.

References m_is_parsed.

◆ is_valid()

bool is_valid ( ) const

Verify that the instance contains non-zero information.

Definition at line 121 of file GenCrossSection.cc.

References cross_section_errors, and cross_sections.

◆ operator!=()

bool operator!= ( const GenCrossSection & a) const

Operator !=.

Definition at line 117 of file GenCrossSection.cc.

◆ operator==()

bool operator== ( const GenCrossSection & a) const

Operator ==.

Definition at line 113 of file GenCrossSection.cc.

◆ particle() [1/2]

GenParticlePtr particle ( )
inlineinherited

return the GenParticle to which this Attribute belongs, if at all.

Definition at line 113 of file Attribute.h.

References m_particle.

◆ particle() [2/2]

ConstGenParticlePtr particle ( ) const
inlineinherited

return the GenParticle to which this Attribute belongs, if at all.

Definition at line 118 of file Attribute.h.

References m_particle.

◆ set_accepted_events()

void set_accepted_events ( const long & n_acc)
inline

Set the number of accepted events.

Definition at line 90 of file GenCrossSection.h.

References accepted_events.

◆ set_attempted_events()

void set_attempted_events ( const long & n_att)
inline

Set the number of attempted events.

Definition at line 96 of file GenCrossSection.h.

References attempted_events.

◆ set_cross_section() [1/2]

void 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

Definition at line 28 of file GenCrossSection.cc.

References accepted_events, attempted_events, cross_section_errors, cross_sections, and Attribute::event().

◆ set_cross_section() [2/2]

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.

Definition at line 39 of file GenCrossSection.cc.

References accepted_events, attempted_events, cross_section_errors, and cross_sections.

◆ set_is_parsed()

void set_is_parsed ( bool flag)
inlineprotectedinherited

Set is_parsed flag.

Definition at line 134 of file Attribute.h.

References m_is_parsed.

◆ set_unparsed_string()

void set_unparsed_string ( const std::string & st)
inlineprotectedinherited

Set unparsed string.

Definition at line 137 of file Attribute.h.

References m_string.

◆ set_xsec() [1/2]

void 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.

References set_xsec(), and windx().

◆ set_xsec() [2/2]

void 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.

References cross_sections.

◆ set_xsec_err() [1/2]

void 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.

References set_xsec_err(), and windx().

◆ set_xsec_err() [2/2]

void 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.

References cross_section_errors.

◆ to_string()

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

◆ unparsed_string()

const std::string & unparsed_string ( ) const
inlineinherited

Get unparsed string.

Definition at line 105 of file Attribute.h.

References m_string.

◆ vertex() [1/2]

GenVertexPtr vertex ( )
inlineinherited

return the GenVertex to which this Attribute belongs, if at all.

Definition at line 123 of file Attribute.h.

References m_vertex.

◆ vertex() [2/2]

ConstGenVertexPtr vertex ( ) const
inlineinherited

return the GenVertex to which this Attribute belongs, if at all.

Definition at line 128 of file Attribute.h.

References m_vertex.

◆ windx()

int windx ( const std::string & wName) const
private

get the weight index given a weight name.

Definition at line 23 of file GenCrossSection.cc.

References Attribute::event(), and GenEvent::run_info().

◆ xsec() [1/2]

double 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.

References windx(), and xsec().

◆ xsec() [2/2]

double 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.

References cross_sections.

◆ xsec_err() [1/2]

double 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.

References windx(), and xsec_err().

◆ xsec_err() [2/2]

double 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.

References cross_section_errors.

◆ xsec_errs()

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

Get the cross-section errors.

Definition at line 85 of file GenCrossSection.h.

References cross_section_errors.

◆ xsecs()

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

Get the cross-sections.

Definition at line 81 of file GenCrossSection.h.

References cross_sections.

Field Documentation

◆ accepted_events

long accepted_events
private

The number of events generated so far.

Definition at line 49 of file GenCrossSection.h.

◆ attempted_events

long attempted_events
private

The number of events attempted so far.

Definition at line 50 of file GenCrossSection.h.

◆ cross_section_errors

std::vector<double> cross_section_errors
private

Per-weight errors.

Definition at line 53 of file GenCrossSection.h.

◆ cross_sections

std::vector<double> cross_sections
private

Per-weight cross-section.

Definition at line 52 of file GenCrossSection.h.

◆ m_event

const GenEvent* m_event
privateinherited

Possibility to be aware of the

Definition at line 145 of file Attribute.h.

◆ m_is_parsed

bool m_is_parsed
privateinherited

Is this attribute parsed?

Definition at line 143 of file Attribute.h.

◆ m_particle

GenParticlePtr m_particle
privateinherited

controlling GenEvent object.

Particle to which assigned.

Definition at line 147 of file Attribute.h.

◆ m_string

std::string m_string
privateinherited

Raw (unparsed) string.

Definition at line 144 of file Attribute.h.

◆ m_vertex

GenVertexPtr m_vertex
privateinherited

Vertex to which assigned.

Definition at line 148 of file Attribute.h.


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