Geant4 11.1.1
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 ip, std::string &dataDirectory)
 
 G4GIDI (G4int ip, std::list< std::string > &dataDirectory)
 
 ~G4GIDI ()
 
G4int numberOfDataDirectories (void)
 
G4int addDataDirectory (std::string &dataDirectory)
 
G4int removeDataDirectory (std::string &dataDirectory)
 
std::string getDataDirectoryAtIndex (G4int index)
 
std::vector< std::string > * getDataDirectories (void)
 
G4bool isThisDataAvailable (std::string &lib_name, G4int iZ, G4int iA, G4int iM=0)
 
G4bool isThisDataAvailable (std::string &lib_name, std::string &targetName)
 
char * dataFilename (std::string &lib_name, G4int iZ, G4int iA, G4int iM=0)
 
char * dataFilename (std::string &lib_name, std::string &targetName)
 
std::vector< std::string > * getNamesOfAvailableLibraries (G4int iZ, G4int iA, G4int iM=0)
 
std::vector< std::string > * getNamesOfAvailableLibraries (std::string &targetName)
 
std::vector< std::string > * getNamesOfAvailableTargets (void)
 
G4GIDI_targetreadTarget (std::string &lib_name, G4int iZ, G4int iA, G4int iM=0, G4bool bind=true)
 
G4GIDI_targetreadTarget (std::string &lib_name, std::string &targetName, G4bool bind=true)
 
G4GIDI_targetgetAlreadyReadTarget (G4int iZ, G4int iA, G4int iM=0)
 
G4GIDI_targetgetAlreadyReadTarget (std::string &targetName)
 
G4int freeTarget (G4int iZ, G4int iA, G4int iM=0)
 
G4int freeTarget (std::string &targetSymbol)
 
G4int freeTarget (G4GIDI_target *target)
 
std::vector< std::string > * getListOfReadTargetsNames (void)
 

Detailed Description

Definition at line 41 of file G4GIDI.hh.

Constructor & Destructor Documentation

◆ G4GIDI() [1/2]

G4GIDI::G4GIDI ( G4int  ip,
std::string &  dataDirectory 
)

Definition at line 37 of file G4GIDI.cc.

37 {
38
39 init( ip );
40 addDataDirectory( dataDirectory );
41}
G4int addDataDirectory(std::string &dataDirectory)
Definition: G4GIDI.cc:106

◆ G4GIDI() [2/2]

G4GIDI::G4GIDI ( G4int  ip,
std::list< std::string > &  dataDirectory 
)

◆ ~G4GIDI()

G4GIDI::~G4GIDI ( void  )

Definition at line 54 of file G4GIDI.cc.

54 {
55
56 G4GIDI_target *target;
57 auto iter = dataDirectories.cbegin();
58
59 while( targets.size( ) > 0 ) {
60 target = targets.back( );
61 targets.pop_back( );
62 delete target;
63 } // Loop checking, 11.06.2015, T. Koi
64
65 while( iter != dataDirectories.cend() ) {
66 delete *iter;
67 dataDirectories.pop_front( );
68 }// Loop checking, 11.06.2015, T. Koi
69}

Member Function Documentation

◆ addDataDirectory()

G4int G4GIDI::addDataDirectory ( std::string &  dataDirectory)

Definition at line 106 of file G4GIDI.cc.

106 {
107
108 for( auto iter = dataDirectories.cbegin( ); iter != dataDirectories.cend( ); ++iter ) {
109 if( (*iter)->path( ) == dataDirectory ) return( 0 );
110 }
111
112 G4GIDI_map *map = new G4GIDI_map( dataDirectory );
113 dataDirectories.push_back( map );
114
115 return( 0 );
116}

Referenced by G4GIDI().

◆ dataFilename() [1/2]

char * G4GIDI::dataFilename ( std::string &  lib_name,
G4int  iZ,
G4int  iA,
G4int  iM = 0 
)

Definition at line 186 of file G4GIDI.cc.

186 {
187
188 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM ), *fileName;
189
190 if( targetName == nullptr ) return( nullptr );
191 string targetSymbol( targetName );
192 fileName = dataFilename( lib_name, targetSymbol );
193 smr_freeMemory( (void **) &targetName );
194 return( fileName );
195}
char * G4GIDI_Misc_Z_A_m_ToName(int iZ, int iA, int im=0)
Definition: G4GIDI_Misc.cc:44
char * dataFilename(std::string &lib_name, G4int iZ, G4int iA, G4int iM=0)
Definition: G4GIDI.cc:186
void * smr_freeMemory(void **p)

Referenced by dataFilename(), isThisDataAvailable(), and readTarget().

◆ dataFilename() [2/2]

char * G4GIDI::dataFilename ( std::string &  lib_name,
std::string &  targetName 
)

Definition at line 199 of file G4GIDI.cc.

199 {
200
201 char *path;
202
203 for( auto iter = dataDirectories.cbegin( ); iter != dataDirectories.cend( ); ++iter )
204 if( ( path = MCGIDI_map_findTarget( nullptr, (*iter)->map, lib_name.c_str(), projectile.c_str( ), targetSymbol.c_str( ) ) ) != nullptr )
205 return( path );
206
207 return( nullptr );
208}
char * MCGIDI_map_findTarget(statusMessageReporting *smr, MCGIDI_map *map, const char *evaluation, const char *projectile, const char *targetName)
Definition: MCGIDI_map.cc:376

◆ freeTarget() [1/3]

G4int G4GIDI::freeTarget ( G4GIDI_target target)

Definition at line 316 of file G4GIDI.cc.

316 {
317
318 for( auto iter_targets = targets.cbegin( ); iter_targets != targets.cend( ); ++iter_targets ) {
319 if( *iter_targets == target ) {
320 targets.erase( iter_targets );
321 delete target;
322 return( 0 );
323 }
324 }
325 return( 1 );
326}

◆ freeTarget() [2/3]

G4int G4GIDI::freeTarget ( G4int  iZ,
G4int  iA,
G4int  iM = 0 
)

Definition at line 330 of file G4GIDI.cc.

330 {
331
332 G4int status;
333 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
334
335 if( targetName == nullptr ) return( 1 );
336 string targetSymbol( targetName );
337 status = freeTarget( targetSymbol );
338 smr_freeMemory( (void **) &targetName );
339 return( status );
340}
int G4int
Definition: G4Types.hh:85
G4int freeTarget(G4int iZ, G4int iA, G4int iM=0)
Definition: G4GIDI.cc:330

Referenced by freeTarget().

◆ freeTarget() [3/3]

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

Definition at line 344 of file G4GIDI.cc.

344 {
345
346 for( auto iter_targets = targets.cbegin( ); iter_targets != targets.cend( ); ++iter_targets ) {
347 if( (*iter_targets)->name == targetSymbol ) return( freeTarget( *iter_targets ) );
348 }
349 return( 1 );
350}

◆ getAlreadyReadTarget() [1/2]

G4GIDI_target * G4GIDI::getAlreadyReadTarget ( G4int  iZ,
G4int  iA,
G4int  iM = 0 
)

Definition at line 292 of file G4GIDI.cc.

292 {
293
294 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
295 G4GIDI_target *target;
296
297 if( targetName == nullptr ) return( nullptr );
298 string targetSymbol( targetName );
299 target = getAlreadyReadTarget( targetSymbol );
300 smr_freeMemory( (void **) &targetName );
301 return( target );
302}
G4GIDI_target * getAlreadyReadTarget(G4int iZ, G4int iA, G4int iM=0)
Definition: G4GIDI.cc:292

Referenced by getAlreadyReadTarget().

◆ getAlreadyReadTarget() [2/2]

G4GIDI_target * G4GIDI::getAlreadyReadTarget ( std::string &  targetName)

Definition at line 306 of file G4GIDI.cc.

306 {
307
308 for( auto iter_targets = targets.cbegin( ); iter_targets != targets.cend( ); ++iter_targets ) {
309 if( ( (*iter_targets)->name == targetSymbol ) ) return( *iter_targets );
310 }
311 return( nullptr );
312}

◆ getDataDirectories()

vector< string > * G4GIDI::getDataDirectories ( void  )

Definition at line 147 of file G4GIDI.cc.

147 {
148
149 std::size_t i = 0;
150 vector<string> *v = new vector<string>( numberOfDataDirectories( ) );
151
152 for( auto iter = dataDirectories.cbegin( ); iter != dataDirectories.cend( ); ++iter, ++i )
153 (*v)[i] = string( (*iter)->fileName( ) );
154 return( v );
155}
G4int numberOfDataDirectories(void)
Definition: G4GIDI.cc:99

◆ getDataDirectoryAtIndex()

string G4GIDI::getDataDirectoryAtIndex ( G4int  index)

Definition at line 132 of file G4GIDI.cc.

132 {
133
134 unsigned i = (unsigned) index;
135
136 if( index >= 0 ) {
137 if( i >= dataDirectories.size( ) ) return( "" );
138 for( auto iter = dataDirectories.cbegin( ); iter != dataDirectories.cend( ); ++iter, --index )
139 if( index == 0 ) return( (*iter)->fileName( ) );
140 }
141
142 return( "" );
143}

◆ getListOfReadTargetsNames()

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

Definition at line 354 of file G4GIDI.cc.

354 {
355
356 vector<string> *listOfTargets;
357
358 listOfTargets = new vector<string>( );
359 if( listOfTargets == nullptr ) return( nullptr );
360 for( auto iter_targets = targets.cbegin( ); iter_targets != targets.cend( ); ++iter_targets ) {
361 listOfTargets->push_back( *(*iter_targets)->getName( ) );
362 }
363 return( listOfTargets );
364}

◆ getNamesOfAvailableLibraries() [1/2]

vector< string > * G4GIDI::getNamesOfAvailableLibraries ( G4int  iZ,
G4int  iA,
G4int  iM = 0 
)

Definition at line 212 of file G4GIDI.cc.

212 {
213
214 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
215 vector<string> *listOfLibraries;
216
217 if( targetName == nullptr ) return( new vector<string>( ) );
218 string targetSymbol( targetName );
219 listOfLibraries = getNamesOfAvailableLibraries( targetSymbol );
220 smr_freeMemory( (void **) &targetName );
221 return( listOfLibraries );
222}
std::vector< std::string > * getNamesOfAvailableLibraries(G4int iZ, G4int iA, G4int iM=0)
Definition: G4GIDI.cc:212

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

◆ getNamesOfAvailableLibraries() [2/2]

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

Definition at line 226 of file G4GIDI.cc.

226 {
227
228 vector<string> *listOfLibraries = new vector<string>( );
229
230 MCGIDI_map *map;
231 MCGIDI_mapEntry *entry;
232
233 for( auto iter = dataDirectories.cbegin( ); iter != dataDirectories.cend( ); ++iter ) {
234 map = MCGIDI_map_findAllOfTarget( &((*iter)->smr), (*iter)->map, projectile.c_str( ), targetName.c_str( ) );
235 for( entry = MCGIDI_map_getFirstEntry( map ); entry != nullptr; entry = MCGIDI_map_getNextEntry( entry ) ) {
236 listOfLibraries->push_back( entry->evaluation );
237 }
238 MCGIDI_map_free( nullptr, map );
239 }
240 return( listOfLibraries );
241}
void * MCGIDI_map_free(statusMessageReporting *smr, MCGIDI_map *map)
Definition: MCGIDI_map.cc:173
MCGIDI_mapEntry * MCGIDI_map_getFirstEntry(MCGIDI_map *map)
Definition: MCGIDI_map.cc:204
MCGIDI_mapEntry * MCGIDI_map_getNextEntry(MCGIDI_mapEntry *entry)
Definition: MCGIDI_map.cc:211
MCGIDI_map * MCGIDI_map_findAllOfTarget(statusMessageReporting *smr, MCGIDI_map *map, const char *projectile, const char *targetName)
Definition: MCGIDI_map.cc:430

◆ getNamesOfAvailableTargets()

vector< string > * G4GIDI::getNamesOfAvailableTargets ( void  )

Definition at line 245 of file G4GIDI.cc.

245 {
246
247 vector<string> *listOfTargets;
248
249 listOfTargets = new vector<string>( );
250 if( listOfTargets == nullptr ) return( nullptr );
251 for( auto iter_map = dataDirectories.cbegin( ); iter_map != dataDirectories.cend( ); ++iter_map ) {
252 if( MCGIDI_map_walkTree( nullptr, (*iter_map)->map, getNamesOfAvailableTargets_walker, (void *) listOfTargets ) != 0 ) {
253 delete listOfTargets;
254 return( nullptr );
255 }
256 }
257 return( listOfTargets );
258}
int getNamesOfAvailableTargets_walker(GIDI::MCGIDI_mapEntry *entry, int level, void *userData)
int MCGIDI_map_walkTree(statusMessageReporting *smr, MCGIDI_map *map, int(*handler)(MCGIDI_mapEntry *entry, int level, void *userData), void *userData)
Definition: MCGIDI_map.cc:494

◆ isThisDataAvailable() [1/2]

G4bool G4GIDI::isThisDataAvailable ( std::string &  lib_name,
G4int  iZ,
G4int  iA,
G4int  iM = 0 
)

Definition at line 159 of file G4GIDI.cc.

159 {
160
161 G4bool b;
162 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
163
164 if( targetName == nullptr ) return( false );
165 string targetSymbol( targetName );
166 b = isThisDataAvailable( lib_name, targetSymbol );
167 smr_freeMemory( (void **) &targetName );
168 return( b );
169}
bool G4bool
Definition: G4Types.hh:86
G4bool isThisDataAvailable(std::string &lib_name, G4int iZ, G4int iA, G4int iM=0)
Definition: G4GIDI.cc:159

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

◆ isThisDataAvailable() [2/2]

G4bool G4GIDI::isThisDataAvailable ( std::string &  lib_name,
std::string &  targetName 
)

Definition at line 173 of file G4GIDI.cc.

173 {
174
175 char *path = dataFilename( lib_name, targetName );
176
177 if( path != nullptr ) {
178 smr_freeMemory( (void **) &path );
179 return( true );
180 }
181 return( false );
182}

◆ numberOfDataDirectories()

G4int G4GIDI::numberOfDataDirectories ( void  )

Definition at line 99 of file G4GIDI.cc.

99 {
100
101 return (G4int)dataDirectories.size( );
102}

Referenced by getDataDirectories().

◆ readTarget() [1/2]

G4GIDI_target * G4GIDI::readTarget ( std::string &  lib_name,
G4int  iZ,
G4int  iA,
G4int  iM = 0,
G4bool  bind = true 
)

Definition at line 262 of file G4GIDI.cc.

262 {
263
264 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
265 G4GIDI_target *target;
266
267 if( targetName == nullptr ) return( nullptr );
268 string targetSymbol( targetName );
269 target = readTarget( lib_name, targetSymbol, bind );
270 smr_freeMemory( (void **) &targetName );
271 return( target );
272}
G4GIDI_target * readTarget(std::string &lib_name, G4int iZ, G4int iA, G4int iM=0, G4bool bind=true)
Definition: G4GIDI.cc:262

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

◆ readTarget() [2/2]

G4GIDI_target * G4GIDI::readTarget ( std::string &  lib_name,
std::string &  targetName,
G4bool  bind = true 
)

Definition at line 276 of file G4GIDI.cc.

276 {
277
278 for( auto iter_targets = targets.cbegin( ); iter_targets != targets.cend( ); ++iter_targets ) {
279 if( (*iter_targets)->name == targetName ) return( nullptr );
280 }
281 char *path = dataFilename( lib_name, targetName );
282 if( path == nullptr ) return( nullptr );
283
284 G4GIDI_target *target = new G4GIDI_target( path );
285 if( bind ) targets.push_back( target );
286 smr_freeMemory( (void **) &path );
287 return( target );
288}

◆ removeDataDirectory()

G4int G4GIDI::removeDataDirectory ( std::string &  dataDirectory)

Definition at line 120 of file G4GIDI.cc.

120 {
121
122 for( auto iter = dataDirectories.cbegin( ); iter != dataDirectories.cend( ); ++iter ) {
123 if( dataDirectory == (*iter)->path( ) ) {
124
125 }
126 }
127 return( 0 );
128}

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