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

#include <PoPI.hpp>

Public Member Functions

 Database ()
 Database (std::string const &a_fileName)
 Database (HAPI::Node const &a_database)
 ~Database ()
LUPI::FormatVersion const & formatVersion (void) const
std::string const & name (void) const
std::string const & version (void) const
std::vector< Alias * > unresolvedAliases ()
std::size_t numberOfUnresolvedAliases ()
std::vector< std::string > unresolvedAliasIds () const
std::vector< Alias * > & aliases ()
void addFile (char const *a_fileName, bool a_warnIfDuplicate)
void addFile (std::string const &a_fileName, bool a_warnIfDuplicate)
void addDatabase (std::string const &a_string, bool a_warnIfDuplicate)
void addDatabase (HAPI::Node const &a_database, bool a_warnIfDuplicate)
void addAlias (Alias *a_alias)
std::string::size_type size (void) const
ParticleList const & list ()
SymbolList const & symbolList ()
std::size_t operator[] (std::string const &a_id) const
template<typename T>
T const & get (std::string const &a_id) const
template<typename T>
T const & get (std::size_t a_index) const
Particle const & particle (std::string const &a_id) const
Particle const & particle (std::size_t a_index) const
IDBase const & idBase (std::string const &a_id) const
IDBase const & idBase (std::size_t &a_index) const
ParticleList const & particleList () const
SymbolList symbolList () const
bool exists (std::string const &a_id) const
bool exists (std::size_t a_index) const
bool existsIntid (int a_intid) const
Suite< ChemicalElement, Database > const & chemicalElements () const
bool isParticle (std::string const &a_id) const
bool isParticle (std::size_t a_index) const
bool isAlias (std::string const &a_id) const
bool isAlias (std::size_t a_index) const
bool isMetaStableAlias (std::string const &a_id) const
bool isMetaStableAlias (std::size_t a_index) const
std::vector< std::string > aliasReferences (std::string const &a_id)
std::string final (std::string const &a_id, bool a_returnAtMetaStableAlias=false) const
std::size_t final (std::size_t a_index, bool a_returnAtMetaStableAlias=false) const
std::string chemicalElementSymbol (std::string const &a_id) const
std::string isotopeSymbol (std::string const &a_id) const
int intid (std::string const &a_id) const
int intid (std::size_t a_index) const
std::size_t indexFromIntid (int a_intid) const
std::size_t add (Base *a_item)
std::size_t addSymbol (SymbolBase *a_item)
void calculateNuclideGammaBranchStateInfos (NuclideGammaBranchStateInfos &a_nuclideGammaBranchStateInfos, Database const *a_pops2, std::vector< std::string > &a_extraGammaBranchStates) const
void calculateNuclideGammaBranchStateInfos2 (NuclideGammaBranchStateInfos &a_nuclideGammaBranchStateInfos) const
double massValue (std::string const &a_id, std::string const &a_unit) const
void saveAs (std::string const &a_fileName) const
void toXMLList (std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
void print (bool a_printIndices)
template<typename T>
T const & get (std::size_t a_index) const
template<typename T>
T const & get (std::string const &a_id) const

Detailed Description

The main class for storing PoPs data.

Definition at line 1128 of file PoPI.hpp.

Constructor & Destructor Documentation

◆ Database() [1/3]

PoPI::Database::Database ( )

Database constructor for an initial empty PoPs database.

Definition at line 37 of file PoPI_database.cc.

37 :
38 m_gaugeBosons( PoPI_gaugeBosonsChars ),
39 m_leptons( PoPI_leptonsChars ),
40 m_baryons( PoPI_baryonsChars ),
41 m_chemicalElements( PoPI_chemicalElementsChars ),
42 m_unorthodoxes( PoPI_unorthodoxesChars ) {
43
44}
#define PoPI_chemicalElementsChars
Definition PoPI.hpp:41
#define PoPI_unorthodoxesChars
#define PoPI_baryonsChars
#define PoPI_gaugeBosonsChars
#define PoPI_leptonsChars

Referenced by calculateNuclideGammaBranchStateInfos().

◆ Database() [2/3]

PoPI::Database::Database ( std::string const & a_fileName)

Database constructor for a PoPs database with data read from the file a_fileName.

Parameters
a_fileName[in] The PoPs file to read in.

Definition at line 52 of file PoPI_database.cc.

52 :
53 m_gaugeBosons( PoPI_gaugeBosonsChars ),
54 m_leptons( PoPI_leptonsChars ),
55 m_baryons( PoPI_baryonsChars ),
56 m_chemicalElements( PoPI_chemicalElementsChars ),
57 m_unorthodoxes( PoPI_unorthodoxesChars ) {
58
59 addFile( a_fileName, false );
60}
void addFile(char const *a_fileName, bool a_warnIfDuplicate)

◆ Database() [3/3]

PoPI::Database::Database ( HAPI::Node const & a_database)

Database constructor for a PoPs database with data read from a HAPI::Node instance. This method is mainly for internal use.

Parameters
a_database[in] A HAPI::Node instance containing the data to parse.

Definition at line 69 of file PoPI_database.cc.

69 :
70 m_gaugeBosons( PoPI_gaugeBosonsChars ),
71 m_leptons( PoPI_leptonsChars ),
72 m_baryons( PoPI_baryonsChars ),
73 m_chemicalElements( PoPI_chemicalElementsChars ),
74 m_unorthodoxes( PoPI_unorthodoxesChars ) {
75
76 addDatabase( a_database, false );
77}
void addDatabase(std::string const &a_string, bool a_warnIfDuplicate)

◆ ~Database()

PoPI::Database::~Database ( )

Destructor for a PoPI::Database instance.

Definition at line 215 of file PoPI_database.cc.

215 {
216
217 for( std::vector<Alias *>::iterator iter = m_aliases.begin( ); iter != m_aliases.end( ); ++iter ) delete *iter;
218}

Member Function Documentation

◆ add()

std::size_t PoPI::Database::add ( Base * a_item)

This method adds a PoPI::Base instance to this and returns the unique index for it.

Parameters
a_item[in] The PoPI::Base instance to add to this.
Returns
The index for the added PoPI::Base instance.

Definition at line 493 of file PoPI_database.cc.

493 {
494
495 std::size_t index = m_list.size( );
496
497 m_idsMap[a_item->ID( )] = index;
498 m_list.push_back( a_item );
499 a_item->setIndex( index );
500
501 if( a_item->intid( ) > 0 ) m_intidsMap[a_item->intid( )] = index;
502
503 if( a_item->isAlias( ) ) m_unresolvedAliases.push_back( (Alias *) a_item );
504 return( index );
505}

Referenced by addSymbol(), and PoPI::IDBase::addToDatabase().

◆ addAlias()

void PoPI::Database::addAlias ( Alias * a_alias)
inline

Added the Alias a_alias to this.

Definition at line 1170 of file PoPI.hpp.

◆ addDatabase() [1/2]

void PoPI::Database::addDatabase ( HAPI::Node const & a_database,
bool a_warnIfDuplicate )

◆ addDatabase() [2/2]

void PoPI::Database::addDatabase ( std::string const & a_string,
bool a_warnIfDuplicate )

Adds the contents of the a_string to this. a_string must be an XML string starting with an PoPs XML node (i.e., element).

Parameters
a_string[in] A std::string instance of PoPs data in an XML format.
a_warnIfDuplicate[in] This argument is currently not used.

Definition at line 114 of file PoPI_database.cc.

114 {
115
116 // a_string must contain a complete & well-formed XML document
117 pugi::xml_document doc;
118
119 pugi::xml_parse_result result = doc.load_string( a_string.c_str( ) );
120 if( result.status != pugi::status_ok ) {
121 char Msg[MsgSize+1];
122
123 snprintf( Msg, MsgSize, "ERROR: in file '%s' in method '%s': %s.", __FILE__, __func__, result.description( ) );
124 throw Exception( Msg );
125 }
126
127 HAPI::PugiXMLNode *database_internal = new HAPI::PugiXMLNode(doc.first_child( ));
128 HAPI::Node database(database_internal);
129 addDatabase( database, a_warnIfDuplicate );
130}
#define MsgSize
xml_parse_result load_string(const char_t *contents, unsigned int options=parse_default)
Definition pugixml.cc:7319
xml_node first_child() const
Definition pugixml.cc:5749
@ status_ok
Definition pugixml.hpp:982
const char * description() const
Definition pugixml.cc:7037
xml_parse_status status
Definition pugixml.hpp:1010

Referenced by addDatabase(), addFile(), and Database().

◆ addFile() [1/2]

void PoPI::Database::addFile ( char const * a_fileName,
bool a_warnIfDuplicate )

Adds the contents of the file a_fileName to this.

Parameters
a_fileName[in] The PoPs file to get data from.
a_warnIfDuplicate[in] This argument is currently not used.

Definition at line 98 of file PoPI_database.cc.

98 {
99
100 HAPI::File *doc = new HAPI::PugiXMLFile( a_fileName, "Database::addFile" );
101 HAPI::Node database = doc->first_child( );
102 addDatabase( database, a_warnIfDuplicate );
103 delete doc;
104}
virtual Node first_child()=0

Referenced by addFile(), and Database().

◆ addFile() [2/2]

void PoPI::Database::addFile ( std::string const & a_fileName,
bool a_warnIfDuplicate )

Adds the contents of the file a_fileName to this.

Parameters
a_fileName[in] The PoPs file to get data from.
a_warnIfDuplicate[in] This argument is currently not used.

Definition at line 86 of file PoPI_database.cc.

86 {
87
88 addFile( a_fileName.c_str( ), a_warnIfDuplicate );
89}

◆ addSymbol()

std::size_t PoPI::Database::addSymbol ( SymbolBase * a_item)

This method adds a PoPI::SymbolBase instance to this and returns the unique index for it.

Parameters
a_item[in] The PoPI::SymbolBase instance to add to this.
Returns
The index for the added PoPI::SymbolBase instance.

Definition at line 516 of file PoPI_database.cc.

516 {
517
518 if( a_item->Class( ) == Particle_class::chemicalElement ) return( this->add( a_item ) );
519
520 std::size_t index = m_symbolList.size( );
521
522 m_symbolMap[a_item->symbol( )] = index;
523 m_symbolList.push_back( a_item );
524 a_item->setIndex( index );
525
526 return( index );
527}
std::size_t add(Base *a_item)

Referenced by PoPI::SymbolBase::addToSymbols().

◆ aliases()

std::vector< Alias * > & PoPI::Database::aliases ( )
inline

Returns a const reference to the m_aliases variable of this.

Definition at line 1164 of file PoPI.hpp.

◆ aliasReferences()

std::vector< std::string > PoPI::Database::aliasReferences ( std::string const & a_id)

Returns a std::vector of std::string's of all aliases in this that resolve to a_id.

Parameters
a_id[in] A particle's id whose.
Returns
Vector of alias ids.

Definition at line 307 of file PoPI_database.cc.

307 {
308
309 std::vector<std::string> ids;
310
311 for( auto aliasIter = m_aliases.begin( ); aliasIter != m_aliases.end( ); ++aliasIter ) {
312 if( final( (*aliasIter)->pid( ) ) == a_id ) ids.push_back( (*aliasIter)->ID( ) );
313 }
314
315 return( ids );
316}

◆ calculateNuclideGammaBranchStateInfos()

void PoPI::Database::calculateNuclideGammaBranchStateInfos ( NuclideGammaBranchStateInfos & a_nuclideGammaBranchStateInfos,
Database const * a_pops2,
std::vector< std::string > & a_extraGammaBranchStates ) const

This method calculates nuclide gamma branching infomation and adds it to a_nuclideGammaBranchStateInfos.

Parameters
a_nuclideGammaBranchStateInfos[in] The NuclideGammaBranchStateInfos instance to added nuclide gamma branching infomation to.
a_pops2A second PoPs used for storing GRIN added particles.
a_extraGammaBranchStatesAny additional nuclide needed by GRIN. Currently, one the capture residual.

Definition at line 537 of file PoPI_database.cc.

538 {
539
540
541 calculateNuclideGammaBranchStateInfos2( a_nuclideGammaBranchStateInfos );
542 if( a_pops2 != nullptr ) {
543 a_pops2->calculateNuclideGammaBranchStateInfos2( a_nuclideGammaBranchStateInfos );
544 for( auto iter = a_extraGammaBranchStates.begin( ); iter != a_extraGammaBranchStates.end( ); ++iter ) {
545 PoPI::Nuclide const &nuclide = a_pops2->get<PoPI::Nuclide>( *iter );
546 nuclide.calculateNuclideGammaBranchStateInfos( *a_pops2, a_nuclideGammaBranchStateInfos, true );
547 }
548 }
549
550 std::vector<NuclideGammaBranchStateInfo *> &nuclideGammaBranchStateInfos = a_nuclideGammaBranchStateInfos.nuclideGammaBranchStateInfos( );
551 for( std::size_t i1 = 0; i1 < nuclideGammaBranchStateInfos.size( ); ++i1 ) {
552 NuclideGammaBranchStateInfo *nuclideGammaBranchStateInfo = nuclideGammaBranchStateInfos[i1];
553
554 nuclideGammaBranchStateInfo->calculateDerivedData( a_nuclideGammaBranchStateInfos );
555 }
556}
void calculateNuclideGammaBranchStateInfos2(NuclideGammaBranchStateInfos &a_nuclideGammaBranchStateInfos) const

◆ calculateNuclideGammaBranchStateInfos2()

void PoPI::Database::calculateNuclideGammaBranchStateInfos2 ( NuclideGammaBranchStateInfos & a_nuclideGammaBranchStateInfos) const

This method calculates nuclide gamma branching infomation and adds it to a_nuclideGammaBranchStateInfos.

Parameters
a_nuclideGammaBranchStateInfos[in] The NuclideGammaBranchStateInfos instance to added nuclide gamma branching infomation to.

Definition at line 564 of file PoPI_database.cc.

564 {
565
566 for( std::size_t i1 = 0; i1 < m_chemicalElements.size( ); ++i1 ) {
567 ChemicalElement const &chemicalElement = m_chemicalElements[i1];
568
569 chemicalElement.calculateNuclideGammaBranchStateInfos( *this, a_nuclideGammaBranchStateInfos );
570 }
571}

Referenced by calculateNuclideGammaBranchStateInfos().

◆ chemicalElements()

Suite< ChemicalElement, Database > const & PoPI::Database::chemicalElements ( ) const
inline

Returns a const reference to the m_chemicalElements variable of this.

Definition at line 1189 of file PoPI.hpp.

◆ chemicalElementSymbol()

std::string PoPI::Database::chemicalElementSymbol ( std::string const & a_id) const

This method returns the chemical element symbol for a_id if it is a PoPs id for a chemicalElement, isotope, nuclide, or nucleus object. Otherwise, it returns an empty string. The PoPs id a_id must be in this.

Parameters
a_id[in] A particle's id whose chemical element symbol is requested.
Returns
The string for the chemical element symbol.

Definition at line 365 of file PoPI_database.cc.

365 {
366
367 std::string symbol1;
368 Base const *base = nullptr;
369
370 auto iter = m_idsMap.find( a_id );
371 if( iter != m_idsMap.end( ) ) {
372 std::string finalId = final( a_id );
373 iter = m_idsMap.find( finalId );
374 base = m_list[iter->second]; }
375 else {
376 auto iter2 = m_symbolMap.find( a_id );
377 if( iter2 != m_symbolMap.end( ) ) base = m_symbolList[iter2->second];
378 }
379
380 if( base != nullptr ) {
381 if( base->isNucleus( ) ) base = static_cast<Nucleus const *>( base )->nuclide( );
382 if( base->isNuclide( ) ) base = static_cast<Nuclide const *>( base )->isotope( );
383 if( base->isIsotope( ) ) base = static_cast<Isotope const *>( base )->chemicalElement( );
384 if( base->isChemicalElement( ) ) symbol1 = base->ID( );
385 }
386
387 return( symbol1 );
388}

◆ exists() [1/2]

bool PoPI::Database::exists ( std::size_t a_index) const

Returns true if the specified index is value and false otherwise. This is, if a particle exists within this with index a_index.

Parameters
a_index[in] A particle index to test.
Returns
true is the specified index is valid and false otherwise.

Definition at line 266 of file PoPI_database.cc.

266 {
267
268 if( a_index >= m_list.size( ) ) return( false );
269 return( true );
270}

◆ exists() [2/2]

bool PoPI::Database::exists ( std::string const & a_id) const

Returns true if the specified id exists within this and false otherwise.

Parameters
a_id[in] A particle id to test.
Returns
true is the specified id exists in this and false otherwise.

Definition at line 280 of file PoPI_database.cc.

280 {
281
282 auto iter = m_idsMap.find( a_id );
283 return( iter != m_idsMap.end( ) );
284}

Referenced by intid(), intid(), MCGIDI::MCGIDI_popsIndex(), GIDI::ParticleInfo::ParticleInfo(), and GIDI::Map::Map::replacementTarget().

◆ existsIntid()

bool PoPI::Database::existsIntid ( int a_intid) const

Returns true if the specified intid exists within this and false otherwise.

Parameters
a_intid[in] A particle's intidd to test.
Returns
true is the specified intid exists in this and false otherwise.

Definition at line 294 of file PoPI_database.cc.

294 {
295
296 return( m_intidsMap.find( a_intid ) != m_intidsMap.end( ) );
297}

◆ final() [1/2]

std::size_t PoPI::Database::final ( std::size_t a_index,
bool a_returnAtMetaStableAlias = false ) const

This method resolves aliases to return an actual particle specified by a_index. That is, if a_index is an alias, then its referenced particle is returned. However, if a_returnAtMetaStableAlias is true and a meta-stable is found while resolving a_index, the then meta-stable index will be returned.

Parameters
a_index[in] A particle's index whose resolved particle index is requested.
a_returnAtMetaStableAlias[in] If true, the resolving will stop if a meta-stable is found.
Returns
The revolved index for a_index.

Definition at line 347 of file PoPI_database.cc.

347 {
348
349 while( isAlias( a_index ) ) {
350 if( a_returnAtMetaStableAlias && isMetaStableAlias( a_index ) ) break;
351 a_index = ((Alias *) m_list[a_index])->pidIndex( );
352 }
353 return( a_index );
354}
bool isMetaStableAlias(std::string const &a_id) const
Definition PoPI.hpp:1196
bool isAlias(std::string const &a_id) const
Definition PoPI.hpp:1194

◆ final() [2/2]

std::string PoPI::Database::final ( std::string const & a_id,
bool a_returnAtMetaStableAlias = false ) const

This method resolves aliases to return an actual particle specified by a_id. That is, if a_id is an alias, then its referenced particle is returned. However, if a_returnAtMetaStableAlias is true and a meta-stable is found while resolving a_id, then the meta-stable id will be returned.

Parameters
a_id[in] A particle's id whose resolved particle id is requested.
a_returnAtMetaStableAlias[in] If true, the resolving will stop if a meta-stable is found.
Returns
The revolved id for a_id.

Definition at line 329 of file PoPI_database.cc.

329 {
330
331 std::size_t index( final( (*this)[a_id], a_returnAtMetaStableAlias ) );
332
333 return( m_list[index]->ID( ) );
334}

Referenced by PoPI::particleA(), PoPI::particleA(), PoPI::particleMetaStableIndex(), PoPI::particleMetaStableIndex(), PoPI::particleZ(), PoPI::particleZ(), PoPI::particleZA(), PoPI::particleZA(), and GIDI::Map::Map::replacementTarget().

◆ formatVersion()

LUPI::FormatVersion const & PoPI::Database::formatVersion ( void ) const
inline

Returns a const reference to the m_formatVersion variable of this.

Definition at line 1157 of file PoPI.hpp.

◆ get() [1/4]

template<typename T>
T const & PoPI::Database::get ( std::size_t a_index) const

Returns the partile in this that has index a_index.

Parameters
a_index[in] The index of the particle to return.
Returns
A const reference to the particle at index a_index.

Definition at line 1233 of file PoPI.hpp.

1233 {
1234
1235 Base *particle = m_list[a_index];
1236 if( particle == nullptr ) throw std::range_error( std::string( "particle not in database" ) );
1237 T const *object = dynamic_cast<T const *>( particle );
1238 if( object == nullptr ) throw std::bad_cast( );
1239
1240 return( *object );
1241}
Particle const & particle(std::string const &a_id) const
Definition PoPI.hpp:1178

◆ get() [2/4]

template<typename T>
T const & PoPI::Database::get ( std::size_t a_index) const

◆ get() [3/4]

template<typename T>
T const & PoPI::Database::get ( std::string const & a_id) const

Returns the partile in this that has index a_index.

Parameters
a_id[in] The PoPs id of the particle to return.
Returns
A const reference to the particle with id a_id.

Definition at line 1251 of file PoPI.hpp.

1251 {
1252
1253 auto index = (*this)[a_id];
1254 Base *particle = m_list[index];
1255 T const *object = dynamic_cast<T const *>( particle );
1256 if( object == nullptr ) throw std::bad_cast( );
1257
1258 return( *object );
1259}

◆ get() [4/4]

◆ idBase() [1/2]

IDBase const & PoPI::Database::idBase ( std::size_t & a_index) const
inline

Returns a const reference to a IDBase instance with id a_index.

Definition at line 1181 of file PoPI.hpp.

◆ idBase() [2/2]

IDBase const & PoPI::Database::idBase ( std::string const & a_id) const
inline

Returns a const reference to a IDBase instance with id a_id.

Definition at line 1180 of file PoPI.hpp.

Referenced by intid().

◆ indexFromIntid()

std::size_t PoPI::Database::indexFromIntid ( int a_intid) const

Returns the index for particle with intid a_intid or -1 if a_intid is not in this.

Parameters
a_index[in] A particle's index whose index is requested.
Returns
The intid for a_index or -1 if a_index not in this.

Definition at line 475 of file PoPI_database.cc.

475 {
476
477 auto iter = m_intidsMap.find( a_intid );
478 if( iter == m_intidsMap.end( ) ) {
479 throw Exception( "Intid " + LUPI::Misc::argumentsToString( "%d", a_intid ) + " not in pops" );
480 }
481
482 return( iter->second );
483}
std::string argumentsToString(char const *a_format,...)
Definition LUPI_misc.cc:305

◆ intid() [1/2]

int PoPI::Database::intid ( std::size_t a_index) const

Returns the intid for particle with index a_index or -1 if a_index is not in this.

Parameters
a_index[in] A particle's index whose index is requested.
Returns
The intid for a_index or -1 if a_index not in this.

Definition at line 451 of file PoPI_database.cc.

451 {
452
453 int intid2 = -1;
454
455 if( exists( a_index ) ) {
456 Base const &base = get<Base const>( a_index );
457
458 if( base.isParticle( ) ) {
459 IDBase const &idBase = static_cast<IDBase const &>( base );
460 intid2 = idBase.intid( );
461 }
462 }
463
464 return( intid2 );
465}
T const & get(std::string const &a_id) const
bool exists(std::string const &a_id) const
IDBase const & idBase(std::string const &a_id) const
Definition PoPI.hpp:1180

◆ intid() [2/2]

int PoPI::Database::intid ( std::string const & a_id) const

Returns the intid for particle a_id or -1 if a_id is not in this.

Parameters
a_id[in] A particle's id whose intid is requested.
Returns
The intid for a_id or -1 if a_id not in this.

Definition at line 431 of file PoPI_database.cc.

431 {
432
433 int intid2 = -1;
434
435 if( exists( a_id ) ) {
436 Base const &base = get<Base const>( a_id );
437 intid2 = base.intid( );
438 }
439
440 return( intid2 );
441}

Referenced by MCGIDI::MCGIDI_popsIntid().

◆ isAlias() [1/2]

bool PoPI::Database::isAlias ( std::size_t a_index) const
inline

Returns true if a_index is an alias and false otherwise.

Definition at line 1195 of file PoPI.hpp.

Referenced by isAlias().

◆ isAlias() [2/2]

bool PoPI::Database::isAlias ( std::string const & a_id) const
inline

Returns true if a_id is an alias and false otherwise.

Definition at line 1194 of file PoPI.hpp.

Referenced by final(), and isAlias().

◆ isMetaStableAlias() [1/2]

bool PoPI::Database::isMetaStableAlias ( std::size_t a_index) const
inline

Returns true if a_index is a meta-stable and false otherwise.

Definition at line 1198 of file PoPI.hpp.

Referenced by isMetaStableAlias().

◆ isMetaStableAlias() [2/2]

bool PoPI::Database::isMetaStableAlias ( std::string const & a_id) const
inline

Returns true if a_id is a meta-stable and false otherwise.

Definition at line 1196 of file PoPI.hpp.

Referenced by final(), and isMetaStableAlias().

◆ isotopeSymbol()

std::string PoPI::Database::isotopeSymbol ( std::string const & a_id) const

This method returns the isotope symbol for a_id if it is a PoPs id for an isotope, nuclide, or nucleus object. Otherwise, it returns an empty string. The PoPs id a_id must be in this.

Parameters
a_id[in] A particle's id whose isotope symbol is requested.
Returns
The string for the isopte symbol.

Definition at line 399 of file PoPI_database.cc.

399 {
400
401 std::string symbol1;
402 Base const *base = nullptr;
403
404 auto iter = m_idsMap.find( a_id );
405 if( iter != m_idsMap.end( ) ) {
406 std::string finalId = final( a_id );
407 iter = m_idsMap.find( finalId );
408 base = m_list[iter->second]; }
409 else {
410 auto iter2 = m_symbolMap.find( a_id );
411 if( iter2 != m_symbolMap.end( ) ) base = m_symbolList[iter2->second];
412 }
413
414 if( base != nullptr ) {
415 if( base->isNucleus( ) ) base = static_cast<Nucleus const *>( base )->nuclide( );
416 if( base->isNuclide( ) ) base = static_cast<Nuclide const *>( base )->isotope( );
417 if( base->isIsotope( ) ) symbol1 = base->ID( );
418 }
419
420 return( symbol1 );
421}

◆ isParticle() [1/2]

bool PoPI::Database::isParticle ( std::size_t a_index) const
inline

Returns true if a_index is a particle and false otherwise.

Definition at line 1193 of file PoPI.hpp.

Referenced by isParticle().

◆ isParticle() [2/2]

bool PoPI::Database::isParticle ( std::string const & a_id) const
inline

Returns true if a_id is a particle and false otherwise.

Definition at line 1192 of file PoPI.hpp.

Referenced by isParticle(), and GIDI::Map::Map::replacementTarget().

◆ list()

ParticleList const & PoPI::Database::list ( )
inline

Returns a const reference to the m_list member.

Definition at line 1173 of file PoPI.hpp.

◆ massValue()

double PoPI::Database::massValue ( std::string const & a_id,
std::string const & a_unit ) const

This method returns the mass of the particle/alias with id a_id. Currently, a_unit is ignored and the mass is returned in unit of amu.

Parameters
a_id[in] The PoPs id of the particle/alias.file to write this to.
a_unit[in] The unit of the returned mass.

Definition at line 581 of file PoPI_database.cc.

581 {
582
583 Particle const &particle2 = particle( final( a_id ) );
584
585 return( particle2.massValue( a_unit ) );
586}

◆ name()

std::string const & PoPI::Database::name ( void ) const
inline

Returns a const reference to the m_name variable of this.

Definition at line 1158 of file PoPI.hpp.

◆ numberOfUnresolvedAliases()

std::size_t PoPI::Database::numberOfUnresolvedAliases ( )
inline

Returns the number of unresolved aliases.

Definition at line 1162 of file PoPI.hpp.

◆ operator[]()

std::size_t PoPI::Database::operator[] ( std::string const & a_id) const

Internally, PoPI::Database stores a unique integer (called an index) for each particle in this. This method returns the the index for the specified particle.

Parameters
a_id[in] The PoPs id for the specified particle.
Returns
The internal index for the specified particle.

Definition at line 246 of file PoPI_database.cc.

246 {
247
248 auto iter = m_idsMap.find( a_id );
249 if( iter == m_idsMap.end( ) ) {
250 std::string errorMessage( "particle '" + a_id + "' not in database -3." );
251 throw Exception( errorMessage );
252 }
253
254 return( iter->second );
255}

◆ particle() [1/2]

Particle const & PoPI::Database::particle ( std::size_t a_index) const
inline

Returns a const reference to the particle with index a_index.

Definition at line 1179 of file PoPI.hpp.

◆ particle() [2/2]

Particle const & PoPI::Database::particle ( std::string const & a_id) const
inline

Returns a const reference to the particle with id a_id.

Definition at line 1178 of file PoPI.hpp.

Referenced by get(), get(), massValue(), print(), and GIDI::Map::Map::replacementTarget().

◆ particleList()

ParticleList const & PoPI::Database::particleList ( ) const
inline

Returns a const reference to the m_list variable of this.

Definition at line 1182 of file PoPI.hpp.

◆ print()

void PoPI::Database::print ( bool a_printIndices)

Prints a brief outline of the contents of this.

Parameters
a_printIndices[in] If true, each particles index is also printed.

Definition at line 647 of file PoPI_database.cc.

647 {
648
649 for( auto iter = m_idsMap.begin( ); iter != m_idsMap.end( ); ++iter ) {
650 std::string label( iter->first );
651 std::size_t index = iter->second;
652 Base *item = m_list[index];
653 std::string is_alias( "" );
654 std::string mass( "" );
655
656 if( item->isAlias( ) ) {
657 is_alias = " is an alias (final is label = '";
658 std::size_t finalIndex = final( index );
659 IDBase const &myfinal = get<IDBase>( finalIndex );
660 is_alias += std::string( myfinal.ID( ) );
661 is_alias += std::string( "')" ); }
662 else if( item->isParticle( ) ) {
663 Particle *particle = (Particle *) item;
664
665 try {
666 double dmass = particle->massValue( "amu" );
667 mass = LUPI::Misc::argumentsToString( " mass = %e amu", dmass ); }
668 catch (...) {
669 mass = " particle has no mass data.";
670 }
671 }
672
673 std::cout << iter->first << " (" << item->ID( ) << ") --> ";
674 if( a_printIndices ) std::cout << index << " (" << item->index( ) << ")";
675 std::cout << is_alias << mass << std::endl;
676 }
677}

◆ saveAs()

void PoPI::Database::saveAs ( std::string const & a_fileName) const

Writes an XML version of this to the file a_fileName.

Parameters
a_fileName[in] The file to write this to.

Definition at line 594 of file PoPI_database.cc.

594 {
595
596 std::string indent1( "" );
597 std::vector<std::string> XMLList;
598
599 XMLList.push_back( "<?xml version=\"1.0\"?>" );
600 toXMLList( XMLList, indent1 );
601
602 std::ofstream fileio;
603 fileio.open( a_fileName.c_str( ) );
604 for( std::vector<std::string>::iterator iter = XMLList.begin( ); iter != XMLList.end( ); ++iter ) {
605 fileio << *iter << std::endl;
606 }
607 fileio.close( );
608}
void toXMLList(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const

◆ size()

std::string::size_type PoPI::Database::size ( void ) const
inline

Returns the number of particle in this.

Definition at line 1172 of file PoPI.hpp.

◆ symbolList() [1/2]

SymbolList const & PoPI::Database::symbolList ( )
inline

Returns a const reference to the m_symbolList member.

Definition at line 1174 of file PoPI.hpp.

◆ symbolList() [2/2]

SymbolList PoPI::Database::symbolList ( ) const
inline

Returns a const reference to the m_symbolList variable of this.

Definition at line 1183 of file PoPI.hpp.

◆ toXMLList()

void PoPI::Database::toXMLList ( std::vector< std::string > & a_XMLList,
std::string const & a_indent1 ) const

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.

Parameters
a_XMLList[in] The list to add an XML output representation of this to.
a_indent1[in] The amount of indentation to added to each line added to a_XMLList.

Definition at line 617 of file PoPI_database.cc.

617 {
618
619 std::string indent2 = a_indent1 + " ";
620 std::string indent3 = indent2 + " ";
621
622 std::string header1 = a_indent1 + "<PoPs name=\"" + m_name + "\" version=\"" + m_version + "\" format=\"" + m_formatVersion.format( ) + "\">";
623 a_XMLList.push_back( std::move( header1 ) );
624
625 if( m_aliases.size( ) > 0 ) {
626 std::string header2 = indent2 + "<" + PoPI_aliasesChars + ">";
627 a_XMLList.push_back( std::move( header2 ) );
628 for( std::vector<Alias *>::const_iterator iter = m_aliases.begin( ); iter != m_aliases.end( ); ++iter )
629 (*iter)->toXMLList( a_XMLList, indent3 );
630 appendXMLEnd( a_XMLList, PoPI_aliasesChars );
631 }
632 m_gaugeBosons.toXMLList( a_XMLList, indent2 );
633 m_leptons.toXMLList( a_XMLList, indent2 );
634 m_baryons.toXMLList( a_XMLList, indent2 );
635 m_unorthodoxes.toXMLList( a_XMLList, indent2 );
636 m_chemicalElements.toXMLList( a_XMLList, indent2 );
637
638 appendXMLEnd( a_XMLList, PoPI_PoPsChars );
639}
#define PoPI_PoPsChars
Definition PoPI.hpp:37
#define PoPI_aliasesChars
Definition PoPI.hpp:52
void appendXMLEnd(std::vector< std::string > &a_XMLList, std::string const &a_label)
Definition PoPI_misc.cc:53

Referenced by saveAs().

◆ unresolvedAliases()

std::vector< Alias * > PoPI::Database::unresolvedAliases ( )
inline

Returns a reference to the m_unresolvedAliases member of this.

Definition at line 1161 of file PoPI.hpp.

◆ unresolvedAliasIds()

std::vector< std::string > PoPI::Database::unresolvedAliasIds ( ) const

This method returns the list of ids for the aliases with unresolved pids.

Returns
A std::vector<std::string> of the ids of the aliases with unresolved pids.

Definition at line 226 of file PoPI_database.cc.

226 {
227
228 std::vector<std::string> ids;
229
230 for( std::vector<Alias *>::const_iterator iter = m_unresolvedAliases.begin( ); iter != m_unresolvedAliases.end( ); ++iter ) {
231 ids.push_back( (*iter)->ID( ) );
232 }
233
234 return( ids );
235}

◆ version()

std::string const & PoPI::Database::version ( void ) const
inline

Returns a const reference to the m_version variable of this.

Definition at line 1159 of file PoPI.hpp.


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