10 #ifndef HEPMC_GENEVENT_H 11 #define HEPMC_GENEVENT_H 13 #include "HepMC/Units.h" 15 #if !defined(__CINT__) 16 #include "HepMC/Data/SmartPointer.h" 17 #include "HepMC/Errors.h" 18 #include "HepMC/GenHeavyIon.h" 19 #include "HepMC/GenPdfInfo.h" 20 #include "HepMC/GenCrossSection.h" 21 #include "HepMC/GenRunInfo.h" 45 #if !defined(__CINT__) 83 double weight(
const std::string& name)
const {
84 if (!
run_info())
throw WeightError(
"GenEvent::weight(str): named access to event weights requires the event to have a GenRunInfo");
89 const std::vector<std::string>&
weight_names(
const std::string& )
const {
90 if (!
run_info())
throw WeightError(
"GenEvent::weight_names(): access to event weight names requires the event to have a GenRunInfo");
91 const std::vector<std::string>& weightnames =
run_info()->weight_names();
92 if (weightnames.empty())
throw WeightError(
"GenEvent::weight_names(): no event weight names are registered for this run");
124 #ifndef HEPMC_NO_DEPRECATED 127 set_units(new_momentum_unit, new_length_unit);
156 const std::vector<GenParticlePtr>&
beams()
const;
176 void add_attribute(
const string &name,
const shared_ptr<Attribute> &att,
int id = 0) {
185 shared_ptr<T>
attribute(
const string &name,
int id = 0)
const;
252 #ifndef HEPMC_NO_DEPRECATED 328 int particles_size()
const {
return m_particles.size(); }
332 bool particles_empty()
const {
return m_particles.empty(); }
336 int vertices_size()
const {
return m_vertices.size(); }
340 bool vertices_empty()
const {
return m_vertices.empty(); }
355 HEPMC_DEPRECATED("instead add particle without production vertex to the event")
361 HEPMC_DEPRECATED("instead add particle without production vertex to the event")
382 void Streamer(TBuffer &b);
391 #if !defined(__CINT__) 419 mutable std::map< string, std::map<int, shared_ptr<Attribute> > >
m_attributes;
422 typedef std::map< string, std::map<int, shared_ptr<Attribute> > >::value_type
att_key_t;
425 typedef std::map<int, shared_ptr<Attribute> >::value_type
att_val_t;
434 #if !defined(__CINT__) 443 std::map< string, std::map<int, shared_ptr<Attribute> > >::iterator i1 =
m_attributes.find(name);
446 return run_info()->attribute<T>(name);
448 return shared_ptr<T>();
451 std::map<int, shared_ptr<Attribute> >::iterator i2 = i1->second.find(
id);
452 if (i2 == i1->second.end() )
return shared_ptr<T>();
454 if (!i2->second->is_parsed() ) {
456 shared_ptr<T> att = make_shared<T>();
457 if ( att->from_string(i2->second->unparsed_string()) && att->init(*
this) ) {
462 return shared_ptr<T>();
465 else return dynamic_pointer_cast<T>(i2->second);
471 #ifndef HEPMC_NO_DEPRECATED const GenCrossSectionPtr cross_section() const
Get cross-section information.
const std::vector< GenParticlePtr > & particles() const
Get list of particles (const)
const GenPdfInfoPtr pdf_info() const
Get PDF information.
Stores additional information about Heavy Ion generator.
Exception related to weight lookups, setting, and index consistency.
const Units::MomentumUnit & momentum_unit() const
Get momentum unit.
string attribute_as_string(const string &name, int id=0) const
Get attribute of any type as string.
void remove_particles(std::vector< GenParticlePtr > v)
Remove a set of particles.
void add_vertex(GenVertexPtr v)
Add vertex.
Stores additional information about PDFs.
void set_pdf_info(const GenPdfInfoPtr &pi)
Set PDF information.
std::map< string, std::map< int, shared_ptr< Attribute > > > m_attributes
Map of event, particle and vertex attributes.
std::pair< GenParticlePtr, GenParticlePtr > beam_particles() const
Get first two particles of the event_pos() vertex.
Stores additional information about cross-section.
double weight(size_t index=0) const
bool valid_beam_particles() const
Test to see if we have exactly two particles in event_pos() vertex.
shared_ptr< T > attribute(const string &name, int id=0) const
Get attribute of type T.
void set_event_number(int num)
Set event number.
int event_number() const
Get event number.
void remove_attribute(const string &name, int id=0)
Remove attribute.
const std::map< string, std::map< int, shared_ptr< Attribute > > > & attributes() const
Get list of attributes.
shared_ptr< class GenPdfInfo > GenPdfInfoPtr
Shared pointer to GenPdfInfo.
void set_units(Units::MomentumUnit new_momentum_unit, Units::LengthUnit new_length_unit)
Change event units Converts event from current units to new ones.
HEPMC_DEPRECATED("Use vertices().size() instead") int vertices_size() const
vertex_iterator vertices_end()
void add_tree(const std::vector< GenParticlePtr > &particles)
Add whole tree in topological order.
void remove_particle(GenParticlePtr v)
Remove particle from the event.
std::vector< double > & weights()
Get event weights as a vector (non-const)
Smart pointer for HepMC objects.
void remove_vertex(GenVertexPtr v)
Remove vertex from the event.
shared_ptr< class GenCrossSection > GenCrossSectionPtr
Shared pointer to GenCrossSection.
void shift_position_by(const FourVector &delta)
Shift position of all vertices in the event by delta.
Stores vertex-related information.
void clear()
Remove contents of this event.
vertex_iterator vertices_begin()
void use_units(Units::MomentumUnit new_momentum_unit, Units::LengthUnit new_length_unit)
Converts event from current units to new ones (compatibility name)
shared_ptr< GenRunInfo > run_info() const
Get a pointer to the the GenRunInfo object.
HEPMC_DEPRECATED("Use particles().size() instead") int particles_size() const
std::map< int, shared_ptr< Attribute > >::value_type att_val_t
Attribute map value type.
particle_iterator particles_begin()
std::vector< GenVertexPtr > & vertices()
Get/set list of vertices (non-const)
HEPMC_DEPRECATED("Use vertices().empty() instead") bool vertices_empty() const
std::vector< GenParticlePtr >::iterator particle_iterator
void set_heavy_ion(const GenHeavyIonPtr &hi)
Set heavy ion generator additional information.
std::vector< GenParticlePtr > m_particles
List of particles.
Units::LengthUnit m_length_unit
Length unit.
std::vector< double > m_weights
Event weights.
const std::vector< GenParticlePtr > & beams() const
Vector of beam particles.
GenVertexPtr m_rootvertex
The root vertex is stored outside the normal vertices list to block user access to it...
std::vector< double > GenWeights
std::vector< string > attribute_names(int id=0) const
Get list of attribute names.
void read_data(const GenEventData &data)
Fill GenEvent based on GenEventData.
void add_attribute(const string &name, const shared_ptr< Attribute > &att, int id=0)
Add event attribute to event.
std::vector< double > WeightContainer
void add_particle(GenParticlePtr p)
Add particle.
std::vector< GenVertexPtr > m_vertices
List of vertices.
MomentumUnit
Momentum units.
std::vector< GenVertexPtr >::iterator vertex_iterator
void shift_position_to(const FourVector &newpos)
Shift position of all vertices in the event to op.
std::map< string, std::map< int, shared_ptr< Attribute > > >::value_type att_key_t
Attribute map key type.
GenEvent(Units::MomentumUnit momentum_unit=Units::GEV, Units::LengthUnit length_unit=Units::MM)
Event constructor without a run.
std::vector< double > WeightContainer
shared_ptr< GenRunInfo > m_run_info
Global run information.
const std::vector< GenVertexPtr > & vertices() const
Get list of vertices (const)
double weight(const std::string &name) const
shared_ptr< class GenHeavyIon > GenHeavyIonPtr
Shared pointer to GenHeavyIon.
void reserve(unsigned int particles, unsigned int vertices=0)
Reserve memory for particles and vertices.
std::vector< GenParticlePtr > & particles()
Get/set list of particles (non-const)
void set_beam_particles(const GenParticlePtr &p1, const GenParticlePtr &p2)
Set incoming beam particles.
std::vector< GenParticlePtr >::const_iterator particle_const_iterator
const FourVector & event_pos() const
Vertex representing the overall event position.
HEPMC_DEPRECATED("Use particles().empty() instead") bool particles_empty() const
particle_iterator particles_end()
Definition of template class SmartPointer.
void set_cross_section(const GenCrossSectionPtr &cs)
Set cross-section information.
std::vector< GenVertexPtr >::const_iterator vertex_const_iterator
Units::MomentumUnit m_momentum_unit
Momentum unit.
const Units::LengthUnit & length_unit() const
Get length unit.
Stores serializable event information.
void set_run_info(shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
const std::vector< double > & weights() const
Get event weight values as a vector.
void write_data(GenEventData &data) const
Fill GenEventData object.
const GenHeavyIonPtr heavy_ion() const
Get heavy ion generator additional information.
Stores particle-related information.
const std::vector< std::string > & weight_names(const std::string &) const
LengthUnit
Position units.