10#ifndef HEPMC3_GENEVENT_H 
   11#define HEPMC3_GENEVENT_H 
   14#include "HepMC3/GenParticle_fwd.h" 
   15#include "HepMC3/GenVertex_fwd.h" 
   16#include "HepMC3/GenPdfInfo_fwd.h" 
   17#include "HepMC3/GenHeavyIon_fwd.h" 
   18#include "HepMC3/GenCrossSection_fwd.h" 
   52    GenEvent(std::shared_ptr<GenRunInfo> run,
 
   69    const std::vector<ConstGenParticlePtr>& 
particles() 
const;
 
   71    const std::vector<ConstGenVertexPtr>& 
vertices() 
const;
 
   84    inline int particles_size()
 const { 
return m_particles.size(); }
 
  103    double weight(
const unsigned long& index=0)
 const { 
if ( index < 
weights().size() ) 
return weights().at(index); 
else  throw std::runtime_error(
"GenEvent::weight(const unsigned long&): weight index outside of range"); 
return 0.0; }
 
  107    double weight(
const std::string& name)
 const {
 
  108        if (!
run_info()) 
throw std::runtime_error(
"GenEvent::weight(const std::string&): named access to event weights requires the event to have a GenRunInfo");
 
 
  114    double& 
weight(
const std::string& name) {
 
  115        if (!
run_info()) 
throw std::runtime_error(
"GenEvent::weight(const std::string&): named access to event weights requires the event to have a GenRunInfo");
 
  116        int pos = 
run_info()->weight_index(name);
 
  117        if ( pos < 0 ) 
throw std::runtime_error(
"GenEvent::weight(const std::string&): no weight with given name in this run");
 
  118        if ( pos >= 
int(
m_weights.size())) 
throw std::runtime_error(
"GenEvent::weight(const std::string&): weight index outside of range");
 
 
  124        if (!
run_info()) 
throw std::runtime_error(
"GenEvent::weight_names(): access to event weight names requires the event to have a GenRunInfo");
 
  125        const std::vector<std::string>& weightnames = 
run_info()->weight_names();
 
  126        if (weightnames.empty()) 
throw std::runtime_error(
"GenEvent::weight_names(): no event weight names are registered for this run");
 
 
  143        if ( run && !run->weight_names().empty() )
 
  144            m_weights.resize(run->weight_names().size(), 1.0);
 
 
  191    std::vector<ConstGenParticlePtr> 
beams() 
const;
 
  194    std::vector<ConstGenParticlePtr> 
beams(
const int status) 
const;
 
  198    const std::vector<GenParticlePtr> & 
beams();
 
  225    void add_attribute(
const std::string &name, 
const std::shared_ptr<Attribute> &att,  
const int& 
id = 0);
 
  231    void add_attributes(
const std::vector<std::string> &names, 
const std::vector<std::shared_ptr<Attribute> > &atts,  
const std::vector<int>& ids);
 
  237    void add_attributes(
const std::string& name, 
const std::vector<std::shared_ptr<Attribute> > &atts,  
const std::vector<int>& ids);
 
  243    void add_attributes(
const std::string& name, 
const std::vector<std::pair<
int, std::shared_ptr<Attribute> > > &atts);
 
  251    std::shared_ptr<T> 
attribute(
const std::string &name,  
const int& 
id = 0) 
const;
 
  261    std::map< std::string, std::map<int, std::shared_ptr<Attribute> > > 
attributes()
 const {
 
 
  306    void add_tree( 
const std::vector<GenParticlePtr> &parts );
 
  311    void reserve(
const size_t& parts, 
const size_t& verts = 0);
 
  358    void Streamer(TBuffer &b);
 
  367#if !defined(__CINT__) 
  394    mutable std::map< std::string, std::map<int, std::shared_ptr<Attribute> > > 
m_attributes;
 
  397    typedef std::map< std::string, std::map<int, std::shared_ptr<Attribute> > >::value_type 
att_key_t;
 
  400    typedef std::map<int, std::shared_ptr<Attribute> >::value_type 
att_val_t;
 
 
  412#if !defined(__CINT__) 
  419    std::map< std::string, std::map<int, std::shared_ptr<Attribute> > >::iterator i1 = 
m_attributes.find(name);
 
  422            return run_info()->attribute<T>(name);
 
  424        return std::shared_ptr<T>();
 
  427    std::map<int, std::shared_ptr<Attribute> >::iterator i2 = i1->second.find(
id);
 
  428    if (i2 == i1->second.end() ) 
return std::shared_ptr<T>();
 
  430    if (!i2->second->is_parsed() ) {
 
  432        std::shared_ptr<T> att = std::make_shared<T>();
 
  435        if ( 
id > 0 && 
id <= 
int(
particles().size()) ) {
 
  438        if ( 
id < 0 && -
id <= 
int(
vertices().size()) ) {
 
  441        if ( att->from_string(i2->second->unparsed_string()) &&
 
  447            return std::shared_ptr<T>();
 
  450    else return std::dynamic_pointer_cast<T>(i2->second);
 
 
Definition of attribute class GenCrossSection.
Definition of attribute class GenHeavyIon.
Definition of event attribute class GenPdfInfo.
Definition of class GenRunInfo.
Definition of class Units.
GenEvent(Units::MomentumUnit mu=Units::GEV, Units::LengthUnit lu=Units::MM)
Event constructor without a run.
bool rotate(const FourVector &delta)
Rotate event using x,y,z components of delta as rotation angles.
std::shared_ptr< T > attribute(const std::string &name, const int &id=0) const
Get attribute of type T.
std::recursive_mutex m_lock_attributes
Mutex lock for the m_attibutes map.
void add_vertex(GenVertexPtr v)
Add vertex.
void shift_position_to(const FourVector &newpos)
Shift position of all vertices in the event to op.
int vertices_size() const
Vertices size, HepMC2 compatibility.
bool vertices_empty() const
Vertices empty, HepMC2 compatibility.
int event_number() const
Get event number.
std::vector< std::string > attribute_names(const int &id=0) const
Get list of attribute names.
void write_data(GenEventData &data) const
Fill GenEventData object.
std::shared_ptr< GenRunInfo > run_info() const
Get a pointer to the the GenRunInfo object.
ConstGenCrossSectionPtr cross_section() const
Get cross-section information (const version)
void remove_particles(std::vector< GenParticlePtr > v)
Remove a set of particles.
void add_particle(GenParticlePtr p)
Add particle.
void set_units(Units::MomentumUnit new_momentum_unit, Units::LengthUnit new_length_unit)
Change event units Converts event from current units to new ones.
std::vector< double > m_weights
Event weights.
ConstGenHeavyIonPtr heavy_ion() const
Get heavy ion generator additional information (const version)
std::map< int, std::shared_ptr< Attribute > >::value_type att_val_t
Attribute map value type.
std::map< std::string, std::map< int, std::shared_ptr< Attribute > > >::value_type att_key_t
Attribute map key type.
void shift_position_by(const FourVector &delta)
Shift position of all vertices in the event by delta.
void remove_vertex(GenVertexPtr v)
Remove vertex from the event.
void reserve(const size_t &parts, const size_t &verts=0)
Reserve memory for particles and vertices.
void set_event_number(const int &num)
Set event number.
double & weight(const std::string &name)
bool boost(const FourVector &delta)
Boost event using x,y,z components of delta as velocities.
std::vector< ConstGenParticlePtr > beams() const
Vector of beam particles.
int m_event_number
Event number.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
ConstGenPdfInfoPtr pdf_info() const
Get PDF information (const version)
std::vector< double > & weights()
Get event weights as a vector (non-const)
const std::vector< ConstGenVertexPtr > & vertices() const
Get list of vertices (const)
const Units::MomentumUnit & momentum_unit() const
Get momentum unit.
const Units::LengthUnit & length_unit() const
Get length unit.
bool reflect(const int axis)
Change sign of axis.
double weight(const unsigned long &index=0) const
void set_cross_section(GenCrossSectionPtr cs)
Set cross-section information.
const FourVector & event_pos() const
Vertex representing the overall event position.
std::map< std::string, std::map< int, std::shared_ptr< Attribute > > > attributes() const
Get a copy of the list of attributes.
void set_heavy_ion(GenHeavyIonPtr hi)
Set heavy ion generator additional information.
void add_attribute(const std::string &name, const std::shared_ptr< Attribute > &att, const int &id=0)
void read_data(const GenEventData &data)
Fill GenEvent based on GenEventData.
std::map< std::string, std::map< int, std::shared_ptr< Attribute > > > m_attributes
Map of event, particle and vertex attributes.
GenPdfInfoPtr pdf_info()
Get PDF information.
const std::vector< std::string > & weight_names() const
Units::MomentumUnit m_momentum_unit
Momentum unit.
bool particles_empty() const
Particles empty, HepMC2 compatibility.
void remove_attribute(const std::string &name, const int &id=0)
Remove attribute.
void remove_particle(GenParticlePtr p)
Remove particle from the event.
std::vector< GenVertexPtr > m_vertices
List of vertices.
GenVertexPtr m_rootvertex
The root vertex is stored outside the normal vertices list to block user access to it.
std::string attribute_as_string(const std::string &name, const int &id=0) const
Get attribute of any type as string.
const std::vector< double > & weights() const
Get event weight values as a vector.
double weight(const std::string &name) const
void clear()
Remove contents of this event.
Units::LengthUnit m_length_unit
Length unit.
GenHeavyIonPtr heavy_ion()
Get heavy ion generator additional information.
std::shared_ptr< GenRunInfo > m_run_info
Global run information.
std::vector< GenParticlePtr > m_particles
List of particles.
void add_beam_particle(GenParticlePtr p1)
Add particle to root vertex.
void add_attributes(const std::vector< std::string > &names, const std::vector< std::shared_ptr< Attribute > > &atts, const std::vector< int > &ids)
Add multiple attributes to event.
void set_beam_particles(GenParticlePtr p1, GenParticlePtr p2)
Set incoming beam particles.
void set_pdf_info(GenPdfInfoPtr pi)
Set PDF information.
GenCrossSectionPtr cross_section()
Get cross-section information.
const std::vector< GenParticlePtr > & particles()
Get/set list of particles (non-const)
const std::vector< GenVertexPtr > & vertices()
Get/set list of vertices (non-const)
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
void add_tree(const std::vector< GenParticlePtr > &parts)
Add whole tree in topological order.
GenEvent & operator=(const GenEvent &)
Assignment operator.
Stores particle-related information.
Stores vertex-related information.
LengthUnit
Position units.
MomentumUnit
Momentum units.
Stores serializable event information.