Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4IonStoppingData Class Reference

#include <G4IonStoppingData.hh>

+ Inheritance diagram for G4IonStoppingData:

Public Member Functions

 G4IonStoppingData (const G4String &dir, G4bool icru)
 
 ~G4IonStoppingData () override
 
G4bool IsApplicable (G4int atomicNumberIon, G4int atomicNumberElem) override
 
G4bool IsApplicable (G4int atomicNumberIon, const G4String &matIdentifier) override
 
G4bool BuildPhysicsVector (G4int ionZ, const G4String &matName) override
 
G4bool BuildPhysicsVector (G4int ionZ, G4int matZ) override
 
G4PhysicsVectorGetPhysicsVector (G4int atomicNumberIon, G4int atomicNumberElem) override
 
G4PhysicsVectorGetPhysicsVector (G4int atomicNumberIon, const G4String &matIdenfier) override
 
G4double GetDEDX (G4double kinEnergyPerNucleon, G4int atomicNumberIon, G4int atomicNumberElem)
 
G4double GetDEDX (G4double kinEnergyPerNucleon, G4int atomicNumberIon, const G4String &matIdentifier)
 
G4bool AddPhysicsVector (G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdentifier)
 
G4bool AddPhysicsVector (G4PhysicsVector *physicsVector, G4int atomicNumberIon, G4int atomicNumberElem)
 
G4bool RemovePhysicsVector (G4int atomicNumberIon, const G4String &matIdentifier)
 
G4bool RemovePhysicsVector (G4int atomicNumberIon, G4int atomicNumberElem)
 
void ClearTable ()
 
void DumpMap ()
 
- Public Member Functions inherited from G4VIonDEDXTable
 G4VIonDEDXTable ()=default
 
virtual ~G4VIonDEDXTable ()=default
 
virtual G4bool BuildPhysicsVector (G4int, G4int)=0
 
virtual G4bool BuildPhysicsVector (G4int, const G4String &)=0
 
virtual G4bool IsApplicable (G4int, G4int)=0
 
virtual G4bool IsApplicable (G4int, const G4String &)=0
 
virtual G4PhysicsVectorGetPhysicsVector (G4int, G4int)=0
 
virtual G4PhysicsVectorGetPhysicsVector (G4int, const G4String &)=0
 
 G4VIonDEDXTable (G4VIonDEDXTable &)=delete
 
const G4VIonDEDXTableoperator= (const G4VIonDEDXTable &)=delete
 

Detailed Description

Definition at line 59 of file G4IonStoppingData.hh.

Constructor & Destructor Documentation

◆ G4IonStoppingData()

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 ( )
override

Definition at line 69 of file G4IonStoppingData.cc.

69 {
70 ClearTable();
71}

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:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40

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}

◆ BuildPhysicsVector() [1/2]

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

Implements G4VIonDEDXTable.

Definition at line 305 of file G4IonStoppingData.cc.

308 {
309 if(IsApplicable(atomicNumberIon, matname))
310 {
311 return true;
312 }
313
314 const char* path = G4FindDataDir("G4LEDATA");
315 if(path == nullptr)
316 {
317 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat521",
318 FatalException, "G4LEDATA environment variable not set");
319 return false;
320 }
321
322 std::ostringstream file;
323 G4String ww = (fICRU90 && (matname == "G4_WATER" ||
324 matname == "G4_AIR" ||
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() );
330
331 std::ifstream ifilestream( fileName );
332
333 if(!ifilestream.is_open())
334 {
335 return false;
336 }
337
338 auto* physicsVector = new G4PhysicsFreeVector(true);
339
340 if( !physicsVector -> Retrieve(ifilestream, true) ) {
341
342 ifilestream.close();
343 return false;
344 }
345
346 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
347 physicsVector -> FillSecondDerivatives();
348
349 // Retrieved vector is added to material store
350 if( !AddPhysicsVector(physicsVector, atomicNumberIon, matname) ) {
351 delete physicsVector;
352 ifilestream.close();
353 return false;
354 }
355
356 ifilestream.close();
357 return true;
358}
const char * G4FindDataDir(const char *)
G4bool IsApplicable(G4int atomicNumberIon, G4int atomicNumberElem) override
G4bool AddPhysicsVector(G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdentifier)

◆ BuildPhysicsVector() [2/2]

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

Implements G4VIonDEDXTable.

Definition at line 362 of file G4IonStoppingData.cc.

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

◆ ClearTable()

void G4IonStoppingData::ClearTable ( )

Definition at line 417 of file G4IonStoppingData.cc.

417 {
418 auto iterMat = dedxMapMaterials.begin();
419 auto iterMat_end = dedxMapMaterials.end();
420
421 for(;iterMat != iterMat_end; iterMat++) {
422
423 G4PhysicsVector* vec = iterMat -> second;
424
425 delete vec;
426 }
427
428 dedxMapMaterials.clear();
429
430 auto iterElem = dedxMapElements.begin();
431 auto iterElem_end = dedxMapElements.end();
432
433 for(;iterElem != iterElem_end; iterElem++) {
434
435 G4PhysicsVector* vec = iterElem -> second;
436
437 delete vec;
438 }
439
440 dedxMapElements.clear();
441}

Referenced by ~G4IonStoppingData().

◆ DumpMap()

void G4IonStoppingData::DumpMap ( )

Definition at line 445 of file G4IonStoppingData.cc.

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

◆ 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 auto iter = dedxMapMaterials.find(key);
156
157 return (iter != dedxMapMaterials.end()) ?
158 (iter->second)->Value(kinEnergyPerNucleon) : 0.0;
159}

◆ 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 auto iter = dedxMapElements.find(key);
140
141 return ( iter != dedxMapElements.end()) ?
142 (iter->second)->Value( kinEnergyPerNucleon) : 0.0;
143}

◆ GetPhysicsVector() [1/2]

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

Implements G4VIonDEDXTable.

Definition at line 117 of file G4IonStoppingData.cc.

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

◆ GetPhysicsVector() [2/2]

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

Implements G4VIonDEDXTable.

Definition at line 103 of file G4IonStoppingData.cc.

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

◆ IsApplicable() [1/2]

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

Implements G4VIonDEDXTable.

Definition at line 89 of file G4IonStoppingData.cc.

93{
94 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
95
96 auto iter = dedxMapMaterials.find(key);
97
98 return iter != dedxMapMaterials.end();
99}

◆ IsApplicable() [2/2]

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

Implements G4VIonDEDXTable.

Definition at line 75 of file G4IonStoppingData.cc.

79{
80 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
81
82 auto iter = dedxMapElements.find(key);
83
84 return iter != dedxMapElements.end();
85}

Referenced by BuildPhysicsVector().

◆ 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 auto 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}

◆ 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 auto 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}

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