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 ] [ 10.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/inclxx/utils/src/G4INCLGlobals.cc (Version 11.3.0) and /processes/hadronic/models/inclxx/utils/src/G4INCLGlobals.cc (Version 6.2)


  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 // INCL++ intra-nuclear cascade model             
 27 // Alain Boudard, CEA-Saclay, France              
 28 // Joseph Cugnon, University of Liege, Belgium    
 29 // Jean-Christophe David, CEA-Saclay, France      
 30 // Pekka Kaitaniemi, CEA-Saclay, France, and H    
 31 // Sylvie Leray, CEA-Saclay, France               
 32 // Davide Mancusi, CEA-Saclay, France             
 33 //                                                
 34 #define INCLXX_IN_GEANT4_MODE 1                   
 35                                                   
 36 #include "globals.hh"                             
 37                                                   
 38 #include "G4INCLGlobals.hh"                       
 39 #include "G4INCLParticle.hh"                      
 40 #ifdef HAVE_WORDEXP                               
 41 #include <wordexp.h>                              
 42 #endif                                            
 43                                                   
 44 namespace G4INCL {                                
 45   namespace Math {                                
 46                                                   
 47     namespace {                                   
 48                                                   
 49       // constants for the Gaussian CDF approx    
 50       const G4double gcdfa1 =  0.254829592;       
 51       const G4double gcdfa2 = -0.284496736;       
 52       const G4double gcdfa3 =  1.421413741;       
 53       const G4double gcdfa4 = -1.453152027;       
 54       const G4double gcdfa5 =  1.061405429;       
 55       const G4double gcdfp  =  0.3275911;         
 56                                                   
 57       // constants for the inverse Gaussian CD    
 58       const G4double igcdfc1 = 2.515517;          
 59       const G4double igcdfc2 = 0.802853;          
 60       const G4double igcdfc3 = 0.010328;          
 61       const G4double igcdfd1 = 1.432788;          
 62       const G4double igcdfd2 = 0.189269;          
 63       const G4double igcdfd3 = 0.001308;          
 64                                                   
 65       G4double inverseGaussianCDFRational(cons    
 66         // Abramowitz and Stegun formula 26.2.    
 67         // The absolute value of the error sho    
 68         return t - ((igcdfc3*t + igcdfc2)*t +     
 69           (((igcdfd3*t + igcdfd2)*t + igcdfd1)    
 70       }                                           
 71                                                   
 72     }                                             
 73                                                   
 74     G4double gaussianCDF(const G4double x)        
 75     {                                             
 76       // Save the sign of x                       
 77       const G4double sgn = sign(x);               
 78       const G4double z = std::fabs(x) * oneOve    
 79                                                   
 80       // A&S formula 7.1.26                       
 81       G4double t = 1.0/(1.0 + gcdfp*z);           
 82       G4double y = 1.0 - (((((gcdfa5*t + gcdfa    
 83                                                   
 84       return 0.5*(1.0 + sgn*y);                   
 85     }                                             
 86                                                   
 87     G4double gaussianCDF(const G4double x, con    
 88       return gaussianCDF((x-x0)/sigma);           
 89     }                                             
 90                                                   
 91     G4double inverseGaussianCDF(G4double x) {     
 92       if (x < 0.5)                                
 93         return -inverseGaussianCDFRational( st    
 94       else                                        
 95         return inverseGaussianCDFRational( std    
 96     }                                             
 97                                                   
 98     G4double arcSin(const G4double x) {           
 99 // assert(x>-1.000001 && x<1.000001);             
100       return ((x > 1.) ? 0. : ((x<-1.) ? pi :     
101     }                                             
102                                                   
103     G4double arcCos(const G4double x) {           
104 // assert(x>-1.000001 && x<1.000001);             
105       return ((x > 1.) ? 0. : ((x<-1.) ? pi :     
106     }                                             
107   }                                               
108                                                   
109   namespace ParticleConfig {                      
110     G4bool isPair(Particle const * const p1, P    
111       return ((p1->getType() == t1 && p2->getT    
112         (p1->getType() == t2 && p2->getType()     
113     }                                             
114   }                                               
115                                                   
116 #ifndef INCLXX_IN_GEANT4_MODE                     
117   namespace String {                              
118     void wrap(std::string &str, const size_t l    
119       const size_t len = str.size();              
120       size_t startPos = 0;                        
121       while(len-startPos > lineLength) { /* Lo    
122         const size_t nextNewline = str.find('\    
123         if(nextNewline!=std::string::npos && n    
124           startPos = nextNewline+1;               
125         else {                                    
126           size_t lastSeparator = str.find_last    
127           if(lastSeparator!=std::string::npos)    
128             str[lastSeparator] = '\n';            
129           startPos = lastSeparator+1;             
130         }                                         
131       }                                           
132     }                                             
133                                                   
134     void replaceAll(std::string &str, const st    
135       if(from.empty())                            
136         return;                                   
137       size_t start_pos = 0;                       
138       size_t cur_max_pos = maxPosition;           
139       const size_t from_len = from.length();      
140       const size_t to_len = to.length();          
141       while((start_pos = str.find(from, start_    
142             && (cur_max_pos==std::string::npos    
143         str.replace(start_pos, from_len, to);     
144         start_pos += to_len; // In case 'to' c    
145         if(cur_max_pos!=std::string::npos)        
146           cur_max_pos += to_len - from_len;       
147       }                                           
148     }                                             
149                                                   
150     std::vector<std::string> tokenize(std::str    
151       size_t startPos = 0, endPos;                
152       std::vector<std::string> tokens;            
153       do {                                        
154         endPos = str.find_first_of(delimiters,    
155         std::string token = str.substr(startPo    
156         tokens.push_back(token);                  
157         startPos = str.find_first_not_of(delim    
158       } while(endPos!=std::string::npos); /* L    
159                                                   
160       return tokens;                              
161     }                                             
162                                                   
163     G4bool isInteger(std::string const &str) {    
164       const size_t pos = str.find_first_not_of    
165       return (pos==std::string::npos);            
166     }                                             
167                                                   
168     std::string expandPath(std::string const &    
169 #ifdef HAVE_WORDEXP                               
170       wordexp_t expansionResult;                  
171       std::string result;                         
172       G4int err = wordexp(path.c_str(), &expan    
173       if(err)                                     
174         result = path;                            
175       else                                        
176         result = expansionResult.we_wordv[0];     
177       wordfree(&expansionResult);                 
178       return result;                              
179 #else                                             
180       // no-op if wordexp.h is not found          
181       return path;                                
182 #endif                                            
183     }                                             
184   }                                               
185                                                   
186 #endif // INCLXX_IN_GEANT4_MODE                   
187                                                   
188 }                                                 
189