Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_particle.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include "PoPI.hpp"
11
12namespace PoPI {
13
14/*! \class Particle
15 * The base class representing a particle.
16 */
17
18/* *********************************************************************************************************//**
19 * @param a_node [in] The **HAPI::Node** node to be parsed.
20 * @param a_class [in] The class of the particle.
21 * @param a_family [in] The family of the particle.
22 * @param a_hasNucleus [in] Indicates if the particle is or contains a nucleus. 0 = no, -1 = yes and 1 = is nucleus.
23 ***********************************************************************************************************/
24
25Particle::Particle( HAPI::Node const &a_node, Particle_class a_class, std::string const &a_family, int a_hasNucleus ) :
26 IDBase( a_node, a_class ),
27 m_baseId( "" ),
28 m_family( a_family ),
29 m_anti( "" ),
30 m_hasNucleus( a_hasNucleus ),
31 m_mass( a_node.child( PoPI_massChars ) ),
32 m_spin( a_node.child( PoPI_spinChars ) ),
33 m_parity( a_node.child( PoPI_parityChars ) ),
34 m_charge( a_node.child( PoPI_chargeChars ) ),
35 m_halflife( a_node.child( PoPI_halflifeChars ) ),
36 m_decayData( a_node.child( PoPI_decayDataChars ) ) {
37
38 m_baseId = baseAntiQualifierFromID( ID( ), m_anti );
39}
40
41/* *********************************************************************************************************//**
42 ***********************************************************************************************************/
43
47
48/* *********************************************************************************************************//**
49 * Returns the mass of the particle in units of *a_unit*. Currently not fully implement and does not support *a_unit*.
50 *
51 * @param a_unit [in] The unit to return the mass in.
52 *
53 * @return The mass in unit of *a_unit*.
54 ***********************************************************************************************************/
55
56double Particle::massValue( char const *a_unit ) const {
57
58 if( m_mass.size( ) == 0 ) throw Exception( "Particle '" + ID( ) + "' does not have any mass data." );
59
60 PQ_double const *pq_mass = dynamic_cast<PQ_double const *>( mass( )[0] );
61
62 if( pq_mass == nullptr ) throw Exception( "Particle '" + ID( ) + "' does not have a PoPI::PQ_double mass." );
63 return( pq_mass->value( a_unit ) );
64}
65
66/* *********************************************************************************************************//**
67 * Adds the contents of *this* to *a_XMLList* where each item in *a_XMLList* is one line (without linefeeds) to output as an XML representation of *this*.
68 *
69 * @param a_XMLList [in] The list to add an XML output representation of *this* to.
70 * @param a_indent1 [in] The amount of indentation to added to each line added to *a_XMLList*.
71 ***********************************************************************************************************/
72
73void Particle::toXMLList( std::vector<std::string> &a_XMLList, std::string const &a_indent1 ) const {
74
75 std::string indent2 = a_indent1 + " ";
76
77 std::string header = a_indent1 + "<" + family( ) + " id=\"" + ID( ) + "\"" + toXMLListExtraAttributes( ) + ">";
78 a_XMLList.push_back( std::move( header ) );
79
80 m_mass.toXMLList( a_XMLList, indent2 );
81 m_spin.toXMLList( a_XMLList, indent2 );
82 m_parity.toXMLList( a_XMLList, indent2 );
83 m_charge.toXMLList( a_XMLList, indent2 );
84 m_halflife.toXMLList( a_XMLList, indent2 );
85 toXMLListExtraElements( a_XMLList, indent2 );
86 m_decayData.toXMLList( a_XMLList, indent2 );
87
88 appendXMLEnd( a_XMLList, family( ) );
89}
90
91/* *********************************************************************************************************//**
92 * Currently there are no extra attributes to add. Ergo, returns an empty string.
93 ***********************************************************************************************************/
94
95std::string Particle::toXMLListExtraAttributes( void ) const {
96
97 return( "" );
98}
99
100/* *********************************************************************************************************//**
101 * Currently there are no extra child nodes to add.
102 *
103 * @param a_XMLList [in] The list to add an XML output representation of *this* to.
104 * @param a_indent1 [in] The amount of indentation to added to each line added to *a_XMLList*.
105 ***********************************************************************************************************/
106
107void Particle::toXMLListExtraElements( LUPI_maybeUnused std::vector<std::string> &a_XMLList, LUPI_maybeUnused std::string const &a_indent1 ) const {
108
109 return;
110}
111
112}
#define LUPI_maybeUnused
#define PoPI_chargeChars
Definition PoPI.hpp:76
#define PoPI_halflifeChars
Definition PoPI.hpp:77
#define PoPI_parityChars
Definition PoPI.hpp:75
#define PoPI_massChars
Definition PoPI.hpp:73
#define PoPI_spinChars
Definition PoPI.hpp:74
#define PoPI_decayDataChars
Definition PoPI.hpp:84
std::string const & ID(void) const
Definition PoPI.hpp:652
IDBase(std::string const &a_id, Particle_class a_class)
Definition PoPI_base.cc:63
double value(void) const
Definition PoPI.hpp:443
Particle(HAPI::Node const &a_node, Particle_class a_class, std::string const &a_family, int a_hasNucleus=0)
virtual std::string toXMLListExtraAttributes(void) const
virtual ~Particle()
virtual double massValue(char const *a_unit) const
virtual PQ_suite const & mass(void) const
Definition PoPI.hpp:878
virtual void toXMLListExtraElements(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
void toXMLList(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
std::string const & family(void) const
Definition PoPI.hpp:874
Definition PoPI.hpp:28
void appendXMLEnd(std::vector< std::string > &a_XMLList, std::string const &a_label)
Definition PoPI_misc.cc:53
std::string baseAntiQualifierFromID(std::string const &a_id, std::string &a_anti, std::string *a_qualifier=nullptr)
Definition PoPI_misc.cc:458
Particle_class
Definition PoPI.hpp:58