Geant4 Cross Reference |
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 /** \file G4INCLNuclearMassTable.cc 39 * \brief Functions that encapsulate a mass ta 40 * 41 * \date 22nd October 2013 42 * \author Davide Mancusi 43 */ 44 45 #ifndef INCLXX_IN_GEANT4_MODE 46 47 #include "G4INCLNuclearMassTable.hh" 48 #include "G4INCLParticleTable.hh" 49 #include "G4INCLGlobals.hh" 50 #include <algorithm> 51 #include <istream> 52 53 namespace G4INCL { 54 55 namespace { 56 57 G4ThreadLocal G4double **theTable = NULL; 58 G4ThreadLocal G4int AMax = 0; 59 G4ThreadLocal G4int *ZMaxArray = NULL; 60 G4ThreadLocal G4double protonMass = 0.; 61 G4ThreadLocal G4double neutronMass = 0.; 62 63 const G4double amu = 931.494061; // atomic 64 const G4double eMass = 0.5109988; // elect 65 66 G4double getWeizsaeckerMass(const G4int A, 67 const G4int Npairing = (A-Z)%2; 68 const G4int Zpairing = Z%2; 69 const G4double fA = (G4double) A; 70 const G4double fZ = (G4double) Z; 71 G4double binding = 72 - 15.67*fA // 73 + 17.23*Math::pow23(fA) 74 + 93.15*((fA/2.-fZ)*(fA/2.-fZ))/fA 75 + 0.6984523*fZ*fZ*Math::powMinus13(fA) 76 if( Npairing == Zpairing ) binding += (N 77 78 return fZ*::G4INCL::ParticleTable::getRe 79 *::G4INCL::ParticleTable::getRealMass( 80 } 81 82 void setMass(const G4int A, const G4int Z, 83 theTable[A][Z] = mass; 84 } 85 86 class MassRecord { 87 public: 88 MassRecord() : 89 A(0), 90 Z(0), 91 excess(0.) 92 {} 93 94 MassRecord(const G4int a, const G4int 95 A(a), 96 Z(z), 97 excess(e) 98 {} 99 100 friend std::istream &operator>>(std::i 101 102 G4int A; 103 G4int Z; 104 G4double excess; 105 }; 106 107 std::istream &operator>>(std::istream &in, 108 return (in >> record.A >> record.Z >> re 109 } 110 111 G4bool compareA(const MassRecord &lhs, con 112 return (lhs.A < rhs.A); 113 } 114 115 } 116 117 namespace NuclearMassTable { 118 119 void initialize(const std::string &path, c 120 protonMass = pMass; 121 neutronMass = nMass; 122 123 // Clear the existing tables, if any 124 deleteTable(); 125 126 // File name 127 std::string fileName(path + "/walletlife 128 INCL_DEBUG("Reading real nuclear masses 129 130 // Open the file stream 131 std::ifstream massTableIn(fileName.c_str 132 if(!massTableIn.good()) { 133 std::cerr << "Cannot open " << fileNam 134 std::abort(); 135 return; 136 } 137 138 // read the file 139 std::vector<MassRecord> records; 140 MassRecord record; 141 while(massTableIn.good()) { /* Loop chec 142 massTableIn >> record; 143 records.push_back(record); 144 } 145 massTableIn.close(); 146 INCL_DEBUG("Read " << records.size() << 147 148 // determine the max A 149 AMax = std::max_element(records.begin(), 150 INCL_DEBUG("Max A in nuclear-mass table 151 ZMaxArray = new G4int[AMax+1]; 152 std::fill(ZMaxArray, ZMaxArray+AMax+1, 0 153 theTable = new G4double*[AMax+1]; 154 std::fill(theTable, theTable+AMax+1, sta 155 156 // determine the max A per Z 157 for(std::vector<MassRecord>::const_itera 158 ZMaxArray[i->A] = std::max(ZMaxArray[i 159 } 160 161 // allocate the arrays 162 for(G4int A=1; A<=AMax; ++A) { 163 theTable[A] = new G4double[ZMaxArray[A 164 std::fill(theTable[A], theTable[A]+ZMa 165 } 166 167 // fill the actual masses 168 for(std::vector<MassRecord>::const_itera 169 setMass(i->A, i->Z, i->A*amu + i->exce 170 } 171 } 172 173 G4double getMass(const G4int A, const G4in 174 if(A>AMax || Z>ZMaxArray[A]) { 175 INCL_DEBUG("Real mass unavailable for 176 << ", using Weizsaecker's f 177 << '\n'); 178 return getWeizsaeckerMass(A,Z); 179 } 180 181 const G4double mass = theTable[A][Z]; 182 if(mass<0.) { 183 INCL_DEBUG("Real mass unavailable for 184 << ", using Weizsaecker's f 185 << '\n'); 186 return getWeizsaeckerMass(A,Z); 187 } else 188 return mass; 189 } 190 191 G4double getMass(const G4int A, const G4in 192 if(S>=0) return getMass(A,Z); 193 194 // assert(A >= 1); 195 // assert(Z < A); 196 // assert(S*(-1)<=A); 197 198 const G4double mL = ParticleTable::getReal 199 if(A == (-1)*S) return A*mL; 200 201 if( A==2 && Z == 0) { // No stable hypernu 202 return mL+ParticleTable::getRealMass(Neu 203 } 204 else if( Z == 0) { // No stable hypernucle 205 return (A+S)*ParticleTable::getRealMass( 206 } 207 else if( A==2 && Z == 1) { 208 return mL+ParticleTable::getRealMass(Pro 209 } 210 211 212 const G4double b7=25.; // (MeV) 213 const G4double b8=10.5; // Slope 214 const G4double a2=0.13; // BindingEnergy f 215 const G4double a3=2.2; // BindingEnergy f 216 const G4double eps =0.0001; // security va 217 218 G4double mass = getMass(A+S, Z); 219 220 G4double bs=0.; 221 if (A+S ==2) bs=a2; // for nnL 222 else if(A+S ==3) bs=a3; // for 3nL 223 else if(A+S >3) bs=b7*std::exp(-b8/(A+S+1 224 mass += (-1)*S*(mL-bs) + eps; 225 226 return mass; 227 } 228 229 void deleteTable() { 230 delete[] ZMaxArray; 231 ZMaxArray = NULL; 232 for(G4int A=1; A<=AMax; ++A) 233 delete[] theTable[A]; 234 delete[] theTable; 235 theTable = NULL; 236 } 237 } 238 239 } 240 241 #endif // INCLXX_IN_GEANT4_MODE 242