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 Member Functions | Protected Attributes | List of all members
marley::Event Class Reference

Container for ingoing and outgoing momentum 4-vectors from a reaction. More...

#include <Event.hh>

Public Member Functions

 Event (const Event &other_event)
 Copy constructor.
 
 Event (const marley::Particle &a, const marley::Particle &b, const marley::Particle &c, const marley::Particle &d, double Ex, int twoJ, const marley::Parity &P)
 Create a two-two scattering event. More...
 
 Event (double Ex=0.)
 Create an event with dummy particles.
 
 Event (Event &&other_event)
 Move constructor.
 
void add_final_particle (const marley::Particle &p)
 Add a Particle to the vector of final particles.
 
void add_initial_particle (const marley::Particle &p)
 Add a Particle to the vector of initial particles.
 
void clear ()
 Deletes all particles from the event and resets the nuclear excitation energy to zero.
 
marley::Particleejectile ()
 Get a non-const reference to the ejectile.
 
const marley::Particleejectile () const
 Get a const reference to the ejectile.
 
double Ex () const
 Get the excitation energy of the residue just after the initial two-body reaction.
 
const marley::Particlefinal_particle (size_t idx) const
 Returns a const reference to the final particle with the given index. More...
 
size_t final_particle_count () const
 Returns the number of final particles in the Event.
 
void from_json (const marley::JSON &json)
 Replace the existing event contents with those read from a JSON representation.
 
std::vector< marley::Particle * > & get_final_particles ()
 Get a non-const reference to the vector of final particles.
 
const std::vector< marley::Particle * > & get_final_particles () const
 Get a const reference to the vector of final particles.
 
std::vector< marley::Particle * > & get_initial_particles ()
 Get a non-const reference to the vector of initial particles.
 
const std::vector< marley::Particle * > & get_initial_particles () const
 Get a const reference to the vector of initial particles.
 
const marley::Particleinitial_particle (size_t idx) const
 Returns a const reference to the initial particle with the given index. More...
 
size_t initial_particle_count () const
 Returns the number of initial particles in the Event.
 
Eventoperator= (const Event &other_event)
 Copy assignment operator.
 
Eventoperator= (Event &&other_event)
 Move assignment operator.
 
marley::Parity parity () const
 Get the intrinsic parity of the residue just after the initial two-body reaction.
 
void print (std::ostream &out) const
 Print this event to a std::ostream. More...
 
void print_human_readable (std::ostream &out, int num=-1) const
 Print this event to a std::ostream in an annotated format easily readable by humans. More...
 
marley::Particleprojectile ()
 Get a non-const reference to the projectile.
 
const marley::Particleprojectile () const
 Get a const reference to the projectile.
 
void read (std::istream &in)
 Read in this event from a std::istream. Any previous contents of this event will be deleted. More...
 
bool read_hepevt (std::istream &in, double *flux_avg_tot_xsec=nullptr)
 Read in this event from a std::istream, assuming it will appear there in HEPEVT format. Any previous contents of this event will be deleted. More...
 
marley::Particleresidue ()
 Get a non-const reference to the residue.
 
const marley::Particleresidue () const
 Get a const reference to the residue.
 
marley::Particletarget ()
 Get a non-const reference to the target.
 
const marley::Particletarget () const
 Get a const reference to the target.
 
marley::JSON to_json () const
 Create a JSON representation of this event.
 
int twoJ () const
 Get two times the spin of the residue just after the initial two-body reaction.
 
void write_hepevt (size_t event_num, double flux_avg_tot_xsec, std::ostream &out) const
 Write a HEPEVT record for this event to a std::ostream. Use the spacetime origin (t = 0 mm/c, x = 0 mm, y = 0 mm, z = 0 mm) as the initial position 4-vector for all particles. More...
 

Protected Member Functions

void delete_particles ()
 Deletes all owned Particle objects and clears the vectors of initial and final particles.
 
void dump_hepevt_particle (const marley::Particle &p, std::ostream &os, int status, int jmohep1=0, int jmohep2=0) const
 Helper function for write_hepevt() More...
 

Protected Attributes

double Ex_
 Excitation energy (MeV) of the residue immediately after the two-two scattering reaction. More...
 
std::vector< marley::Particle * > final_particles_
 Vector of pointers to each of the final state particles.
 
std::vector< marley::Particle * > initial_particles_
 Vector of pointers to each of the initial state particles.
 
Parity parity_
 The parity of the residue immediately after the two-two scattering reaction.
 
int twoJ_
 Two times the spin of the residue immediately after the two-two scattering reaction.
 

Detailed Description

Container for ingoing and outgoing momentum 4-vectors from a reaction.

For a two-two scattering reaction a + b → c + d, this class calls the ingoing particles the projectile (a) and target (b). The outgoing particles are called the ejectile (c) and residue (d). If the residue is a composite particle (e.g., a nucleus), then the class member Ex_ stores its excitation energy just after the two-two reaction occurred. After MARLEY simulates its de-excitation, the residue Particle object will be in its ground state, and the final_particles_ member of this class will include Particle objects representing the de-excitation products.

Note
This class manually manages memory (using the “rule of 5”) for the Particle objects that it owns. A better implementation from a modern C++ perspective would be to use vectors of std::unique_ptr<marley::Particle> objects and let those manage the memory (i.e., use the “rule of zero”). This design choice was made to ensure compatibility with ROOT 5, which cannot generate dictionaries for C++11 classes like std::unique_ptr.

Constructor & Destructor Documentation

◆ Event()

marley::Event::Event ( const marley::Particle a,
const marley::Particle b,
const marley::Particle c,
const marley::Particle d,
double  Ex,
int  twoJ,
const marley::Parity P 
)

Create a two-two scattering event.

Parameters
athe projectile
bthe target
cthe ejectile
dthe residue
Exresidue excitation energy (MeV) just after the two-two reaction

Member Function Documentation

◆ dump_hepevt_particle()

void marley::Event::dump_hepevt_particle ( const marley::Particle p,
std::ostream &  os,
int  status,
int  jmohep1 = 0,
int  jmohep2 = 0 
) const
protected

Helper function for write_hepevt()

Parameters
pParticle to write to the HEPEVT record
osstd::ostream being written to
statusInteger status code to use for this particle in the HEPEVT output
jmohep1Index of the first mother for this particle (used only for a "MARLEY info" dummy particle at the moment)
jmohep2Index of the second mother for this particle (used only for a "MARLEY info" dummy particle at the moment)

◆ final_particle()

const marley::Particle & marley::Event::final_particle ( size_t  idx) const
inline

Returns a const reference to the final particle with the given index.

Parameters
[in]idxIndex of the desired particle
Exceptions
std::out_of_rangeif idx is greater than or equal to the size of the vector of final particles

◆ initial_particle()

const marley::Particle & marley::Event::initial_particle ( size_t  idx) const
inline

Returns a const reference to the initial particle with the given index.

Parameters
[in]idxIndex of the desired particle
Exceptions
std::out_of_rangeif idx is greater than or equal to the size of the vector of initial particles

◆ print()

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

Print this event to a std::ostream.

Parameters
outThe std::ostream to which this event will be written

◆ print_human_readable()

void marley::Event::print_human_readable ( std::ostream &  out,
int  num = -1 
) const

Print this event to a std::ostream in an annotated format easily readable by humans.

Parameters
outThe std::ostream to which this event will be written
numAn optional event number that will be printed with the rest of the event. If num is negative, then it will be skipped.

◆ read()

void marley::Event::read ( std::istream &  in)

Read in this event from a std::istream. Any previous contents of this event will be deleted.

Parameters
inThe std::istream from which this event will be read

◆ read_hepevt()

bool marley::Event::read_hepevt ( std::istream &  in,
double *  flux_avg_tot_xsec = nullptr 
)

Read in this event from a std::istream, assuming it will appear there in HEPEVT format. Any previous contents of this event will be deleted.

A marley::Error will be thrown if

  • There are not exactly two particles in the event with the status code HEPEVT_INITIAL_STATE_STATUS_CODE
  • There is not exactly one particle with status code HEPEVT_INITIAL_STATE_STATUS_CODE that is an ion (a particle for which marley_utils::is_ion() returns true)
  • More than one lepton (a particle for which marley_utils::is_lepton() returns true) appears in the event with status code HEPEVT_FINAL_STATE_STATUS_CODE
  • Zero of the particles with status code HEPEVT_FINAL_STATE_STATUS_CODE are ions
    Returns
    True if the input stream was in a good state after attempting to read in the full HEPEVT record, or false otherwise. This behavior is designed to enable the return value of this function to be used as a while loop condition when reading in multiple HEPEVT records from an input stream. If the return value is false, the event object contents will have been cleared by this function.

◆ write_hepevt()

void marley::Event::write_hepevt ( size_t  event_num,
double  flux_avg_tot_xsec,
std::ostream &  out 
) const

Write a HEPEVT record for this event to a std::ostream. Use the spacetime origin (t = 0 mm/c, x = 0 mm, y = 0 mm, z = 0 mm) as the initial position 4-vector for all particles.

Parameters
[in]flux_avg_tot_xsecThe flux-averaged total reaction cross section (MeV -2) to include in the output HEPEVT record
[in]event_numThe event number to use in the output HEPEVT record
[out]Thestd::ostream to which the HEPEVT record will be written
Todo:
Alter marley::Event::write_hepevt() so that the user can specify a vertex position 4-vector to use.

Member Data Documentation

◆ Ex_

double marley::Event::Ex_
protected

Excitation energy (MeV) of the residue immediately after the two-two scattering reaction.

Note
The Ex_ class member is always zero for residues that have no excited states.

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