HepMC3 event record library: GenParticle Class Reference

HepMC3 event record library

Public Member Functions | Private Attributes | Friends
GenParticle Class Reference

## Detailed Description

Stores particle-related information.

Definition at line 34 of file GenParticle.h.

`#include <GenParticle.h>`

Inheritance diagram for GenParticle:
[legend]
Collaboration diagram for GenParticle:
[legend]

## 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.
GenEvent * | parent_event ()
| Get the parent event.
const GenEvent * | parent_event () const
| Get the parent event (const).
int | id () const
| Get the particle ID number (not PDG ID).
const GenParticleData & | data () 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 FourVector & | momentum () 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
GenEvent * | m_event
| Parent event.
int | m_id
| Index.
GenParticleData | m_data
| Particle data.
std::weak_ptr< GenVertex > | m_production_vertex
| Production vertex.
std::weak_ptr< GenVertex > | m_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 )

Default constructor.

Definition at line 20 of file GenParticle.cc.

References m_data, m_event, and m_id.

## ◆ GenParticle() [2/2]

GenParticle | ( | const GenParticleData & | data | ) |

Constructor based on particle data.

Definition at line 30 of file GenParticle.cc.

References m_data, m_event, and m_id.

## Member Function Documentation

## ◆ abs_pid()

int abs_pid | ( |  | ) | const
| inline

Get absolute value of PDG ID.

Definition at line 95 of file GenParticle.h.

References 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 parent_event().

## ◆ attribute()

template<class T>

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

Get attribute of type T.

Definition at line 165 of file GenParticle.h.

References GenEvent::attribute(), id(), and 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 109 of file GenParticle.cc.

References GenEvent::attribute_as_string(), and 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 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 end_vertex(), and 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 end_vertex(), and m_end_vertex.

## ◆ data()

const GenParticleData & data | ( |  | ) | const
| inline

Get particle data.

Definition at line 70 of file GenParticle.h.

References m_data.

## ◆ end_vertex() [1/2]

GenVertexPtr end_vertex | ( |  | ) |

Get end vertex.

Definition at line 70 of file GenParticle.cc.

References 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 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 36 of file GenParticle.cc.

References m_data.

## ◆ id()

int id | ( |  | ) | const
| inline

Get the particle ID number (not PDG ID).

Definition at line 68 of file GenParticle.h.

References m_id.

## ◆ in_event()

bool in_event | ( |  | ) | const
| inline

Check if this particle belongs to an event.

Definition at line 60 of file GenParticle.h.

References m_event.

## ◆ is_generated_mass_set()

bool is_generated_mass_set | ( |  | ) | const
| inline

Check if generated mass is set.

Definition at line 98 of file GenParticle.h.

References m_data.

## ◆ momentum()

const FourVector & momentum | ( |  | ) | const
| inline

Get momentum.

Definition at line 97 of file GenParticle.h.

References m_data.

## ◆ parent_event() [1/2]

GenEvent * parent_event | ( |  | ) |
| inline

Get the parent event.

Definition at line 63 of file GenParticle.h.

References m_event.

## ◆ parent_event() [2/2]

const GenEvent * parent_event | ( |  | ) | const
| inline

Get the parent event (const).

Definition at line 65 of file GenParticle.h.

References 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 m_production_vertex, and 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 m_production_vertex, and production_vertex().

## ◆ pdg_id()

int pdg_id | ( |  | ) | const
| inline

Get PDG ID.

Deprecated
  Use pid() instead

Definition at line 139 of file GenParticle.h.

References pid().

## ◆ pid()

int pid | ( |  | ) | const
| inline

Get PDG ID.

Definition at line 94 of file GenParticle.h.

References m_data.

## ◆ production_vertex() [1/2]

GenVertexPtr production_vertex | ( |  | ) |

Get production vertex.

Definition at line 62 of file GenParticle.cc.

References 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 m_production_vertex.

## ◆ remove_attribute()

void remove_attribute | ( | const std::string & | name | ) |

Remove attribute.

Definition at line 105 of file GenParticle.cc.

References 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 m_data.

## ◆ set_momentum()

void set_momentum | ( | const FourVector & | momentum | ) |

Set momentum.

Definition at line 48 of file GenParticle.cc.

References m_data.

## ◆ set_pdg_id()

void set_pdg_id | ( | const int & | pidin | ) |
| inline

Set PDG ID.

Deprecated
  Use set_pid() instead

Definition at line 143 of file GenParticle.h.

References set_pid().

## ◆ set_pid()

void set_pid | ( | int | pid | ) |

Set PDG ID.

Definition at line 40 of file GenParticle.cc.

References m_data.

## ◆ set_status()

void set_status | ( | int | status | ) |

Set status code.

Definition at line 44 of file GenParticle.cc.

References m_data.

## ◆ status()

int status | ( |  | ) | const
| inline

Get status code.

Definition at line 96 of file GenParticle.h.

References m_data.

## ◆ unset_generated_mass()

void unset_generated_mass | ( |  | ) |

Declare that generated mass is not set.

Definition at line 57 of file GenParticle.cc.

References m_data.

## Friends And Related Symbol Documentation

## ◆ GenEvent

friend class GenEvent
| friend

Definition at line 37 of file GenParticle.h.

## ◆ GenVertex

friend class GenVertex
| friend

Definition at line 36 of file GenParticle.h.

## Field Documentation

## ◆ m_data

GenParticleData m_data
| private

Particle data.

Definition at line 152 of file GenParticle.h.

## ◆ m_end_vertex

std::weak_ptr<GenVertex> m_end_vertex
| private

End vertex.

Definition at line 155 of file GenParticle.h.

## ◆ m_event

GenEvent* m_event
| private

Parent event.

Definition at line 150 of file GenParticle.h.

## ◆ m_id

int m_id
| private

Index.

Definition at line 151 of file GenParticle.h.

## ◆ m_production_vertex

std::weak_ptr<GenVertex> m_production_vertex
| private

Production vertex.

Definition at line 154 of file GenParticle.h.

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

- GenParticle.h
- GenParticle.cc