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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/lend/src/G4GIDI.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/G4GIDI.cc (Version 6.1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26                                                   
 27 #include <iostream>                               
 28                                                   
 29 #include "G4GIDI.hh"                              
 30                                                   
 31 using namespace std;                              
 32 using namespace GIDI;                             
 33                                                   
 34 /*                                                
 35 **********************************************    
 36 */                                                
 37 G4GIDI::G4GIDI( G4int ip, const string &dataDi    
 38                                                   
 39     init( ip );                                   
 40     addDataDirectory( dataDirectory );            
 41 }                                                 
 42 /*                                                
 43 **********************************************    
 44 */                                                
 45 G4GIDI::G4GIDI( G4int ip, list<string> &dataDi    
 46                                                   
 47     init( ip );                                   
 48     for( auto iter = dataDirectoryList.begin(     
 49       addDataDirectory( *iter );                  
 50 }                                                 
 51 /*                                                
 52 **********************************************    
 53 */                                                
 54 G4GIDI::~G4GIDI( void ) {                         
 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 }                                                 
 70 /*                                                
 71 **********************************************    
 72 */                                                
 73 G4int G4GIDI::init( G4int ip ) {                  
 74                                                   
 75     projectileID = ip;                            
 76     if( ip == 0 ) {                               
 77         projectile = string( "g" ); }             
 78     else if( ip == 1 ) {                          
 79         projectile = string( "n" ); }             
 80     else if( ip == 2 ) {                          
 81         projectile = string( "p" ); }             
 82     else if( ip == 3 ) {                          
 83         projectile = string( "d" ); }             
 84     else if( ip == 4 ) {                          
 85         projectile = string( "t" ); }             
 86     else if( ip == 5 ) {                          
 87         projectile = string( "h" ); }             
 88     else if( ip == 6 ) {                          
 89         projectile = string( "a" ); }             
 90     else {                                        
 91         printf( "Invalid projectile ID = %d\n"    
 92         throw 1;                                  
 93     }                                             
 94     return( 0 );                                  
 95 }                                                 
 96 /*                                                
 97 **********************************************    
 98 */                                                
 99 G4int G4GIDI::numberOfDataDirectories( void )     
100                                                   
101     return (G4int)dataDirectories.size( );        
102 }                                                 
103 /*                                                
104 **********************************************    
105 */                                                
106 G4int G4GIDI::addDataDirectory( const string &    
107                                                   
108     for( auto iter = dataDirectories.cbegin( )    
109         if( (*iter)->path( ) == dataDirectory     
110     }                                             
111                                                   
112     G4GIDI_map *map = new G4GIDI_map( dataDire    
113     dataDirectories.push_back( map );             
114                                                   
115     return( 0 );                                  
116 }                                                 
117 /*                                                
118 **********************************************    
119 */                                                
120 G4int G4GIDI::removeDataDirectory( const strin    
121                                                   
122     for( auto iter = dataDirectories.cbegin( )    
123         if( dataDirectory == (*iter)->path( )     
124                                                   
125         }                                         
126     }                                             
127     return( 0 );                                  
128 }                                                 
129 /*                                                
130 **********************************************    
131 */                                                
132 string G4GIDI::getDataDirectoryAtIndex( G4int     
133                                                   
134     unsigned i = (unsigned) index;                
135                                                   
136     if( index >= 0 ) {                            
137         if( i >= dataDirectories.size( ) ) ret    
138         for( auto iter = dataDirectories.cbegi    
139           if( index == 0 ) return( (*iter)->fi    
140     }                                             
141                                                   
142     return( "" );                                 
143 }                                                 
144 /*                                                
145 **********************************************    
146 */                                                
147 vector<string> *G4GIDI::getDataDirectories( vo    
148                                                   
149     std::size_t i = 0;                            
150     vector<string> *v = new vector<string>( nu    
151                                                   
152     for( auto iter = dataDirectories.cbegin( )    
153       (*v)[i] = string( (*iter)->fileName( ) )    
154     return( v );                                  
155 }                                                 
156 /*                                                
157 **********************************************    
158 */                                                
159 G4bool G4GIDI::isThisDataAvailable( const stri    
160                                                   
161     G4bool b;                                     
162     char *targetName = G4GIDI_Misc_Z_A_m_ToNam    
163                                                   
164     if( targetName == nullptr ) return( false     
165     string targetSymbol( targetName );            
166     b = isThisDataAvailable( lib_name, targetS    
167     smr_freeMemory( (void **) &targetName );      
168     return( b );                                  
169 }                                                 
170 /*                                                
171 **********************************************    
172 */                                                
173 G4bool G4GIDI::isThisDataAvailable( const stri    
174                                                   
175     char *path = dataFilename( lib_name, targe    
176                                                   
177     if( path != nullptr ) {                       
178         smr_freeMemory( (void **) &path );        
179         return( true );                           
180     }                                             
181     return( false );                              
182 }                                                 
183 /*                                                
184 **********************************************    
185 */                                                
186 char *G4GIDI::dataFilename( const string &lib_    
187                                                   
188     char *targetName = G4GIDI_Misc_Z_A_m_ToNam    
189                                                   
190     if( targetName == nullptr ) return( nullpt    
191     string targetSymbol( targetName );            
192     fileName = dataFilename( lib_name, targetS    
193     smr_freeMemory( (void **) &targetName );      
194     return( fileName );                           
195 }                                                 
196 /*                                                
197 **********************************************    
198 */                                                
199 char *G4GIDI::dataFilename( const string &lib_    
200                                                   
201    char *path;                                    
202                                                   
203    for( auto iter = dataDirectories.cbegin( );    
204       if( ( path = MCGIDI_map_findTarget( null    
205          return( path );                          
206                                                   
207    return( nullptr );                             
208 }                                                 
209 /*                                                
210 **********************************************    
211 */                                                
212 vector<string> *G4GIDI::getNamesOfAvailableLib    
213                                                   
214     char *targetName = G4GIDI_Misc_Z_A_m_ToNam    
215     vector<string> *listOfLibraries;              
216                                                   
217     if( targetName == nullptr ) return( new ve    
218     string targetSymbol( targetName );            
219     listOfLibraries = getNamesOfAvailableLibra    
220     smr_freeMemory( (void **) &targetName );      
221     return( listOfLibraries );                    
222 }                                                 
223 /*                                                
224 **********************************************    
225 */                                                
226 vector<string> *G4GIDI::getNamesOfAvailableLib    
227                                                   
228     vector<string> *listOfLibraries = new vect    
229                                                   
230     MCGIDI_map *map;                              
231     MCGIDI_mapEntry *entry;                       
232                                                   
233     for( auto iter = dataDirectories.cbegin( )    
234         map = MCGIDI_map_findAllOfTarget( &((*    
235         for( entry = MCGIDI_map_getFirstEntry(    
236             listOfLibraries->push_back( entry-    
237         }                                         
238         MCGIDI_map_free( nullptr, map );          
239     }                                             
240     return( listOfLibraries );                    
241 }                                                 
242 /*                                                
243 **********************************************    
244 */                                                
245 vector<string> *G4GIDI::getNamesOfAvailableTar    
246                                                   
247     vector<string> *listOfTargets;                
248                                                   
249     listOfTargets = new vector<string>( );        
250     if( listOfTargets == nullptr ) return( nul    
251     for( auto iter_map = dataDirectories.cbegi    
252         if( MCGIDI_map_walkTree( nullptr, (*it    
253             delete listOfTargets;                 
254             return( nullptr );                    
255         }                                         
256     }                                             
257     return( listOfTargets );                      
258 }                                                 
259 /*                                                
260 **********************************************    
261 */                                                
262 G4GIDI_target *G4GIDI::readTarget( const strin    
263                                                   
264     char *targetName = G4GIDI_Misc_Z_A_m_ToNam    
265     G4GIDI_target *target;                        
266                                                   
267     if( targetName == nullptr ) return( nullpt    
268     string targetSymbol( targetName );            
269     target = readTarget( lib_name, targetSymbo    
270     smr_freeMemory( (void **) &targetName );      
271     return( target );                             
272 }                                                 
273 /*                                                
274 **********************************************    
275 */                                                
276 G4GIDI_target *G4GIDI::readTarget( const strin    
277                                                   
278     for( auto iter_targets = targets.cbegin( )    
279         if( (*iter_targets)->name == targetNam    
280     }                                             
281     char *path = dataFilename( lib_name, targe    
282     if( path == nullptr ) return( nullptr );      
283                                                   
284     G4GIDI_target *target = new G4GIDI_target(    
285     if( bind ) targets.push_back( target );       
286     smr_freeMemory( (void **) &path );            
287     return( target );                             
288 }                                                 
289 /*                                                
290 **********************************************    
291 */                                                
292 G4GIDI_target *G4GIDI::getAlreadyReadTarget( G    
293                                                   
294     char *targetName = G4GIDI_Misc_Z_A_m_ToNam    
295     G4GIDI_target *target;                        
296                                                   
297     if( targetName == nullptr ) return( nullpt    
298     string targetSymbol( targetName );            
299     target = getAlreadyReadTarget( targetSymbo    
300     smr_freeMemory( (void **) &targetName );      
301     return( target );                             
302 }                                                 
303 /*                                                
304 **********************************************    
305 */                                                
306 G4GIDI_target *G4GIDI::getAlreadyReadTarget( c    
307                                                   
308     for( auto iter_targets = targets.cbegin( )    
309         if( ( (*iter_targets)->name == targetS    
310     }                                             
311     return( nullptr );                            
312 }                                                 
313 /*                                                
314 **********************************************    
315 */                                                
316 G4int G4GIDI::freeTarget( G4GIDI_target *targe    
317                                                   
318     for( auto iter_targets = targets.cbegin( )    
319         if( *iter_targets == target ) {           
320             targets.erase( iter_targets );        
321             delete target;                        
322             return( 0 );                          
323         }                                         
324     }                                             
325     return( 1 );                                  
326 }                                                 
327 /*                                                
328 **********************************************    
329 */                                                
330 G4int G4GIDI::freeTarget( G4int iZ, G4int iA,     
331                                                   
332     G4int status;                                 
333     char *targetName = G4GIDI_Misc_Z_A_m_ToNam    
334                                                   
335     if( targetName == nullptr ) return( 1 );      
336     string targetSymbol( targetName );            
337     status = freeTarget( targetSymbol );          
338     smr_freeMemory( (void **) &targetName );      
339     return( status );                             
340 }                                                 
341 /*                                                
342 **********************************************    
343 */                                                
344 G4int G4GIDI::freeTarget( const string &target    
345                                                   
346     for( auto iter_targets = targets.cbegin( )    
347         if( (*iter_targets)->name == targetSym    
348     }                                             
349     return( 1 );                                  
350 }                                                 
351 /*                                                
352 **********************************************    
353 */                                                
354 vector<string> *G4GIDI::getListOfReadTargetsNa    
355                                                   
356     vector<string> *listOfTargets;                
357                                                   
358     listOfTargets = new vector<string>( );        
359     if( listOfTargets == nullptr ) return( nul    
360     for( auto iter_targets = targets.cbegin( )    
361         listOfTargets->push_back( *(*iter_targ    
362     }                                             
363     return( listOfTargets );                      
364 }                                                 
365