HepMC3 event record library: GenRunInfo Class Reference

HepMC3 event record library

Data Structures | Public Member Functions
GenRunInfo Class Reference

## Detailed Description

Stores run-related information.

Manages run-related information. Contains run-wide attributes

Examples
  class_example_write.cc.

Definition at line 33 of file GenRunInfo.h.

`#include <GenRunInfo.h>`

Collaboration diagram for GenRunInfo:
[legend]

## Data Structures
struct | ToolInfo
| Interrnal struct for keeping track of tools. More...

## Public Member Functions
| GenRunInfo ()
| Default constructor.
| GenRunInfo (const GenRunInfo &r)
| Copy constructor.
GenRunInfo & | operator= (const GenRunInfo &r)
| Assignmet.
const std::vector< ToolInfo > & | tools () const
| The vector of tools used to produce this run.
std::vector< ToolInfo > & | tools ()
| The vector of tools used to produce this run.
bool | has_weight (const std::string &name) const
| Check if a weight name is present.
std::map< std::string, int > | weight_indices () const
| Returns a copy of indices map.
int | weight_index (const std::string &name) const
| Return the index corresponding to a weight name.
const std::vector< std::string > & | weight_names () const
| Get the vector of weight names.
void | set_weight_names (const std::vector< std::string > &names)
| Set the names of the weights in this run.
void | add_attribute (const std::string &name, const std::shared_ptr< Attribute > &att)
| add an attribute This will overwrite existing attribute if an attribute with the same name is present
void | remove_attribute (const std::string &name)
| Remove attribute.
template<class T>
std::shared_ptr< T > | attribute (const std::string &name) const
| Get attribute of type T.
std::string | attribute_as_string (const std::string &name) const
| Get attribute of any type as string.
std::vector< std::string > | attribute_names () const
| Get list of attribute names.
std::map< std::string, std::shared_ptr< Attribute > > | attributes () const
| Get a copy of the list of attributes.
Methods to fill GenRunInfoData and to read it back
void | write_data (GenRunInfoData &data) const
| Fill GenRunInfoData object.
void | read_data (const GenRunInfoData &data)
| Fill GenRunInfo based on GenRunInfoData.

## Private Attributes
Fields
std::vector< ToolInfo > | m_tools
| The vector of tools used to produce this run.
std::map< std::string, int > | m_weight_indices
| A map of weight names mapping to indices.
std::vector< std::string > | m_weight_names
| A vector of weight names.
std::map< std::string, std::shared_ptr< Attribute > > | m_attributes
| Map of attributes.
std::recursive_mutex | m_lock_attributes
| Mutex lock for the m_attibutes map.

## Constructor & Destructor Documentation

## ◆ GenRunInfo() [1/2]

GenRunInfo | ( |  | ) |
| inline

Default constructor.

Definition at line 54 of file GenRunInfo.h.

## ◆ GenRunInfo() [2/2]

GenRunInfo | ( | const GenRunInfo & | r | ) |

Copy constructor.

Definition at line 107 of file GenRunInfo.cc.

References GenRunInfo(), m_lock_attributes, read_data(), and write_data().

## Member Function Documentation

## ◆ add_attribute()

void add_attribute | ( | const std::string & | name,
|  | const std::shared_ptr< Attribute > & | att )
| inline

add an attribute This will overwrite existing attribute if an attribute with the same name is present

Definition at line 102 of file GenRunInfo.h.

References m_attributes, and m_lock_attributes.

## ◆ attribute()

template<class T>

std::shared_ptr< T > attribute | ( | const std::string & | name | ) | const

Get attribute of type T.

Definition at line 181 of file GenRunInfo.h.

References m_attributes, and m_lock_attributes.

## ◆ attribute_as_string()

std::string attribute_as_string | ( | const std::string & | name | ) | const

Get attribute of any type as string.

Definition at line 40 of file GenRunInfo.cc.

References m_attributes, and m_lock_attributes.

## ◆ attribute_names()

std::vector< std::string > attribute_names | ( |  | ) | const

Get list of attribute names.

Definition at line 77 of file GenRunInfo.cc.

References m_attributes.

## ◆ attributes()

std::map< std::string, std::shared_ptr< Attribute > > attributes | ( |  | ) | const
| inline

Get a copy of the list of attributes.

Note
  To avoid thread issues, this is returns a copy. Better solution may be needed.

Definition at line 126 of file GenRunInfo.h.

References m_attributes.

## ◆ has_weight()

bool has_weight | ( | const std::string & | name | ) | const
| inline

Check if a weight name is present.

Definition at line 72 of file GenRunInfo.h.

References m_weight_indices.

## ◆ operator=()

GenRunInfo & operator= | ( | const GenRunInfo & | r | ) |

Assignmet.

Definition at line 119 of file GenRunInfo.cc.

References GenRunInfo(), m_lock_attributes, read_data(), and write_data().

## ◆ read_data()

void read_data | ( | const GenRunInfoData & | data | ) |

Fill GenRunInfo based on GenRunInfoData.

Definition at line 86 of file GenRunInfo.cc.

References add_attribute(), GenRunInfoData::attribute_name, GenRunInfoData::attribute_string, GenRunInfo::ToolInfo::description, GenRunInfo::ToolInfo::name, set_weight_names(), GenRunInfoData::tool_description, GenRunInfoData::tool_name, GenRunInfoData::tool_version, tools(), GenRunInfo::ToolInfo::version, and GenRunInfoData::weight_names.

## ◆ remove_attribute()

void remove_attribute | ( | const std::string & | name | ) |
| inline

Remove attribute.

Definition at line 109 of file GenRunInfo.h.

References m_attributes, and m_lock_attributes.

## ◆ set_weight_names()

void set_weight_names | ( | const std::vector< std::string > & | names | ) |

Set the names of the weights in this run.

For consistency, the length of the vector should be the same as the number of weights in the events in the run.

Definition at line 20 of file GenRunInfo.cc.

References has_weight(), m_weight_indices, and m_weight_names.

## ◆ tools() [1/2]

std::vector< ToolInfo > & tools | ( |  | ) |
| inline

The vector of tools used to produce this run.

Definition at line 67 of file GenRunInfo.h.

References m_tools.

## ◆ tools() [2/2]

const std::vector< ToolInfo > & tools | ( |  | ) | const
| inline

The vector of tools used to produce this run.

Definition at line 63 of file GenRunInfo.h.

References m_tools.

## ◆ weight_index()

int weight_index | ( | const std::string & | name | ) | const
| inline

Return the index corresponding to a weight name.

Returns
  -1 if name was not found

Definition at line 83 of file GenRunInfo.h.

References m_weight_indices.

## ◆ weight_indices()

std::map< std::string, int > weight_indices | ( |  | ) | const
| inline

Returns a copy of indices map.

Definition at line 77 of file GenRunInfo.h.

References m_weight_indices.

## ◆ weight_names()

const std::vector< std::string > & weight_names | ( |  | ) | const
| inline

Get the vector of weight names.

Definition at line 89 of file GenRunInfo.h.

References m_weight_names.

## ◆ write_data()

void write_data | ( | GenRunInfoData & | data | ) | const

Fill GenRunInfoData object.

Definition at line 53 of file GenRunInfo.cc.

References GenRunInfoData::attribute_name, GenRunInfoData::attribute_string, m_attributes, GenRunInfoData::tool_description, GenRunInfoData::tool_name, GenRunInfoData::tool_version, tools(), weight_names(), and GenRunInfoData::weight_names.

## Field Documentation

## ◆ m_attributes

std::map< std::string, std::shared_ptr<Attribute> > m_attributes
| mutableprivate

Map of attributes.

Definition at line 165 of file GenRunInfo.h.

## ◆ m_lock_attributes

std::recursive_mutex m_lock_attributes
| mutableprivate

Mutex lock for the m_attibutes map.

Definition at line 168 of file GenRunInfo.h.

## ◆ m_tools

std::vector<ToolInfo> m_tools
| private

The vector of tools used to produce this run.

Definition at line 156 of file GenRunInfo.h.

## ◆ m_weight_indices

std::map<std::string, int> m_weight_indices
| private

A map of weight names mapping to indices.

Definition at line 159 of file GenRunInfo.h.

## ◆ m_weight_names

std::vector<std::string> m_weight_names
| private

A vector of weight names.

Definition at line 162 of file GenRunInfo.h.

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

- GenRunInfo.h
- GenRunInfo.cc