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

Detailed Description

Definition at line 73 of file G4GIDI.hh.

Constructor & Destructor Documentation

◆ G4GIDI() [1/2]

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

Definition at line 72 of file G4GIDI.cc.

72 {
73
74 init( ip );
75 addDataDirectory( dataDirectory );
76}
int addDataDirectory(std::string &dataDirectory)
Definition: G4GIDI.cc:124

◆ G4GIDI() [2/2]

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

Definition at line 80 of file G4GIDI.cc.

80 {
81
82 list<string>::iterator iter;
83
84 init( ip );
85 for( iter = dataDirectoryList.begin( ); iter != dataDirectoryList.end( ); ++iter ) addDataDirectory( *iter );
86}

◆ ~G4GIDI()

G4GIDI::~G4GIDI ( void  )

Definition at line 90 of file G4GIDI.cc.

90 {
91
92 G4GIDI_target *target;
93 list<G4GIDI_map *>::iterator iter;
94
95 while( targets.size( ) > 0 ) {
96 target = targets.back( );
97 targets.pop_back( );
98 delete target;
99 }
100
101 while( ( iter = dataDirectories.begin( ) ) != dataDirectories.end( ) ) {
102 delete *iter;
103 dataDirectories.pop_front( );
104 }
105}

Member Function Documentation

◆ addDataDirectory()

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

Definition at line 124 of file G4GIDI.cc.

124 {
125
126 list<G4GIDI_map *>::iterator iter;
127
128 for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
129 if( (*iter)->path( ) == dataDirectory ) return( 0 );
130 }
131
132 G4GIDI_map *map = new G4GIDI_map( dataDirectory );
133 dataDirectories.push_back( map );
134
135 return( 0 );
136}

Referenced by G4GIDI().

◆ dataFilename() [1/2]

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

Definition at line 211 of file G4GIDI.cc.

211 {
212
213 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM ), *fileName;
214
215 if( targetName == NULL ) return( NULL );
216 string targetSymbol( targetName );
217 fileName = dataFilename( lib_name, targetSymbol );
218 xData_free( NULL, targetName );
219 return( fileName );
220}
char * G4GIDI_Misc_Z_A_m_ToName(int iZ, int iA, int im=0)
Definition: G4GIDI_Misc.cc:76
char * dataFilename(std::string &lib_name, int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:211
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89

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

◆ dataFilename() [2/2]

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

Definition at line 224 of file G4GIDI.cc.

224 {
225
226 //char *path, *projectile = "n_1";
227 char *path, *projectile = (char*)"n_1";
228 list<G4GIDI_map *>::iterator iter;
229
230 for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
231 if( ( path = tpia_map_findTarget( &((*iter)->smr), (*iter)->map, lib_name.c_str( ), projectile, targetSymbol.c_str( ) ) ) != NULL ) {
232 return( path );
233 }
234 }
235 return( NULL );
236}
char * tpia_map_findTarget(statusMessageReporting *smr, tpia_map *map, const char *evaluation, const char *projectile, const char *targetName)
Definition: tpia_map.cc:327

◆ freeTarget() [1/3]

int G4GIDI::freeTarget ( G4GIDI_target target)

Definition at line 351 of file G4GIDI.cc.

351 {
352
353 vector<G4GIDI_target *>::iterator iter_targets;
354
355 for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
356 if( *iter_targets == target ) {
357 targets.erase( iter_targets );
358 delete target;
359 return( 0 );
360 }
361 }
362 return( 1 );
363}

◆ freeTarget() [2/3]

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

Definition at line 367 of file G4GIDI.cc.

367 {
368
369 int status;
370 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
371
372 if( targetName == NULL ) return( 1 );
373 string targetSymbol( targetName );
374 status = freeTarget( targetSymbol );
375 xData_free( NULL, targetName );
376 return( status );
377}
int freeTarget(int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:367

Referenced by freeTarget().

◆ freeTarget() [3/3]

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

Definition at line 381 of file G4GIDI.cc.

381 {
382
383 vector<G4GIDI_target *>::iterator iter_targets;
384
385 for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
386 if( (*iter_targets)->name == targetSymbol ) return( freeTarget( *iter_targets ) );
387 }
388 return( 1 );
389}

◆ getAlreadyReadTarget() [1/2]

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

Definition at line 325 of file G4GIDI.cc.

325 {
326
327 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
328 G4GIDI_target *target;
329
330 if( targetName == NULL ) return( NULL );
331 string targetSymbol( targetName );
332 target = getAlreadyReadTarget( targetSymbol );
333 xData_free( NULL, targetName );
334 return( target );
335}
G4GIDI_target * getAlreadyReadTarget(int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:325

Referenced by getAlreadyReadTarget().

◆ getAlreadyReadTarget() [2/2]

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

Definition at line 339 of file G4GIDI.cc.

339 {
340
341 vector<G4GIDI_target *>::iterator iter_targets;
342
343 for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
344 if( ( (*iter_targets)->name == targetSymbol ) ) return( *iter_targets );
345 }
346 return( NULL );
347}

◆ getDataDirectories()

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

Definition at line 172 of file G4GIDI.cc.

172 {
173
174 int i = 0;
175 list<G4GIDI_map *>::iterator iter;
176 vector<string> *v = new vector<string>( numberOfDataDirectories( ) );
177
178 for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++, i++ ) (*v)[i] = string( (*iter)->fileName( ) );
179 return( v );
180}
int numberOfDataDirectories(void)
Definition: G4GIDI.cc:117

◆ getDataDirectoryAtIndex()

string G4GIDI::getDataDirectoryAtIndex ( int  index)

Definition at line 155 of file G4GIDI.cc.

155 {
156
157#if 0
158 list<G4GIDI_map *>::iterator iter;
159 unsigned i = (unsigned) index;
160
161 if( i < 0 ) return( "" );
162 if( i >= dataDirectories.size( ) ) return( "" );
163 for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++, i-- ) {
164 if( i == 0 ) return( (*iter)->fileName( ) );
165 }
166#endif
167 return( "" );
168}

◆ getListOfReadTargetsNames()

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

Definition at line 393 of file G4GIDI.cc.

393 {
394
395 vector<G4GIDI_target *>::iterator iter_targets;
396 vector<string> *listOfTargets;
397
398 listOfTargets = new vector<string>( );
399 if( listOfTargets == NULL ) return( NULL );
400 for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
401 listOfTargets->push_back( *(*iter_targets)->getName( ) );
402 }
403 return( listOfTargets );
404}

◆ getNamesOfAvailableLibraries() [1/2]

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

Definition at line 240 of file G4GIDI.cc.

240 {
241
242 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
243 vector<string> *listOfLibraries;
244
245 if( targetName == NULL ) return( new vector<string>( ) );
246 string targetSymbol( targetName );
247 listOfLibraries = getNamesOfAvailableLibraries( targetSymbol );
248 xData_free( NULL, targetName );
249 return( listOfLibraries );
250}
std::vector< std::string > * getNamesOfAvailableLibraries(int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:240

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

◆ getNamesOfAvailableLibraries() [2/2]

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

Definition at line 254 of file G4GIDI.cc.

254 {
255
256 //char *projectile = "n_1";
257 char *projectile = (char*)"n_1";
258 list<G4GIDI_map *>::iterator iter;
259 vector<string> *listOfLibraries = new vector<string>( );
260
261 tpia_map *map;
262 tpia_mapEntry *entry;
263 for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
264 map = tpia_map_findAllOfTarget( &((*iter)->smr), (*iter)->map, projectile, targetName.c_str( ) );
265 for( entry = tpia_map_getFirstEntry( map ); entry != NULL; entry = tpia_map_getNextEntry( entry ) ) {
266 listOfLibraries->push_back( entry->evaluation );
267 }
268 tpia_map_free( NULL, map );
269 }
270 return( listOfLibraries );
271}
char * evaluation
Definition: tpia_map.h:67
tpia_mapEntry * tpia_map_getNextEntry(tpia_mapEntry *entry)
Definition: tpia_map.cc:222
tpia_mapEntry * tpia_map_getFirstEntry(tpia_map *map)
Definition: tpia_map.cc:215
tpia_map * tpia_map_findAllOfTarget(statusMessageReporting *smr, tpia_map *map, const char *projectile, const char *targetName)
Definition: tpia_map.cc:393
void * tpia_map_free(statusMessageReporting *smr, tpia_map *map)
Definition: tpia_map.cc:184

◆ getNamesOfAvailableTargets()

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

Definition at line 275 of file G4GIDI.cc.

275 {
276
277 vector<string> *listOfTargets;
278 list<G4GIDI_map *>::iterator iter_map;
279
280 listOfTargets = new vector<string>( );
281 if( listOfTargets == NULL ) return( NULL );
282 for( iter_map = dataDirectories.begin( ); iter_map != dataDirectories.end( ); iter_map++ ) {
283 if( tpia_map_walkTree( NULL, (*iter_map)->map, getNamesOfAvailableTargets_walker, (void *) listOfTargets ) != 0 ) {
284 delete listOfTargets;
285 return( NULL );
286 }
287 }
288 return( listOfTargets );
289}
int getNamesOfAvailableTargets_walker(GIDI::tpia_mapEntry *entry, int level, void *userData)
int tpia_map_walkTree(statusMessageReporting *smr, tpia_map *map, int(*handler)(tpia_mapEntry *entry, int level, void *userData), void *userData)
Definition: tpia_map.cc:457

◆ isThisDataAvailable() [1/2]

bool G4GIDI::isThisDataAvailable ( std::string &  lib_name,
int  iZ,
int  iA,
int  iM = 0 
)

Definition at line 184 of file G4GIDI.cc.

184 {
185
186 bool b;
187 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
188
189 if( targetName == NULL ) return( false );
190 string targetSymbol( targetName );
191 b = isThisDataAvailable( lib_name, targetSymbol );
192 xData_free( NULL, targetName );
193 return( b );
194}
bool isThisDataAvailable(std::string &lib_name, int iZ, int iA, int iM=0)
Definition: G4GIDI.cc:184

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

◆ isThisDataAvailable() [2/2]

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

Definition at line 198 of file G4GIDI.cc.

198 {
199
200 char *path = dataFilename( lib_name, targetName );
201
202 if( path != NULL ) {
203 xData_free( NULL, path );
204 return( true );
205 }
206 return( false );
207}

◆ numberOfDataDirectories()

int G4GIDI::numberOfDataDirectories ( void  )

Definition at line 117 of file G4GIDI.cc.

117 {
118
119 return( dataDirectories.size( ) );
120}

Referenced by getDataDirectories().

◆ readTarget() [1/2]

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

Definition at line 293 of file G4GIDI.cc.

293 {
294
295 char *targetName = G4GIDI_Misc_Z_A_m_ToName( iZ, iA, iM );
296 G4GIDI_target *target;
297
298 if( targetName == NULL ) return( NULL );
299 string targetSymbol( targetName );
300 target = readTarget( lib_name, targetSymbol, bind );
301 xData_free( NULL, targetName );
302 return( target );
303}
G4GIDI_target * readTarget(std::string &lib_name, int iZ, int iA, int iM=0, bool bind=true)
Definition: G4GIDI.cc:293

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

◆ readTarget() [2/2]

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

Definition at line 307 of file G4GIDI.cc.

307 {
308
309 vector<G4GIDI_target *>::iterator iter_targets;
310
311 for( iter_targets = targets.begin( ); iter_targets != targets.end( ); iter_targets++ ) {
312 if( (*iter_targets)->name == targetName ) return( NULL );
313 }
314 char *path = dataFilename( lib_name, targetName );
315 if( path == NULL ) return( NULL );
316
317 G4GIDI_target *target = new G4GIDI_target( path );
318 if( bind ) targets.push_back( target );
319 xData_free( NULL, path );
320 return( target );
321}

◆ removeDataDirectory()

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

Definition at line 140 of file G4GIDI.cc.

140 {
141
142 list<G4GIDI_map *>::iterator iter;
143
144 for( iter = dataDirectories.begin( ); iter != dataDirectories.end( ); iter++ ) {
145 if( dataDirectory == (*iter)->path( ) ) {
146
147 }
148 }
149 return( 0 );
150}

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