10 #ifndef HEPMC3_GENRUNINFO_H
11 #define HEPMC3_GENRUNINFO_H
13 #if !defined(__CINT__)
27 struct GenRunInfoData;
60 #if !defined(__CINT__)
63 const std::vector<ToolInfo> &
tools()
const {
67 std::vector<ToolInfo> &
tools() {
73 return m_weight_indices.find(name) != m_weight_indices.end();
79 std::map<std::string, int>::const_iterator it = m_weight_indices.find(name);
80 return it == m_weight_indices.end()? -1: it->second;
85 return m_weight_names;
92 void set_weight_names(
const std::vector<std::string> & names);
98 const std::shared_ptr<Attribute> &att) {
99 std::lock_guard<std::recursive_mutex> lock(m_lock_attributes);
100 if ( att ) m_attributes[name] = att;
105 std::lock_guard<std::recursive_mutex> lock(m_lock_attributes);
106 m_attributes.erase(name);
111 std::shared_ptr<T> attribute(
const std::string &
name)
const;
114 std::string attribute_as_string(
const std::string &
name)
const;
117 std::vector<std::string> attribute_names()
const;
121 std::map< std::string, std::shared_ptr<Attribute> >
attributes()
const {
139 void Streamer(TBuffer &b);
148 #if !defined(__CINT__)
160 mutable std::map< std::string, std::shared_ptr<Attribute> >
m_attributes;
169 #if !defined(__CINT__)
177 std::lock_guard<std::recursive_mutex> lock(m_lock_attributes);
178 std::map< std::string, std::shared_ptr<Attribute> >
::iterator i =
179 m_attributes.find(name);
180 if( i == m_attributes.end() )
return std::shared_ptr<T>();
182 if( !i->second->is_parsed() ) {
184 std::shared_ptr<T> att = std::make_shared<T>();
185 if ( att->from_string(i->second->unparsed_string()) &&
193 return std::shared_ptr<T>();
195 else return std::dynamic_pointer_cast<T>(i->second);
int weight_index(const std::string &name) const
Return the index corresponding to a weight name.
GenRunInfo()
Default constructor.
std::recursive_mutex m_lock_attributes
Mutex lock for the m_attibutes map.
std::vector< std::string > m_weight_names
A vector of weight names.
Stores run-related information.
const std::vector< std::string > & weight_names() const
Get the vector of weight names.
const std::vector< ToolInfo > & tools() const
The vector of tools used to produce this run.
std::map< std::string, std::shared_ptr< Attribute > > attributes() const
Get a copy of the list of attributes.
std::map< std::string, int > m_weight_indices
A map of weight names mapping to indices.
bool has_weight(const std::string &name) const
Check if a weight name is present.
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...
std::map< std::string, std::shared_ptr< Attribute > > m_attributes
Map of attributes.
std::shared_ptr< T > attribute(const std::string &name) const
Get attribute of type T.
Stores serializable run information.
Definition of class Units.
void remove_attribute(const std::string &name)
Remove attribute.
Annotation for function names.
Definition of class Attribute, class IntAttribute and class StringAttribute.
std::vector< ToolInfo > m_tools
The vector of tools used to produce this run.
std::vector< ToolInfo > & tools()
The vector of tools used to produce this run.