Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_alias.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#define PoPI_metaStableIndexChars "metaStableIndex"
15
16/*! \class Alias
17 * This class represents a **PoPs** alias instance.
18 */
19
20/* *********************************************************************************************************//**
21 * Constructor that parses an **HAPI** instance to create a **GNDS** alias node.
22 *
23 * @param a_node [in] The **HAPI::Node** to be parsed.
24 * @param a_DB [in] The **PoPI::Database:: instance to add the constructed **Alias** to.
25 * @param a_class [in] The particle class for **Alias**.
26 ***********************************************************************************************************/
27
28Alias::Alias( HAPI::Node const &a_node, Database *a_DB, Particle_class a_class ) :
29 IDBase( a_node, a_class ),
30 m_pid( a_node.attribute( PoPI_pidChars ).value( ) ),
31 m_pidIndex( SIZE_MAX ) {
32
33 if( supportedNucleusAliases.find( ID( ) ) != supportedNucleusAliases.end( ) ) {
34 ParseIdInfo idInfo( supportedNucleusAliases[ID( )] );
35
36 setIntid( 1000 * ( 1000 * (idInfo.index( ) + 500) + idInfo.Z( ) ) + idInfo.A( ) ); // Anti is currently not supported.
37 }
38 if( a_class == Particle_class::alias ) addToDatabase( a_DB );
39}
40
41/* *********************************************************************************************************//**
42 ***********************************************************************************************************/
43
45
46}
47
48/* *********************************************************************************************************//**
49 * 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*.
50 *
51 * @param a_XMLList [in] The list to add an XML output representation of *this* to.
52 * @param a_indent1 [in] The amount of indentation to added to each line added to *a_XMLList*.
53 ***********************************************************************************************************/
54
55void Alias::toXMLList( std::vector<std::string> &a_XMLList, std::string const &a_indent1 ) const {
56
57 std::string header = a_indent1 + "<particle id=\"" + ID( ) + "\" pid=\"" + m_pid + "\"/>";
58 a_XMLList.push_back( std::move( header ) );
59}
60
61/*! \class MetaStable
62 * This class represents **PoPs** metaStable instance.
63 */
64
65/* *********************************************************************************************************//**
66 * Constructor that parses an **HAPI** instance to create a **GNDS** metastable alias node.
67 *
68 * @param a_node [in] The **HAPI::Node** to be parsed.
69 * @param a_DB [in] The **PoPI::Database:: instance to add the constructed **MetaStable** to.
70 ***********************************************************************************************************/
71
73 Alias( a_node, a_DB, Particle_class::nuclideMetaStable ), // Initial guess. */
74 m_metaStableIndex( a_node.attribute( PoPI_metaStableIndexChars ).as_int( ) ) {
75
76 ParseIdInfo idInfo( ID( ) );
77 if( idInfo.isNuclear( ) ) {
79 int intid2 = intidHelper( false, m_class, 1000 * idInfo.Z( ) + idInfo.A( ) );
80 setIntid( intid2 + 1000000 * idInfo.index( ) );
81 }
82
83 addToDatabase( a_DB );
84}
85
86/* *********************************************************************************************************//**
87 ***********************************************************************************************************/
88
92
93/* *********************************************************************************************************//**
94 * 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*.
95 *
96 * @param a_XMLList [in] The list to add an XML output representation of *this* to.
97 * @param a_indent1 [in] The amount of indentation to added to each line added to *a_XMLList*.
98 ***********************************************************************************************************/
99
100void MetaStable::toXMLList( std::vector<std::string> &a_XMLList, std::string const &a_indent1 ) const {
101
102 std::string indexStr = LUPI::Misc::argumentsToString( "%d", m_metaStableIndex );
103 std::string header = a_indent1 + "<metaStable id=\"" + ID( ) + "\" pid=\"" + pid( ) + "\" metaStableIndex=\"" + indexStr + "\"/>";
104 a_XMLList.push_back( std::move( header ) );
105}
106
107}
#define PoPI_pidChars
Definition PoPI.hpp:92
#define PoPI_metaStableIndexChars
Definition PoPI_alias.cc:14
Alias(HAPI::Node const &a_node, Database *a_DB, Particle_class a_class=Particle_class::alias)
Definition PoPI_alias.cc:28
void toXMLList(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
Definition PoPI_alias.cc:55
std::string const & pid(void) const
Definition PoPI.hpp:1096
virtual ~Alias()
Definition PoPI_alias.cc:44
friend MetaStable
Definition PoPI.hpp:673
friend Alias
Definition PoPI.hpp:674
std::string const & ID(void) const
Definition PoPI.hpp:652
std::size_t addToDatabase(Database *a_DB)
Definition PoPI_base.cc:95
IDBase(std::string const &a_id, Particle_class a_class)
Definition PoPI_base.cc:63
virtual ~MetaStable()
Definition PoPI_alias.cc:89
void toXMLList(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
bool isNucleus()
Definition PoPI.hpp:286
bool isNuclear()
Definition PoPI.hpp:285
std::string argumentsToString(char const *a_format,...)
Definition LUPI_misc.cc:305
Definition PoPI.hpp:28
std::map< std::string, std::string > supportedNucleusAliases
int intidHelper(bool a_isAnti, Particle_class a_family, int a_SSSSSSS)
Definition PoPI_intId.cc:47
Particle_class
Definition PoPI.hpp:58