Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 << 25 // >> 26 // 26 // =========================================== 27 // =========================================================================== 27 // GEANT4 class source file 28 // GEANT4 class source file 28 // 29 // 29 // Class: G4IonStoppingData 30 // Class: G4IonStoppingData 30 // 31 // 31 // Base class: G4VIonDEDXTable << 32 // Base class: G4VIonDEDXTable 32 // << 33 // 33 // Author: Anton Lechner (Anton. 34 // Author: Anton Lechner (Anton.Lechner@cern.ch) 34 // 35 // 35 // First implementation: 03. 11. 2009 36 // First implementation: 03. 11. 2009 36 // 37 // 37 // Modifications: 38 // Modifications: 38 // 25.10.2010 V.Ivanchenko fixed warnings repo 39 // 25.10.2010 V.Ivanchenko fixed warnings reported by the Coverity tool 39 // 25.10.2011: new scheme for G4Exception (mm 40 // 25.10.2011: new scheme for G4Exception (mma) 40 // 41 // 41 // 42 // 42 // Class description: Class which can read ion 43 // Class description: Class which can read ion stopping power data from 43 // $G4LEDATA/ion_stopping_d 44 // $G4LEDATA/ion_stopping_data 44 // 45 // 45 // Comments: 46 // Comments: 46 // 47 // 47 // =========================================== << 48 // =========================================================================== >> 49 // 48 50 49 #include "G4IonStoppingData.hh" << 51 #include <fstream> >> 52 #include <sstream> >> 53 #include <iomanip> 50 54 51 #include "G4PhysicalConstants.hh" << 55 #include "G4IonStoppingData.hh" 52 #include "G4PhysicsFreeVector.hh" << 53 #include "G4PhysicsVector.hh" 56 #include "G4PhysicsVector.hh" >> 57 #include "G4LPhysicsFreeVector.hh" >> 58 #include "G4PhysicalConstants.hh" 54 #include "G4SystemOfUnits.hh" 59 #include "G4SystemOfUnits.hh" 55 60 56 #include <fstream> << 57 #include <iomanip> << 58 #include <sstream> << 59 #include <utility> << 60 << 61 // ########################################### 61 // ######################################################################### 62 62 63 G4IonStoppingData::G4IonStoppingData(const G4S << 63 G4IonStoppingData::G4IonStoppingData(const G4String& leDirectory) : >> 64 subDir( leDirectory ) { >> 65 >> 66 } 64 67 65 // ########################################### 68 // ######################################################################### 66 69 67 G4IonStoppingData::~G4IonStoppingData() { Clea << 70 G4IonStoppingData::~G4IonStoppingData() { >> 71 >> 72 ClearTable(); >> 73 } 68 74 69 // ########################################### 75 // ######################################################################### 70 76 71 G4bool G4IonStoppingData::IsApplicable(G4int a << 77 G4bool G4IonStoppingData::IsApplicable( 72 G4int atomicNumberElem // Atomic number of << 78 G4int atomicNumberIon, // Atomic number of ion 73 ) << 79 G4int atomicNumberElem // Atomic number of elemental material >> 80 ) 74 { 81 { 75 G4IonDEDXKeyElem key = std::make_pair(atomic 82 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 76 83 77 auto iter = dedxMapElements.find(key); << 84 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key); 78 85 79 return iter != dedxMapElements.end(); << 86 return (iter == dedxMapElements.end()) ? false : true; 80 } 87 } 81 88 82 // ########################################### 89 // ######################################################################### 83 90 84 G4bool G4IonStoppingData::IsApplicable(G4int a << 91 G4bool G4IonStoppingData::IsApplicable( 85 const G4String& matIdentifier // Name or ch << 92 G4int atomicNumberIon, // Atomic number of ion 86 ) << 93 const G4String& matIdentifier // Name or chemical formula of material >> 94 ) 87 { 95 { 88 G4IonDEDXKeyMat key = std::make_pair(atomicN 96 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 89 97 90 auto iter = dedxMapMaterials.find(key); << 98 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key); 91 99 92 return iter != dedxMapMaterials.end(); << 100 return (iter == dedxMapMaterials.end()) ? false : true; 93 } 101 } 94 102 95 // ########################################### 103 // ######################################################################### 96 104 97 G4PhysicsVector* G4IonStoppingData::GetPhysics << 105 G4PhysicsVector* G4IonStoppingData::GetPhysicsVector( 98 G4int atomicNumberElem // Atomic number of << 106 G4int atomicNumberIon, // Atomic number of ion 99 ) << 107 G4int atomicNumberElem // Atomic number of elemental material >> 108 ) 100 { 109 { 101 G4IonDEDXKeyElem key = std::make_pair(atomic 110 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 102 111 103 auto iter = dedxMapElements.find(key); << 112 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key); 104 113 105 return (iter != dedxMapElements.end()) ? ite << 114 return (iter != dedxMapElements.end()) ? iter->second : nullptr; 106 } 115 } 107 116 108 // ########################################### 117 // ######################################################################### 109 118 110 G4PhysicsVector* G4IonStoppingData::GetPhysics << 119 G4PhysicsVector* G4IonStoppingData::GetPhysicsVector( 111 const G4String& matIdentifier // Name or ch << 120 G4int atomicNumberIon, // Atomic number of ion 112 ) << 121 const G4String& matIdentifier // Name or chemical formula of material >> 122 ) 113 { 123 { 114 G4IonDEDXKeyMat key = std::make_pair(atomicN 124 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 115 125 116 auto iter = dedxMapMaterials.find(key); << 126 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key); 117 127 118 return (iter != dedxMapMaterials.end()) ? it << 128 return (iter != dedxMapMaterials.end()) ? iter->second : nullptr; 119 } 129 } 120 130 121 // ########################################### 131 // ######################################################################### 122 132 123 G4double G4IonStoppingData::GetDEDX(G4double k << 133 G4double G4IonStoppingData::GetDEDX( 124 G4int atomicNumberIon, // Atomic number of << 134 G4double kinEnergyPerNucleon, // Kinetic energy per nucleon 125 G4int atomicNumberElem // Atomic number of << 135 G4int atomicNumberIon, // Atomic number of ion 126 ) << 136 G4int atomicNumberElem // Atomic number of elemental material >> 137 ) 127 { 138 { 128 G4IonDEDXKeyElem key = std::make_pair(atomic 139 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 129 140 130 auto iter = dedxMapElements.find(key); << 141 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key); 131 142 132 return (iter != dedxMapElements.end()) ? (it << 143 return ( iter != dedxMapElements.end()) ? >> 144 (iter->second)->Value( kinEnergyPerNucleon) : 0.0; 133 } 145 } 134 146 135 // ########################################### 147 // ######################################################################### 136 148 137 G4double G4IonStoppingData::GetDEDX(G4double k << 149 G4double G4IonStoppingData::GetDEDX( 138 G4int atomicNumberIon, // Atomic number of << 150 G4double kinEnergyPerNucleon, // Kinetic energy per nucleon 139 const G4String& matIdentifier // Name or ch << 151 G4int atomicNumberIon, // Atomic number of ion 140 ) << 152 const G4String& matIdentifier // Name or chemical formula of material >> 153 ) 141 { 154 { 142 G4IonDEDXKeyMat key = std::make_pair(atomicN 155 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 143 156 144 auto iter = dedxMapMaterials.find(key); << 157 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key); 145 158 146 return (iter != dedxMapMaterials.end()) ? (i << 159 return (iter != dedxMapMaterials.end()) ? >> 160 (iter->second)->Value(kinEnergyPerNucleon) : 0.0; 147 } 161 } 148 162 149 // ########################################### 163 // ######################################################################### 150 164 151 G4bool G4IonStoppingData::AddPhysicsVector(G4P << 165 G4bool G4IonStoppingData::AddPhysicsVector( 152 G4int atomicNumberIon, // Atomic number of << 166 G4PhysicsVector* physicsVector, // Physics vector 153 const G4String& matIdentifier // Name of el << 167 G4int atomicNumberIon, // Atomic number of ion 154 ) << 168 const G4String& matIdentifier // Name of elemental material >> 169 ) 155 { 170 { 156 if (physicsVector == nullptr) { << 171 if(physicsVector == nullptr) { 157 G4Exception("G4IonStoppingData::AddPhysics << 172 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material", 158 "Pointer to vector is null-pointer."); << 173 "mat037", FatalException, >> 174 "Pointer to vector is null-pointer."); 159 return false; 175 return false; 160 } 176 } 161 177 162 if (matIdentifier.empty()) { << 178 if(matIdentifier.empty()) { 163 G4Exception("G4IonStoppingData::AddPhysics << 179 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material", 164 "Invalid name of the material."); << 180 "mat038", FatalException, "Invalid name of the material."); 165 return false; 181 return false; 166 } 182 } 167 183 168 if (atomicNumberIon <= 0) { << 184 if(atomicNumberIon <= 0) { 169 G4Exception("G4IonStoppingData::AddPhysics << 185 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material", 170 "Illegal atomic number."); << 186 "mat039", FatalException, "Illegal atomic number."); 171 return false; 187 return false; 172 } 188 } 173 189 174 G4IonDEDXKeyMat mkey = std::make_pair(atomic 190 G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier); 175 191 176 if (dedxMapMaterials.count(mkey) == 1) { << 192 if(dedxMapMaterials.count(mkey) == 1) { 177 G4ExceptionDescription ed; 193 G4ExceptionDescription ed; 178 ed << "Vector with Z1 = " << atomicNumberI << 194 ed << "Vector with Z1 = " << atomicNumberIon << ", mat = " >> 195 << matIdentifier 179 << "already exists. Remove first before 196 << "already exists. Remove first before replacing."; 180 G4Exception("G4IonStoppingData::AddPhysics << 197 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material", >> 198 "mat040", FatalException, ed); 181 return false; 199 return false; 182 } 200 } 183 201 184 dedxMapMaterials[mkey] = physicsVector; 202 dedxMapMaterials[mkey] = physicsVector; 185 203 186 return true; 204 return true; 187 } 205 } 188 206 189 // ########################################### 207 // ######################################################################### 190 208 191 G4bool G4IonStoppingData::AddPhysicsVector(G4P << 209 G4bool G4IonStoppingData::AddPhysicsVector( 192 G4int atomicNumberIon, // Atomic number of << 210 G4PhysicsVector* physicsVector, // Physics vector 193 G4int atomicNumberElem // Atomic number of << 211 G4int atomicNumberIon, // Atomic number of ion 194 ) << 212 G4int atomicNumberElem // Atomic number of elemental material >> 213 ) 195 { 214 { 196 if (physicsVector == nullptr) { << 215 if(physicsVector == nullptr) { 197 G4Exception("G4IonStoppingData::AddPhysics << 216 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat037", 198 "Pointer to vector is null-pointer."); << 217 FatalException, "Pointer to vector is null-pointer."); 199 return false; << 218 return false; 200 } 219 } 201 220 202 if (atomicNumberIon <= 0) { << 221 if(atomicNumberIon <= 0) { 203 G4Exception("G4IonStoppingData::AddPhysics << 222 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat038", 204 "Invalid ion number."); << 223 FatalException, "Invalid ion number."); 205 return false; 224 return false; 206 } 225 } 207 226 208 if (atomicNumberElem <= 0) { << 227 if(atomicNumberElem <= 0) { 209 G4Exception("G4IonStoppingData::AddPhysics << 228 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat039", 210 "Illegal atomic number."); << 229 FatalException, "Illegal atomic number."); 211 return false; 230 return false; 212 } 231 } 213 232 214 G4IonDEDXKeyElem key = std::make_pair(atomic 233 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 215 234 216 if (dedxMapElements.count(key) == 1) { << 235 if(dedxMapElements.count(key) == 1) { 217 G4ExceptionDescription ed; 236 G4ExceptionDescription ed; 218 ed << "Vector with Z1 = " << atomicNumberI << 237 ed << "Vector with Z1 = " << atomicNumberIon << ", Z= " >> 238 << atomicNumberElem 219 << "already exists. Remove first before 239 << "already exists. Remove first before replacing."; 220 G4Exception("G4IonStoppingData::AddPhysics << 240 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat040", >> 241 FatalException, ed); 221 return false; 242 return false; 222 } 243 } 223 244 224 dedxMapElements[key] = physicsVector; 245 dedxMapElements[key] = physicsVector; 225 246 226 return true; 247 return true; 227 } 248 } 228 249 229 // ########################################### 250 // ######################################################################### 230 251 231 G4bool G4IonStoppingData::RemovePhysicsVector( << 252 G4bool G4IonStoppingData::RemovePhysicsVector( 232 const G4String& matIdentifier // Name or ch << 253 G4int atomicNumberIon, // Atomic number of ion 233 ) << 254 const G4String& matIdentifier // Name or chemical formula of material 234 { << 255 ) { >> 256 235 G4IonDEDXKeyMat key = std::make_pair(atomicN 257 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 236 258 237 auto iter = dedxMapMaterials.find(key); << 259 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key); 238 260 239 if (iter == dedxMapMaterials.end()) { << 261 if(iter == dedxMapMaterials.end()) { 240 G4Exception("G4IonStoppingData::RemovePhys << 262 G4Exception ("G4IonStoppingData::RemovePhysicsVector() for material", 241 "Invalid name of the material."); << 263 "mat038", FatalException, "Invalid name of the material."); 242 return false; 264 return false; 243 } 265 } 244 266 245 G4PhysicsVector* physicsVector = (*iter).sec 267 G4PhysicsVector* physicsVector = (*iter).second; 246 268 247 // Deleting key of physics vector from mater 269 // Deleting key of physics vector from material map 248 dedxMapMaterials.erase(key); 270 dedxMapMaterials.erase(key); 249 271 250 // Deleting physics vector 272 // Deleting physics vector 251 delete physicsVector; 273 delete physicsVector; 252 274 253 return true; 275 return true; 254 } 276 } 255 277 256 // ########################################### 278 // ######################################################################### 257 279 258 G4bool G4IonStoppingData::RemovePhysicsVector( << 280 G4bool G4IonStoppingData::RemovePhysicsVector( 259 G4int atomicNumberElem // Atomic number of << 281 G4int atomicNumberIon, // Atomic number of ion 260 ) << 282 G4int atomicNumberElem // Atomic number of elemental material 261 { << 283 ) { 262 G4IonDEDXKeyElem key = std::make_pair(atomic 284 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 263 285 264 auto iter = dedxMapElements.find(key); << 286 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key); 265 287 266 if (iter == dedxMapElements.end()) { << 288 if(iter == dedxMapElements.end()) { 267 G4Exception("G4IonStoppingData::RemovePhys << 289 G4Exception ("G4IonStoppingData::RemovePhysicsVector() for element", 268 "Invalid element."); << 290 "mat038", FatalException, "Invalid element."); 269 return false; 291 return false; 270 } 292 } 271 293 272 G4PhysicsVector* physicsVector = (*iter).sec 294 G4PhysicsVector* physicsVector = (*iter).second; 273 295 274 // Deleting key of physics vector from mater 296 // Deleting key of physics vector from material map 275 dedxMapElements.erase(key); 297 dedxMapElements.erase(key); 276 298 277 // Deleting physics vector 299 // Deleting physics vector 278 delete physicsVector; 300 delete physicsVector; 279 301 280 return true; 302 return true; 281 } 303 } 282 304 283 // ########################################### 305 // ######################################################################### 284 306 285 G4bool G4IonStoppingData::BuildPhysicsVector(G << 307 G4bool G4IonStoppingData::BuildPhysicsVector( 286 const G4String& matname // Name of material << 308 G4int atomicNumberIon, // Atomic number of ion 287 ) << 309 const G4String& matIdentifier // Name of material 288 { << 310 ) { 289 if (IsApplicable(atomicNumberIon, matname)) << 290 return true; << 291 } << 292 << 293 const char* path = G4FindDataDir("G4LEDATA") << 294 if (path == nullptr) { << 295 G4Exception("G4IonStoppingData::BuildPhysi << 296 "G4LEDATA environment variable not set") << 297 return false; << 298 } << 299 << 300 std::ostringstream file; << 301 G4String ww = << 302 (fICRU90 && (matname == "G4_WATER" || matn << 303 << 304 << 305 file << path << "/" << subDir << ww << "/z" << 306 G4String fileName = G4String(file.str().c_st << 307 << 308 std::ifstream ifilestream(fileName); << 309 311 310 if (! ifilestream.is_open()) { << 312 if( IsApplicable(atomicNumberIon, matIdentifier) ) return true; 311 return false; << 312 } << 313 313 314 auto* physicsVector = new G4PhysicsFreeVecto << 314 char* path = getenv("G4LEDATA"); 315 << 315 if ( !path ) { 316 if (! physicsVector->Retrieve(ifilestream, t << 316 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat521", 317 ifilestream.close(); << 317 FatalException, "G4LEDATA environment variable not set"); 318 return false; 318 return false; 319 } 319 } 320 << 320 321 physicsVector->ScaleVector(MeV, MeV * cm2 / << 321 std::ostringstream file; 322 physicsVector->FillSecondDerivatives(); << 322 >> 323 file << path << "/" << subDir << "/z" >> 324 << atomicNumberIon << "_" << matIdentifier >> 325 << ".dat"; >> 326 >> 327 G4String fileName = G4String( file.str().c_str() ); >> 328 >> 329 std::ifstream ifilestream( fileName ); >> 330 >> 331 if ( !ifilestream.is_open() ) return false; >> 332 >> 333 G4LPhysicsFreeVector* physicsVector = new G4LPhysicsFreeVector(); >> 334 >> 335 if( !physicsVector -> Retrieve(ifilestream, true) ) { >> 336 >> 337 ifilestream.close(); >> 338 return false; >> 339 } >> 340 >> 341 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) ); >> 342 physicsVector -> SetSpline( true ); >> 343 physicsVector -> FillSecondDerivatives(); 323 344 324 // Retrieved vector is added to material sto 345 // Retrieved vector is added to material store 325 if (! AddPhysicsVector(physicsVector, atomic << 346 if( !AddPhysicsVector(physicsVector, atomicNumberIon, matIdentifier) ) { 326 delete physicsVector; << 347 delete physicsVector; 327 ifilestream.close(); << 348 ifilestream.close(); 328 return false; << 349 return false; 329 } 350 } 330 351 331 ifilestream.close(); 352 ifilestream.close(); 332 return true; 353 return true; 333 } 354 } 334 355 335 // ########################################### 356 // ######################################################################### 336 357 337 G4bool G4IonStoppingData::BuildPhysicsVector(G << 358 G4bool G4IonStoppingData::BuildPhysicsVector( 338 G4int ZElem // Atomic number of elemental m << 359 G4int atomicNumberIon, // Atomic number of ion 339 ) << 360 G4int atomicNumberElem // Atomic number of elemental material 340 { << 361 ) 341 if (IsApplicable(ZIon, ZElem)) { << 362 { 342 return true; << 363 if( IsApplicable(atomicNumberIon, atomicNumberElem) ) return true; 343 } << 364 344 << 365 char* path = getenv("G4LEDATA"); 345 const char* path = G4FindDataDir("G4LEDATA") << 366 if ( !path ) { 346 if (path == nullptr) { << 367 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat522", 347 G4Exception("G4IonStoppingData::BuildPhysi << 368 FatalException, "G4LEDATA environment variable not set"); 348 "G4LEDATA environment variable not set") << 349 return false; 369 return false; 350 } 370 } 351 std::ostringstream file; 371 std::ostringstream file; 352 G4String ww = << 372 353 (fICRU90 && ZIon <= 18 && (ZElem == 1 || Z << 373 file << path << "/" << subDir << "/z" 354 << 374 << atomicNumberIon << "_" << atomicNumberElem 355 file << path << "/" << subDir << ww << "/z" << 375 << ".dat"; 356 << 376 357 G4String fileName = G4String(file.str().c_st << 377 G4String fileName = G4String( file.str().c_str() ); 358 std::ifstream ifilestream(fileName); << 378 359 << 379 std::ifstream ifilestream( fileName ); 360 if (! ifilestream.is_open()) { << 380 361 return false; << 381 if ( !ifilestream.is_open() ) return false; 362 } << 382 363 auto* physicsVector = new G4PhysicsFreeVecto << 383 G4LPhysicsFreeVector* physicsVector = new G4LPhysicsFreeVector(); 364 << 384 365 if (! physicsVector->Retrieve(ifilestream, t << 385 if( !physicsVector -> Retrieve(ifilestream, true) ) { 366 ifilestream.close(); << 386 367 return false; << 387 ifilestream.close(); 368 } << 388 return false; 369 << 389 } 370 physicsVector->ScaleVector(MeV, MeV * cm2 / << 390 371 physicsVector->FillSecondDerivatives(); << 391 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) ); >> 392 physicsVector -> SetSpline( true ); >> 393 physicsVector -> FillSecondDerivatives(); 372 394 373 // Retrieved vector is added to material sto 395 // Retrieved vector is added to material store 374 if (! AddPhysicsVector(physicsVector, ZIon, << 396 if( !AddPhysicsVector(physicsVector, atomicNumberIon, atomicNumberElem) ) { 375 delete physicsVector; << 397 delete physicsVector; 376 ifilestream.close(); << 398 ifilestream.close(); 377 return false; << 399 return false; 378 } 400 } 379 401 380 ifilestream.close(); 402 ifilestream.close(); 381 return true; 403 return true; 382 } 404 } 383 405 384 // ########################################### 406 // ######################################################################### 385 407 386 void G4IonStoppingData::ClearTable() << 408 void G4IonStoppingData::ClearTable() { 387 { << 388 auto iterMat = dedxMapMaterials.begin(); << 389 auto iterMat_end = dedxMapMaterials.end(); << 390 409 391 for (; iterMat != iterMat_end; iterMat++) { << 410 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin(); 392 G4PhysicsVector* vec = iterMat->second; << 411 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end(); 393 412 394 delete vec; << 413 for(;iterMat != iterMat_end; iterMat++) { >> 414 >> 415 G4PhysicsVector* vec = iterMat -> second; >> 416 >> 417 if(vec != 0) delete vec; 395 } 418 } 396 419 397 dedxMapMaterials.clear(); 420 dedxMapMaterials.clear(); 398 421 399 auto iterElem = dedxMapElements.begin(); << 422 G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin(); 400 auto iterElem_end = dedxMapElements.end(); << 423 G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end(); 401 424 402 for (; iterElem != iterElem_end; iterElem++) << 425 for(;iterElem != iterElem_end; iterElem++) { 403 G4PhysicsVector* vec = iterElem->second; << 404 426 405 delete vec; << 427 G4PhysicsVector* vec = iterElem -> second; >> 428 >> 429 if(vec != 0) delete vec; 406 } 430 } 407 431 408 dedxMapElements.clear(); 432 dedxMapElements.clear(); 409 } 433 } 410 434 411 // ########################################### 435 // ######################################################################### 412 436 413 void G4IonStoppingData::DumpMap() << 437 void G4IonStoppingData::DumpMap() { 414 { << 415 auto iterMat = dedxMapMaterials.begin(); << 416 auto iterMat_end = dedxMapMaterials.end(); << 417 << 418 G4cout << std::setw(15) << std::right << "At << 419 << "Material name" << G4endl; << 420 << 421 for (; iterMat != iterMat_end; iterMat++) { << 422 G4IonDEDXKeyMat key = iterMat->first; << 423 G4PhysicsVector* physicsVector = iterMat-> << 424 438 425 G4int atomicNumberIon = key.first; << 439 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin(); 426 G4String matIdentifier = key.second; << 440 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end(); 427 441 428 if (physicsVector != nullptr) { << 442 G4cout << std::setw(15) << std::right 429 G4cout << std::setw(15) << std::right << << 443 << "Atomic nmb ion" 430 << matIdentifier << G4endl; << 444 << std::setw(25) << std::right 431 } << 445 << "Material name" >> 446 << G4endl; >> 447 >> 448 for(;iterMat != iterMat_end; iterMat++) { >> 449 G4IonDEDXKeyMat key = iterMat -> first; >> 450 G4PhysicsVector* physicsVector = iterMat -> second; >> 451 >> 452 G4int atomicNumberIon = key.first; >> 453 G4String matIdentifier = key.second; >> 454 >> 455 if(physicsVector != 0) { >> 456 G4cout << std::setw(15) << std::right >> 457 << atomicNumberIon >> 458 << std::setw(25) << std::right >> 459 << matIdentifier >> 460 << G4endl; >> 461 } >> 462 } >> 463 >> 464 G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin(); >> 465 G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end(); >> 466 >> 467 G4cout << std::setw(15) << std::right >> 468 << "Atomic nmb ion" >> 469 << std::setw(25) << std::right >> 470 << "Atomic nmb material" >> 471 << G4endl; >> 472 >> 473 for(;iterElem != iterElem_end; iterElem++) { >> 474 G4IonDEDXKeyElem key = iterElem -> first; >> 475 G4PhysicsVector* physicsVector = iterElem -> second; >> 476 >> 477 G4int atomicNumberIon = key.first; >> 478 G4int atomicNumberElem = key.second; >> 479 >> 480 if(physicsVector != 0) { >> 481 G4cout << std::setw(15) << std::right >> 482 << atomicNumberIon >> 483 << std::setw(25) << std::right >> 484 << atomicNumberElem >> 485 << G4endl; >> 486 } 432 } 487 } 433 488 434 auto iterElem = dedxMapElements.begin(); << 435 auto iterElem_end = dedxMapElements.end(); << 436 << 437 G4cout << std::setw(15) << std::right << "At << 438 << "Atomic nmb material" << G4endl; << 439 << 440 for (; iterElem != iterElem_end; iterElem++) << 441 G4IonDEDXKeyElem key = iterElem->first; << 442 G4PhysicsVector* physicsVector = iterElem- << 443 << 444 G4int atomicNumberIon = key.first; << 445 G4int atomicNumberElem = key.second; << 446 << 447 if (physicsVector != nullptr) { << 448 G4cout << std::setw(15) << std::right << << 449 << atomicNumberElem << G4endl; << 450 } << 451 } << 452 } 489 } 453 490 454 // ########################################### 491 // ######################################################################### >> 492 455 493