Geant4-11
Public Member Functions | Private Types | Private Member Functions | Private Attributes
G4IonStoppingData Class Reference

#include <G4IonStoppingData.hh>

Inheritance diagram for G4IonStoppingData:
G4VIonDEDXTable

Public Member Functions

G4bool AddPhysicsVector (G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdentifier)
 
G4bool AddPhysicsVector (G4PhysicsVector *physicsVector, G4int atomicNumberIon, G4int atomicNumberElem)
 
G4bool BuildPhysicsVector (G4int ionZ, const G4String &matName)
 
G4bool BuildPhysicsVector (G4int ionZ, G4int matZ)
 
void ClearTable ()
 
void DumpMap ()
 
 G4IonStoppingData (const G4String &dir, G4bool icru)
 
G4double GetDEDX (G4double kinEnergyPerNucleon, G4int atomicNumberIon, const G4String &matIdentifier)
 
G4double GetDEDX (G4double kinEnergyPerNucleon, G4int atomicNumberIon, G4int atomicNumberElem)
 
G4PhysicsVectorGetPhysicsVector (G4int atomicNumberIon, const G4String &matIdenfier)
 
G4PhysicsVectorGetPhysicsVector (G4int atomicNumberIon, G4int atomicNumberElem)
 
G4bool IsApplicable (G4int atomicNumberIon, const G4String &matIdentifier)
 
G4bool IsApplicable (G4int atomicNumberIon, G4int atomicNumberElem)
 
G4bool RemovePhysicsVector (G4int atomicNumberIon, const G4String &matIdentifier)
 
G4bool RemovePhysicsVector (G4int atomicNumberIon, G4int atomicNumberElem)
 
virtual ~G4IonStoppingData ()
 

Private Types

typedef std::pair< G4int, G4intG4IonDEDXKeyElem
 
typedef std::pair< G4int, G4StringG4IonDEDXKeyMat
 
typedef std::map< G4IonDEDXKeyElem, G4PhysicsVector * > G4IonDEDXMapElem
 
typedef std::map< G4IonDEDXKeyMat, G4PhysicsVector * > G4IonDEDXMapMat
 

Private Member Functions

 G4IonStoppingData (G4IonStoppingData &)=delete
 
const G4IonStoppingDataoperator= (const G4IonStoppingData &)=delete
 

Private Attributes

G4IonDEDXMapElem dedxMapElements
 
G4IonDEDXMapMat dedxMapMaterials
 
G4bool fICRU90
 
G4String subDir
 

Detailed Description

Definition at line 59 of file G4IonStoppingData.hh.

Member Typedef Documentation

◆ G4IonDEDXKeyElem

typedef std::pair<G4int, G4int> G4IonStoppingData::G4IonDEDXKeyElem
private

Definition at line 161 of file G4IonStoppingData.hh.

◆ G4IonDEDXKeyMat

typedef std::pair<G4int, G4String> G4IonStoppingData::G4IonDEDXKeyMat
private

Definition at line 162 of file G4IonStoppingData.hh.

◆ G4IonDEDXMapElem

Definition at line 164 of file G4IonStoppingData.hh.

◆ G4IonDEDXMapMat

Definition at line 165 of file G4IonStoppingData.hh.

Constructor & Destructor Documentation

◆ G4IonStoppingData() [1/2]

G4IonStoppingData::G4IonStoppingData ( const G4String dir,
G4bool  icru 
)

Definition at line 63 of file G4IonStoppingData.cc.

63 :
64 subDir(dir), fICRU90(val) {
65}

◆ ~G4IonStoppingData()

G4IonStoppingData::~G4IonStoppingData ( )
virtual

Definition at line 69 of file G4IonStoppingData.cc.

69 {
70 ClearTable();
71}

References ClearTable().

◆ G4IonStoppingData() [2/2]

G4IonStoppingData::G4IonStoppingData ( G4IonStoppingData )
privatedelete

Member Function Documentation

◆ AddPhysicsVector() [1/2]

G4bool G4IonStoppingData::AddPhysicsVector ( G4PhysicsVector physicsVector,
G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 163 of file G4IonStoppingData.cc.

168{
169 if(physicsVector == nullptr) {
170 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material",
171 "mat037", FatalException,
172 "Pointer to vector is null-pointer.");
173 return false;
174 }
175
176 if(matIdentifier.empty()) {
177 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material",
178 "mat038", FatalException, "Invalid name of the material.");
179 return false;
180 }
181
182 if(atomicNumberIon <= 0) {
183 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material",
184 "mat039", FatalException, "Illegal atomic number.");
185 return false;
186 }
187
188 G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier);
189
190 if(dedxMapMaterials.count(mkey) == 1) {
192 ed << "Vector with Z1 = " << atomicNumberIon << ", mat = "
193 << matIdentifier
194 << "already exists. Remove first before replacing.";
195 G4Exception ("G4IonStoppingData::AddPhysicsVector() for material",
196 "mat040", FatalException, ed);
197 return false;
198 }
199
200 dedxMapMaterials[mkey] = physicsVector;
201
202 return true;
203}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
G4IonDEDXMapMat dedxMapMaterials
std::pair< G4int, G4String > G4IonDEDXKeyMat

References dedxMapMaterials, FatalException, and G4Exception().

Referenced by BuildPhysicsVector().

◆ AddPhysicsVector() [2/2]

G4bool G4IonStoppingData::AddPhysicsVector ( G4PhysicsVector physicsVector,
G4int  atomicNumberIon,
G4int  atomicNumberElem 
)

Definition at line 207 of file G4IonStoppingData.cc.

212{
213 if(physicsVector == nullptr) {
214 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat037",
215 FatalException, "Pointer to vector is null-pointer.");
216 return false;
217 }
218
219 if(atomicNumberIon <= 0) {
220 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat038",
221 FatalException, "Invalid ion number.");
222 return false;
223 }
224
225 if(atomicNumberElem <= 0) {
226 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat039",
227 FatalException, "Illegal atomic number.");
228 return false;
229 }
230
231 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
232
233 if(dedxMapElements.count(key) == 1) {
235 ed << "Vector with Z1 = " << atomicNumberIon << ", Z= "
236 << atomicNumberElem
237 << "already exists. Remove first before replacing.";
238 G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat040",
239 FatalException, ed);
240 return false;
241 }
242
243 dedxMapElements[key] = physicsVector;
244
245 return true;
246}
G4IonDEDXMapElem dedxMapElements
std::pair< G4int, G4int > G4IonDEDXKeyElem

References dedxMapElements, FatalException, and G4Exception().

◆ BuildPhysicsVector() [1/2]

G4bool G4IonStoppingData::BuildPhysicsVector ( G4int  ionZ,
const G4String matName 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 305 of file G4IonStoppingData.cc.

308 {
309
310 if( IsApplicable(atomicNumberIon, matname) ) return true;
311
312 const char* path = std::getenv("G4LEDATA");
313 if ( !path ) {
314 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat521",
315 FatalException, "G4LEDATA environment variable not set");
316 return false;
317 }
318
319 std::ostringstream file;
320 G4String ww = (fICRU90 && (matname == "G4_WATER" ||
321 matname == "G4_AIR" ||
322 matname == "G4_GRAPHITE")) ? "90" : "73";
323
324 file << path << "/" << subDir << ww << "/z"
325 << atomicNumberIon << "_" << matname << ".dat";
326 G4String fileName = G4String( file.str().c_str() );
327
328 std::ifstream ifilestream( fileName );
329
330 if ( !ifilestream.is_open() ) return false;
331
332 G4PhysicsFreeVector* physicsVector = new G4PhysicsFreeVector(true);
333
334 if( !physicsVector -> Retrieve(ifilestream, true) ) {
335
336 ifilestream.close();
337 return false;
338 }
339
340 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
341 physicsVector -> FillSecondDerivatives();
342
343 // Retrieved vector is added to material store
344 if( !AddPhysicsVector(physicsVector, atomicNumberIon, matname) ) {
345 delete physicsVector;
346 ifilestream.close();
347 return false;
348 }
349
350 ifilestream.close();
351 return true;
352}
static constexpr double cm2
Definition: G4SIunits.hh:100
static constexpr double g
Definition: G4SIunits.hh:168
static constexpr double MeV
Definition: G4SIunits.hh:200
G4bool IsApplicable(G4int atomicNumberIon, G4int atomicNumberElem)
G4bool AddPhysicsVector(G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdentifier)

References AddPhysicsVector(), cm2, FatalException, fICRU90, geant4_check_module_cycles::file, g, G4Exception(), IsApplicable(), MeV, and subDir.

◆ BuildPhysicsVector() [2/2]

G4bool G4IonStoppingData::BuildPhysicsVector ( G4int  ionZ,
G4int  matZ 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 356 of file G4IonStoppingData.cc.

360{
361 if( IsApplicable(ZIon, ZElem) ) return true;
362
363 char* path = std::getenv("G4LEDATA");
364 if ( !path ) {
365 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat522",
366 FatalException, "G4LEDATA environment variable not set");
367 return false;
368 }
369 std::ostringstream file;
370 G4String ww = (fICRU90 && ZIon <= 18 &&
371 (ZElem == 1 || ZElem == 6 ||
372 ZElem == 7 || ZElem == 8)) ? "90" : "73";
373
374 file << path << "/" << subDir << ww << "/z"
375 << ZIon << "_" << ZElem << ".dat";
376
377 G4String fileName = G4String( file.str().c_str() );
378 std::ifstream ifilestream( fileName );
379
380 if ( !ifilestream.is_open() ) return false;
381 G4PhysicsFreeVector* physicsVector = new G4PhysicsFreeVector(true);
382
383 if( !physicsVector -> Retrieve(ifilestream, true) ) {
384 ifilestream.close();
385 return false;
386 }
387
388 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
389 physicsVector -> FillSecondDerivatives();
390
391 // Retrieved vector is added to material store
392 if( !AddPhysicsVector(physicsVector, ZIon, ZElem) ) {
393 delete physicsVector;
394 ifilestream.close();
395 return false;
396 }
397
398 ifilestream.close();
399 return true;
400}

References AddPhysicsVector(), cm2, FatalException, fICRU90, geant4_check_module_cycles::file, g, G4Exception(), IsApplicable(), MeV, and subDir.

◆ ClearTable()

void G4IonStoppingData::ClearTable ( )

Definition at line 404 of file G4IonStoppingData.cc.

404 {
405
406 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
407 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
408
409 for(;iterMat != iterMat_end; iterMat++) {
410
411 G4PhysicsVector* vec = iterMat -> second;
412
413 if(vec != 0) delete vec;
414 }
415
416 dedxMapMaterials.clear();
417
418 G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin();
419 G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end();
420
421 for(;iterElem != iterElem_end; iterElem++) {
422
423 G4PhysicsVector* vec = iterElem -> second;
424
425 if(vec != 0) delete vec;
426 }
427
428 dedxMapElements.clear();
429}
static constexpr double second
Definition: G4SIunits.hh:137

References dedxMapElements, dedxMapMaterials, and second.

Referenced by ~G4IonStoppingData().

◆ DumpMap()

void G4IonStoppingData::DumpMap ( )

Definition at line 433 of file G4IonStoppingData.cc.

433 {
434
435 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
436 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
437
438 G4cout << std::setw(15) << std::right
439 << "Atomic nmb ion"
440 << std::setw(25) << std::right
441 << "Material name"
442 << G4endl;
443
444 for(;iterMat != iterMat_end; iterMat++) {
445 G4IonDEDXKeyMat key = iterMat -> first;
446 G4PhysicsVector* physicsVector = iterMat -> second;
447
448 G4int atomicNumberIon = key.first;
449 G4String matIdentifier = key.second;
450
451 if(physicsVector != 0) {
452 G4cout << std::setw(15) << std::right
453 << atomicNumberIon
454 << std::setw(25) << std::right
455 << matIdentifier
456 << G4endl;
457 }
458 }
459
460 G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin();
461 G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end();
462
463 G4cout << std::setw(15) << std::right
464 << "Atomic nmb ion"
465 << std::setw(25) << std::right
466 << "Atomic nmb material"
467 << G4endl;
468
469 for(;iterElem != iterElem_end; iterElem++) {
470 G4IonDEDXKeyElem key = iterElem -> first;
471 G4PhysicsVector* physicsVector = iterElem -> second;
472
473 G4int atomicNumberIon = key.first;
474 G4int atomicNumberElem = key.second;
475
476 if(physicsVector != 0) {
477 G4cout << std::setw(15) << std::right
478 << atomicNumberIon
479 << std::setw(25) << std::right
480 << atomicNumberElem
481 << G4endl;
482 }
483 }
484
485}
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

References dedxMapElements, dedxMapMaterials, G4cout, G4endl, and second.

◆ GetDEDX() [1/2]

G4double G4IonStoppingData::GetDEDX ( G4double  kinEnergyPerNucleon,
G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 147 of file G4IonStoppingData.cc.

152{
153 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
154
155 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
156
157 return (iter != dedxMapMaterials.end()) ?
158 (iter->second)->Value(kinEnergyPerNucleon) : 0.0;
159}

References dedxMapMaterials.

◆ GetDEDX() [2/2]

G4double G4IonStoppingData::GetDEDX ( G4double  kinEnergyPerNucleon,
G4int  atomicNumberIon,
G4int  atomicNumberElem 
)

Definition at line 131 of file G4IonStoppingData.cc.

136{
137 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
138
139 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
140
141 return ( iter != dedxMapElements.end()) ?
142 (iter->second)->Value( kinEnergyPerNucleon) : 0.0;
143}

References dedxMapElements.

◆ GetPhysicsVector() [1/2]

G4PhysicsVector * G4IonStoppingData::GetPhysicsVector ( G4int  atomicNumberIon,
const G4String matIdenfier 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 117 of file G4IonStoppingData.cc.

121{
122 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
123
124 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
125
126 return (iter != dedxMapMaterials.end()) ? iter->second : nullptr;
127}

References dedxMapMaterials.

◆ GetPhysicsVector() [2/2]

G4PhysicsVector * G4IonStoppingData::GetPhysicsVector ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 103 of file G4IonStoppingData.cc.

107{
108 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
109
110 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
111
112 return (iter != dedxMapElements.end()) ? iter->second : nullptr;
113}

References dedxMapElements.

◆ IsApplicable() [1/2]

G4bool G4IonStoppingData::IsApplicable ( G4int  atomicNumberIon,
const G4String matIdentifier 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 89 of file G4IonStoppingData.cc.

93{
94 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
95
96 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
97
98 return (iter == dedxMapMaterials.end()) ? false : true;
99}

References dedxMapMaterials.

◆ IsApplicable() [2/2]

G4bool G4IonStoppingData::IsApplicable ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 75 of file G4IonStoppingData.cc.

79{
80 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
81
82 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
83
84 return (iter == dedxMapElements.end()) ? false : true;
85}

References dedxMapElements.

Referenced by BuildPhysicsVector().

◆ operator=()

const G4IonStoppingData & G4IonStoppingData::operator= ( const G4IonStoppingData )
privatedelete

◆ RemovePhysicsVector() [1/2]

G4bool G4IonStoppingData::RemovePhysicsVector ( G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 250 of file G4IonStoppingData.cc.

253 {
254
255 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
256
257 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
258
259 if(iter == dedxMapMaterials.end()) {
260 G4Exception ("G4IonStoppingData::RemovePhysicsVector() for material",
261 "mat038", FatalException, "Invalid name of the material.");
262 return false;
263 }
264
265 G4PhysicsVector* physicsVector = (*iter).second;
266
267 // Deleting key of physics vector from material map
268 dedxMapMaterials.erase(key);
269
270 // Deleting physics vector
271 delete physicsVector;
272
273 return true;
274}

References dedxMapMaterials, FatalException, and G4Exception().

◆ RemovePhysicsVector() [2/2]

G4bool G4IonStoppingData::RemovePhysicsVector ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)

Definition at line 278 of file G4IonStoppingData.cc.

281 {
282 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
283
284 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
285
286 if(iter == dedxMapElements.end()) {
287 G4Exception ("G4IonStoppingData::RemovePhysicsVector() for element",
288 "mat038", FatalException, "Invalid element.");
289 return false;
290 }
291
292 G4PhysicsVector* physicsVector = (*iter).second;
293
294 // Deleting key of physics vector from material map
295 dedxMapElements.erase(key);
296
297 // Deleting physics vector
298 delete physicsVector;
299
300 return true;
301}

References dedxMapElements, FatalException, and G4Exception().

Field Documentation

◆ dedxMapElements

G4IonDEDXMapElem G4IonStoppingData::dedxMapElements
private

◆ dedxMapMaterials

G4IonDEDXMapMat G4IonStoppingData::dedxMapMaterials
private

◆ fICRU90

G4bool G4IonStoppingData::fICRU90
private

Definition at line 170 of file G4IonStoppingData.hh.

Referenced by BuildPhysicsVector().

◆ subDir

G4String G4IonStoppingData::subDir
private

Definition at line 159 of file G4IonStoppingData.hh.

Referenced by BuildPhysicsVector().


The documentation for this class was generated from the following files: