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 "G4PhysicsFreeVector.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& dir, G4bool val) : >> 64 subDir(dir), fICRU90(val) { >> 65 } 64 66 65 // ########################################### 67 // ######################################################################### 66 68 67 G4IonStoppingData::~G4IonStoppingData() { Clea << 69 G4IonStoppingData::~G4IonStoppingData() { >> 70 ClearTable(); >> 71 } 68 72 69 // ########################################### 73 // ######################################################################### 70 74 71 G4bool G4IonStoppingData::IsApplicable(G4int a << 75 G4bool G4IonStoppingData::IsApplicable( 72 G4int atomicNumberElem // Atomic number of << 76 G4int atomicNumberIon, // Atomic number of ion 73 ) << 77 G4int atomicNumberElem // Atomic number of elemental material >> 78 ) 74 { 79 { 75 G4IonDEDXKeyElem key = std::make_pair(atomic 80 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 76 81 77 auto iter = dedxMapElements.find(key); 82 auto iter = dedxMapElements.find(key); 78 83 79 return iter != dedxMapElements.end(); 84 return iter != dedxMapElements.end(); 80 } 85 } 81 86 82 // ########################################### 87 // ######################################################################### 83 88 84 G4bool G4IonStoppingData::IsApplicable(G4int a << 89 G4bool G4IonStoppingData::IsApplicable( 85 const G4String& matIdentifier // Name or ch << 90 G4int atomicNumberIon, // Atomic number of ion 86 ) << 91 const G4String& matIdentifier // Name or chemical formula of material >> 92 ) 87 { 93 { 88 G4IonDEDXKeyMat key = std::make_pair(atomicN 94 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 89 95 90 auto iter = dedxMapMaterials.find(key); 96 auto iter = dedxMapMaterials.find(key); 91 97 92 return iter != dedxMapMaterials.end(); 98 return iter != dedxMapMaterials.end(); 93 } 99 } 94 100 95 // ########################################### 101 // ######################################################################### 96 102 97 G4PhysicsVector* G4IonStoppingData::GetPhysics << 103 G4PhysicsVector* G4IonStoppingData::GetPhysicsVector( 98 G4int atomicNumberElem // Atomic number of << 104 G4int atomicNumberIon, // Atomic number of ion 99 ) << 105 G4int atomicNumberElem // Atomic number of elemental material >> 106 ) 100 { 107 { 101 G4IonDEDXKeyElem key = std::make_pair(atomic 108 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 102 109 103 auto iter = dedxMapElements.find(key); 110 auto iter = dedxMapElements.find(key); 104 111 105 return (iter != dedxMapElements.end()) ? ite << 112 return (iter != dedxMapElements.end()) ? iter->second : nullptr; 106 } 113 } 107 114 108 // ########################################### 115 // ######################################################################### 109 116 110 G4PhysicsVector* G4IonStoppingData::GetPhysics << 117 G4PhysicsVector* G4IonStoppingData::GetPhysicsVector( 111 const G4String& matIdentifier // Name or ch << 118 G4int atomicNumberIon, // Atomic number of ion 112 ) << 119 const G4String& matIdentifier // Name or chemical formula of material >> 120 ) 113 { 121 { 114 G4IonDEDXKeyMat key = std::make_pair(atomicN 122 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 115 123 116 auto iter = dedxMapMaterials.find(key); 124 auto iter = dedxMapMaterials.find(key); 117 125 118 return (iter != dedxMapMaterials.end()) ? it << 126 return (iter != dedxMapMaterials.end()) ? iter->second : nullptr; 119 } 127 } 120 128 121 // ########################################### 129 // ######################################################################### 122 130 123 G4double G4IonStoppingData::GetDEDX(G4double k << 131 G4double G4IonStoppingData::GetDEDX( 124 G4int atomicNumberIon, // Atomic number of << 132 G4double kinEnergyPerNucleon, // Kinetic energy per nucleon 125 G4int atomicNumberElem // Atomic number of << 133 G4int atomicNumberIon, // Atomic number of ion 126 ) << 134 G4int atomicNumberElem // Atomic number of elemental material >> 135 ) 127 { 136 { 128 G4IonDEDXKeyElem key = std::make_pair(atomic 137 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 129 138 130 auto iter = dedxMapElements.find(key); 139 auto iter = dedxMapElements.find(key); 131 140 132 return (iter != dedxMapElements.end()) ? (it << 141 return ( iter != dedxMapElements.end()) ? >> 142 (iter->second)->Value( kinEnergyPerNucleon) : 0.0; 133 } 143 } 134 144 135 // ########################################### 145 // ######################################################################### 136 146 137 G4double G4IonStoppingData::GetDEDX(G4double k << 147 G4double G4IonStoppingData::GetDEDX( 138 G4int atomicNumberIon, // Atomic number of << 148 G4double kinEnergyPerNucleon, // Kinetic energy per nucleon 139 const G4String& matIdentifier // Name or ch << 149 G4int atomicNumberIon, // Atomic number of ion 140 ) << 150 const G4String& matIdentifier // Name or chemical formula of material >> 151 ) 141 { 152 { 142 G4IonDEDXKeyMat key = std::make_pair(atomicN 153 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 143 154 144 auto iter = dedxMapMaterials.find(key); 155 auto iter = dedxMapMaterials.find(key); 145 156 146 return (iter != dedxMapMaterials.end()) ? (i << 157 return (iter != dedxMapMaterials.end()) ? >> 158 (iter->second)->Value(kinEnergyPerNucleon) : 0.0; 147 } 159 } 148 160 149 // ########################################### 161 // ######################################################################### 150 162 151 G4bool G4IonStoppingData::AddPhysicsVector(G4P << 163 G4bool G4IonStoppingData::AddPhysicsVector( 152 G4int atomicNumberIon, // Atomic number of << 164 G4PhysicsVector* physicsVector, // Physics vector 153 const G4String& matIdentifier // Name of el << 165 G4int atomicNumberIon, // Atomic number of ion 154 ) << 166 const G4String& matIdentifier // Name of elemental material >> 167 ) 155 { 168 { 156 if (physicsVector == nullptr) { << 169 if(physicsVector == nullptr) { 157 G4Exception("G4IonStoppingData::AddPhysics << 170 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material", 158 "Pointer to vector is null-pointer."); << 171 "mat037", FatalException, >> 172 "Pointer to vector is null-pointer."); 159 return false; 173 return false; 160 } 174 } 161 175 162 if (matIdentifier.empty()) { << 176 if(matIdentifier.empty()) { 163 G4Exception("G4IonStoppingData::AddPhysics << 177 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material", 164 "Invalid name of the material."); << 178 "mat038", FatalException, "Invalid name of the material."); 165 return false; 179 return false; 166 } 180 } 167 181 168 if (atomicNumberIon <= 0) { << 182 if(atomicNumberIon <= 0) { 169 G4Exception("G4IonStoppingData::AddPhysics << 183 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material", 170 "Illegal atomic number."); << 184 "mat039", FatalException, "Illegal atomic number."); 171 return false; 185 return false; 172 } 186 } 173 187 174 G4IonDEDXKeyMat mkey = std::make_pair(atomic 188 G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier); 175 189 176 if (dedxMapMaterials.count(mkey) == 1) { << 190 if(dedxMapMaterials.count(mkey) == 1) { 177 G4ExceptionDescription ed; 191 G4ExceptionDescription ed; 178 ed << "Vector with Z1 = " << atomicNumberI << 192 ed << "Vector with Z1 = " << atomicNumberIon << ", mat = " >> 193 << matIdentifier 179 << "already exists. Remove first before 194 << "already exists. Remove first before replacing."; 180 G4Exception("G4IonStoppingData::AddPhysics << 195 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material", >> 196 "mat040", FatalException, ed); 181 return false; 197 return false; 182 } 198 } 183 199 184 dedxMapMaterials[mkey] = physicsVector; 200 dedxMapMaterials[mkey] = physicsVector; 185 201 186 return true; 202 return true; 187 } 203 } 188 204 189 // ########################################### 205 // ######################################################################### 190 206 191 G4bool G4IonStoppingData::AddPhysicsVector(G4P << 207 G4bool G4IonStoppingData::AddPhysicsVector( 192 G4int atomicNumberIon, // Atomic number of << 208 G4PhysicsVector* physicsVector, // Physics vector 193 G4int atomicNumberElem // Atomic number of << 209 G4int atomicNumberIon, // Atomic number of ion 194 ) << 210 G4int atomicNumberElem // Atomic number of elemental material >> 211 ) 195 { 212 { 196 if (physicsVector == nullptr) { << 213 if(physicsVector == nullptr) { 197 G4Exception("G4IonStoppingData::AddPhysics << 214 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat037", 198 "Pointer to vector is null-pointer."); << 215 FatalException, "Pointer to vector is null-pointer."); 199 return false; << 216 return false; 200 } 217 } 201 218 202 if (atomicNumberIon <= 0) { << 219 if(atomicNumberIon <= 0) { 203 G4Exception("G4IonStoppingData::AddPhysics << 220 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat038", 204 "Invalid ion number."); << 221 FatalException, "Invalid ion number."); 205 return false; 222 return false; 206 } 223 } 207 224 208 if (atomicNumberElem <= 0) { << 225 if(atomicNumberElem <= 0) { 209 G4Exception("G4IonStoppingData::AddPhysics << 226 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat039", 210 "Illegal atomic number."); << 227 FatalException, "Illegal atomic number."); 211 return false; 228 return false; 212 } 229 } 213 230 214 G4IonDEDXKeyElem key = std::make_pair(atomic 231 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 215 232 216 if (dedxMapElements.count(key) == 1) { << 233 if(dedxMapElements.count(key) == 1) { 217 G4ExceptionDescription ed; 234 G4ExceptionDescription ed; 218 ed << "Vector with Z1 = " << atomicNumberI << 235 ed << "Vector with Z1 = " << atomicNumberIon << ", Z= " >> 236 << atomicNumberElem 219 << "already exists. Remove first before 237 << "already exists. Remove first before replacing."; 220 G4Exception("G4IonStoppingData::AddPhysics << 238 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat040", >> 239 FatalException, ed); 221 return false; 240 return false; 222 } 241 } 223 242 224 dedxMapElements[key] = physicsVector; 243 dedxMapElements[key] = physicsVector; 225 244 226 return true; 245 return true; 227 } 246 } 228 247 229 // ########################################### 248 // ######################################################################### 230 249 231 G4bool G4IonStoppingData::RemovePhysicsVector( << 250 G4bool G4IonStoppingData::RemovePhysicsVector( 232 const G4String& matIdentifier // Name or ch << 251 G4int atomicNumberIon, // Atomic number of ion 233 ) << 252 const G4String& matIdentifier // Name or chemical formula of material 234 { << 253 ) { >> 254 235 G4IonDEDXKeyMat key = std::make_pair(atomicN 255 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 236 256 237 auto iter = dedxMapMaterials.find(key); 257 auto iter = dedxMapMaterials.find(key); 238 258 239 if (iter == dedxMapMaterials.end()) { << 259 if(iter == dedxMapMaterials.end()) { 240 G4Exception("G4IonStoppingData::RemovePhys << 260 G4Exception ("G4IonStoppingData::RemovePhysicsVector() for material", 241 "Invalid name of the material."); << 261 "mat038", FatalException, "Invalid name of the material."); 242 return false; 262 return false; 243 } 263 } 244 264 245 G4PhysicsVector* physicsVector = (*iter).sec 265 G4PhysicsVector* physicsVector = (*iter).second; 246 266 247 // Deleting key of physics vector from mater 267 // Deleting key of physics vector from material map 248 dedxMapMaterials.erase(key); 268 dedxMapMaterials.erase(key); 249 269 250 // Deleting physics vector 270 // Deleting physics vector 251 delete physicsVector; 271 delete physicsVector; 252 272 253 return true; 273 return true; 254 } 274 } 255 275 256 // ########################################### 276 // ######################################################################### 257 277 258 G4bool G4IonStoppingData::RemovePhysicsVector( << 278 G4bool G4IonStoppingData::RemovePhysicsVector( 259 G4int atomicNumberElem // Atomic number of << 279 G4int atomicNumberIon, // Atomic number of ion 260 ) << 280 G4int atomicNumberElem // Atomic number of elemental material 261 { << 281 ) { 262 G4IonDEDXKeyElem key = std::make_pair(atomic 282 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 263 283 264 auto iter = dedxMapElements.find(key); 284 auto iter = dedxMapElements.find(key); 265 285 266 if (iter == dedxMapElements.end()) { << 286 if(iter == dedxMapElements.end()) { 267 G4Exception("G4IonStoppingData::RemovePhys << 287 G4Exception ("G4IonStoppingData::RemovePhysicsVector() for element", 268 "Invalid element."); << 288 "mat038", FatalException, "Invalid element."); 269 return false; 289 return false; 270 } 290 } 271 291 272 G4PhysicsVector* physicsVector = (*iter).sec 292 G4PhysicsVector* physicsVector = (*iter).second; 273 293 274 // Deleting key of physics vector from mater 294 // Deleting key of physics vector from material map 275 dedxMapElements.erase(key); 295 dedxMapElements.erase(key); 276 296 277 // Deleting physics vector 297 // Deleting physics vector 278 delete physicsVector; 298 delete physicsVector; 279 299 280 return true; 300 return true; 281 } 301 } 282 302 283 // ########################################### 303 // ######################################################################### 284 304 285 G4bool G4IonStoppingData::BuildPhysicsVector(G << 305 G4bool G4IonStoppingData::BuildPhysicsVector( 286 const G4String& matname // Name of material << 306 G4int atomicNumberIon, // Atomic number of ion 287 ) << 307 const G4String& matname // Name of material 288 { << 308 ) { 289 if (IsApplicable(atomicNumberIon, matname)) << 309 if(IsApplicable(atomicNumberIon, matname)) >> 310 { 290 return true; 311 return true; 291 } 312 } 292 313 293 const char* path = G4FindDataDir("G4LEDATA") 314 const char* path = G4FindDataDir("G4LEDATA"); 294 if (path == nullptr) { << 315 if(path == nullptr) 295 G4Exception("G4IonStoppingData::BuildPhysi << 316 { 296 "G4LEDATA environment variable not set") << 317 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat521", >> 318 FatalException, "G4LEDATA environment variable not set"); 297 return false; 319 return false; 298 } 320 } 299 321 300 std::ostringstream file; 322 std::ostringstream file; 301 G4String ww = << 323 G4String ww = (fICRU90 && (matname == "G4_WATER" || 302 (fICRU90 && (matname == "G4_WATER" || matn << 324 matname == "G4_AIR" || 303 << 325 matname == "G4_GRAPHITE")) ? "90" : "73"; >> 326 >> 327 file << path << "/" << subDir << ww << "/z" >> 328 << atomicNumberIon << "_" << matname << ".dat"; >> 329 G4String fileName = G4String( file.str().c_str() ); 304 330 305 file << path << "/" << subDir << ww << "/z" << 331 std::ifstream ifilestream( fileName ); 306 G4String fileName = G4String(file.str().c_st << 307 332 308 std::ifstream ifilestream(fileName); << 333 if(!ifilestream.is_open()) 309 << 334 { 310 if (! ifilestream.is_open()) { << 311 return false; 335 return false; 312 } 336 } 313 337 314 auto* physicsVector = new G4PhysicsFreeVecto 338 auto* physicsVector = new G4PhysicsFreeVector(true); 315 339 316 if (! physicsVector->Retrieve(ifilestream, t << 340 if( !physicsVector -> Retrieve(ifilestream, true) ) { 317 ifilestream.close(); << 341 318 return false; << 342 ifilestream.close(); >> 343 return false; 319 } 344 } 320 345 321 physicsVector->ScaleVector(MeV, MeV * cm2 / << 346 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) ); 322 physicsVector->FillSecondDerivatives(); << 347 physicsVector -> FillSecondDerivatives(); 323 348 324 // Retrieved vector is added to material sto 349 // Retrieved vector is added to material store 325 if (! AddPhysicsVector(physicsVector, atomic << 350 if( !AddPhysicsVector(physicsVector, atomicNumberIon, matname) ) { 326 delete physicsVector; << 351 delete physicsVector; 327 ifilestream.close(); << 352 ifilestream.close(); 328 return false; << 353 return false; 329 } 354 } 330 355 331 ifilestream.close(); 356 ifilestream.close(); 332 return true; 357 return true; 333 } 358 } 334 359 335 // ########################################### 360 // ######################################################################### 336 361 337 G4bool G4IonStoppingData::BuildPhysicsVector(G << 362 G4bool G4IonStoppingData::BuildPhysicsVector( 338 G4int ZElem // Atomic number of elemental m << 363 G4int ZIon, // Atomic number of ion 339 ) << 364 G4int ZElem // Atomic number of elemental material >> 365 ) 340 { 366 { 341 if (IsApplicable(ZIon, ZElem)) { << 367 if(IsApplicable(ZIon, ZElem)) >> 368 { 342 return true; 369 return true; 343 } 370 } 344 371 345 const char* path = G4FindDataDir("G4LEDATA") 372 const char* path = G4FindDataDir("G4LEDATA"); 346 if (path == nullptr) { << 373 if(path == nullptr) 347 G4Exception("G4IonStoppingData::BuildPhysi << 374 { 348 "G4LEDATA environment variable not set") << 375 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat522", >> 376 FatalException, "G4LEDATA environment variable not set"); 349 return false; 377 return false; 350 } 378 } 351 std::ostringstream file; 379 std::ostringstream file; 352 G4String ww = << 380 G4String ww = (fICRU90 && ZIon <= 18 && 353 (fICRU90 && ZIon <= 18 && (ZElem == 1 || Z << 381 (ZElem == 1 || ZElem == 6 || 354 << 382 ZElem == 7 || ZElem == 8)) ? "90" : "73"; 355 file << path << "/" << subDir << ww << "/z" << 383 356 << 384 file << path << "/" << subDir << ww << "/z" 357 G4String fileName = G4String(file.str().c_st << 385 << ZIon << "_" << ZElem << ".dat"; 358 std::ifstream ifilestream(fileName); << 386 >> 387 G4String fileName = G4String( file.str().c_str() ); >> 388 std::ifstream ifilestream( fileName ); 359 389 360 if (! ifilestream.is_open()) { << 390 if(!ifilestream.is_open()) >> 391 { 361 return false; 392 return false; 362 } 393 } 363 auto* physicsVector = new G4PhysicsFreeVecto 394 auto* physicsVector = new G4PhysicsFreeVector(true); 364 395 365 if (! physicsVector->Retrieve(ifilestream, t << 396 if( !physicsVector -> Retrieve(ifilestream, true) ) { 366 ifilestream.close(); << 397 ifilestream.close(); 367 return false; << 398 return false; 368 } 399 } 369 400 370 physicsVector->ScaleVector(MeV, MeV * cm2 / << 401 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) ); 371 physicsVector->FillSecondDerivatives(); << 402 physicsVector -> FillSecondDerivatives(); 372 403 373 // Retrieved vector is added to material sto 404 // Retrieved vector is added to material store 374 if (! AddPhysicsVector(physicsVector, ZIon, << 405 if( !AddPhysicsVector(physicsVector, ZIon, ZElem) ) { 375 delete physicsVector; << 406 delete physicsVector; 376 ifilestream.close(); << 407 ifilestream.close(); 377 return false; << 408 return false; 378 } 409 } 379 410 380 ifilestream.close(); 411 ifilestream.close(); 381 return true; 412 return true; 382 } 413 } 383 414 384 // ########################################### 415 // ######################################################################### 385 416 386 void G4IonStoppingData::ClearTable() << 417 void G4IonStoppingData::ClearTable() { 387 { << 418 auto iterMat = dedxMapMaterials.begin(); 388 auto iterMat = dedxMapMaterials.begin(); << 389 auto iterMat_end = dedxMapMaterials.end(); 419 auto iterMat_end = dedxMapMaterials.end(); 390 420 391 for (; iterMat != iterMat_end; iterMat++) { << 421 for(;iterMat != iterMat_end; iterMat++) { 392 G4PhysicsVector* vec = iterMat->second; << 422 >> 423 G4PhysicsVector* vec = iterMat -> second; 393 424 394 delete vec; 425 delete vec; 395 } 426 } 396 427 397 dedxMapMaterials.clear(); 428 dedxMapMaterials.clear(); 398 429 399 auto iterElem = dedxMapElements.begin(); << 430 auto iterElem = dedxMapElements.begin(); 400 auto iterElem_end = dedxMapElements.end(); 431 auto iterElem_end = dedxMapElements.end(); 401 432 402 for (; iterElem != iterElem_end; iterElem++) << 433 for(;iterElem != iterElem_end; iterElem++) { 403 G4PhysicsVector* vec = iterElem->second; << 434 >> 435 G4PhysicsVector* vec = iterElem -> second; 404 436 405 delete vec; 437 delete vec; 406 } 438 } 407 439 408 dedxMapElements.clear(); 440 dedxMapElements.clear(); 409 } 441 } 410 442 411 // ########################################### 443 // ######################################################################### 412 444 413 void G4IonStoppingData::DumpMap() << 445 void G4IonStoppingData::DumpMap() { 414 { << 446 auto iterMat = dedxMapMaterials.begin(); 415 auto iterMat = dedxMapMaterials.begin(); << 416 auto iterMat_end = dedxMapMaterials.end(); 447 auto iterMat_end = dedxMapMaterials.end(); 417 448 418 G4cout << std::setw(15) << std::right << "At << 449 G4cout << std::setw(15) << std::right 419 << "Material name" << G4endl; << 450 << "Atomic nmb ion" 420 << 451 << std::setw(25) << std::right 421 for (; iterMat != iterMat_end; iterMat++) { << 452 << "Material name" 422 G4IonDEDXKeyMat key = iterMat->first; << 453 << G4endl; 423 G4PhysicsVector* physicsVector = iterMat-> << 454 424 << 455 for(;iterMat != iterMat_end; iterMat++) { 425 G4int atomicNumberIon = key.first; << 456 G4IonDEDXKeyMat key = iterMat -> first; 426 G4String matIdentifier = key.second; << 457 G4PhysicsVector* physicsVector = iterMat -> second; 427 << 458 428 if (physicsVector != nullptr) { << 459 G4int atomicNumberIon = key.first; 429 G4cout << std::setw(15) << std::right << << 460 G4String matIdentifier = key.second; 430 << matIdentifier << G4endl; << 461 431 } << 462 if(physicsVector != nullptr) >> 463 { >> 464 G4cout << std::setw(15) << std::right << atomicNumberIon >> 465 << std::setw(25) << std::right << matIdentifier << G4endl; >> 466 } 432 } 467 } 433 468 434 auto iterElem = dedxMapElements.begin(); << 469 auto iterElem = dedxMapElements.begin(); 435 auto iterElem_end = dedxMapElements.end(); 470 auto iterElem_end = dedxMapElements.end(); 436 471 437 G4cout << std::setw(15) << std::right << "At << 472 G4cout << std::setw(15) << std::right 438 << "Atomic nmb material" << G4endl; << 473 << "Atomic nmb ion" 439 << 474 << std::setw(25) << std::right 440 for (; iterElem != iterElem_end; iterElem++) << 475 << "Atomic nmb material" 441 G4IonDEDXKeyElem key = iterElem->first; << 476 << G4endl; 442 G4PhysicsVector* physicsVector = iterElem- << 477 443 << 478 for(;iterElem != iterElem_end; iterElem++) { 444 G4int atomicNumberIon = key.first; << 479 G4IonDEDXKeyElem key = iterElem -> first; 445 G4int atomicNumberElem = key.second; << 480 G4PhysicsVector* physicsVector = iterElem -> second; 446 << 481 447 if (physicsVector != nullptr) { << 482 G4int atomicNumberIon = key.first; 448 G4cout << std::setw(15) << std::right << << 483 G4int atomicNumberElem = key.second; 449 << atomicNumberElem << G4endl; << 484 450 } << 485 if(physicsVector != nullptr) >> 486 { >> 487 G4cout << std::setw(15) << std::right << atomicNumberIon >> 488 << std::setw(25) << std::right << atomicNumberElem << G4endl; >> 489 } 451 } 490 } >> 491 452 } 492 } 453 493 454 // ########################################### 494 // ######################################################################### >> 495 455 496