HepMC3 event record library
|
Stores event-related information.
Manages event-related information. Contains lists of GenParticle and GenVertex objects
Definition at line 41 of file GenEvent.h.
#include <GenEvent.h>
Public Member Functions | |
GenEvent (Units::MomentumUnit momentum_unit=Units::GEV, Units::LengthUnit length_unit=Units::MM) | |
Event constructor without a run. | |
GenEvent (std::shared_ptr< GenRunInfo > run, Units::MomentumUnit momentum_unit=Units::GEV, Units::LengthUnit length_unit=Units::MM) | |
Constructor with associated run. | |
GenEvent (const GenEvent &) | |
Copy constructor. | |
~GenEvent () | |
Destructor. | |
GenEvent & | operator= (const GenEvent &) |
Assignment operator. | |
Particle and vertex access | |
const std::vector< ConstGenParticlePtr > & | particles () const |
Get list of particles (const) | |
const std::vector< ConstGenVertexPtr > & | vertices () const |
Get list of vertices (const) | |
const std::vector< GenParticlePtr > & | particles () |
Get/set list of particles (non-const) | |
const std::vector< GenVertexPtr > & | vertices () |
Get/set list of vertices (non-const) | |
int | particles_size () const |
Particles size, HepMC2 compatiility. | |
bool | particles_empty () const |
Particles empty, HepMC2 compatiility. | |
int | vertices_size () const |
Vertices size, HepMC2 compatiility. | |
bool | vertices_empty () const |
Vertices empty, HepMC2 compatiility. | |
Event weights | |
const std::vector< double > & | weights () const |
Get event weight values as a vector. | |
std::vector< double > & | weights () |
Get event weights as a vector (non-const) | |
double | weight (const unsigned long &index=0) const |
double | weight (const std::string &name) const |
double & | weight (const std::string &name) |
const std::vector< std::string > & | weight_names () const |
Auxiliary info and event metadata | |
std::shared_ptr< GenRunInfo > | run_info () const |
Get a pointer to the the GenRunInfo object. | |
void | set_run_info (std::shared_ptr< GenRunInfo > run) |
Set the GenRunInfo object by smart pointer. | |
int | event_number () const |
Get event number. | |
void | set_event_number (const int &num) |
Set event number. | |
const Units::MomentumUnit & | momentum_unit () const |
Get momentum unit. | |
const Units::LengthUnit & | length_unit () const |
Get length unit. | |
void | set_units (Units::MomentumUnit new_momentum_unit, Units::LengthUnit new_length_unit) |
Change event units Converts event from current units to new ones. | |
GenHeavyIonPtr | heavy_ion () |
Get heavy ion generator additional information. | |
ConstGenHeavyIonPtr | heavy_ion () const |
Get heavy ion generator additional information (const version) | |
void | set_heavy_ion (GenHeavyIonPtr hi) |
Set heavy ion generator additional information. | |
GenPdfInfoPtr | pdf_info () |
Get PDF information. | |
ConstGenPdfInfoPtr | pdf_info () const |
Get PDF information (const version) | |
void | set_pdf_info (GenPdfInfoPtr pi) |
Set PDF information. | |
GenCrossSectionPtr | cross_section () |
Get cross-section information. | |
ConstGenCrossSectionPtr | cross_section () const |
Get cross-section information (const version) | |
void | set_cross_section (GenCrossSectionPtr cs) |
Set cross-section information. | |
Event position | |
const FourVector & | event_pos () const |
Vertex representing the overall event position. | |
std::vector< ConstGenParticlePtr > | beams () const |
Vector of beam particles. | |
const std::vector< GenParticlePtr > & | beams () |
Vector of beam particles. | |
void | shift_position_by (const FourVector &delta) |
Shift position of all vertices in the event by delta. | |
void | shift_position_to (const FourVector &newpos) |
Shift position of all vertices in the event to op. | |
bool | boost (const FourVector &v) |
Boost event using x,y,z components of v as velocities. | |
bool | rotate (const FourVector &v) |
Rotate event using x,y,z components of v as rotation angles. | |
bool | reflect (const int axis) |
Change sign of axis. | |
Additional attributes | |
Add event attribute to event This will overwrite existing attribute if an attribute with the same name is present | |
void | add_attribute (const std::string &name, const std::shared_ptr< Attribute > &att, const int &id=0) |
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 | add_attributes (const std::string &name, const std::vector< std::shared_ptr< Attribute > > &atts, const std::vector< int > &ids) |
Add multiple attributes to event. | |
void | add_attributes (const std::string &name, const std::vector< std::pair< int, std::shared_ptr< Attribute > > > &atts) |
Add multiple attributes to event. | |
void | remove_attribute (const std::string &name, const int &id=0) |
Remove attribute. | |
template<class T > | |
std::shared_ptr< T > | attribute (const std::string &name, const int &id=0) const |
Get attribute of type T. | |
std::string | attribute_as_string (const std::string &name, const int &id=0) const |
Get attribute of any type as string. | |
std::vector< std::string > | attribute_names (const int &id=0) const |
Get list of attribute names. | |
std::map< std::string, std::map< int, std::shared_ptr< Attribute > > > | attributes () const |
Get a copy of the list of attributes. | |
Particle and vertex modification | |
void | add_particle (GenParticlePtr p) |
Add particle. | |
void | add_vertex (GenVertexPtr v) |
Add vertex. | |
void | remove_particle (GenParticlePtr v) |
Remove particle from the event. | |
void | remove_particles (std::vector< GenParticlePtr > v) |
Remove a set of particles. | |
void | remove_vertex (GenVertexPtr v) |
Remove vertex from the event. | |
void | add_tree (const std::vector< GenParticlePtr > &particles) |
Add whole tree in topological order. | |
void | reserve (const size_t &particles, const size_t &vertices=0) |
Reserve memory for particles and vertices. | |
void | clear () |
Remove contents of this event. | |
Deprecated functionality | |
void | add_particle (GenParticle *p) |
Add particle by raw pointer. | |
void | add_vertex (GenVertex *v) |
Add vertex by raw pointer. | |
void | set_beam_particles (GenParticlePtr p1, GenParticlePtr p2) |
Set incoming beam particles. | |
void | add_beam_particle (GenParticlePtr p1) |
Add particle to root vertex. | |
Methods to fill GenEventData and to read it back | |
void | write_data (GenEventData &data) const |
Fill GenEventData object. | |
void | read_data (const GenEventData &data) |
Fill GenEvent based on GenEventData. | |
Fields | |
typedef std::map< std::string, std::map< int, std::shared_ptr< Attribute > > >::value_type | att_key_t |
Attribute map key type. | |
typedef std::map< int, std::shared_ptr< Attribute > >::value_type | att_val_t |
Attribute map value type. | |
std::vector< GenParticlePtr > | m_particles |
List of particles. | |
std::vector< GenVertexPtr > | m_vertices |
List of vertices. | |
int | m_event_number |
Event number. | |
std::vector< double > | m_weights |
Event weights. | |
Units::MomentumUnit | m_momentum_unit |
Momentum unit. | |
Units::LengthUnit | m_length_unit |
Length unit. | |
GenVertexPtr | m_rootvertex |
The root vertex is stored outside the normal vertices list to block user access to it. | |
std::shared_ptr< GenRunInfo > | m_run_info |
Global run information. | |
std::map< std::string, std::map< int, std::shared_ptr< Attribute > > > | m_attributes |
Map of event, particle and vertex attributes. | |
std::recursive_mutex | m_lock_attributes |
Mutex lock for the m_attibutes map. | |
|
private |
Attribute map key type.
Definition at line 391 of file GenEvent.h.
Attribute map value type.
Definition at line 394 of file GenEvent.h.
GenEvent | ( | Units::MomentumUnit | momentum_unit = Units::GEV , |
Units::LengthUnit | length_unit = Units::MM |
||
) |
Event constructor without a run.
Definition at line 21 of file GenEvent.cc.
GenEvent | ( | std::shared_ptr< GenRunInfo > | run, |
Units::MomentumUnit | momentum_unit = Units::GEV , |
||
Units::LengthUnit | length_unit = Units::MM |
||
) |
Constructor with associated run.
Definition at line 28 of file GenEvent.cc.
References GenEvent::m_weights.
Copy constructor.
Definition at line 62 of file GenEvent.cc.
References GenEvent::m_lock_attributes, GenEvent::read_data(), and GenEvent::write_data().
~GenEvent | ( | ) |
Destructor.
Definition at line 74 of file GenEvent.cc.
References GenEvent::m_attributes, GenEvent::m_particles, and GenEvent::m_vertices.
void add_attribute | ( | const std::string & | name, |
const std::shared_ptr< Attribute > & | att, | ||
const int & | id = 0 |
||
) |
Disallow empty strings
Definition at line 806 of file GenEvent.cc.
References GenEvent::m_attributes, GenEvent::m_lock_attributes, GenEvent::particles(), and GenEvent::vertices().
void add_attributes | ( | const std::string & | name, |
const std::vector< std::pair< int, std::shared_ptr< Attribute > > > & | atts | ||
) |
Add multiple attributes to event.
This will overwrite existing attributes if attributes with the same names are present
Disallow empty strings
Definition at line 876 of file GenEvent.cc.
References GenEvent::m_attributes, GenEvent::m_lock_attributes, GenEvent::m_particles, GenEvent::m_vertices, GenEvent::particles_size(), and GenEvent::vertices_size().
void add_attributes | ( | const std::string & | name, |
const std::vector< std::shared_ptr< Attribute > > & | atts, | ||
const std::vector< int > & | ids | ||
) |
Add multiple attributes to event.
This will overwrite existing attributes if attributes with the same names are present
Disallow empty strings
Definition at line 852 of file GenEvent.cc.
References GenEvent::m_attributes, GenEvent::m_lock_attributes, GenEvent::m_particles, GenEvent::m_vertices, GenEvent::particles_size(), and GenEvent::vertices_size().
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.
This will overwrite existing attributes if attributes with the same names are present
Disallow empty strings
Definition at line 821 of file GenEvent.cc.
References GenEvent::m_attributes, GenEvent::m_lock_attributes, GenEvent::m_particles, GenEvent::m_vertices, GenEvent::particles_size(), and GenEvent::vertices_size().
void add_beam_particle | ( | GenParticlePtr | p1 | ) |
Add particle to root vertex.
Definition at line 765 of file GenEvent.cc.
References GenEvent::add_particle(), and HEPMC3_WARNING.
void add_particle | ( | GenParticle * | p | ) |
Add particle by raw pointer.
Definition at line 750 of file GenEvent.cc.
References GenEvent::add_particle().
void add_particle | ( | GenParticlePtr | p | ) |
Add particle.
Definition at line 48 of file GenEvent.cc.
References GenEvent::m_particles, GenEvent::m_rootvertex, and GenEvent::particles().
void add_tree | ( | const std::vector< GenParticlePtr > & | particles | ) |
Add whole tree in topological order.
This function will find the beam particles (particles that have no production vertices or their production vertices have no particles) and will add the whole decay tree starting from these particles.
Definition at line 265 of file GenEvent.cc.
References GenEvent::add_attribute(), GenEvent::add_vertex(), HEPMC3_DEBUG, HEPMC3_DEBUG_CODE_BLOCK, HEPMC3_WARNING, GenEvent::m_attributes, GenEvent::m_lock_attributes, GenEvent::m_rootvertex, GenEvent::m_vertices, GenEvent::particles(), and HepMC3::visit_children().
void add_vertex | ( | GenVertex * | v | ) |
Add vertex by raw pointer.
Definition at line 755 of file GenEvent.cc.
References GenEvent::add_vertex().
void add_vertex | ( | GenVertexPtr | v | ) |
Add vertex.
Definition at line 96 of file GenEvent.cc.
References GenEvent::add_particle(), GenEvent::m_vertices, and GenEvent::vertices().
std::shared_ptr< T > attribute | ( | const std::string & | name, |
const int & | id = 0 |
||
) | const |
Get attribute of type T.
Definition at line 409 of file GenEvent.h.
References GenEvent::m_attributes, GenEvent::m_lock_attributes, GenEvent::m_particles, GenEvent::m_vertices, GenEvent::particles(), GenEvent::run_info(), and GenEvent::vertices().
std::string attribute_as_string | ( | const std::string & | name, |
const int & | id = 0 |
||
) | const |
Get attribute of any type as string.
Definition at line 784 of file GenEvent.cc.
References GenEvent::m_attributes, GenEvent::m_lock_attributes, and GenEvent::run_info().
std::vector< std::string > attribute_names | ( | const int & | id = 0 | ) | const |
Get list of attribute names.
Definition at line 621 of file GenEvent.cc.
References GenEvent::m_attributes.
|
inline |
Get a copy of the list of attributes.
Definition at line 257 of file GenEvent.h.
References GenEvent::m_attributes, and GenEvent::m_lock_attributes.
const std::vector< GenParticlePtr > & beams | ( | ) |
Vector of beam particles.
Definition at line 420 of file GenEvent.cc.
References GenEvent::m_rootvertex.
std::vector< ConstGenParticlePtr > beams | ( | ) | const |
Vector of beam particles.
Definition at line 416 of file GenEvent.cc.
References GenEvent::m_rootvertex.
bool boost | ( | const FourVector & | v | ) |
Boost event using x,y,z components of v as velocities.
Definition at line 553 of file GenEvent.cc.
References FourVector::e(), HEPMC3_WARNING, FourVector::length2(), GenEvent::m_particles, FourVector::x(), FourVector::y(), and FourVector::z().
void clear | ( | ) |
Remove contents of this event.
Definition at line 599 of file GenEvent.cc.
References GenEvent::m_attributes, GenEvent::m_event_number, GenEvent::m_lock_attributes, GenEvent::m_particles, GenEvent::m_rootvertex, GenEvent::m_vertices, and GenEvent::m_weights.
|
inline |
Get cross-section information.
Definition at line 175 of file GenEvent.h.
|
inline |
Get cross-section information (const version)
Definition at line 177 of file GenEvent.h.
|
inline |
Get event number.
Definition at line 148 of file GenEvent.h.
References GenEvent::m_event_number.
const FourVector & event_pos | ( | ) | const |
Vertex representing the overall event position.
Definition at line 412 of file GenEvent.cc.
References GenEvent::m_rootvertex.
|
inline |
Get heavy ion generator additional information.
Definition at line 161 of file GenEvent.h.
|
inline |
Get heavy ion generator additional information (const version)
Definition at line 163 of file GenEvent.h.
|
inline |
|
inline |
Assignment operator.
Definition at line 82 of file GenEvent.cc.
References GenEvent::m_lock_attributes, GenEvent::read_data(), and GenEvent::write_data().
|
inline |
Get/set list of particles (non-const)
Definition at line 75 of file GenEvent.h.
References GenEvent::m_particles.
const std::vector< ConstGenParticlePtr > & particles | ( | ) | const |
Get list of particles (const)
Definition at line 39 of file GenEvent.cc.
References GenEvent::m_particles.
|
inline |
Particles empty, HepMC2 compatiility.
Definition at line 87 of file GenEvent.h.
References GenEvent::m_particles.
|
inline |
Particles size, HepMC2 compatiility.
Definition at line 85 of file GenEvent.h.
References GenEvent::m_particles.
|
inline |
Get PDF information.
Definition at line 168 of file GenEvent.h.
|
inline |
Get PDF information (const version)
Definition at line 170 of file GenEvent.h.
void read_data | ( | const GenEventData & | data | ) |
Fill GenEvent based on GenEventData.
Definition at line 690 of file GenEvent.cc.
References GenEvent::add_attribute(), GenEventData::attribute_id, GenEventData::attribute_name, GenEventData::attribute_string, GenEvent::clear(), GenEventData::event_number, GenEventData::event_pos, HEPMC3_WARNING, GenEventData::length_unit, GenEventData::links1, GenEventData::links2, GenEvent::m_length_unit, GenEvent::m_momentum_unit, GenEvent::m_particles, GenEvent::m_rootvertex, GenEvent::m_vertices, GenEventData::momentum_unit, GenEventData::particles, GenEvent::set_event_number(), GenEvent::shift_position_to(), GenEventData::vertices, GenEventData::weights, and GenEvent::weights().
bool reflect | ( | const int | axis | ) |
Change sign of axis.
Definition at line 521 of file GenEvent.cc.
References HEPMC3_WARNING, GenEvent::m_particles, GenEvent::m_vertices, FourVector::setT(), FourVector::setX(), FourVector::setY(), and FourVector::setZ().
void remove_attribute | ( | const std::string & | name, |
const int & | id = 0 |
||
) |
Remove attribute.
Definition at line 609 of file GenEvent.cc.
References GenEvent::m_attributes, and GenEvent::m_lock_attributes.
void remove_particle | ( | GenParticlePtr | v | ) |
Remove particle from the event.
This function will remove whole sub-tree starting from this particle if it is the only incoming particle of this vertex. It will also production vertex of this particle if this vertex has no more outgoing particles
Definition at line 116 of file GenEvent.cc.
References HEPMC3_DEBUG, GenEvent::m_attributes, GenEvent::m_lock_attributes, GenEvent::m_particles, and GenEvent::remove_vertex().
void remove_particles | ( | std::vector< GenParticlePtr > | v | ) |
Remove a set of particles.
This function follows rules of GenEvent::remove_particle to remove a list of particles from the event.
Definition at line 184 of file GenEvent.cc.
References GenEvent::remove_particle().
void remove_vertex | ( | GenVertexPtr | v | ) |
Remove vertex from the event.
This will remove all sub-trees of all outgoing particles of this vertex
Definition at line 192 of file GenEvent.cc.
References HEPMC3_DEBUG, GenEvent::m_attributes, GenEvent::m_lock_attributes, GenEvent::m_vertices, and GenEvent::remove_particle().
void reserve | ( | const size_t & | particles, |
const size_t & | vertices = 0 |
||
) |
Reserve memory for particles and vertices.
Helps optimize event creation when size of the event is known beforehand
Definition at line 385 of file GenEvent.cc.
References GenEvent::m_particles, and GenEvent::m_vertices.
bool rotate | ( | const FourVector & | v | ) |
Rotate event using x,y,z components of v as rotation angles.
Definition at line 434 of file GenEvent.cc.
References FourVector::e(), GenEvent::m_particles, GenEvent::m_vertices, FourVector::t(), FourVector::x(), FourVector::y(), and FourVector::z().
|
inline |
Get a pointer to the the GenRunInfo object.
Definition at line 137 of file GenEvent.h.
References GenEvent::m_run_info.
void set_beam_particles | ( | GenParticlePtr | p1, |
GenParticlePtr | p2 | ||
) |
Set incoming beam particles.
Definition at line 760 of file GenEvent.cc.
References GenEvent::m_rootvertex.
|
inline |
Set cross-section information.
Definition at line 179 of file GenEvent.h.
References GenEvent::add_attribute().
|
inline |
Set event number.
Definition at line 150 of file GenEvent.h.
References GenEvent::m_event_number.
|
inline |
Set heavy ion generator additional information.
Definition at line 165 of file GenEvent.h.
References GenEvent::add_attribute().
|
inline |
Set PDF information.
Definition at line 172 of file GenEvent.h.
References GenEvent::add_attribute().
|
inline |
Set the GenRunInfo object by smart pointer.
Definition at line 141 of file GenEvent.h.
References GenEvent::m_run_info, and GenEvent::m_weights.
void set_units | ( | Units::MomentumUnit | new_momentum_unit, |
Units::LengthUnit | new_length_unit | ||
) |
Change event units Converts event from current units to new ones.
Definition at line 391 of file GenEvent.cc.
References Units::convert(), FourVector::is_zero(), GenEvent::m_length_unit, GenEvent::m_momentum_unit, GenEvent::m_particles, and GenEvent::m_vertices.
void shift_position_by | ( | const FourVector & | delta | ) |
Shift position of all vertices in the event by delta.
Definition at line 424 of file GenEvent.cc.
References GenEvent::event_pos(), GenEvent::m_rootvertex, and GenEvent::m_vertices.
|
inline |
Shift position of all vertices in the event to op.
Definition at line 200 of file GenEvent.h.
References GenEvent::event_pos(), and GenEvent::shift_position_by().
|
inline |
Get/set list of vertices (non-const)
Definition at line 77 of file GenEvent.h.
References GenEvent::m_vertices.
const std::vector< ConstGenVertexPtr > & vertices | ( | ) | const |
Get list of vertices (const)
Definition at line 43 of file GenEvent.cc.
References GenEvent::m_vertices.
|
inline |
Vertices empty, HepMC2 compatiility.
Definition at line 91 of file GenEvent.h.
References GenEvent::m_vertices.
|
inline |
Vertices size, HepMC2 compatiility.
Definition at line 89 of file GenEvent.h.
References GenEvent::m_vertices.
|
inline |
Get event weight accessed by weight name
Definition at line 114 of file GenEvent.h.
References GenEvent::m_weights, and GenEvent::run_info().
|
inline |
Get event weight accessed by weight name
Definition at line 107 of file GenEvent.h.
References GenEvent::run_info(), and GenEvent::weight().
|
inline |
Get event weight accessed by index (or the canonical/first one if there is no argument)
Definition at line 103 of file GenEvent.h.
References GenEvent::weights().
|
inline |
Get event weight names, if there are some
Definition at line 123 of file GenEvent.h.
References GenEvent::run_info().
|
inline |
Get event weights as a vector (non-const)
Definition at line 100 of file GenEvent.h.
References GenEvent::m_weights.
|
inline |
Get event weight values as a vector.
Definition at line 98 of file GenEvent.h.
References GenEvent::m_weights.
void write_data | ( | GenEventData & | data | ) | const |
Fill GenEventData object.
Definition at line 633 of file GenEvent.cc.
References GenEventData::attribute_id, GenEventData::attribute_name, GenEventData::attribute_string, GenEvent::attributes(), GenEventData::event_number, GenEvent::event_number(), GenEventData::event_pos, GenEvent::event_pos(), HEPMC3_WARNING, GenEventData::length_unit, GenEvent::length_unit(), GenEventData::links1, GenEventData::links2, GenEvent::m_attributes, GenEventData::momentum_unit, GenEvent::momentum_unit(), GenEventData::particles, GenEvent::particles(), GenEventData::vertices, GenEvent::vertices(), GenEventData::weights, and GenEvent::weights().
|
mutableprivate |
Map of event, particle and vertex attributes.
Keys are name and ID (0 = event, <0 = vertex, >0 = particle)
Definition at line 388 of file GenEvent.h.
|
private |
Event number.
Definition at line 369 of file GenEvent.h.
|
private |
Length unit.
Definition at line 377 of file GenEvent.h.
|
mutableprivate |
Mutex lock for the m_attibutes map.
Definition at line 397 of file GenEvent.h.
|
private |
Momentum unit.
Definition at line 375 of file GenEvent.h.
|
private |
List of particles.
Definition at line 364 of file GenEvent.h.
|
private |
The root vertex is stored outside the normal vertices list to block user access to it.
Definition at line 380 of file GenEvent.h.
|
private |
Global run information.
Definition at line 383 of file GenEvent.h.
|
private |
List of vertices.
Definition at line 366 of file GenEvent.h.
|
private |
Event weights.
Definition at line 372 of file GenEvent.h.