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: G4ExtDEDXTable 30 // Class: G4ExtDEDXTable 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: 29. 02. 2009 36 // First implementation: 29. 02. 2009 36 // 37 // 37 // Modifications: 38 // Modifications: 38 // 03.11.2009 A. Lechner: Added new methods B 39 // 03.11.2009 A. Lechner: Added new methods BuildPhysicsVector according 39 // to interface changes in base cla 40 // to interface changes in base class G4VIonDEDXTable. 40 // 25.10.2010 V.Ivanchenko fixed bug in usage << 41 // 25.10.2010 V.Ivanchenko fixed bug in usage of iterators reported by the 41 // Coverity tool 42 // Coverity tool 42 // 01.11.2010 V.Ivanchenko fixed remaining bug << 43 // 01.11.2010 V.Ivanchenko fixed remaining bugs reported by Coverity 43 // 44 // 44 // 45 // 45 // Class description: 46 // Class description: 46 // Utility class for users to add their own 47 // Utility class for users to add their own electronic stopping powers 47 // for ions. This class is dedicated for us 48 // for ions. This class is dedicated for use with G4IonParametrisedLossModel 48 // of the low-energy electromagnetic packag 49 // of the low-energy electromagnetic package. 49 // 50 // 50 // Comments: 51 // Comments: 51 // 52 // 52 // =========================================== << 53 // =========================================================================== 53 << 54 // 54 #include "G4ExtDEDXTable.hh" << 55 55 56 #include "G4PhysicsFreeVector.hh" << 56 #include "G4ExtDEDXTable.hh" 57 #include "G4PhysicsLinearVector.hh" << 58 #include "G4PhysicsLogVector.hh" << 59 #include "G4PhysicsVector.hh" 57 #include "G4PhysicsVector.hh" 60 #include "G4PhysicsVectorType.hh" 58 #include "G4PhysicsVectorType.hh" 61 << 59 #include "G4PhysicsFreeVector.hh" >> 60 #include "G4PhysicsLogVector.hh" >> 61 #include "G4PhysicsLinearVector.hh" 62 #include <fstream> 62 #include <fstream> 63 #include <iomanip> << 64 #include <sstream> 63 #include <sstream> >> 64 #include <iomanip> 65 65 66 // ########################################### 66 // ######################################################################### 67 67 68 G4ExtDEDXTable::~G4ExtDEDXTable() { ClearTable << 68 G4ExtDEDXTable::~G4ExtDEDXTable() { >> 69 >> 70 ClearTable(); >> 71 } 69 72 70 // ########################################### 73 // ######################################################################### 71 74 72 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4in << 75 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4int ionZ, G4int matZ) { 73 { << 76 74 return IsApplicable(ionZ, matZ); << 77 return IsApplicable( ionZ, matZ ); 75 } 78 } 76 79 >> 80 77 // ########################################### 81 // ######################################################################### 78 82 79 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4in << 83 G4bool G4ExtDEDXTable::BuildPhysicsVector(G4int ionZ, 80 { << 84 const G4String& matName) { 81 return IsApplicable(ionZ, matName); << 85 >> 86 return IsApplicable( ionZ, matName ); 82 } 87 } 83 88 84 // ########################################### 89 // ######################################################################### 85 90 86 G4bool G4ExtDEDXTable::IsApplicable(G4int atom << 91 G4bool G4ExtDEDXTable::IsApplicable( 87 G4int atomicNumberElem // Atomic number of << 92 G4int atomicNumberIon, // Atomic number of ion 88 ) << 93 G4int atomicNumberElem // Atomic number of elemental material >> 94 ) 89 { 95 { 90 G4IonDEDXKeyElem key = std::make_pair(atomic 96 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 91 97 92 auto iter = dedxMapElements.find(key); 98 auto iter = dedxMapElements.find(key); 93 99 94 return iter != dedxMapElements.end(); 100 return iter != dedxMapElements.end(); 95 } 101 } 96 102 97 // ########################################### 103 // ######################################################################### 98 104 99 G4bool G4ExtDEDXTable::IsApplicable(G4int atom << 105 G4bool G4ExtDEDXTable::IsApplicable( 100 const G4String& matIdentifier // Name or ch << 106 G4int atomicNumberIon, // Atomic number of ion 101 ) << 107 const G4String& matIdentifier // Name or chemical formula of material >> 108 ) 102 { 109 { 103 G4IonDEDXKeyMat key = std::make_pair(atomicN 110 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 104 111 105 auto iter = dedxMapMaterials.find(key); 112 auto iter = dedxMapMaterials.find(key); 106 113 107 return iter != dedxMapMaterials.end(); 114 return iter != dedxMapMaterials.end(); 108 } 115 } 109 116 110 // ########################################### 117 // ######################################################################### 111 118 112 G4PhysicsVector* G4ExtDEDXTable::GetPhysicsVec << 119 G4PhysicsVector* G4ExtDEDXTable::GetPhysicsVector( 113 G4int atomicNumberElem // Atomic number of << 120 G4int atomicNumberIon, // Atomic number of ion 114 ) << 121 G4int atomicNumberElem // Atomic number of elemental material >> 122 ) 115 { 123 { 116 G4IonDEDXKeyElem key = std::make_pair(atomic 124 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 117 125 118 auto iter = dedxMapElements.find(key); 126 auto iter = dedxMapElements.find(key); 119 127 120 return (iter != dedxMapElements.end()) ? ite << 128 return (iter != dedxMapElements.end()) ? iter->second : nullptr; 121 } 129 } 122 130 123 // ########################################### 131 // ######################################################################### 124 132 125 G4PhysicsVector* G4ExtDEDXTable::GetPhysicsVec << 133 G4PhysicsVector* G4ExtDEDXTable::GetPhysicsVector( 126 const G4String& matIdentifier // Name or ch << 134 G4int atomicNumberIon, // Atomic number of ion 127 ) << 135 const G4String& matIdentifier // Name or chemical formula of material >> 136 ) 128 { 137 { 129 G4IonDEDXKeyMat key = std::make_pair(atomicN 138 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 130 139 131 auto iter = dedxMapMaterials.find(key); 140 auto iter = dedxMapMaterials.find(key); 132 141 133 return (iter != dedxMapMaterials.end()) ? it << 142 return (iter != dedxMapMaterials.end()) ? iter->second : nullptr; 134 } 143 } 135 144 136 // ########################################### 145 // ######################################################################### 137 146 138 G4double G4ExtDEDXTable::GetDEDX(G4double kinE << 147 G4double G4ExtDEDXTable::GetDEDX( 139 G4int atomicNumberIon, // Atomic number of << 148 G4double kinEnergyPerNucleon, // Kinetic energy per nucleon 140 G4int atomicNumberElem // Atomic number of << 149 G4int atomicNumberIon, // Atomic number of ion 141 ) << 150 G4int atomicNumberElem // Atomic number of elemental material >> 151 ) 142 { 152 { 143 G4IonDEDXKeyElem key = std::make_pair(atomic 153 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 144 154 145 auto iter = dedxMapElements.find(key); 155 auto iter = dedxMapElements.find(key); 146 156 147 return (iter != dedxMapElements.end()) ? (it << 157 return ( iter != dedxMapElements.end() ) ? >> 158 (iter->second)->Value( kinEnergyPerNucleon) : 0.0; 148 } 159 } 149 160 150 // ########################################### 161 // ######################################################################### 151 162 152 G4double G4ExtDEDXTable::GetDEDX(G4double kinE << 163 G4double G4ExtDEDXTable::GetDEDX( 153 G4int atomicNumberIon, // Atomic number of << 164 G4double kinEnergyPerNucleon, // Kinetic energy per nucleon 154 const G4String& matIdentifier // Name or ch << 165 G4int atomicNumberIon, // Atomic number of ion 155 ) << 166 const G4String& matIdentifier // Name or chemical formula of material >> 167 ) 156 { 168 { 157 G4IonDEDXKeyMat key = std::make_pair(atomicN 169 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 158 170 159 auto iter = dedxMapMaterials.find(key); 171 auto iter = dedxMapMaterials.find(key); 160 172 161 return (iter != dedxMapMaterials.end()) ? (i << 173 return (iter != dedxMapMaterials.end()) ? >> 174 (iter->second)->Value( kinEnergyPerNucleon) : 0.0; 162 } 175 } 163 176 164 // ########################################### 177 // ######################################################################### 165 178 166 G4bool G4ExtDEDXTable::AddPhysicsVector(G4Phys << 179 G4bool G4ExtDEDXTable::AddPhysicsVector( 167 G4int atomicNumberIon, // Atomic number of << 180 G4PhysicsVector* physicsVector, // Physics vector 168 const G4String& matIdentifier, // Name of e << 181 G4int atomicNumberIon, // Atomic number of ion 169 G4int atomicNumberElem // Atomic number of << 182 const G4String& matIdentifier, // Name of elemental material 170 ) << 183 G4int atomicNumberElem // Atomic number of elemental material 171 { << 184 ) { 172 if (physicsVector == nullptr) { << 185 173 G4Exception("G4ExtDEDXTable::AddPhysicsVec << 186 if(physicsVector == nullptr) { 174 "Pointer to vector is null-pointer."); << 187 G4Exception ("G4ExtDEDXTable::AddPhysicsVector() for material", >> 188 "mat037", FatalException, >> 189 "Pointer to vector is null-pointer."); 175 return false; 190 return false; 176 } 191 } 177 192 178 if (matIdentifier.empty()) { << 193 if(matIdentifier.empty()) { 179 G4Exception("G4ExtDEDXTable::AddPhysicsVec << 194 G4Exception ("G4ExtDEDXTable::AddPhysicsVector() for material", 180 "Invalid name of the material."); << 195 "mat038", FatalException, "Invalid name of the material."); 181 return false; << 196 return false; 182 } 197 } 183 198 184 if (atomicNumberIon <= 2) { << 199 if(atomicNumberIon <= 2) { 185 G4Exception("G4ExtDEDXTable::AddPhysicsVec << 200 G4Exception ("G4ExtDEDXTable::AddPhysicsVector() for material", 186 "Illegal atomic number."); << 201 "mat039", FatalException, "Illegal atomic number."); 187 return false; 202 return false; 188 } 203 } 189 204 190 if (atomicNumberElem > 0) { << 205 if(atomicNumberElem > 0) { 191 G4IonDEDXKeyElem key = std::make_pair(atom << 192 206 193 if (dedxMapElements.count(key) == 1) { << 207 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem); 194 G4Exception("G4ExtDEDXTable::AddPhysicsV << 208 195 "Vector already exist, remove it befor << 209 if(dedxMapElements.count(key) == 1) { 196 return false; << 210 G4Exception ("G4ExtDEDXTable::AddPhysicsVector() for material", 197 } << 211 "mat037", FatalException, >> 212 "Vector already exist, remove it before replacing."); >> 213 return false; >> 214 } 198 215 199 dedxMapElements[key] = physicsVector; << 216 dedxMapElements[key] = physicsVector; 200 } 217 } 201 218 202 G4IonDEDXKeyMat mkey = std::make_pair(atomic 219 G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier); 203 220 204 if (dedxMapMaterials.count(mkey) == 1) { << 221 if(dedxMapMaterials.count(mkey) == 1) { 205 G4Exception("G4ExtDEDXTable::AddPhysicsVec << 222 G4Exception ("G4ExtDEDXTable::AddPhysicsVector() for material", 206 "Vector already exist, remove it before << 223 "mat037", FatalException, >> 224 "Vector already exist, remove it before replacing."); 207 return false; 225 return false; 208 } 226 } 209 227 210 dedxMapMaterials[mkey] = physicsVector; 228 dedxMapMaterials[mkey] = physicsVector; 211 229 212 return true; 230 return true; 213 } 231 } 214 232 215 // ########################################### 233 // ######################################################################### 216 234 217 G4bool G4ExtDEDXTable::RemovePhysicsVector(G4i << 235 G4bool G4ExtDEDXTable::RemovePhysicsVector( 218 const G4String& matIdentifier // Name or ch << 236 G4int atomicNumberIon, // Atomic number of ion 219 ) << 237 const G4String& matIdentifier // Name or chemical formula of material 220 { << 238 ) { >> 239 221 G4PhysicsVector* physicsVector = nullptr; 240 G4PhysicsVector* physicsVector = nullptr; 222 241 223 // Deleting key of physics vector from mater 242 // Deleting key of physics vector from material map 224 G4IonDEDXKeyMat key = std::make_pair(atomicN 243 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier); 225 244 226 auto iter = dedxMapMaterials.find(key); 245 auto iter = dedxMapMaterials.find(key); 227 246 228 if (iter == dedxMapMaterials.end()) { << 247 if(iter == dedxMapMaterials.end()) { 229 G4Exception("G4ExtDEDXTable::RemovePhysics << 248 G4Exception ("G4ExtDEDXTable::RemovePhysicsVector() for material", 230 "Pointer to vector is null-pointer."); << 249 "mat037", FatalException, >> 250 "Pointer to vector is null-pointer."); 231 return false; 251 return false; 232 } 252 } 233 253 234 physicsVector = (*iter).second; 254 physicsVector = (*iter).second; 235 dedxMapMaterials.erase(key); 255 dedxMapMaterials.erase(key); 236 256 237 // Deleting key of physics vector from eleme 257 // Deleting key of physics vector from elemental material map (if it exists) 238 G4IonDEDXMapElem::iterator it; 258 G4IonDEDXMapElem::iterator it; >> 259 >> 260 for(it=dedxMapElements.begin(); it!=dedxMapElements.end(); ++it) { 239 261 240 for (it = dedxMapElements.begin(); it != ded << 262 if( (*it).second == physicsVector ) { 241 if ((*it).second == physicsVector) { << 263 dedxMapElements.erase(it); 242 dedxMapElements.erase(it); << 264 break; 243 break; << 265 } 244 } << 245 } 266 } 246 267 247 // Deleting physics vector 268 // Deleting physics vector 248 delete physicsVector; 269 delete physicsVector; 249 270 250 return true; 271 return true; 251 } 272 } 252 273 253 // ########################################### 274 // ######################################################################### 254 275 255 G4bool G4ExtDEDXTable::StorePhysicsTable(const << 276 G4bool G4ExtDEDXTable::StorePhysicsTable( 256 ) << 277 const G4String& fileName // File name 257 { << 278 ) { 258 G4bool success = true; 279 G4bool success = true; 259 280 260 std::ofstream ofilestream; 281 std::ofstream ofilestream; 261 282 262 ofilestream.open(fileName, std::ios::out); << 283 ofilestream.open( fileName, std::ios::out ); 263 284 264 if (! ofilestream) { << 285 if( !ofilestream ) { 265 G4ExceptionDescription ed; 286 G4ExceptionDescription ed; 266 ed << "Cannot open file " << fileName; << 287 ed << "Cannot open file " << fileName; 267 G4Exception("G4IonStoppingData::StorePhysi << 288 G4Exception ("G4IonStoppingData::StorePhysicsTable()", >> 289 "mat030", FatalException, ed); 268 success = false; 290 success = false; 269 } << 291 } 270 else { 292 else { 271 size_t nmbMatTables = dedxMapMaterials.siz << 272 293 273 ofilestream << nmbMatTables << G4endl << G << 294 size_t nmbMatTables = dedxMapMaterials.size(); 274 295 275 auto iterMat = dedxMapMaterials.begin(); << 296 ofilestream << nmbMatTables << G4endl << G4endl; 276 auto iterMat_end = dedxMapMaterials.end(); << 277 297 278 for (; iterMat != iterMat_end; iterMat++) << 298 auto iterMat = dedxMapMaterials.begin(); 279 G4IonDEDXKeyMat key = iterMat->first; << 299 auto iterMat_end = dedxMapMaterials.end(); 280 G4PhysicsVector* physicsVector = iterMat << 281 300 282 G4int atomicNumberIon = key.first; << 301 for(;iterMat != iterMat_end; iterMat++) { 283 G4String matIdentifier = key.second; << 302 G4IonDEDXKeyMat key = iterMat -> first; >> 303 G4PhysicsVector* physicsVector = iterMat -> second; 284 304 285 G4int atomicNumberElem = FindAtomicNumbe << 305 G4int atomicNumberIon = key.first; >> 306 G4String matIdentifier = key.second; 286 307 287 if (physicsVector != nullptr) { << 308 G4int atomicNumberElem = FindAtomicNumberElement(physicsVector); 288 ofilestream << atomicNumberIon << " " << 289 309 290 if (atomicNumberElem > 0) { << 310 if(physicsVector != nullptr) { 291 ofilestream << " " << atomicNumberE << 311 ofilestream << atomicNumberIon << " " << matIdentifier; 292 } << 293 << 294 ofilestream << " # <Atomic number ion << 295 312 296 if (atomicNumberElem > 0) { << 313 if(atomicNumberElem > 0) 297 ofilestream << "<Atomic number eleme << 314 { >> 315 ofilestream << " " << atomicNumberElem; 298 } 316 } 299 317 300 ofilestream << G4endl << physicsVector << 318 ofilestream << " # <Atomic number ion> <Material name> "; 301 319 302 physicsVector->Store(ofilestream, true << 320 if(atomicNumberElem > 0) 303 << 321 { 304 ofilestream << G4endl; << 322 ofilestream << "<Atomic number element>"; 305 } << 323 } 306 else { << 324 307 G4Exception("G4IonStoppingData::StoreP << 325 ofilestream << G4endl << physicsVector -> GetType() << G4endl; 308 "Cannot store vector."); << 326 309 } << 327 physicsVector -> Store(ofilestream, true); 310 } << 328 >> 329 ofilestream << G4endl; >> 330 } else { >> 331 G4Exception ("G4IonStoppingData::StorePhysicsTable()", >> 332 "mat030", FatalException,"Cannot store vector."); >> 333 } >> 334 } 311 } 335 } 312 336 313 ofilestream.close(); 337 ofilestream.close(); 314 338 315 return success; << 339 return success; 316 } 340 } 317 341 318 // ########################################### 342 // ######################################################################### 319 343 320 G4bool G4ExtDEDXTable::RetrievePhysicsTable(co << 344 G4bool G4ExtDEDXTable::RetrievePhysicsTable(const G4String& fileName) 321 { << 345 { 322 std::ifstream ifilestream; 346 std::ifstream ifilestream; 323 ifilestream.open(fileName, std::ios::in | st << 347 ifilestream.open( fileName, std::ios::in|std::ios::binary ); 324 if (! ifilestream) { << 348 if( ! ifilestream ) { 325 G4ExceptionDescription ed; 349 G4ExceptionDescription ed; 326 ed << "Cannot open file " << fileName; << 350 ed << "Cannot open file " << fileName; 327 G4Exception("G4IonStoppingData::RetrievePh << 351 G4Exception ("G4IonStoppingData::RetrievePhysicsTable()", >> 352 "mat030", FatalException, ed); 328 return false; 353 return false; 329 } << 354 } 330 355 331 // std::string::size_type nmbVectors; << 356 //std::string::size_type nmbVectors; 332 G4int nmbVectors = 0; 357 G4int nmbVectors = 0; 333 ifilestream >> nmbVectors; 358 ifilestream >> nmbVectors; 334 if (ifilestream.fail() || nmbVectors <= 0) { << 359 if( ifilestream.fail() || nmbVectors <= 0) { 335 G4cout << "G4ExtDEDXTable::RetrievePhysics << 360 G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 336 << " File content of " << fileName << 361 << " File content of " << fileName << " ill-formated." 337 << " Nvectors= " << nmbVectors << G << 362 << " Nvectors= " << nmbVectors 338 ifilestream.close(); << 363 << G4endl; 339 return false; << 364 ifilestream.close(); >> 365 return false; 340 } 366 } 341 367 342 for (G4int i = 0; i < nmbVectors; ++i) { << 368 for(G4int i = 0; i<nmbVectors; ++i) { >> 369 343 G4String line = ""; 370 G4String line = ""; 344 // Loop checking, 07-Aug-2015, Vladimir Iv 371 // Loop checking, 07-Aug-2015, Vladimir Ivanchenko 345 while (line.empty()) { << 372 while( line.empty() ) { 346 getline(ifilestream, line); << 373 347 if (ifilestream.fail()) { << 374 getline( ifilestream, line ); 348 G4cout << "G4ExtDEDXTable::RetrievePhy << 375 if( ifilestream.fail() ) { 349 << " File content of " << fileN << 376 G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 350 ifilestream.close(); << 377 << " File content of " << fileName << " ill-formated." 351 return false; << 378 << G4endl; >> 379 ifilestream.close(); >> 380 return false; 352 } 381 } 353 382 354 std::string::size_type pos = line.find_f << 383 std::string::size_type pos = line.find_first_of("#"); 355 if (pos != std::string::npos && pos > 0) << 384 if(pos != std::string::npos && pos > 0) { 356 line = line.substr(0, pos); << 385 line = line.substr(0, pos); 357 } 386 } 358 } 387 } 359 388 360 std::istringstream headerstream(line); << 389 std::istringstream headerstream( line ); 361 390 362 std::string::size_type atomicNumberIon; 391 std::string::size_type atomicNumberIon; 363 headerstream >> atomicNumberIon; 392 headerstream >> atomicNumberIon; 364 393 365 G4String materialName; 394 G4String materialName; 366 headerstream >> materialName; 395 headerstream >> materialName; 367 396 368 if (headerstream.fail() || std::string::np << 397 if( headerstream.fail() || std::string::npos == atomicNumberIon) { 369 G4cout << "G4ExtDEDXTable::RetrievePhysi << 398 G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 370 << " File content of " << fileNam << 399 << " File content of " << fileName << " ill-formated " 371 << " (vector header)." << G4endl; << 400 << " (vector header)." >> 401 << G4endl; 372 ifilestream.close(); 402 ifilestream.close(); 373 return false; 403 return false; 374 } << 404 } 375 405 376 std::string::size_type atomicNumberMat; 406 std::string::size_type atomicNumberMat; 377 headerstream >> atomicNumberMat; 407 headerstream >> atomicNumberMat; 378 408 379 if (headerstream.eof() || std::string::npo << 409 if( headerstream.eof() || std::string::npos == atomicNumberMat) { 380 atomicNumberMat = 0; << 410 atomicNumberMat = 0; 381 } 411 } 382 412 383 G4int vectorType; 413 G4int vectorType; 384 ifilestream >> vectorType; 414 ifilestream >> vectorType; 385 << 415 386 G4PhysicsVector* physicsVector = CreatePhy 416 G4PhysicsVector* physicsVector = CreatePhysicsVector(vectorType); 387 417 388 if (physicsVector == nullptr) { << 418 if(physicsVector == nullptr) { 389 G4cout << "G4ExtDEDXTable::RetrievePhysi 419 G4cout << "G4ExtDEDXTable::RetrievePhysicsTable " 390 << " illegal physics Vector type << 420 << " illegal physics Vector type " << vectorType >> 421 << " in " << fileName >> 422 << G4endl; 391 ifilestream.close(); 423 ifilestream.close(); 392 return false; 424 return false; 393 } 425 } 394 426 395 if (! physicsVector->Retrieve(ifilestream, << 427 if( !physicsVector -> Retrieve(ifilestream, true) ) { 396 G4cout << "G4ExtDEDXTable::RetrievePhysi << 428 G4cout << "G4ExtDEDXTable::RetrievePhysicsTable() " 397 << " File content of " << fileNam << 429 << " File content of " << fileName << " ill-formated." >> 430 << G4endl; 398 ifilestream.close(); 431 ifilestream.close(); 399 return false; 432 return false; 400 } << 433 } 401 physicsVector->FillSecondDerivatives(); << 434 physicsVector -> FillSecondDerivatives(); 402 435 403 // Retrieved vector is added to material s 436 // Retrieved vector is added to material store 404 if (! AddPhysicsVector( << 437 if( !AddPhysicsVector(physicsVector, (G4int)atomicNumberIon, 405 physicsVector, (G4int)atomicNumberIo << 438 materialName, (G4int)atomicNumberMat) ) { 406 { << 439 407 delete physicsVector; 440 delete physicsVector; 408 ifilestream.close(); 441 ifilestream.close(); 409 return false; 442 return false; 410 } 443 } 411 } 444 } 412 445 413 ifilestream.close(); 446 ifilestream.close(); 414 447 415 return true; 448 return true; 416 } 449 } 417 450 418 // ########################################### 451 // ######################################################################### 419 452 420 G4PhysicsVector* G4ExtDEDXTable::CreatePhysics << 453 G4PhysicsVector* G4ExtDEDXTable::CreatePhysicsVector(G4int vectorType) { 421 { << 454 422 G4PhysicsVector* physicsVector = nullptr; 455 G4PhysicsVector* physicsVector = nullptr; 423 456 424 switch (vectorType) { 457 switch (vectorType) { 425 case T_G4PhysicsLinearVector: << 426 physicsVector = new G4PhysicsLinearVecto << 427 break; << 428 << 429 case T_G4PhysicsLogVector: << 430 physicsVector = new G4PhysicsLogVector(t << 431 break; << 432 << 433 case T_G4PhysicsFreeVector: << 434 physicsVector = new G4PhysicsFreeVector( << 435 break; << 436 458 437 default: << 459 case T_G4PhysicsLinearVector: 438 break; << 460 physicsVector = new G4PhysicsLinearVector(true); >> 461 break; >> 462 >> 463 case T_G4PhysicsLogVector: >> 464 physicsVector = new G4PhysicsLogVector(true); >> 465 break; >> 466 >> 467 case T_G4PhysicsFreeVector: >> 468 physicsVector = new G4PhysicsFreeVector(true); >> 469 break; >> 470 >> 471 default: >> 472 break; 439 } 473 } 440 return physicsVector; 474 return physicsVector; 441 } 475 } 442 476 443 // ########################################### 477 // ######################################################################### 444 478 445 G4int G4ExtDEDXTable::FindAtomicNumberElement( << 479 G4int G4ExtDEDXTable::FindAtomicNumberElement( 446 { << 480 G4PhysicsVector* physicsVector >> 481 ) { >> 482 447 G4int atomicNumber = 0; 483 G4int atomicNumber = 0; 448 484 449 auto iter = dedxMapElements.begin(); << 485 auto iter = dedxMapElements.begin(); 450 auto iter_end = dedxMapElements.end(); 486 auto iter_end = dedxMapElements.end(); 451 487 452 for (; iter != iter_end; ++iter) { << 488 for(;iter != iter_end; ++iter) { 453 if ((*iter).second == physicsVector) { << 489 454 G4IonDEDXKeyElem key = (*iter).first; << 490 if( (*iter).second == physicsVector ) { 455 atomicNumber = key.second; << 491 456 } << 492 G4IonDEDXKeyElem key = (*iter).first; >> 493 atomicNumber = key.second; >> 494 } 457 } 495 } 458 496 459 return atomicNumber; 497 return atomicNumber; 460 } 498 } 461 499 462 // ########################################### 500 // ######################################################################### 463 501 464 void G4ExtDEDXTable::ClearTable() << 502 void G4ExtDEDXTable::ClearTable() { 465 { << 503 auto iterMat = dedxMapMaterials.begin(); 466 auto iterMat = dedxMapMaterials.begin(); << 467 auto iterMat_end = dedxMapMaterials.end(); 504 auto iterMat_end = dedxMapMaterials.end(); 468 505 469 for (; iterMat != iterMat_end; ++iterMat) { << 506 for(;iterMat != iterMat_end; ++iterMat) { 470 G4PhysicsVector* vec = iterMat->second; << 507 >> 508 G4PhysicsVector* vec = iterMat -> second; 471 509 472 delete vec; 510 delete vec; 473 } 511 } 474 512 475 dedxMapElements.clear(); 513 dedxMapElements.clear(); 476 dedxMapMaterials.clear(); 514 dedxMapMaterials.clear(); 477 } 515 } 478 516 479 // ########################################### 517 // ######################################################################### 480 518 481 void G4ExtDEDXTable::DumpMap() << 519 void G4ExtDEDXTable::DumpMap() { 482 { << 520 auto iterMat = dedxMapMaterials.begin(); 483 auto iterMat = dedxMapMaterials.begin(); << 484 auto iterMat_end = dedxMapMaterials.end(); 521 auto iterMat_end = dedxMapMaterials.end(); 485 522 486 G4cout << std::setw(15) << std::right << "At << 523 G4cout << std::setw(15) << std::right 487 << "Material name" << std::setw(25) < << 524 << "Atomic nmb ion" >> 525 << std::setw(25) << std::right >> 526 << "Material name" >> 527 << std::setw(25) << std::right >> 528 << "Atomic nmb material" >> 529 << G4endl; >> 530 >> 531 for(;iterMat != iterMat_end; ++iterMat) { >> 532 G4IonDEDXKeyMat key = iterMat -> first; >> 533 G4PhysicsVector* physicsVector = iterMat -> second; 488 534 489 for (; iterMat != iterMat_end; ++iterMat) { << 535 G4int atomicNumberIon = key.first; 490 G4IonDEDXKeyMat key = iterMat->first; << 536 G4String matIdentifier = key.second; 491 G4PhysicsVector* physicsVector = iterMat-> << 492 << 493 G4int atomicNumberIon = key.first; << 494 G4String matIdentifier = key.second; << 495 537 496 G4int atomicNumberElem = FindAtomicNumberE << 538 G4int atomicNumberElem = FindAtomicNumberElement(physicsVector); 497 539 498 if (physicsVector != nullptr) { << 540 if(physicsVector != nullptr) 499 G4cout << std::setw(15) << std::right << << 541 { 500 << matIdentifier << std::setw(25) << 542 G4cout << std::setw(15) << std::right << atomicNumberIon >> 543 << std::setw(25) << std::right << matIdentifier << std::setw(25) >> 544 << std::right; >> 545 >> 546 if(atomicNumberElem > 0) >> 547 { >> 548 G4cout << atomicNumberElem; >> 549 } >> 550 else >> 551 { >> 552 G4cout << "N/A"; >> 553 } 501 554 502 if (atomicNumberElem > 0) { << 555 G4cout << G4endl; 503 G4cout << atomicNumberElem; << 504 } << 505 else { << 506 G4cout << "N/A"; << 507 } 556 } 508 << 509 G4cout << G4endl; << 510 } << 511 } 557 } >> 558 512 } 559 } 513 560 514 // ########################################### 561 // ######################################################################### >> 562 515 563