LDMX Software
simcore::hepmc::HepMCParticle Class Reference

Wrapper class for HepMC3::GenParticle. More...

#include <HepMCParticle.h>

Public Member Functions

 HepMCParticle (std::shared_ptr< HepMC3::GenParticle > particle)
 Class constructor.
 
int getPdgId () const
 Get the PDG code.
 
int getStatus () const
 Get the status code.
 
double getMomentum (int index) const
 Get a momentum component by index.
 
double getMass () const
 Get the particle's mass.
 
std::shared_ptr< HepMC3::GenParticle > getGenParticle () const
 Get the underlying HepMC3 GenParticle.
 
void print () const
 Print particle information to an output stream.
 

Private Attributes

std::shared_ptr< HepMC3::GenParticle > particle_
 The underlying HepMC3 GenParticle.
 

Friends

std::ostream & operator<< (std::ostream &stream, const HepMCParticle &particle)
 Overloaded stream operator.
 

Detailed Description

Wrapper class for HepMC3::GenParticle.

Definition at line 28 of file HepMCParticle.h.

Constructor & Destructor Documentation

◆ HepMCParticle()

simcore::hepmc::HepMCParticle::HepMCParticle ( std::shared_ptr< HepMC3::GenParticle > particle)

Class constructor.

Parameters
particleShared pointer to HepMC3 GenParticle

Definition at line 11 of file HepMCParticle.cxx.

12 : particle_(particle) {
13 if (!particle_) {
14 EXCEPTION_RAISE("NullParticle",
15 "Attempted to create HepMCParticle with null GenParticle");
16 }
17}
std::shared_ptr< HepMC3::GenParticle > particle_
The underlying HepMC3 GenParticle.

References particle_.

Member Function Documentation

◆ getGenParticle()

std::shared_ptr< HepMC3::GenParticle > simcore::hepmc::HepMCParticle::getGenParticle ( ) const

Get the underlying HepMC3 GenParticle.

Returns
Shared pointer to the HepMC3 GenParticle

Definition at line 43 of file HepMCParticle.cxx.

43 {
44 return particle_;
45}

References particle_.

◆ getMass()

double simcore::hepmc::HepMCParticle::getMass ( ) const

Get the particle's mass.

Returns
The particle's mass.

Definition at line 41 of file HepMCParticle.cxx.

41{ return particle_->generated_mass(); }

References particle_.

◆ getMomentum()

double simcore::hepmc::HepMCParticle::getMomentum ( int index) const

Get a momentum component by index.

Index 0: px, 1: py, 2: pz, 3: E

Returns
The momentum component by index.

Definition at line 23 of file HepMCParticle.cxx.

23 {
24 const HepMC3::FourVector& momentum = particle_->momentum();
25 switch (index) {
26 case 0:
27 return momentum.px();
28 case 1:
29 return momentum.py();
30 case 2:
31 return momentum.pz();
32 case 3:
33 return momentum.e();
34 default:
35 EXCEPTION_RAISE(
36 "InvalidIndex",
37 "Momentum index must be 0 (px), 1 (py), 2 (pz), or 3 (E)");
38 }
39}

References particle_.

◆ getPdgId()

int simcore::hepmc::HepMCParticle::getPdgId ( ) const

Get the PDG code.

Returns
The PDG code.

Definition at line 19 of file HepMCParticle.cxx.

19{ return particle_->pid(); }

References particle_.

◆ getStatus()

int simcore::hepmc::HepMCParticle::getStatus ( ) const

Get the status code.

Returns
The status code.

Definition at line 21 of file HepMCParticle.cxx.

21{ return particle_->status(); }

References particle_.

◆ print()

void simcore::hepmc::HepMCParticle::print ( ) const

Print particle information to an output stream.

Definition at line 47 of file HepMCParticle.cxx.

47{ std::cout << *this << std::endl; }

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & stream,
const HepMCParticle & particle )
friend

Overloaded stream operator.

Parameters
streamThe output stream.
particleThe particle to print.

Definition at line 49 of file HepMCParticle.cxx.

49 {
50 stream << "HepMCParticle: " << "PDG=" << particle.getPdgId()
51 << " Status=" << particle.getStatus()
52 << " px=" << particle.getMomentum(0)
53 << " py=" << particle.getMomentum(1)
54 << " pz=" << particle.getMomentum(2)
55 << " E=" << particle.getMomentum(3) << " mass=" << particle.getMass();
56 return stream;
57}

Member Data Documentation

◆ particle_

std::shared_ptr<HepMC3::GenParticle> simcore::hepmc::HepMCParticle::particle_
private

The underlying HepMC3 GenParticle.

Definition at line 84 of file HepMCParticle.h.

Referenced by getGenParticle(), getMass(), getMomentum(), getPdgId(), getStatus(), and HepMCParticle().


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