HepMC3 event record library
Public Member Functions | Private Attributes | Friends
GenParticle Class Reference

Detailed Description

Stores particle-related information.

Definition at line 31 of file GenParticle.h.

#include <GenParticle.h>

+ Inheritance diagram for GenParticle:
+ Collaboration diagram for GenParticle:

Public Member Functions

 GenParticle (const FourVector &momentum=FourVector::ZERO_VECTOR(), int pid=0, int status=0)
 Default constructor.
 
 GenParticle (const GenParticleData &data)
 Constructor based on particle data.
 
bool in_event () const
 Check if this particle belongs to an event.
 
GenEventparent_event ()
 Get parent event.
 
const GenEventparent_event () const
 Get parent event.
 
int id () const
 Get particle id.
 
const GenParticleDatadata () const
 Get particle data.
 
ConstGenVertexPtr production_vertex () const
 Get production vertex (const version)
 
ConstGenVertexPtr end_vertex () const
 Get end vertex (const version)
 
GenVertexPtr production_vertex ()
 Get production vertex.
 
GenVertexPtr end_vertex ()
 Get end vertex.
 
std::vector< GenParticlePtr > parents ()
 Convenience access to immediate incoming particles via production vertex.
 
std::vector< ConstGenParticlePtr > parents () const
 Convenience access to immediate incoming particles via production vertex (const version)
 
std::vector< GenParticlePtr > children ()
 Convenience access to immediate outgoing particles via end vertex.
 
std::vector< ConstGenParticlePtr > children () const
 Convenience access to immediate outgoing particles via end vertex.
 
int pid () const
 Get PDG ID.
 
int abs_pid () const
 Get absolute value of PDG ID.
 
int status () const
 Get status code.
 
const FourVectormomentum () const
 Get momentum.
 
bool is_generated_mass_set () const
 Check if generated mass is set.
 
double generated_mass () const
 Get generated mass.
 
void set_pid (int pid)
 Set PDG ID.
 
void set_status (int status)
 Set status code.
 
void set_momentum (const FourVector &momentum)
 Set momentum.
 
void set_generated_mass (double m)
 Set generated mass.
 
void unset_generated_mass ()
 Declare that generated mass is not set.
 
bool add_attribute (const std::string &name, std::shared_ptr< Attribute > att)
 Add an attribute to this particle.
 
std::vector< std::string > attribute_names () const
 Get list of names of attributes assigned to this particle.
 
void remove_attribute (const std::string &name)
 Remove attribute.
 
template<class T >
std::shared_ptr< T > attribute (const std::string &name) const
 Get attribute of type T.
 
std::string attribute_as_string (const std::string &name) const
 Get attribute of any type as string.
 
Deprecated functionality
int pdg_id () const
 Get PDG ID.
 
void set_pdg_id (const int &pidin)
 Set PDG ID.
 

Private Attributes

GenEventm_event
 Parent event.
 
int m_id
 Index.
 
GenParticleData m_data
 Particle data.
 
std::weak_ptr< GenVertexm_production_vertex
 Production vertex.
 
std::weak_ptr< GenVertexm_end_vertex
 End vertex.
 

Friends

class GenVertex
 
class GenEvent
 

Constructor & Destructor Documentation

◆ GenParticle() [1/2]

GenParticle ( const FourVector momentum = FourVector::ZERO_VECTOR(),
int  pid = 0,
int  status = 0 
)

◆ GenParticle() [2/2]

GenParticle ( const GenParticleData data)

Constructor based on particle data.

Definition at line 29 of file GenParticle.cc.

Member Function Documentation

◆ abs_pid()

int abs_pid ( ) const
inline

Get absolute value of PDG ID.

Definition at line 87 of file GenParticle.h.

References GenParticle::pid().

◆ add_attribute()

bool add_attribute ( const std::string &  name,
std::shared_ptr< Attribute att 
)

Add an attribute to this particle.

This will overwrite existing attribute if an attribute with the same name is present. The attribute will be stored in the parent_event().

Returns
false if there is no parent_event();

Definition at line 94 of file GenParticle.cc.

References GenEvent::add_attribute(), and GenParticle::parent_event().

◆ attribute()

std::shared_ptr< T > attribute ( const std::string &  name) const

Get attribute of type T.

Definition at line 157 of file GenParticle.h.

References GenEvent::attribute(), GenParticle::id(), and GenParticle::parent_event().

◆ attribute_as_string()

std::string attribute_as_string ( const std::string &  name) const

Get attribute of any type as string.

Definition at line 110 of file GenParticle.cc.

References GenEvent::attribute_as_string(), and GenParticle::parent_event().

◆ attribute_names()

std::vector< std::string > attribute_names ( ) const

Get list of names of attributes assigned to this particle.

Definition at line 100 of file GenParticle.cc.

References GenEvent::attribute_names(), and GenParticle::parent_event().

◆ children() [1/2]

std::vector< GenParticlePtr > children ( )

Convenience access to immediate outgoing particles via end vertex.

Note
Less efficient than via the vertex since return must be by value (in case there is no vertex)

Definition at line 86 of file GenParticle.cc.

References GenParticle::end_vertex(), and GenParticle::m_end_vertex.

◆ children() [2/2]

std::vector< ConstGenParticlePtr > children ( ) const

Convenience access to immediate outgoing particles via end vertex.

Note
Less efficient than via the vertex since return must be by value (in case there is no vertex)

Definition at line 90 of file GenParticle.cc.

References GenParticle::end_vertex(), and GenParticle::m_end_vertex.

◆ data()

const GenParticleData & data ( ) const
inline

Get particle data.

Definition at line 61 of file GenParticle.h.

References GenParticle::m_data.

◆ end_vertex() [1/2]

GenVertexPtr end_vertex ( )

Get end vertex.

Definition at line 70 of file GenParticle.cc.

References GenParticle::m_end_vertex.

◆ end_vertex() [2/2]

ConstGenVertexPtr end_vertex ( ) const

Get end vertex (const version)

Definition at line 74 of file GenParticle.cc.

References GenParticle::m_end_vertex.

◆ generated_mass()

double generated_mass ( ) const

Get generated mass.

This function will return mass as set by a generator/tool. If not set, it will return momentum().m()

Definition at line 35 of file GenParticle.cc.

References GenParticleData::is_mass_set, FourVector::m(), GenParticle::m_data, GenParticleData::mass, and GenParticleData::momentum.

◆ id()

int id ( ) const
inline

Get particle id.

Definition at line 60 of file GenParticle.h.

References GenParticle::m_id.

◆ in_event()

bool in_event ( ) const
inline

Check if this particle belongs to an event.

Definition at line 51 of file GenParticle.h.

References GenParticle::m_event.

◆ is_generated_mass_set()

bool is_generated_mass_set ( ) const
inline

Check if generated mass is set.

Definition at line 90 of file GenParticle.h.

References GenParticleData::is_mass_set, and GenParticle::m_data.

◆ momentum()

const FourVector & momentum ( ) const
inline

Get momentum.

Definition at line 89 of file GenParticle.h.

References GenParticle::m_data, and GenParticleData::momentum.

◆ parent_event() [1/2]

GenEvent * parent_event ( )
inline

Get parent event.

Definition at line 58 of file GenParticle.h.

References GenParticle::m_event.

◆ parent_event() [2/2]

const GenEvent * parent_event ( ) const
inline

Get parent event.

Definition at line 59 of file GenParticle.h.

References GenParticle::m_event.

◆ parents() [1/2]

std::vector< GenParticlePtr > parents ( )

Convenience access to immediate incoming particles via production vertex.

Note
Less efficient than via the vertex since return must be by value (in case there is no vertex)

Definition at line 78 of file GenParticle.cc.

References GenParticle::m_production_vertex, and GenParticle::production_vertex().

◆ parents() [2/2]

std::vector< ConstGenParticlePtr > parents ( ) const

Convenience access to immediate incoming particles via production vertex (const version)

Note
Less efficient than via the vertex since return must be by value (in case there is no vertex)

Definition at line 82 of file GenParticle.cc.

References GenParticle::m_production_vertex, and GenParticle::production_vertex().

◆ pdg_id()

int pdg_id ( ) const
inline

Get PDG ID.

Deprecated:
Use pid() instead

Definition at line 132 of file GenParticle.h.

References GenParticle::pid().

◆ pid()

int pid ( ) const
inline

Get PDG ID.

Definition at line 86 of file GenParticle.h.

References GenParticle::m_data, and GenParticleData::pid.

◆ production_vertex() [1/2]

GenVertexPtr production_vertex ( )

Get production vertex.

Definition at line 62 of file GenParticle.cc.

References GenParticle::m_production_vertex.

◆ production_vertex() [2/2]

ConstGenVertexPtr production_vertex ( ) const

Get production vertex (const version)

Definition at line 66 of file GenParticle.cc.

References GenParticle::m_production_vertex.

◆ remove_attribute()

void remove_attribute ( const std::string &  name)

Remove attribute.

Definition at line 106 of file GenParticle.cc.

References GenParticle::parent_event(), and GenEvent::remove_attribute().

◆ set_generated_mass()

void set_generated_mass ( double  m)

Set generated mass.

Definition at line 52 of file GenParticle.cc.

References GenParticleData::is_mass_set, GenParticle::m_data, and GenParticleData::mass.

◆ set_momentum()

void set_momentum ( const FourVector momentum)

Set momentum.

Definition at line 48 of file GenParticle.cc.

References GenParticle::m_data, and GenParticleData::momentum.

◆ set_pdg_id()

void set_pdg_id ( const int &  pidin)
inline

Set PDG ID.

Deprecated:
Use set_pid() instead

Definition at line 136 of file GenParticle.h.

References GenParticle::set_pid().

◆ set_pid()

void set_pid ( int  pid)

Set PDG ID.

Definition at line 40 of file GenParticle.cc.

References GenParticle::m_data, and GenParticleData::pid.

◆ set_status()

void set_status ( int  status)

Set status code.

Definition at line 44 of file GenParticle.cc.

References GenParticle::m_data, and GenParticleData::status.

◆ status()

int status ( ) const
inline

Get status code.

Definition at line 88 of file GenParticle.h.

References GenParticle::m_data, and GenParticleData::status.

◆ unset_generated_mass()

void unset_generated_mass ( )

Declare that generated mass is not set.

Definition at line 57 of file GenParticle.cc.

References GenParticleData::is_mass_set, GenParticle::m_data, and GenParticleData::mass.

Friends And Related Function Documentation

◆ GenEvent

friend class GenEvent
friend

Definition at line 34 of file GenParticle.h.

◆ GenVertex

friend class GenVertex
friend

Definition at line 33 of file GenParticle.h.

Field Documentation

◆ m_data

GenParticleData m_data
private

Particle data.

Definition at line 146 of file GenParticle.h.

◆ m_end_vertex

std::weak_ptr<GenVertex> m_end_vertex
private

End vertex.

Definition at line 149 of file GenParticle.h.

◆ m_event

GenEvent* m_event
private

Parent event.

Definition at line 144 of file GenParticle.h.

◆ m_id

int m_id
private

Index.

Definition at line 145 of file GenParticle.h.

◆ m_production_vertex

std::weak_ptr<GenVertex> m_production_vertex
private

Production vertex.

Definition at line 148 of file GenParticle.h.


The documentation for this class was generated from the following files: