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

#include <G4GIDI.hh>

Public Member Functions

 G4GIDI (G4int a_ip, std::string const &a_dataDirectory)
 G4GIDI (G4int a_ip, std::list< std::string > const &a_dataDirectory)
 ~G4GIDI ()
G4int projectileIP () const
G4int numberOfDataDirectories () const
G4int addDataDirectory (std::string const &a_dataDirectory)
G4int removeDataDirectory (std::string const &a_dataDirectory)
std::string const getDataDirectoryAtIndex (G4int a_index) const
std::vector< std::string > * getDataDirectories () const
bool isThisDataAvailable (std::string const &a_lib_name, G4int a_Z, G4int a_A, G4int a_M=0) const
bool isThisDataAvailable (std::string const &a_lib_name, std::string const &a_targetName) const
std::string dataFilename (std::string const &lib_name, G4int a_Z, G4int a_A, G4int a_M=0) const
std::string dataFilename (std::string const &lib_name, std::string const &a_targetName) const
std::vector< std::string > * getNamesOfAvailableLibraries (G4int a_Z, G4int a_A, G4int a_M=0) const
std::vector< std::string > * getNamesOfAvailableLibraries (std::string const &a_targetName) const
std::vector< std::string > * getNamesOfAvailableTargets () const
G4GIDI_targetreadTarget (std::string const &lib_name, G4int a_Z, G4int a_A, G4int a_M=0, bool a_bind=true)
G4GIDI_targetreadTarget (std::string const &lib_name, std::string const &a_targetName, bool a_bind=true)
G4GIDI_targetgetAlreadyReadTarget (G4int a_Z, G4int a_A, G4int a_M=0)
G4GIDI_targetgetAlreadyReadTarget (std::string const &a_targetName)
G4int freeTarget (G4int a_Z, G4int a_A, G4int a_M=0)
G4int freeTarget (std::string const &a_targetSymbol)
G4int freeTarget (G4GIDI_target *a_target)
std::vector< std::string > * getListOfReadTargetsNames ()

Detailed Description

A class to store map files for a particular projectile.

Definition at line 124 of file G4GIDI.hh.

Constructor & Destructor Documentation

◆ G4GIDI() [1/2]

G4GIDI::G4GIDI ( G4int a_ip,
std::string const & a_dataDirectory )
Parameters
a_ip[in] One of the following ids for the projectile (0:photon, 1:neutron, 2:proton, 3:deutron, 4:triton, 5:helion or 6:alpha).
a_dataDirectory[in] A path to a map file to load.

Definition at line 84 of file G4GIDI.cc.

84 :
85 m_projectileIP( a_ip ),
86 m_projectile( projectileStringFromID( a_ip ) ) {
87
88 addDataDirectory( a_dataDirectory );
89}
G4int addDataDirectory(std::string const &a_dataDirectory)
Definition G4GIDI.cc:121

◆ G4GIDI() [2/2]

G4GIDI::G4GIDI ( G4int a_ip,
std::list< std::string > const & a_dataDirectories )
Parameters
a_id[in] This argument is ignored but needed for backwards compatibility.
a_dataDirectories[in] A list of paths to a map files to load.

Definition at line 97 of file G4GIDI.cc.

97 :
98 m_projectileIP( a_ip ),
99 m_projectile( projectileStringFromID( a_ip ) ) {
100
101 for( auto mapIter = a_dataDirectories.begin( ); mapIter != a_dataDirectories.end( ); ++mapIter ) {
102 addDataDirectory( *mapIter );
103 }
104}

◆ ~G4GIDI()

G4GIDI::~G4GIDI ( )

Definition at line 109 of file G4GIDI.cc.

109 {
110
111 for( auto mapIter = m_maps.begin( ); mapIter != m_maps.end( ); ++mapIter ) delete *mapIter;
112 for( auto protareIter = m_protares.begin( ); protareIter != m_protares.end( ); ++protareIter ) delete *protareIter;
113}

Member Function Documentation

◆ addDataDirectory()

int G4GIDI::addDataDirectory ( std::string const & a_dataDirectory)

Adds the map file a_dataDirectory to this.

Parameters
a_dataDirectory[in] A path to a map file to load.

Definition at line 121 of file G4GIDI.cc.

121 {
122
123 for( auto mapIter = m_maps.begin( ); mapIter != m_maps.end( ); ++mapIter ) {
124 if( (*mapIter)->fileName( ) == a_dataDirectory ) return( 0 );
125 }
126
127 m_maps.push_back( new GIDI::Map::Map( a_dataDirectory, G4GIDI_pops ) );
128
129 return( 0 );
130}
PoPI::Database G4GIDI_pops
Definition G4GIDI.cc:29

Referenced by G4GIDI().

◆ dataFilename() [1/2]

std::string G4GIDI::dataFilename ( std::string const & a_lib_name,
G4int a_Z,
G4int a_A,
G4int a_M = 0 ) const

Returns the file path to the specified target or nullptr if the target does not exists.

Parameters
a_lib_name[in] The evaluation. Call be an empty string.
a_Z[in] The atomic number of the target.
a_A[in] The mass number of the taret.
a_M[in] The meta-stable index of the target.
Returns
A std::string of the protare's path.

Definition at line 233 of file G4GIDI.cc.

233 {
234
235 return( dataFilename( a_lib_name, G4GIDI_Misc_Z_A_m_ToName( a_Z, a_A, a_M ) ) );
236}
std::string G4GIDI_Misc_Z_A_m_ToName(int a_Z, int a_A, int a_M)
std::string dataFilename(std::string const &lib_name, G4int a_Z, G4int a_A, G4int a_M=0) const
Definition G4GIDI.cc:233

Referenced by dataFilename().

◆ dataFilename() [2/2]

std::string G4GIDI::dataFilename ( std::string const & a_lib_name,
std::string const & a_targetName ) const

Returns the file path to the specified target or nullptr if the target does not exists.

Parameters
a_lib_name[in] The evaluation. Call be an empty string.
a_targetName[in] The target PoPs id.
Returns
Boolean value.

Definition at line 247 of file G4GIDI.cc.

247 {
248
249 for( auto mapIter = m_maps.begin( ); mapIter!= m_maps.end( ); ++mapIter ) {
250 std::string path = (*mapIter)->protareFilename( m_projectile, a_targetName, "", a_lib_name );
251 if( path != "" ) return( path );
252 }
253
254 return( "" );
255}

◆ freeTarget() [1/3]

G4int G4GIDI::freeTarget ( G4GIDI_target * a_target)

If a_target is in member m_protares, removed it from m_protares, delete it and return 0. Otherwise, do nothing and return 1.

Parameters
a_target[in] The evaluation. Call be an empty std::string.
Returns
Integer value.

Definition at line 430 of file G4GIDI.cc.

430 {
431
432 for( auto iter_protare = m_protares.cbegin( ); iter_protare != m_protares.cend( ); ++iter_protare ) {
433 if( *iter_protare == a_target ) {
434 m_protares.erase( iter_protare );
435 delete a_target;
436 return( 0 );
437 }
438 }
439 return( 1 );
440}

◆ freeTarget() [2/3]

G4int G4GIDI::freeTarget ( G4int a_Z,
G4int a_A,
G4int a_M = 0 )

Determines target name from a_Z, a_A and a_M and calls freeTarget with target's name, and returns its return value.

Parameters
a_Z[in] The atomic number of the target.
a_A[in] The mass number of the taret.
a_M[in] The meta-stable index of the target.
Returns
Integer value.

Definition at line 453 of file G4GIDI.cc.

453 {
454
455 return( freeTarget( G4GIDI_Misc_Z_A_m_ToName( a_Z, a_A, a_M ) ) );
456}
G4int freeTarget(G4int a_Z, G4int a_A, G4int a_M=0)
Definition G4GIDI.cc:453

Referenced by freeTarget(), and freeTarget().

◆ freeTarget() [3/3]

G4int G4GIDI::freeTarget ( std::string const & targetSymbol)

If target with name targetSymbol is in member m_protares, call freeTarget with target's pointer and return freeTarget's return value. Otherwise, return 1.

Returns
Integer value.

Definition at line 465 of file G4GIDI.cc.

465 {
466
467 for( auto iter_protare = m_protares.cbegin( ); iter_protare != m_protares.cend( ); ++iter_protare ) {
468 if( *(*iter_protare)->getName( ) == targetSymbol ) return( freeTarget( *iter_protare ) );
469 }
470 return( 1 );
471}

◆ getAlreadyReadTarget() [1/2]

G4GIDI_target * G4GIDI::getAlreadyReadTarget ( G4int a_Z,
G4int a_A,
G4int a_M = 0 )

Determines target name from a_Z, a_A and a_M and calls getAlreadyReadTarget with target's name, and returns its return value.

Parameters
a_Z[in] The atomic number of the target.
a_A[in] The mass number of the taret.
a_M[in] The meta-stable index of the target.
Returns
Pointer to an G4GIDI_target instance of nullptr.

Definition at line 398 of file G4GIDI.cc.

398 {
399
400 return( getAlreadyReadTarget( G4GIDI_Misc_Z_A_m_ToName( a_Z, a_A, a_M ) ) );
401}
G4GIDI_target * getAlreadyReadTarget(G4int a_Z, G4int a_A, G4int a_M=0)
Definition G4GIDI.cc:398

Referenced by getAlreadyReadTarget().

◆ getAlreadyReadTarget() [2/2]

G4GIDI_target * G4GIDI::getAlreadyReadTarget ( std::string const & a_targetName)

Returns the pointer to the G4GIDI_target with name a_targetName in member m_protares or nullptr if one does not exists in m_protares.

Parameters
a_targetName[in] The name of the target.
Returns
Pointer to an G4GIDI_target instance of nullptr.

Definition at line 412 of file G4GIDI.cc.

412 {
413
414 for( auto iter_protare = m_protares.cbegin( ); iter_protare != m_protares.cend( ); ++iter_protare ) {
415 if( *(*iter_protare)->getName( ) == a_targetName ) return( *iter_protare );
416 }
417
418 return( nullptr );
419}

◆ getDataDirectories()

std::vector< std::string > * G4GIDI::getDataDirectories ( ) const

Returns a list of paths to all loaded map files.

Returns
Returns a pointer that the user owns (i.e., the user is responsible for free-ing).

Definition at line 177 of file G4GIDI.cc.

177 {
178
179 std::vector<std::string> *list = new std::vector<std::string>( );
180
181 for( auto mapIter = m_maps.begin( ); mapIter!= m_maps.end( ); ++mapIter ) {
182 list->push_back( (*mapIter)->fileName( ) );
183 }
184
185 return( list );
186}

◆ getDataDirectoryAtIndex()

std::string const G4GIDI::getDataDirectoryAtIndex ( G4int a_index) const

Removes the map file with path a_dataDirectory from this.

Parameters
a_dataDirectory[in] A path to a map file to unload.

Definition at line 162 of file G4GIDI.cc.

162 {
163
164 std::string nullString;
165
166 if( ( a_index < 0 ) || ( a_index >= static_cast<int>( m_maps.size( ) ) ) ) return( nullString );
167
168 return( m_maps[a_index]->fileName( ) );
169}

◆ getListOfReadTargetsNames()

std::vector< std::string > * G4GIDI::getListOfReadTargetsNames ( void )

If target with name targetSymbol is in member m_protares, call freeTarget with target's pointer and return freeTarget's return value. Otherwise, return 1.

Returns
Integer value.

Definition at line 480 of file G4GIDI.cc.

480 {
481
482 std::vector<std::string> *listOfTargets = new std::vector<std::string>( );
483
484 for( auto iter_protare = m_protares.cbegin( ); iter_protare != m_protares.cend( ); ++iter_protare ) {
485 listOfTargets->push_back( *(*iter_protare)->getName( ) );
486 }
487
488 return( listOfTargets );
489}

◆ getNamesOfAvailableLibraries() [1/2]

std::vector< std::string > * G4GIDI::getNamesOfAvailableLibraries ( G4int a_Z,
G4int a_A,
G4int a_M = 0 ) const

Determines target name from a_Z, a_A and a_M and calls getNamesOfAvailableLibraries with target's name, and returns its return value.

Parameters
a_Z[in] The atomic number of the target.
a_A[in] The mass number of the taret.
a_M[in] The meta-stable index of the target.
Returns
Pointer to vector<string>.

Definition at line 268 of file G4GIDI.cc.

268 {
269
270 return( getNamesOfAvailableLibraries( G4GIDI_Misc_Z_A_m_ToName( a_Z, a_A, a_M ) ) );
271}
std::vector< std::string > * getNamesOfAvailableLibraries(G4int a_Z, G4int a_A, G4int a_M=0) const
Definition G4GIDI.cc:268

Referenced by G4LENDManager::GetLENDTarget(), getNamesOfAvailableLibraries(), and G4LENDManager::IsLENDTargetAvailable().

◆ getNamesOfAvailableLibraries() [2/2]

std::vector< std::string > * G4GIDI::getNamesOfAvailableLibraries ( std::string const & a_targetName) const

Returns the list of all evaluations that have a target named a_targetName. User is responsible for freeing the returned list.

Returns
Pointer to vector<string>.

Definition at line 279 of file G4GIDI.cc.

279 {
280
281 std::vector<std::string> *listOfLibraries = new std::vector<std::string>( );
282
283 for( auto mapIter = m_maps.cbegin( ); mapIter != m_maps.cend( ); ++mapIter ) {
284 std::vector<GIDI::Map::ProtareBase const *> entries;
285 (*mapIter)->findProtareEntries( entries, std::regex( m_projectile ), std::regex( a_targetName ) );
286 for( auto entryIter = entries.begin( ); entryIter != entries.end( ); ++entryIter ) {
287 listOfLibraries->push_back( (*entryIter)->evaluation( ) );
288 }
289 }
290
291 return( listOfLibraries );
292}

◆ getNamesOfAvailableTargets()

std::vector< std::string > * G4GIDI::getNamesOfAvailableTargets ( ) const

Returns the list of available targets for this.

Returns
Returns a pointer that the user owns (i.e., the user is responsible for free-ing).

Definition at line 300 of file G4GIDI.cc.

300 {
301
302 std::vector<std::string> *list = new std::vector<std::string>( );
303 std::set<std::string> targetIDs;
304
305 for( auto mapIter = m_maps.begin( ); mapIter!= m_maps.end( ); ++mapIter ) {
306 auto protareBases = (*mapIter)->directory( m_projectile );
307
308 for( auto protareBaseIter = protareBases.begin( ); protareBaseIter != protareBases.end( ); ++protareBaseIter ) {
309 targetIDs.insert( (*protareBaseIter)->targetID( ) );
310 }
311 }
312
313 for( auto targetIter = targetIDs.begin( ); targetIter != targetIDs.end( ); ++targetIter ) {
314 (*list).push_back( (*targetIter) );
315 }
316
317 return( list );
318}

◆ isThisDataAvailable() [1/2]

bool G4GIDI::isThisDataAvailable ( std::string const & a_lib_name,
G4int a_Z,
G4int a_A,
G4int a_M = 0 ) const

Returns true if the specified target exists in a map file and false otherwise.

Parameters
a_lib_name[in] The evaluation. Call be an empty string.
a_Z[in] The atomic number of the target.
a_A[in] The mass number of the taret.
a_M[in] The meta-stable index of the target.
Returns
Boolean value.

Definition at line 199 of file G4GIDI.cc.

199 {
200
201 return( isThisDataAvailable( a_lib_name, G4GIDI_Misc_Z_A_m_ToName( a_Z, a_A, a_M ) ) );
202}
bool isThisDataAvailable(std::string const &a_lib_name, G4int a_Z, G4int a_A, G4int a_M=0) const
Definition G4GIDI.cc:199

Referenced by G4LENDManager::GetLENDTarget(), and isThisDataAvailable().

◆ isThisDataAvailable() [2/2]

bool G4GIDI::isThisDataAvailable ( std::string const & a_lib_name,
std::string const & a_targetName ) const

Returns true if the specified target exists in a map file and false otherwise.

Parameters
a_lib_name[in] The evaluation. Call be an empty string.
a_targetName[in] The target PoPs id.
Returns
Boolean value.

Definition at line 213 of file G4GIDI.cc.

213 {
214
215 for( auto mapIter = m_maps.begin( ); mapIter!= m_maps.end( ); ++mapIter ) {
216 if( (*mapIter)->isProtareAvailable( m_projectile, a_targetName, "", a_lib_name ) ) return( true );
217 }
218
219 return( false );
220}

◆ numberOfDataDirectories()

G4int G4GIDI::numberOfDataDirectories ( ) const
inline

Definition at line 139 of file G4GIDI.hh.

139{ return( static_cast<G4int>( m_maps.size( ) ) ); }
int G4int
Definition G4Types.hh:85

◆ projectileIP()

G4int G4GIDI::projectileIP ( ) const
inline

Definition at line 137 of file G4GIDI.hh.

137{ return( m_projectileIP ); }

◆ readTarget() [1/2]

G4GIDI_target * G4GIDI::readTarget ( std::string const & a_lib_name,
G4int a_Z,
G4int a_A,
G4int a_M = 0,
bool bind = true )

Returns the specified target or nullptr if the target does not exists.

Parameters
a_lib_name[in] The evaluation. Call be an empty string.
a_Z[in] The atomic number of the target.
a_A[in] The mass number of the taret.
a_M[in] The meta-stable index of the target.
Returns
Boolean value.

Definition at line 331 of file G4GIDI.cc.

331 {
332
333 return( readTarget( a_lib_name, G4GIDI_Misc_Z_A_m_ToName( a_Z, a_A, a_M ), bind ) );
334}
G4GIDI_target * readTarget(std::string const &lib_name, G4int a_Z, G4int a_A, G4int a_M=0, bool a_bind=true)
Definition G4GIDI.cc:331

Referenced by G4LENDManager::GetLENDTarget(), and readTarget().

◆ readTarget() [2/2]

G4GIDI_target * G4GIDI::readTarget ( std::string const & a_lib_name,
std::string const & a_targetName,
bool a_bind = true )

Returns the protare specified by a_targetName and the projectile for this.

Parameters
a_lib_name[in] The evaluation. Call be an empty std::string.
a_targetName[in] The target PoPs id.
a_bind[in] If true, read target is added to member m_protares.
Returns
Boolean value.

Definition at line 346 of file G4GIDI.cc.

346 {
347
348 for( auto iter_protare = m_protares.cbegin( ); iter_protare != m_protares.cend( ); ++iter_protare ) {
349 if( *(*iter_protare)->getName( ) == a_targetName ) return( nullptr );
350 }
351
352 GIDI::Construction::Settings construction( GIDI::Construction::ParseMode::all, GIDI::Construction::PhotoMode::nuclearOnly );
353 construction.setGRIN_continuumGammas( true );
354
355 for( auto mapIter = m_maps.begin( ); mapIter!= m_maps.end( ); ++mapIter ) {
356 GIDI::Protare *GIDI_protare = (*mapIter)->protare( construction, G4GIDI_pops, m_projectile, a_targetName, "", a_lib_name );
357 if( GIDI_protare != nullptr ) {
358 LUPI::StatusMessageReporting smr;
359 GIDI::Styles::TemperatureInfos temperatures = GIDI_protare->temperatures( );
360 std::string label( temperatures[0].griddedCrossSection( ) );
361 MCGIDI::Transporting::MC MC( G4GIDI_pops, m_projectile, &GIDI_protare->styles( ), label, GIDI::Transporting::DelayedNeutrons::off, 20 ); // FIXME: 20
362 MC.setThrowOnError( false );
363 MC.setSampleNonTransportingParticles( true );
364 MCGIDI::DomainHash domainHash( 4000, 1e-8, 10 );
365 std::set<size_t> reactionsToExclude;
366
367 GIDI::Transporting::Particles particles;
368 GIDI::Transporting::Particle neutron( PoPI::IDs::neutron );
369 particles.add( neutron );
370
371 GIDI::Styles::TemperatureInfos temperatures1;
372 temperatures1.push_back( temperatures[0] );
373 MCGIDI::Protare *MCGIDI_protare = MCGIDI::protareFromGIDIProtare( smr, *GIDI_protare, G4GIDI_pops, MC, particles, domainHash,
374 temperatures1, reactionsToExclude );
375 //if( !smr.isOk( ) ) throw LUPI::Exception( smr.constructFullMessage( "G4GIDI::readTarget:" ) );
376
377 G4GIDI_target *protare = new G4GIDI_target( G4GIDI_pops, domainHash, *GIDI_protare, MCGIDI_protare );
378 delete GIDI_protare;
379 if( a_bind ) m_protares.push_back( protare );
380 return( protare );
381 }
382 }
383
384 return( nullptr );
385}
virtual Styles::TemperatureInfos temperatures() const =0
virtual Styles::Suite & styles()=0
bool add(Particle const &a_particle)
std::vector< Styles::TemperatureInfo > TemperatureInfos
Definition GIDI.hpp:3440
LUPI_HOST Protare * protareFromGIDIProtare(LUPI::StatusMessageReporting &a_smr, GIDI::Protare const &a_protare, PoPI::Database const &a_pops, Transporting::MC &a_settings, GIDI::Transporting::Particles const &a_particles, DomainHash const &a_domainHash, GIDI::Styles::TemperatureInfos const &a_temperatureInfos, GIDI::ExcludeReactionsSet const &a_reactionsToExclude, std::size_t a_reactionsToExcludeOffset=0, bool a_allowFixedGrid=true)
static std::string const neutron
Definition PoPI.hpp:164

◆ removeDataDirectory()

int G4GIDI::removeDataDirectory ( std::string const & a_dataDirectory)

Removes the map file with path a_dataDirectory from this.

Parameters
a_dataDirectory[in] A path to a map file to unload.

Definition at line 138 of file G4GIDI.cc.

138 {
139
140 std::size_t index = 0;
141
142 for( auto mapIter = m_maps.begin( ); mapIter!= m_maps.end( ); ++mapIter, ++index ) {
143 if( a_dataDirectory == (*mapIter)->fileName( ) ) {
144 delete *mapIter;
145
146 ++index;
147 for( ; index < m_maps.size( ); ++index ) m_maps[index-1] = m_maps[index];
148 m_maps[index-1] = nullptr;
149 m_maps.resize( m_maps.size( ) - 1 );
150 }
151 }
152
153 return( 0 );
154}

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