10#ifndef HEPMC3_GENRUNINFO_H
11#define HEPMC3_GENRUNINFO_H
14#include "HepMC3/Units.h"
15#include "HepMC3/Attribute.h"
63 const std::vector<ToolInfo> &
tools()
const {
67 std::vector<ToolInfo> &
tools() {
73 return m_weight_indices.find(name) != m_weight_indices.end();
78 return m_weight_indices;
84 std::map<std::string, int>::const_iterator it = m_weight_indices.find(name);
85 return it == m_weight_indices.end()? -1: it->second;
90 return m_weight_names;
103 const std::shared_ptr<Attribute> &att) {
104 std::lock_guard<std::recursive_mutex> lock(m_lock_attributes);
105 if ( att ) m_attributes[name] = att;
110 std::lock_guard<std::recursive_mutex> lock(m_lock_attributes);
111 m_attributes.erase(name);
116 std::shared_ptr<T>
attribute(
const std::string &name)
const;
126 std::map< std::string, std::shared_ptr<Attribute> >
attributes()
const {
144 void Streamer(TBuffer &b);
153#if !defined(__CINT__)
156 std::vector<ToolInfo> m_tools;
159 std::map<std::string, int> m_weight_indices;
162 std::vector<std::string> m_weight_names;
165 mutable std::map< std::string, std::shared_ptr<Attribute> > m_attributes;
168 mutable std::recursive_mutex m_lock_attributes;
174#if !defined(__CINT__)
182 std::lock_guard<std::recursive_mutex> lock(m_lock_attributes);
183 std::map< std::string, std::shared_ptr<Attribute> >::iterator i =
184 m_attributes.find(name);
185 if ( i == m_attributes.end() )
return std::shared_ptr<T>();
187 if ( !i->second->is_parsed() ) {
189 std::shared_ptr<T> att = std::make_shared<T>();
190 if ( att->from_string(i->second->unparsed_string()) &&
198 return std::shared_ptr<T>();
200 else return std::dynamic_pointer_cast<T>(i->second);
205template<typename T> std::map<std::string, T> weight_indices() const {
206 std::map<std::string, T> ret;
207 ret.insert(m_weight_indices.begin(),m_weight_indices.end());
Stores run-related information.
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.
void remove_attribute(const std::string &name)
Remove attribute.
std::string version
The version of the tool.
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 read_data(const GenRunInfoData &data)
Fill GenRunInfo based on GenRunInfoData.
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.
void set_weight_names(const std::vector< std::string > &names)
Set the names of the weights in this run.
GenRunInfo & operator=(const GenRunInfo &r)
Assignmet.
const std::vector< std::string > & weight_names() const
Get the vector of weight names.
std::map< std::string, std::shared_ptr< Attribute > > attributes() const
Get a copy of the list of attributes.
std::string description
Other information about how the tool was used in the run.
const std::vector< ToolInfo > & tools() const
The vector of tools used to produce this run.
GenRunInfo()
Default constructor.
std::string attribute_as_string(const std::string &name) const
Get attribute of any type as string.
std::string name
The name of the tool.
std::shared_ptr< T > attribute(const std::string &name) const
Get attribute of type T.
void write_data(GenRunInfoData &data) const
Fill GenRunInfoData object.
std::vector< std::string > attribute_names() const
Get list of attribute names.
Stores serializable run information.