MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
HepMC3::GenParticle Class Reference

Stores particle-related information. More...

#include <GenParticle.h>

Inheritance diagram for HepMC3::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.
 
int abs_pid () const
 Get absolute value of PDG ID.
 
bool add_attribute (const std::string &name, std::shared_ptr< Attribute > att)
 Add an attribute to this particle.
 
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.
 
std::vector< std::string > attribute_names () const
 Get list of names of attributes assigned to this particle.
 
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.
 
const GenParticleDatadata () const
 Get particle data.
 
GenVertexPtr end_vertex ()
 Get end vertex.
 
ConstGenVertexPtr end_vertex () const
 Get end vertex (const version)
 
double generated_mass () const
 Get generated mass.
 
int id () const
 Get the particle ID number (not PDG ID)
 
bool in_event () const
 Check if this particle belongs to an event.
 
bool is_generated_mass_set () const
 Check if generated mass is set.
 
const FourVectormomentum () const
 Get momentum.
 
GenEventparent_event ()
 Get the parent event.
 
const GenEventparent_event () const
 Get the parent event (const)
 
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)
 
int pid () const
 Get PDG ID.
 
GenVertexPtr production_vertex ()
 Get production vertex.
 
ConstGenVertexPtr production_vertex () const
 Get production vertex (const version)
 
void remove_attribute (const std::string &name)
 Remove attribute.
 
void set_generated_mass (double m)
 Set generated mass.
 
void set_momentum (const FourVector &momentum)
 Set momentum.
 
void set_pid (int pid)
 Set PDG ID.
 
void set_status (int status)
 Set status code.
 
int status () const
 Get status code.
 
void unset_generated_mass ()
 Declare that generated mass is not set.
 
Deprecated functionality
int pdg_id () const
 Get PDG ID.
 
void set_pdg_id (const int &pidin)
 Set PDG ID.
 

Friends

class GenEvent
 
class GenVertex
 

Detailed Description

Stores particle-related information.

Definition at line 34 of file GenParticle.h.

Constructor & Destructor Documentation

◆ GenParticle() [1/2]

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

Default constructor.

Definition at line 231 of file marley_hepmc3.cc.

231 :
232 m_event(nullptr),
233 m_id(0) {
234 m_data.pid = pidin;
235 m_data.momentum = mom;
236 m_data.status = stat;
237 m_data.is_mass_set = false;
238 m_data.mass = 0.0;
239}

◆ GenParticle() [2/2]

HepMC3::GenParticle::GenParticle ( const GenParticleData & data)

Constructor based on particle data.

Definition at line 241 of file marley_hepmc3.cc.

241 :
242 m_event(nullptr),
243 m_id(0),
244 m_data(dat) {
245}

Member Function Documentation

◆ abs_pid()

int HepMC3::GenParticle::abs_pid ( ) const
inline

Get absolute value of PDG ID.

Definition at line 95 of file GenParticle.h.

References pid().

◆ add_attribute()

bool HepMC3::GenParticle::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 305 of file marley_hepmc3.cc.

305 {
306 if ( !parent_event() ) return false;
307 parent_event()->add_attribute(name, att, id());
308 return true;
309}
void add_attribute(const std::string &name, const std::shared_ptr< Attribute > &att, const int &id=0)
GenEvent * parent_event()
Get the parent event.
Definition GenParticle.h:63

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

Referenced by marley::NuclearReaction::set_nuclear_residue_attributes().

◆ attribute()

template<class T>
std::shared_ptr< T > HepMC3::GenParticle::attribute ( const std::string & name) const

Get attribute of type T.

Definition at line 165 of file GenParticle.h.

165 {
166 return parent_event()?
167 parent_event()->attribute<T>(name, id()): std::shared_ptr<T>();
168}
std::shared_ptr< T > attribute(const std::string &name, const int &id=0) const
Get attribute of type T.
Definition GenEvent.h:418
int id() const
Get the particle ID number (not PDG ID)
Definition GenParticle.h:68

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

◆ attribute_as_string()

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

Get attribute of any type as string.

Definition at line 320 of file marley_hepmc3.cc.

320 {
321 return parent_event() ? parent_event()->attribute_as_string(name, id()) : std::string();
322}
std::string attribute_as_string(const std::string &name, const int &id=0) const
Get attribute of any type as string.

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

◆ attribute_names()

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

Get list of names of attributes assigned to this particle.

Definition at line 311 of file marley_hepmc3.cc.

311 {
312 if ( parent_event() ) return parent_event()->attribute_names(id());
313 return {};
314}
std::vector< std::string > attribute_names(const int &id=0) const
Get list of attribute names.

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

◆ children() [1/2]

std::vector< GenParticlePtr > HepMC3::GenParticle::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 297 of file marley_hepmc3.cc.

297 {
298 return (m_end_vertex.expired())? std::vector<GenParticlePtr>() : end_vertex()->particles_out();
299}
ConstGenVertexPtr end_vertex() const
Get end vertex (const version)

References end_vertex().

◆ children() [2/2]

std::vector< ConstGenParticlePtr > HepMC3::GenParticle::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 301 of file marley_hepmc3.cc.

301 {
302 return (m_end_vertex.expired()) ? std::vector<ConstGenParticlePtr>() : end_vertex()->particles_out();
303}

References end_vertex().

◆ data()

const GenParticleData & HepMC3::GenParticle::data ( ) const
inline

Get particle data.

Definition at line 70 of file GenParticle.h.

◆ end_vertex() [1/2]

GenVertexPtr HepMC3::GenParticle::end_vertex ( )

Get end vertex.

Definition at line 281 of file marley_hepmc3.cc.

281 {
282 return m_end_vertex.lock();
283}

◆ end_vertex() [2/2]

ConstGenVertexPtr HepMC3::GenParticle::end_vertex ( ) const

Get end vertex (const version)

Definition at line 285 of file marley_hepmc3.cc.

285 {
286 return std::const_pointer_cast<const GenVertex>(m_end_vertex.lock());
287}

Referenced by children(), and children().

◆ generated_mass()

double HepMC3::GenParticle::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 247 of file marley_hepmc3.cc.

247 {
248 return m_data.is_mass_set ? m_data.mass : m_data.momentum.m();
249}

◆ id()

int HepMC3::GenParticle::id ( ) const
inline

Get the particle ID number (not PDG ID)

Definition at line 68 of file GenParticle.h.

68{ return m_id; }

Referenced by attribute().

◆ in_event()

bool HepMC3::GenParticle::in_event ( ) const
inline

Check if this particle belongs to an event.

Definition at line 60 of file GenParticle.h.

60{ return (bool) (m_event); }

◆ is_generated_mass_set()

bool HepMC3::GenParticle::is_generated_mass_set ( ) const
inline

Check if generated mass is set.

Definition at line 98 of file GenParticle.h.

◆ momentum()

const FourVector & HepMC3::GenParticle::momentum ( ) const
inline

Get momentum.

Definition at line 97 of file GenParticle.h.

Referenced by marley::RotationMatrix::rotate_particle_inplace().

◆ parent_event() [1/2]

GenEvent * HepMC3::GenParticle::parent_event ( )
inline

Get the parent event.

Definition at line 63 of file GenParticle.h.

63{ return m_event; }

Referenced by add_attribute(), attribute(), attribute_as_string(), attribute_names(), and remove_attribute().

◆ parent_event() [2/2]

const GenEvent * HepMC3::GenParticle::parent_event ( ) const
inline

Get the parent event (const)

Definition at line 65 of file GenParticle.h.

65{ return m_event; }

◆ parents() [1/2]

std::vector< GenParticlePtr > HepMC3::GenParticle::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 289 of file marley_hepmc3.cc.

289 {
290 return (m_production_vertex.expired())? std::vector<GenParticlePtr>() : production_vertex()->particles_in();
291}
ConstGenVertexPtr production_vertex() const
Get production vertex (const version)

References production_vertex().

◆ parents() [2/2]

std::vector< ConstGenParticlePtr > HepMC3::GenParticle::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 293 of file marley_hepmc3.cc.

293 {
294 return (m_production_vertex.expired()) ? std::vector<ConstGenParticlePtr>() : production_vertex()->particles_in();
295}

References production_vertex().

◆ pdg_id()

int HepMC3::GenParticle::pdg_id ( ) const
inline

Get PDG ID.

Deprecated
Use pid() instead

Definition at line 139 of file GenParticle.h.

139{ return pid(); }
int pid() const
Get PDG ID.
Definition GenParticle.h:94

References pid().

◆ pid()

int HepMC3::GenParticle::pid ( ) const
inline

Get PDG ID.

Definition at line 94 of file GenParticle.h.

Referenced by abs_pid(), and pdg_id().

◆ production_vertex() [1/2]

GenVertexPtr HepMC3::GenParticle::production_vertex ( )

Get production vertex.

Definition at line 273 of file marley_hepmc3.cc.

273 {
274 return m_production_vertex.lock();
275}

◆ production_vertex() [2/2]

ConstGenVertexPtr HepMC3::GenParticle::production_vertex ( ) const

Get production vertex (const version)

Definition at line 277 of file marley_hepmc3.cc.

277 {
278 return std::const_pointer_cast<const GenVertex>(m_production_vertex.lock());
279}

Referenced by parents(), and parents().

◆ remove_attribute()

void HepMC3::GenParticle::remove_attribute ( const std::string & name)

Remove attribute.

Definition at line 316 of file marley_hepmc3.cc.

316 {
317 if ( parent_event() ) parent_event()->remove_attribute(name, id());
318}
void remove_attribute(const std::string &name, const int &id=0)
Remove attribute.

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

◆ set_generated_mass()

void HepMC3::GenParticle::set_generated_mass ( double m)

Set generated mass.

Definition at line 263 of file marley_hepmc3.cc.

263 {
264 m_data.mass = m;
265 m_data.is_mass_set = true;
266}

◆ set_momentum()

void HepMC3::GenParticle::set_momentum ( const FourVector & momentum)

Set momentum.

Definition at line 259 of file marley_hepmc3.cc.

259 {
260 m_data.momentum = mom;
261}

Referenced by marley::RotationMatrix::rotate_particle_inplace().

◆ set_pdg_id()

void HepMC3::GenParticle::set_pdg_id ( const int & pidin)
inline

Set PDG ID.

Deprecated
Use set_pid() instead

Definition at line 143 of file GenParticle.h.

143{ set_pid(pidin); }
void set_pid(int pid)
Set PDG ID.

References set_pid().

◆ set_pid()

void HepMC3::GenParticle::set_pid ( int pid)

Set PDG ID.

Definition at line 251 of file marley_hepmc3.cc.

251 {
252 m_data.pid = pidin;
253}

Referenced by set_pdg_id().

◆ set_status()

void HepMC3::GenParticle::set_status ( int status)

Set status code.

Definition at line 255 of file marley_hepmc3.cc.

255 {
256 m_data.status = stat;
257}

Referenced by marley::DecayScheme::do_cascade().

◆ status()

int HepMC3::GenParticle::status ( ) const
inline

Get status code.

Definition at line 96 of file GenParticle.h.

◆ unset_generated_mass()

void HepMC3::GenParticle::unset_generated_mass ( )

Declare that generated mass is not set.

Definition at line 268 of file marley_hepmc3.cc.

268 {
269 m_data.mass = 0.;
270 m_data.is_mass_set = false;
271}

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.


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