MARLEY (Model of Argon Reaction Low Energy Yields)  v1.2.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Public Member Functions | Protected Attributes | List of all members
marley::Particle Class Reference

Momentum four-vector for a simulated particle. More...

#include <Particle.hh>

Public Member Functions

 Particle (int pdg_code, double E, double px, double py, double pz, double m)
 
 Particle (int pdg_code, double E, double px, double py, double pz, double m, int q)
 
 Particle (int pdg_code, double m)
 
 Particle (int pdg_code, double m, int q)
 
 Particle (int pdg_code, double px, double py, double pz, double m)
 
 Particle (int pdg_code, double px, double py, double pz, double m, int q)
 
double charge () const
 Get the particle's charge in units of the proton charge.
 
void clear ()
 Resets all data members to zero.
 
void from_json (const marley::JSON &json)
 Replaces the existing object contents with new ones loaded from a JSON representation of a Particle.
 
double kinetic_energy () const
 Get the particle's kinetic energy (MeV)
 
double mass () const
 Get the particle's mass (MeV)
 
double momentum_magnitude () const
 Get the magnitude of the particle's 3-momentum (MeV)
 
int pdg_code () const
 Get the Particle Data Group code for this particle.
 
void print (std::ostream &out) const
 Print information about this particle to a std::ostream. More...
 
double px () const
 Get the x component of the particle's 3-momentum (MeV)
 
double py () const
 Get the y component of the particle's 3-momentum (MeV)
 
double pz () const
 Get the z component of the particle's 3-momentum (MeV)
 
void read (std::istream &in)
 Read in this particle from a std::istream. Any previous contents of this particle will be deleted.
 
void set_charge (int q)
 Set the particle's charge. More...
 
void set_mass (double m)
 Set the particle's mass. More...
 
void set_px (double px)
 Set the x component of the particle's 3-momentum. More...
 
void set_py (double py)
 Set the y component of the particle's 3-momentum. More...
 
void set_pz (double pz)
 Set the z component of the particle's 3-momentum. More...
 
void set_total_energy (double Etot)
 Set the particle's total energy. More...
 
marley::JSON to_json () const
 Create a JSON representation of this Particle.
 
double total_energy () const
 Get the particle's total energy (MeV)
 

Protected Attributes

int charge_ = 0
 Electric charge (net charge in the case of atoms) expressed as an integer multiple of the proton charge. More...
 
double four_momentum_ [4]
 momentum 4-vector for this particle (MeV) More...
 
double mass_ = 0.
 mass (MeV)
 
int pdg_code_ = 0
 Particle Data Group code identifying this particle More...
 

Detailed Description

Momentum four-vector for a simulated particle.

Constructor & Destructor Documentation

◆ Particle() [1/6]

marley::Particle::Particle ( int  pdg_code,
double  m 
)
Parameters
pdg_codeParticle Data Group code
mmass (MeV)

◆ Particle() [2/6]

marley::Particle::Particle ( int  pdg_code,
double  m,
int  q 
)
Parameters
pdg_codeParticle Data Group code
mmass (MeV)
qcharge in units of the proton charge

◆ Particle() [3/6]

marley::Particle::Particle ( int  pdg_code,
double  px,
double  py,
double  pz,
double  m 
)
Parameters
pdg_codeParticle Data Group code
px3-momentum x component (MeV)
py3-momentum y component (MeV)
pz3-momentum z component (MeV)
mmass (MeV)

◆ Particle() [4/6]

marley::Particle::Particle ( int  pdg_code,
double  px,
double  py,
double  pz,
double  m,
int  q 
)
Parameters
pdg_codeParticle Data Group code
px3-momentum x component (MeV)
py3-momentum y component (MeV)
pz3-momentum z component (MeV)
mmass (MeV)
qcharge in units of the proton charge

◆ Particle() [5/6]

marley::Particle::Particle ( int  pdg_code,
double  E,
double  px,
double  py,
double  pz,
double  m 
)
Parameters
pdg_codeParticle Data Group code
Etotal energy (MeV)
px3-momentum x component (MeV)
py3-momentum y component (MeV)
pz3-momentum z component (MeV)
mmass (MeV)

◆ Particle() [6/6]

marley::Particle::Particle ( int  pdg_code,
double  E,
double  px,
double  py,
double  pz,
double  m,
int  q 
)
Parameters
pdg_codeParticle Data Group code
Etotal energy (MeV)
px3-momentum x component (MeV)
py3-momentum y component (MeV)
pz3-momentum z component (MeV)
mmass (MeV)
qcharge in units of the proton charge

Member Function Documentation

◆ print()

void marley::Particle::print ( std::ostream &  out) const

Print information about this particle to a std::ostream.

Note
Although marley::Event::print() guarantees full precision for stream output, this function does not if it is called directly. If you need to serialize individual particle objects to text and read them back in again, either use an output stream with the proper precision set in advance (at least std::numeric_limits<double>::max_digits10), or consider using JSON input/output.

◆ set_charge()

void marley::Particle::set_charge ( int  q)
inline

Set the particle's charge.

Parameters
qcharge in units of the proton charge

◆ set_mass()

void marley::Particle::set_mass ( double  m)
inline

Set the particle's mass.

Parameters
mmass (MeV)

◆ set_px()

void marley::Particle::set_px ( double  px)
inline

Set the x component of the particle's 3-momentum.

Parameters
px3-momentum x component (MeV)

◆ set_py()

void marley::Particle::set_py ( double  py)
inline

Set the y component of the particle's 3-momentum.

Parameters
py3-momentum y component (MeV)

◆ set_pz()

void marley::Particle::set_pz ( double  pz)
inline

Set the z component of the particle's 3-momentum.

Parameters
pz3-momentum z component (MeV)

◆ set_total_energy()

void marley::Particle::set_total_energy ( double  Etot)
inline

Set the particle's total energy.

Parameters
Etottotal energy (MeV)

Member Data Documentation

◆ charge_

int marley::Particle::charge_ = 0
protected

Electric charge (net charge in the case of atoms) expressed as an integer multiple of the proton charge.

This class member allows a marley::Particle to represent an atom or ion. The charge_ data member was added because the 2014 PDG codes do not include a prescription for representing ionization states of atoms.

Todo:
Add error handling for cases where a marley::Particle is constructed with a charge that is inappropriate.

◆ four_momentum_

double marley::Particle::four_momentum_[4]
protected

momentum 4-vector for this particle (MeV)

The order of the components is (E, px, py, pz)

Note
This should be replaced by the more modern std::array<double, 4>. However, we use a C-style array here to allow ROOT 5, which is widely used but not C++11 compliant, to generate dictionaries for this class for TFile I/O. It'd be nice to include a default initializer here (say, = {0., 0., 0., 0.}), but ROOT 5 can't handle that either.

◆ pdg_code_

int marley::Particle::pdg_code_ = 0
protected

Particle Data Group code identifying this particle

See the full list of PDG codes for details.


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