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();
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;
97 void set_weight_names(
const std::vector<std::string> & 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;
119 std::string attribute_as_string(
const std::string &name)
const;
122 std::vector<std::string> attribute_names()
const;
126 std::map< std::string, std::shared_ptr<Attribute> >
attributes()
const {
144 void Streamer(TBuffer &b);
153 #if !defined(__CINT__)
165 mutable std::map< std::string, std::shared_ptr<Attribute> >
m_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);
205 template<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());
Definition of class Attribute, class IntAttribute and class StringAttribute.
Definition of class Units.
Stores run-related information.
std::vector< ToolInfo > & tools()
The vector of tools used to produce this run.
std::recursive_mutex m_lock_attributes
Mutex lock for the m_attibutes map.
std::shared_ptr< T > attribute(const std::string &name) const
Get attribute of type T.
std::map< std::string, int > m_weight_indices
A map of weight names mapping to indices.
std::vector< ToolInfo > m_tools
The vector of tools used to produce this run.
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.
void remove_attribute(const std::string &name)
Remove attribute.
std::map< std::string, std::shared_ptr< Attribute > > m_attributes
Map of attributes.
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
bool has_weight(const std::string &name) const
Check if a weight name is present.
std::vector< std::string > m_weight_names
A vector of weight names.
GenRunInfo()
Default constructor.
int weight_index(const std::string &name) const
Return the index corresponding to a weight name.
std::map< std::string, int > weight_indices() const
Returns a copy of indices map.
const std::vector< ToolInfo > & tools() const
The vector of tools used to produce this run.
Stores serializable run information.