Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI::Transporting::Particles Class Reference

#include <GIDI.hpp>

Public Member Functions

 Particles ()
 ~Particles ()
std::map< std::string, Particle > & particles ()
std::map< std::string, Particle > const & particles () const
Particle const * particle (std::string const &a_particleID) const
bool add (Particle const &a_particle)
bool remove (std::string const &a_particleID)
void clear ()
bool hasParticle (std::string const &a_id) const
void process (Protare const &a_protare, std::string const &a_label)
std::vector< std::string > sortedIDs (bool a_orderIsAscending=true) const
void print () const

Detailed Description

Stores a list of Particle instances.

Definition at line 3683 of file GIDI.hpp.

Constructor & Destructor Documentation

◆ Particles()

GIDI::Transporting::Particles::Particles ( )

Definition at line 26 of file GIDI_settings_particle.cc.

26 {
27
28}

◆ ~Particles()

GIDI::Transporting::Particles::~Particles ( )

Definition at line 33 of file GIDI_settings_particle.cc.

33 {
34
35}

Member Function Documentation

◆ add()

bool GIDI::Transporting::Particles::add ( Particle const & a_particle)

Adds the Particle a_particle to this. If a particle with the same id as a_particle exists in this the a_particle is not added and false is returned.

Parameters
a_particle[in] The Particle to add to this as a particle to transport.
Returns
Return true if particle is add and false otherwise.

Definition at line 63 of file GIDI_settings_particle.cc.

63 {
64
65 std::string const &pid = a_particle.pid( );
66
67 if( m_particles.find( pid ) != m_particles.end( ) ) return( false );
68 m_particles.insert( std::pair<std::string, Particle>( pid, Particle( a_particle ) ) );
69 return( true );
70}

Referenced by G4GIDI::readTarget().

◆ clear()

void GIDI::Transporting::Particles::clear ( )
inline

Definition at line 3697 of file GIDI.hpp.

3697{ m_particles.clear( ); }

◆ hasParticle()

bool GIDI::Transporting::Particles::hasParticle ( std::string const & a_id) const

Returns true if Particle with id a_id is in this and false otherwise.

Parameters
a_id[in] The PoPs id of the particle to check for in this.
Returns
Return 0 if particle exist is remove and non-zero otherwise.

Definition at line 97 of file GIDI_settings_particle.cc.

97 {
98
99 return( particle( a_id ) != nullptr );
100}
Particle const * particle(std::string const &a_particleID) const

Referenced by GIDI::Product::areAllProductsTracked(), MCGIDI::HeatedCrossSectionContinuousEnergy::HeatedCrossSectionContinuousEnergy(), MCGIDI::OutputChannel::OutputChannel(), and GIDI::Product::productIDs().

◆ particle()

Particle const * GIDI::Transporting::Particles::particle ( std::string const & a_pid) const

Returns a pointer to the Particle in this with PoPs id a_pid.

Parameters
a_pid[in] The PoPs id of the particle to return.
Returns
Pointer to particle if it exists or nullptr otherwise.

Definition at line 45 of file GIDI_settings_particle.cc.

45 {
46
47 for( auto particleIter = m_particles.begin( ); particleIter != m_particles.end( ); ++particleIter ) {
48 if( PoPI::compareSpecialParticleIDs( (*particleIter).first, a_pid ) ) return( &(*particleIter).second );
49 }
50
51 return( nullptr );
52}
bool compareSpecialParticleIDs(std::string const &a_id1, std::string const &a_id2)
Definition PoPI_misc.cc:133

Referenced by GIDI::collapse(), GIDI::collapse(), hasParticle(), MCGIDI::MultiGroupHash::MultiGroupHash(), GIDI::Transporting::Settings::multiGroupZeroMatrix(), GIDI::Transporting::Settings::multiGroupZeroVector(), print(), process(), and remove().

◆ particles() [1/2]

◆ particles() [2/2]

std::map< std::string, Particle > const & GIDI::Transporting::Particles::particles ( ) const
inline

Returns the value of the m_particles member.

Definition at line 3693 of file GIDI.hpp.

◆ print()

void GIDI::Transporting::Particles::print ( ) const

Prints the contents of this to std::cout. Mainly used for debugging.

Definition at line 151 of file GIDI_settings_particle.cc.

151 {
152
153 std::cout << "particles:" << std::endl;
154
155 std::vector<std::string> IDs = sortedIDs( );
156 for( std::vector<std::string>::const_iterator iter = IDs.begin( ); iter != IDs.end( ); ++iter ) {
157 Particle const &particle = m_particles.at( *iter );
158
159 particle.print( " " );
160 }
161}
std::vector< std::string > sortedIDs(bool a_orderIsAscending=true) const

◆ process()

void GIDI::Transporting::Particles::process ( Protare const & a_protare,
std::string const & a_label )

Process all the data in this. This includes determining the mapping between the uncollapsed (specified by a_label) and the collapsed multi-group boundaries, and grouping the flux data for each Particle.

Parameters
a_protare[in] The Protare whose multi-group data are to accessed.
a_label[in] The label of the multi-group data to process.

Definition at line 111 of file GIDI_settings_particle.cc.

111 {
112
113 if( a_label == "" ) return;
114
115 Styles::Base const *style = a_protare.styles( ).get<Styles::Base>( a_label );
116
117 if( style->moniker( ) == GIDI_SnElasticUpScatterStyleChars ) style = a_protare.styles( ).get<Styles::Base>( style->derivedStyle( ) );
118 if( style->moniker( ) != GIDI_heatedMultiGroupStyleChars ) throw Exception( "Label does not yield a heatedMultiGroup style." );
119
120 Styles::HeatedMultiGroup const &heatedMultiGroup = *static_cast<Styles::HeatedMultiGroup const *>( style );
121
122 for( std::map<std::string, Particle>::iterator iter = m_particles.begin( ); iter != m_particles.end( ); ++iter ) {
123 std::string pid = iter->first;
124 Particle *particle = &(iter->second);
125
126 particle->process( heatedMultiGroup.transportable( pid ) );
127 }
128}
#define GIDI_heatedMultiGroupStyleChars
Definition GIDI.hpp:253
#define GIDI_SnElasticUpScatterStyleChars
Definition GIDI.hpp:254

◆ remove()

bool GIDI::Transporting::Particles::remove ( std::string const & a_pid)

Removes the Particle in this with PoPs id a_pid.

Parameters
a_pid[in] The PoPs id of the particle to remove from this.
Returns
Return true if particle exist is remove and non-zero otherwise.

Definition at line 80 of file GIDI_settings_particle.cc.

80 {
81
82 std::map<std::string, Particle>::iterator particle = m_particles.find( a_pid );
83
84 if( particle == m_particles.end( ) ) return( false );
85 m_particles.erase( a_pid );
86 return( true );
87}

◆ sortedIDs()

std::vector< std::string > GIDI::Transporting::Particles::sortedIDs ( bool a_orderIsAscending = true) const

Returns the particle IDs of this as a sorted std::vector<std::string> list.

Parameters
a_orderIsAscending[in] If true IDs are sorted in ascending order, otherwise IDs are in descending order.
Returns
The list of sorted particle IDs.

Definition at line 138 of file GIDI_settings_particle.cc.

138 {
139
140 std::vector<std::string> keys;
141
142 for( std::map<std::string, Particle>::const_iterator iter = m_particles.begin( ); iter != m_particles.end( ); ++iter ) keys.push_back( (*iter).first );
143
144 return( sortedListOfStrings( keys, a_orderIsAscending ) );
145}
std::vector< std::string > sortedListOfStrings(std::vector< std::string > const &a_strings, bool a_orderIsAscending=true)
Definition GIDI_misc.cc:353

Referenced by print().


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