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 31 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 8 of file HepMCParticle.cxx.

9 : particle_(particle) {
10 if (!particle_) {
11 EXCEPTION_RAISE("NullParticle",
12 "Attempted to create HepMCParticle with null GenParticle");
13 }
14}
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 40 of file HepMCParticle.cxx.

40 {
41 return particle_;
42}

References particle_.

◆ getMass()

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

Get the particle's mass.

Returns
The particle's mass.

Definition at line 38 of file HepMCParticle.cxx.

38{ 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 20 of file HepMCParticle.cxx.

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

References particle_.

◆ getPdgId()

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

Get the PDG code.

Returns
The PDG code.

Definition at line 16 of file HepMCParticle.cxx.

16{ return particle_->pid(); }

References particle_.

◆ getStatus()

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

Get the status code.

Returns
The status code.

Definition at line 18 of file HepMCParticle.cxx.

18{ return particle_->status(); }

References particle_.

◆ print()

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

Print particle information to an output stream.

Definition at line 44 of file HepMCParticle.cxx.

44{ 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 46 of file HepMCParticle.cxx.

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

Member Data Documentation

◆ particle_

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

The underlying HepMC3 GenParticle.

Definition at line 87 of file HepMCParticle.h.

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


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