Geant4 11.2.2
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
 
 G4IonStoppingData (G4IonStoppingData &)=delete
 
const G4IonStoppingDataoperator= (const G4IonStoppingData &)=delete
 
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
 
 G4VIonDEDXTable (G4VIonDEDXTable &)=delete
 
const G4VIonDEDXTableoperator= (const G4VIonDEDXTable &)=delete
 

Detailed Description

Definition at line 57 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: subDir(dir), fICRU90(val) {}

◆ ~G4IonStoppingData()

G4IonStoppingData::~G4IonStoppingData ( )
override

Definition at line 67 of file G4IonStoppingData.cc.

◆ G4IonStoppingData() [2/2]

G4IonStoppingData::G4IonStoppingData ( G4IonStoppingData & )
delete

Member Function Documentation

◆ AddPhysicsVector() [1/2]

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

Definition at line 151 of file G4IonStoppingData.cc.

155{
156 if (physicsVector == nullptr) {
157 G4Exception("G4IonStoppingData::AddPhysicsVector() for material", "mat037", FatalException,
158 "Pointer to vector is null-pointer.");
159 return false;
160 }
161
162 if (matIdentifier.empty()) {
163 G4Exception("G4IonStoppingData::AddPhysicsVector() for material", "mat038", FatalException,
164 "Invalid name of the material.");
165 return false;
166 }
167
168 if (atomicNumberIon <= 0) {
169 G4Exception("G4IonStoppingData::AddPhysicsVector() for material", "mat039", FatalException,
170 "Illegal atomic number.");
171 return false;
172 }
173
174 G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier);
175
176 if (dedxMapMaterials.count(mkey) == 1) {
178 ed << "Vector with Z1 = " << atomicNumberIon << ", mat = " << matIdentifier
179 << "already exists. Remove first before replacing.";
180 G4Exception("G4IonStoppingData::AddPhysicsVector() for material", "mat040", FatalException, ed);
181 return false;
182 }
183
184 dedxMapMaterials[mkey] = physicsVector;
185
186 return true;
187}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription

Referenced by BuildPhysicsVector(), and BuildPhysicsVector().

◆ AddPhysicsVector() [2/2]

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

Definition at line 191 of file G4IonStoppingData.cc.

195{
196 if (physicsVector == nullptr) {
197 G4Exception("G4IonStoppingData::AddPhysicsVector() for element", "mat037", FatalException,
198 "Pointer to vector is null-pointer.");
199 return false;
200 }
201
202 if (atomicNumberIon <= 0) {
203 G4Exception("G4IonStoppingData::AddPhysicsVector() for element", "mat038", FatalException,
204 "Invalid ion number.");
205 return false;
206 }
207
208 if (atomicNumberElem <= 0) {
209 G4Exception("G4IonStoppingData::AddPhysicsVector() for element", "mat039", FatalException,
210 "Illegal atomic number.");
211 return false;
212 }
213
214 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
215
216 if (dedxMapElements.count(key) == 1) {
218 ed << "Vector with Z1 = " << atomicNumberIon << ", Z= " << atomicNumberElem
219 << "already exists. Remove first before replacing.";
220 G4Exception("G4IonStoppingData::AddPhysicsVector() for element", "mat040", FatalException, ed);
221 return false;
222 }
223
224 dedxMapElements[key] = physicsVector;
225
226 return true;
227}

◆ BuildPhysicsVector() [1/2]

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

Implements G4VIonDEDXTable.

Definition at line 285 of file G4IonStoppingData.cc.

288{
289 if (IsApplicable(atomicNumberIon, matname)) {
290 return true;
291 }
292
293 const char* path = G4FindDataDir("G4LEDATA");
294 if (path == nullptr) {
295 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat521", FatalException,
296 "G4LEDATA environment variable not set");
297 return false;
298 }
299
300 std::ostringstream file;
301 G4String ww =
302 (fICRU90 && (matname == "G4_WATER" || matname == "G4_AIR" || matname == "G4_GRAPHITE")) ? "90"
303 : "73";
304
305 file << path << "/" << subDir << ww << "/z" << atomicNumberIon << "_" << matname << ".dat";
306 G4String fileName = G4String(file.str().c_str());
307
308 std::ifstream ifilestream(fileName);
309
310 if (! ifilestream.is_open()) {
311 return false;
312 }
313
314 auto* physicsVector = new G4PhysicsFreeVector(true);
315
316 if (! physicsVector->Retrieve(ifilestream, true)) {
317 ifilestream.close();
318 return false;
319 }
320
321 physicsVector->ScaleVector(MeV, MeV * cm2 / (0.001 * g));
322 physicsVector->FillSecondDerivatives();
323
324 // Retrieved vector is added to material store
325 if (! AddPhysicsVector(physicsVector, atomicNumberIon, matname)) {
326 delete physicsVector;
327 ifilestream.close();
328 return false;
329 }
330
331 ifilestream.close();
332 return true;
333}
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 337 of file G4IonStoppingData.cc.

340{
341 if (IsApplicable(ZIon, ZElem)) {
342 return true;
343 }
344
345 const char* path = G4FindDataDir("G4LEDATA");
346 if (path == nullptr) {
347 G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat522", FatalException,
348 "G4LEDATA environment variable not set");
349 return false;
350 }
351 std::ostringstream file;
352 G4String ww =
353 (fICRU90 && ZIon <= 18 && (ZElem == 1 || ZElem == 6 || ZElem == 7 || ZElem == 8)) ? "90" : "73";
354
355 file << path << "/" << subDir << ww << "/z" << ZIon << "_" << ZElem << ".dat";
356
357 G4String fileName = G4String(file.str().c_str());
358 std::ifstream ifilestream(fileName);
359
360 if (! ifilestream.is_open()) {
361 return false;
362 }
363 auto* physicsVector = new G4PhysicsFreeVector(true);
364
365 if (! physicsVector->Retrieve(ifilestream, true)) {
366 ifilestream.close();
367 return false;
368 }
369
370 physicsVector->ScaleVector(MeV, MeV * cm2 / (0.001 * g));
371 physicsVector->FillSecondDerivatives();
372
373 // Retrieved vector is added to material store
374 if (! AddPhysicsVector(physicsVector, ZIon, ZElem)) {
375 delete physicsVector;
376 ifilestream.close();
377 return false;
378 }
379
380 ifilestream.close();
381 return true;
382}

◆ ClearTable()

void G4IonStoppingData::ClearTable ( )

Definition at line 386 of file G4IonStoppingData.cc.

387{
388 auto iterMat = dedxMapMaterials.begin();
389 auto iterMat_end = dedxMapMaterials.end();
390
391 for (; iterMat != iterMat_end; iterMat++) {
392 G4PhysicsVector* vec = iterMat->second;
393
394 delete vec;
395 }
396
397 dedxMapMaterials.clear();
398
399 auto iterElem = dedxMapElements.begin();
400 auto iterElem_end = dedxMapElements.end();
401
402 for (; iterElem != iterElem_end; iterElem++) {
403 G4PhysicsVector* vec = iterElem->second;
404
405 delete vec;
406 }
407
408 dedxMapElements.clear();
409}

Referenced by ~G4IonStoppingData().

◆ DumpMap()

void G4IonStoppingData::DumpMap ( )

Definition at line 413 of file G4IonStoppingData.cc.

414{
415 auto iterMat = dedxMapMaterials.begin();
416 auto iterMat_end = dedxMapMaterials.end();
417
418 G4cout << std::setw(15) << std::right << "Atomic nmb ion" << std::setw(25) << std::right
419 << "Material name" << G4endl;
420
421 for (; iterMat != iterMat_end; iterMat++) {
422 G4IonDEDXKeyMat key = iterMat->first;
423 G4PhysicsVector* physicsVector = iterMat->second;
424
425 G4int atomicNumberIon = key.first;
426 G4String matIdentifier = key.second;
427
428 if (physicsVector != nullptr) {
429 G4cout << std::setw(15) << std::right << atomicNumberIon << std::setw(25) << std::right
430 << matIdentifier << G4endl;
431 }
432 }
433
434 auto iterElem = dedxMapElements.begin();
435 auto iterElem_end = dedxMapElements.end();
436
437 G4cout << std::setw(15) << std::right << "Atomic nmb ion" << std::setw(25) << std::right
438 << "Atomic nmb material" << G4endl;
439
440 for (; iterElem != iterElem_end; iterElem++) {
441 G4IonDEDXKeyElem key = iterElem->first;
442 G4PhysicsVector* physicsVector = iterElem->second;
443
444 G4int atomicNumberIon = key.first;
445 G4int atomicNumberElem = key.second;
446
447 if (physicsVector != nullptr) {
448 G4cout << std::setw(15) << std::right << atomicNumberIon << std::setw(25) << std::right
449 << atomicNumberElem << G4endl;
450 }
451 }
452}
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

◆ GetDEDX() [1/2]

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

Definition at line 137 of file G4IonStoppingData.cc.

141{
142 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
143
144 auto iter = dedxMapMaterials.find(key);
145
146 return (iter != dedxMapMaterials.end()) ? (iter->second)->Value(kinEnergyPerNucleon) : 0.0;
147}

◆ GetDEDX() [2/2]

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

Definition at line 123 of file G4IonStoppingData.cc.

127{
128 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
129
130 auto iter = dedxMapElements.find(key);
131
132 return (iter != dedxMapElements.end()) ? (iter->second)->Value(kinEnergyPerNucleon) : 0.0;
133}

◆ GetPhysicsVector() [1/2]

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

Implements G4VIonDEDXTable.

Definition at line 110 of file G4IonStoppingData.cc.

113{
114 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
115
116 auto iter = dedxMapMaterials.find(key);
117
118 return (iter != dedxMapMaterials.end()) ? iter->second : nullptr;
119}

◆ GetPhysicsVector() [2/2]

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

Implements G4VIonDEDXTable.

Definition at line 97 of file G4IonStoppingData.cc.

100{
101 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
102
103 auto iter = dedxMapElements.find(key);
104
105 return (iter != dedxMapElements.end()) ? iter->second : nullptr;
106}

◆ IsApplicable() [1/2]

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

Implements G4VIonDEDXTable.

Definition at line 84 of file G4IonStoppingData.cc.

87{
88 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
89
90 auto iter = dedxMapMaterials.find(key);
91
92 return iter != dedxMapMaterials.end();
93}

◆ IsApplicable() [2/2]

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

Implements G4VIonDEDXTable.

Definition at line 71 of file G4IonStoppingData.cc.

74{
75 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
76
77 auto iter = dedxMapElements.find(key);
78
79 return iter != dedxMapElements.end();
80}

Referenced by BuildPhysicsVector(), and BuildPhysicsVector().

◆ operator=()

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

◆ RemovePhysicsVector() [1/2]

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

Definition at line 231 of file G4IonStoppingData.cc.

234{
235 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
236
237 auto iter = dedxMapMaterials.find(key);
238
239 if (iter == dedxMapMaterials.end()) {
240 G4Exception("G4IonStoppingData::RemovePhysicsVector() for material", "mat038", FatalException,
241 "Invalid name of the material.");
242 return false;
243 }
244
245 G4PhysicsVector* physicsVector = (*iter).second;
246
247 // Deleting key of physics vector from material map
248 dedxMapMaterials.erase(key);
249
250 // Deleting physics vector
251 delete physicsVector;
252
253 return true;
254}

◆ RemovePhysicsVector() [2/2]

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

Definition at line 258 of file G4IonStoppingData.cc.

261{
262 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
263
264 auto iter = dedxMapElements.find(key);
265
266 if (iter == dedxMapElements.end()) {
267 G4Exception("G4IonStoppingData::RemovePhysicsVector() for element", "mat038", FatalException,
268 "Invalid element.");
269 return false;
270 }
271
272 G4PhysicsVector* physicsVector = (*iter).second;
273
274 // Deleting key of physics vector from material map
275 dedxMapElements.erase(key);
276
277 // Deleting physics vector
278 delete physicsVector;
279
280 return true;
281}

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