Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI::ParseIdInfo Class Reference

#include <PoPI.hpp>

Public Member Functions

 ParseIdInfo (std::string const &a_id)
bool isSupported ()
std::string const & Id ()
bool isNuclear ()
bool isNucleus ()
bool isChemicalElement ()
bool isAnti ()
std::string const & symbol ()
int Z ()
int A ()
int index ()
std::string const & qualifier ()
void print (bool a_terse, std::string const &a_indent="") const

Detailed Description

Definition at line 262 of file PoPI.hpp.

Constructor & Destructor Documentation

◆ ParseIdInfo()

PoPI::ParseIdInfo::ParseIdInfo ( std::string const & a_id)

This class breaks down a PoPs id for a nuclide or nuclear into its components (e.g., Z, A, index). The a_id can also be a nuclear meta-stable or one of the light paritlce aliases (i.e., "d", "t", "h" or "a"). If a_id is a light particle alias, its nucleus equavalent is used. Also, "p" is treated as "h1", and "n" returns Z = 0 and A = 1. Currently, no other PoPs id's are supported.

Parameters
a_id[in] The PoPs id of the particle.

Definition at line 1024 of file PoPI_chemicalElement.cc.

1024 :
1025 m_isSupported( false ),
1026 m_id( a_id ),
1027 m_isNuclear( false ),
1028 m_isNucleus( false ),
1029 m_isChemicalElement( false ),
1030 m_isAnti( false ),
1031 m_isMetaStable( false ),
1032 m_symbol( "" ),
1033 m_Z( 0 ),
1034 m_A( 0 ),
1035 m_index( 0 ),
1036 m_qualifier( "" ) {
1037
1038 std::string a_anti;
1039
1040 std::string baseId = baseAntiQualifierFromID( a_id, a_anti, &m_qualifier );
1041 m_isAnti = IDs::anti == a_anti;
1042
1043 if( supportedNucleusAliases.find( baseId ) != supportedNucleusAliases.end( ) ) {
1044 baseId = supportedNucleusAliases[baseId]; }
1045 else if( baseId == IDs::proton ) {
1046 baseId = protonFakeAlias;
1047 }
1048
1049 if( baseId == "n" ) {
1050 m_A = 1;
1051 m_isSupported = true;
1052 return;
1053 }
1054
1055 std::vector<std::string> parts;
1056 if( baseId.find( "_m" ) != std::string::npos ) {
1057 m_isMetaStable = true;
1058 parts = LUPI::Misc::splitString( baseId, "_m" ); }
1059 else {
1060 parts = LUPI::Misc::splitString( baseId, "_e" );
1061 }
1062
1063// Now look for something of the form "SA(_[em]N)" in parts[0] where S is symbol, A is atomic number and "_[em]N" is options nulcear level or
1064// meta-stable specifier. If no match is found, assume a_id does not define a nuclear id.
1065 std::string isotope = parts[0];
1066 std::size_t digitIndex = isotope.find_first_of( "01233456789" );
1067
1068 std::string symbol( isotope.substr( 0, digitIndex ) ); // This should be S.
1069 std::string symbolCap;
1070 if( symbol.size( ) > 0 ) {
1071 char firstChar[2];
1072 firstChar[0] = static_cast<char>( std::toupper( symbol[0] ) );
1073 firstChar[1] = 0;
1074 std::string firstStringChar( firstChar );
1075 symbolCap = firstStringChar + symbol.substr( 1 );
1076 }
1077
1078 if( digitIndex != std::string::npos ) {
1079 std::string AStr( isotope.substr( digitIndex ) ); // This should be A.
1080 if( symbol.size( ) > 0 ) {
1081 m_Z = Z_FromChemicalElementSymbol( symbolCap );
1082 if( m_Z > 0 ) { // We have a valid chemical element symbol.
1083 if( ( AStr.size( ) > 0 ) && ( LUPI::Misc::stringToInt( AStr, m_A ) ) ) {
1084 if( m_A < 0 ) {
1085 m_A = 0; }
1086 else {
1087 bool isValidNuclearId = parts.size( ) == 1;
1088
1089 if( parts.size( ) > 1 ) {
1090 isValidNuclearId = ( parts.size( ) == 2 ) && LUPI::Misc::stringToInt( parts[1], m_index );
1091 }
1092
1093 if( isValidNuclearId ) { // Should be a valid nuclear id.
1094 m_symbol = symbolCap;
1095 m_isNuclear = true;
1096 m_isNucleus = symbolCap != symbol;
1097 }
1098 }
1099 }
1100 m_isSupported = true;
1101 }
1102 } }
1103 else if( symbol.size( ) > 0 ) {
1104 m_Z = Z_FromChemicalElementSymbol( symbolCap );
1105 if( m_Z > 0 ) {
1106 m_symbol = std::move( symbolCap );
1107 m_isChemicalElement = true;
1108 m_isSupported = true;
1109 }
1110 }
1111}
std::string const & symbol()
Definition PoPI.hpp:289
std::vector< std::string > splitString(std::string const &a_string, char a_delimiter, bool a_strip=false)
Definition LUPI_misc.cc:103
bool stringToInt(std::string const &a_string, int &a_value)
Definition LUPI_misc.cc:260
std::map< std::string, std::string > supportedNucleusAliases
std::string baseAntiQualifierFromID(std::string const &a_id, std::string &a_anti, std::string *a_qualifier=nullptr)
Definition PoPI_misc.cc:458
int Z_FromChemicalElementSymbol(std::string const &a_symbol)
static std::string const anti
Definition PoPI.hpp:173
static std::string const proton
Definition PoPI.hpp:165

Referenced by ParseIdInfo().

Member Function Documentation

◆ A()

int PoPI::ParseIdInfo::A ( )
inline

Returns the value of the m_A member.

Definition at line 291 of file PoPI.hpp.

Referenced by MCGIDI::MCGIDI_popsIntid(), and PoPI::MetaStable::MetaStable().

◆ Id()

std::string const & PoPI::ParseIdInfo::Id ( )
inline

Returns a reference to the m_id member.

Definition at line 284 of file PoPI.hpp.

◆ index()

int PoPI::ParseIdInfo::index ( )
inline

Returns the value of the m_index member.

Definition at line 292 of file PoPI.hpp.

Referenced by PoPI::MetaStable::MetaStable().

◆ isAnti()

bool PoPI::ParseIdInfo::isAnti ( )
inline

Returns the value of the m_isAnti member.

Definition at line 288 of file PoPI.hpp.

◆ isChemicalElement()

bool PoPI::ParseIdInfo::isChemicalElement ( )
inline

Returns the value of the m_isChemicalElement member.

Definition at line 287 of file PoPI.hpp.

◆ isNuclear()

bool PoPI::ParseIdInfo::isNuclear ( )
inline

Returns the value of the m_isNuclear member.

Definition at line 285 of file PoPI.hpp.

Referenced by MCGIDI::MCGIDI_popsIntid(), PoPI::MetaStable::MetaStable(), and GIDI::Map::Map::protare().

◆ isNucleus()

bool PoPI::ParseIdInfo::isNucleus ( )
inline

Returns the value of the m_isNucleus member.

Definition at line 286 of file PoPI.hpp.

Referenced by PoPI::MetaStable::MetaStable().

◆ isSupported()

bool PoPI::ParseIdInfo::isSupported ( )
inline

Returns the value of the *m_isSupported.

Definition at line 283 of file PoPI.hpp.

Referenced by MCGIDI::MCGIDI_popsIntid(), and GIDI::Map::Map::protare().

◆ print()

void PoPI::ParseIdInfo::print ( bool a_terse,
std::string const & a_indent = "" ) const

This method prints the contents of this. This is mainly for debugging.

Parameters
a_terse[in] If true, all members are printed on one line with no description. Otherwise, each member is printed on a separate line with a description.
a_indent[in] The amount of indentation on each line before anything is printed.

Definition at line 1120 of file PoPI_chemicalElement.cc.

1120 {
1121
1122 if( a_terse ) {
1123 std::cout << a_indent << m_id
1124 << boolToString( m_isSupported, " " ).c_str( )
1125 << boolToString( m_isNuclear, " " ).c_str( )
1126 << boolToString( m_isNucleus, " " ).c_str( )
1127 << boolToString( m_isChemicalElement, " " ).c_str( )
1128 << boolToString( m_isAnti, " " ).c_str( )
1129 << boolToString( m_isMetaStable, " " ).c_str( )
1130 << LUPI::Misc::argumentsToString( " %s", m_symbol.c_str( ) )
1131 << LUPI::Misc::argumentsToString( " %d", m_Z )
1132 << LUPI::Misc::argumentsToString( " %d", m_A )
1133 << LUPI::Misc::argumentsToString( " %d", m_index )
1134 << LUPI::Misc::argumentsToString( " %s", m_qualifier.c_str( ) )
1135 << std::endl; }
1136 else {
1137 std::cout << a_indent << "id = " << m_id << std::endl;
1138 std::cout << a_indent << LUPI::Misc::argumentsToString( " isSupported = %s", boolToString( m_isSupported, "" ).c_str( ) ) << std::endl;
1139 std::cout << a_indent << LUPI::Misc::argumentsToString( " isNuclear = %s", boolToString( m_isNuclear, "" ).c_str( ) ) << std::endl;
1140 std::cout << a_indent << LUPI::Misc::argumentsToString( " isNucleus = %s", boolToString( m_isNucleus, "" ).c_str( ) ) << std::endl;
1141 std::cout << a_indent << LUPI::Misc::argumentsToString( " isChemicalElement = %s", boolToString( m_isChemicalElement, "" ).c_str( ) ) << std::endl;
1142 std::cout << a_indent << LUPI::Misc::argumentsToString( " isAnti = %s", boolToString( m_isAnti, "" ).c_str( ) ) << std::endl;
1143 std::cout << a_indent << LUPI::Misc::argumentsToString( " isMetaStable = %s", boolToString( m_isMetaStable, "" ).c_str( ) ) << std::endl;
1144 std::cout << a_indent << LUPI::Misc::argumentsToString( " symbol = <%s>", m_symbol.c_str( ) ) << std::endl;
1145 std::cout << a_indent << LUPI::Misc::argumentsToString( " Z = %d", m_Z ) << std::endl;
1146 std::cout << a_indent << LUPI::Misc::argumentsToString( " A = %d", m_A ) << std::endl;
1147 std::cout << a_indent << LUPI::Misc::argumentsToString( " index = %d", m_index ) << std::endl;
1148 std::cout << a_indent << LUPI::Misc::argumentsToString( " qualifier = <%s>", m_qualifier.c_str( ) ) << std::endl;
1149 }
1150}
std::string argumentsToString(char const *a_format,...)
Definition LUPI_misc.cc:305

◆ qualifier()

std::string const & PoPI::ParseIdInfo::qualifier ( )
inline

Returns a reference to the m_qualifier member.

Definition at line 293 of file PoPI.hpp.

◆ symbol()

std::string const & PoPI::ParseIdInfo::symbol ( )
inline

Returns a reference to the m_symbol member.

Definition at line 289 of file PoPI.hpp.

Referenced by ParseIdInfo(), and GIDI::Map::Map::protare().

◆ Z()

int PoPI::ParseIdInfo::Z ( )
inline

Returns the value of the m_Z member.

Definition at line 290 of file PoPI.hpp.

Referenced by MCGIDI::MCGIDI_popsIntid(), and PoPI::MetaStable::MetaStable().


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