Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4IonStoppingData Class Reference

#include <G4IonStoppingData.hh>

Inheritance diagram for G4IonStoppingData:
Collaboration diagram for G4IonStoppingData:

Public Member Functions

 G4IonStoppingData (const G4String &leDirectory)
 
virtual ~G4IonStoppingData ()
 
G4bool IsApplicable (G4int atomicNumberIon, G4int atomicNumberElem)
 
G4bool IsApplicable (G4int atomicNumberIon, const G4String &matIdentifier)
 
G4bool BuildPhysicsVector (G4int ionZ, const G4String &matName)
 
G4bool BuildPhysicsVector (G4int ionZ, G4int matZ)
 
G4PhysicsVectorGetPhysicsVector (G4int atomicNumberIon, G4int atomicNumberElem)
 
G4PhysicsVectorGetPhysicsVector (G4int atomicNumberIon, const G4String &matIdenfier)
 
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 ()
 
virtual ~G4VIonDEDXTable ()
 

Detailed Description

Definition at line 60 of file G4IonStoppingData.hh.

Constructor & Destructor Documentation

G4IonStoppingData::G4IonStoppingData ( const G4String leDirectory)

Definition at line 64 of file G4IonStoppingData.cc.

64  :
65  subDir( leDirectory ) {
66 
67 }
G4IonStoppingData::~G4IonStoppingData ( )
virtual

Definition at line 71 of file G4IonStoppingData.cc.

71  {
72 
73  ClearTable();
74 }

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 166 of file G4IonStoppingData.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 210 of file G4IonStoppingData.cc.

215 {
216  if(physicsVector == nullptr) {
217  G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat037",
218  FatalException, "Pointer to vector is null-pointer.");
219  return false;
220  }
221 
222  if(atomicNumberIon <= 0) {
223  G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat038",
224  FatalException, "Invalid ion number.");
225  return false;
226  }
227 
228  if(atomicNumberElem <= 0) {
229  G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat039",
230  FatalException, "Illegal atomic number.");
231  return false;
232  }
233 
234  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
235 
236  if(dedxMapElements.count(key) == 1) {
238  ed << "Vector with Z1 = " << atomicNumberIon << ", Z= "
239  << atomicNumberElem
240  << "already exists. Remove first before replacing.";
241  G4Exception ("G4IonStoppingData::AddPhysicsVector() for element", "mat040",
242  FatalException, ed);
243  return false;
244  }
245 
246  dedxMapElements[key] = physicsVector;
247 
248  return true;
249 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

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

Implements G4VIonDEDXTable.

Definition at line 308 of file G4IonStoppingData.cc.

311  {
312 
313  if( IsApplicable(atomicNumberIon, matIdentifier) ) return true;
314 
315  char* path = getenv("G4LEDATA");
316  if ( !path ) {
317  G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat521",
318  FatalException, "G4LEDATA environment variable not set");
319  return false;
320  }
321 
322  std::ostringstream file;
323 
324  file << path << "/" << subDir << "/z"
325  << atomicNumberIon << "_" << matIdentifier
326  << ".dat";
327 
328  G4String fileName = G4String( file.str().c_str() );
329 
330  std::ifstream ifilestream( fileName );
331 
332  if ( !ifilestream.is_open() ) return false;
333 
334  G4LPhysicsFreeVector* physicsVector = new G4LPhysicsFreeVector();
335 
336  if( !physicsVector -> Retrieve(ifilestream, true) ) {
337 
338  ifilestream.close();
339  return false;
340  }
341 
342  physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
343  physicsVector -> SetSpline( true );
344  physicsVector -> FillSecondDerivatives();
345 
346  // Retrieved vector is added to material store
347  if( !AddPhysicsVector(physicsVector, atomicNumberIon, matIdentifier) ) {
348  delete physicsVector;
349  ifilestream.close();
350  return false;
351  }
352 
353  ifilestream.close();
354  return true;
355 }
static constexpr double cm2
Definition: G4SIunits.hh:120
G4bool AddPhysicsVector(G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdentifier)
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
G4bool IsApplicable(G4int atomicNumberIon, G4int atomicNumberElem)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static constexpr double MeV
Definition: G4SIunits.hh:214

Here is the call graph for this function:

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

Implements G4VIonDEDXTable.

Definition at line 359 of file G4IonStoppingData.cc.

363 {
364  if( IsApplicable(atomicNumberIon, atomicNumberElem) ) return true;
365 
366  char* path = getenv("G4LEDATA");
367  if ( !path ) {
368  G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat522",
369  FatalException, "G4LEDATA environment variable not set");
370  return false;
371  }
372  std::ostringstream file;
373 
374  file << path << "/" << subDir << "/z"
375  << atomicNumberIon << "_" << atomicNumberElem
376  << ".dat";
377 
378  G4String fileName = G4String( file.str().c_str() );
379 
380  std::ifstream ifilestream( fileName );
381 
382  if ( !ifilestream.is_open() ) return false;
383 
384  G4LPhysicsFreeVector* physicsVector = new G4LPhysicsFreeVector();
385 
386  if( !physicsVector -> Retrieve(ifilestream, true) ) {
387 
388  ifilestream.close();
389  return false;
390  }
391 
392  physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
393  physicsVector -> SetSpline( true );
394  physicsVector -> FillSecondDerivatives();
395 
396  // Retrieved vector is added to material store
397  if( !AddPhysicsVector(physicsVector, atomicNumberIon, atomicNumberElem) ) {
398  delete physicsVector;
399  ifilestream.close();
400  return false;
401  }
402 
403  ifilestream.close();
404  return true;
405 }
static constexpr double cm2
Definition: G4SIunits.hh:120
G4bool AddPhysicsVector(G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdentifier)
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
G4bool IsApplicable(G4int atomicNumberIon, G4int atomicNumberElem)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static constexpr double MeV
Definition: G4SIunits.hh:214

Here is the call graph for this function:

void G4IonStoppingData::ClearTable ( )

Definition at line 409 of file G4IonStoppingData.cc.

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

Here is the caller graph for this function:

void G4IonStoppingData::DumpMap ( )

Definition at line 438 of file G4IonStoppingData.cc.

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

Definition at line 134 of file G4IonStoppingData.cc.

139 {
140  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
141 
142  G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
143 
144  return ( iter != dedxMapElements.end()) ?
145  (iter->second)->Value( kinEnergyPerNucleon) : 0.0;
146 }
G4double G4IonStoppingData::GetDEDX ( G4double  kinEnergyPerNucleon,
G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 150 of file G4IonStoppingData.cc.

155 {
156  G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
157 
158  G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
159 
160  return (iter != dedxMapMaterials.end()) ?
161  (iter->second)->Value(kinEnergyPerNucleon) : 0.0;
162 }
G4PhysicsVector * G4IonStoppingData::GetPhysicsVector ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 106 of file G4IonStoppingData.cc.

110 {
111  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
112 
113  G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
114 
115  return (iter != dedxMapElements.end()) ? iter->second : nullptr;
116 }
G4PhysicsVector * G4IonStoppingData::GetPhysicsVector ( G4int  atomicNumberIon,
const G4String matIdenfier 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 120 of file G4IonStoppingData.cc.

124 {
125  G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
126 
127  G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
128 
129  return (iter != dedxMapMaterials.end()) ? iter->second : nullptr;
130 }
G4bool G4IonStoppingData::IsApplicable ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 78 of file G4IonStoppingData.cc.

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

Here is the caller graph for this function:

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

Implements G4VIonDEDXTable.

Definition at line 92 of file G4IonStoppingData.cc.

96 {
97  G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
98 
99  G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
100 
101  return (iter == dedxMapMaterials.end()) ? false : true;
102 }
G4bool G4IonStoppingData::RemovePhysicsVector ( G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 253 of file G4IonStoppingData.cc.

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

Here is the call graph for this function:

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

Definition at line 281 of file G4IonStoppingData.cc.

284  {
285  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
286 
287  G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
288 
289  if(iter == dedxMapElements.end()) {
290  G4Exception ("G4IonStoppingData::RemovePhysicsVector() for element",
291  "mat038", FatalException, "Invalid element.");
292  return false;
293  }
294 
295  G4PhysicsVector* physicsVector = (*iter).second;
296 
297  // Deleting key of physics vector from material map
298  dedxMapElements.erase(key);
299 
300  // Deleting physics vector
301  delete physicsVector;
302 
303  return true;
304 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:


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