Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4IonStoppingData Class Reference

#include <G4IonStoppingData.hh>

Inheritance diagram for G4IonStoppingData:
G4VIonDEDXTable

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 }

Member Function Documentation

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

Definition at line 192 of file G4IonStoppingData.cc.

References G4cerr, and G4endl.

Referenced by BuildPhysicsVector().

196  {
197 
198  if(physicsVector == 0) {
199 
200 #ifdef G4VERBOSE
201  G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: Pointer to vector"
202  << " is null-pointer."
203  << G4endl;
204 #endif
205 
206  return false;
207  }
208 
209  if(matIdentifier.empty()) {
210 
211 #ifdef G4VERBOSE
212  G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
213  << "Cannot add physics vector. Invalid name."
214  << G4endl;
215 #endif
216 
217  return false;
218  }
219 
220  if(atomicNumberIon <= 0) {
221 
222 #ifdef G4VERBOSE
223  G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
224  << "Cannot add physics vector. Illegal atomic number."
225  << G4endl;
226 #endif
227 
228  return false;
229  }
230 
231  G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier);
232 
233  if(dedxMapMaterials.count(mkey) == 1) {
234 
235 #ifdef G4VERBOSE
236  G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
237  << "Vector with Z1 = " << atomicNumberIon << ", mat = "
238  << matIdentifier
239  << "already exists. Remove first before replacing."
240  << G4endl;
241 #endif
242 
243  return false;
244  }
245 
246  dedxMapMaterials[mkey] = physicsVector;
247 
248  return true;
249 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
G4bool G4IonStoppingData::AddPhysicsVector ( G4PhysicsVector physicsVector,
G4int  atomicNumberIon,
G4int  atomicNumberElem 
)

Definition at line 253 of file G4IonStoppingData.cc.

References G4cerr, and G4endl.

257  {
258 
259  if(physicsVector == 0) {
260 
261 #ifdef G4VERBOSE
262  G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
263  << "Pointer to vector is null-pointer."
264  << G4endl;
265 #endif
266 
267  return false;
268  }
269 
270  if(atomicNumberIon <= 0) {
271 
272 #ifdef G4VERBOSE
273  G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
274  << "Cannot add physics vector. Illegal atomic number."
275  << G4endl;
276 #endif
277 
278  return false;
279  }
280 
281  if(atomicNumberElem <= 0) {
282 
283 #ifdef G4VERBOSE
284  G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
285  << "Atomic number of element < 0."
286  << G4endl;
287 #endif
288  return false;
289  }
290 
291  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
292 
293  if(dedxMapElements.count(key) == 1) {
294 
295 #ifdef G4VERBOSE
296  G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
297  << "Vector with Z1 = " << atomicNumberIon << ", Z2 = "
298  << atomicNumberElem
299  << " already exists. Remove first before replacing."
300  << G4endl;
301 #endif
302  return false;
303  }
304 
305  dedxMapElements[key] = physicsVector;
306 
307  return true;
308 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
G4bool G4IonStoppingData::BuildPhysicsVector ( G4int  ionZ,
const G4String matName 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 377 of file G4IonStoppingData.cc.

References AddPhysicsVector(), python.hepunit::cm2, FatalException, g(), G4Exception(), IsApplicable(), and python.hepunit::MeV.

380  {
381 
382  if( IsApplicable(atomicNumberIon, matIdentifier) ) return true;
383 
384  char* path = getenv("G4LEDATA");
385  if ( !path ) {
386  G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat521",
387  FatalException, "G4LEDATA environment variable not set");
388  return false;
389  }
390 
391  std::ostringstream file;
392 
393  file << path << "/" << subDir << "/z"
394  << atomicNumberIon << "_" << matIdentifier
395  << ".dat";
396 
397  G4String fileName = G4String( file.str().c_str() );
398 
399  std::ifstream ifilestream( fileName );
400 
401  if ( !ifilestream.is_open() ) return false;
402 
403  G4LPhysicsFreeVector* physicsVector = new G4LPhysicsFreeVector();
404 
405  if( !physicsVector -> Retrieve(ifilestream, true) ) {
406 
407  ifilestream.close();
408  return false;
409  }
410 
411  physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
412  physicsVector -> SetSpline( true );
413  physicsVector -> FillSecondDerivatives();
414 
415  // Retrieved vector is added to material store
416  if( !AddPhysicsVector(physicsVector, atomicNumberIon, matIdentifier) ) {
417  delete physicsVector;
418  ifilestream.close();
419  return false;
420  }
421 
422  ifilestream.close();
423  return true;
424 }
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
G4bool G4IonStoppingData::BuildPhysicsVector ( G4int  ionZ,
G4int  matZ 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 428 of file G4IonStoppingData.cc.

References AddPhysicsVector(), python.hepunit::cm2, FatalException, g(), G4Exception(), IsApplicable(), and python.hepunit::MeV.

431  {
432 
433  if( IsApplicable(atomicNumberIon, atomicNumberElem) ) return true;
434 
435  char* path = getenv("G4LEDATA");
436  if ( !path ) {
437  G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat522",
438  FatalException, "G4LEDATA environment variable not set");
439  return false;
440  }
441  std::ostringstream file;
442 
443  file << path << "/" << subDir << "/z"
444  << atomicNumberIon << "_" << atomicNumberElem
445  << ".dat";
446 
447  G4String fileName = G4String( file.str().c_str() );
448 
449  std::ifstream ifilestream( fileName );
450 
451  if ( !ifilestream.is_open() ) return false;
452 
453  G4LPhysicsFreeVector* physicsVector = new G4LPhysicsFreeVector();
454 
455  if( !physicsVector -> Retrieve(ifilestream, true) ) {
456 
457  ifilestream.close();
458  return false;
459  }
460 
461  physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
462  physicsVector -> SetSpline( true );
463  physicsVector -> FillSecondDerivatives();
464 
465  // Retrieved vector is added to material store
466  if( !AddPhysicsVector(physicsVector, atomicNumberIon, atomicNumberElem) ) {
467  delete physicsVector;
468  ifilestream.close();
469  return false;
470  }
471 
472  ifilestream.close();
473  return true;
474 }
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
void G4IonStoppingData::ClearTable ( )

Definition at line 478 of file G4IonStoppingData.cc.

References python.hepunit::second.

478  {
479 
480  G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
481  G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
482 
483  for(;iterMat != iterMat_end; iterMat++) {
484 
485  G4PhysicsVector* vec = iterMat -> second;
486 
487  if(vec != 0) delete vec;
488  }
489 
490  dedxMapMaterials.clear();
491 
492  G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin();
493  G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end();
494 
495  for(;iterElem != iterElem_end; iterElem++) {
496 
497  G4PhysicsVector* vec = iterElem -> second;
498 
499  if(vec != 0) delete vec;
500  }
501 
502  dedxMapElements.clear();
503 }
void G4IonStoppingData::DumpMap ( )

Definition at line 507 of file G4IonStoppingData.cc.

References G4cout, G4endl, right, and python.hepunit::second.

507  {
508 
509  G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
510  G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
511 
512  G4cout << std::setw(15) << std::right
513  << "Atomic nmb ion"
514  << std::setw(25) << std::right
515  << "Material name"
516  << G4endl;
517 
518  for(;iterMat != iterMat_end; iterMat++) {
519  G4IonDEDXKeyMat key = iterMat -> first;
520  G4PhysicsVector* physicsVector = iterMat -> second;
521 
522  G4int atomicNumberIon = key.first;
523  G4String matIdentifier = key.second;
524 
525  if(physicsVector != 0) {
526  G4cout << std::setw(15) << std::right
527  << atomicNumberIon
528  << std::setw(25) << std::right
529  << matIdentifier
530  << G4endl;
531  }
532  }
533 
534  G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin();
535  G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end();
536 
537  G4cout << std::setw(15) << std::right
538  << "Atomic nmb ion"
539  << std::setw(25) << std::right
540  << "Atomic nmb material"
541  << G4endl;
542 
543  for(;iterElem != iterElem_end; iterElem++) {
544  G4IonDEDXKeyElem key = iterElem -> first;
545  G4PhysicsVector* physicsVector = iterElem -> second;
546 
547  G4int atomicNumberIon = key.first;
548  G4int atomicNumberElem = key.second;
549 
550  if(physicsVector != 0) {
551  G4cout << std::setw(15) << std::right
552  << atomicNumberIon
553  << std::setw(25) << std::right
554  << atomicNumberElem
555  << G4endl;
556  }
557  }
558 
559 }
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 146 of file G4IonStoppingData.cc.

References test::b, and python.hepunit::second.

150  {
151  G4double dedx = 0;
152 
153  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
154 
155  G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
156 
157  if( iter != dedxMapElements.end() ) {
158  G4PhysicsVector* physicsVector = iter -> second;
159 
160  G4bool b;
161  dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );
162  }
163 
164  return dedx;
165 }
bool G4bool
Definition: G4Types.hh:79
double G4double
Definition: G4Types.hh:76
G4double G4IonStoppingData::GetDEDX ( G4double  kinEnergyPerNucleon,
G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 169 of file G4IonStoppingData.cc.

References test::b, and python.hepunit::second.

173  {
174  G4double dedx = 0;
175 
176  G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
177 
178  G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
179 
180  if(iter != dedxMapMaterials.end()) {
181  G4PhysicsVector* physicsVector = iter -> second;
182 
183  G4bool b;
184  dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );
185  }
186 
187  return dedx;
188 }
bool G4bool
Definition: G4Types.hh:79
double G4double
Definition: G4Types.hh:76
G4PhysicsVector * G4IonStoppingData::GetPhysicsVector ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 110 of file G4IonStoppingData.cc.

References python.hepunit::second.

113  {
114 
115  G4PhysicsVector* physVector = 0;
116 
117  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
118 
119  G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
120 
121  if(iter != dedxMapElements.end()) physVector = iter -> second;
122 
123  return physVector;
124 }
G4PhysicsVector * G4IonStoppingData::GetPhysicsVector ( G4int  atomicNumberIon,
const G4String matIdenfier 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 128 of file G4IonStoppingData.cc.

References python.hepunit::second.

131  {
132 
133  G4PhysicsVector* physVector = 0;
134 
135  G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
136 
137  G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
138 
139  if(iter != dedxMapMaterials.end()) physVector = iter -> second;
140 
141  return physVector;
142 }
G4bool G4IonStoppingData::IsApplicable ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 78 of file G4IonStoppingData.cc.

Referenced by BuildPhysicsVector().

81  {
82  G4bool isApplicable = true;
83  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
84 
85  G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
86 
87  if(iter == dedxMapElements.end()) isApplicable = false;
88 
89  return isApplicable;
90 }
bool G4bool
Definition: G4Types.hh:79
G4bool G4IonStoppingData::IsApplicable ( G4int  atomicNumberIon,
const G4String matIdentifier 
)
virtual

Implements G4VIonDEDXTable.

Definition at line 94 of file G4IonStoppingData.cc.

97  {
98  G4bool isApplicable = true;
99  G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
100 
101  G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
102 
103  if(iter == dedxMapMaterials.end()) isApplicable = false;
104 
105  return isApplicable;
106 }
bool G4bool
Definition: G4Types.hh:79
G4bool G4IonStoppingData::RemovePhysicsVector ( G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 312 of file G4IonStoppingData.cc.

References G4cerr, and G4endl.

315  {
316 
317  G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
318 
319  G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
320 
321  if(iter == dedxMapMaterials.end()) {
322 
323 #ifdef G4VERBOSE
324  G4cerr << "G4IonStoppingData::RemovePhysicsVector() Warning: "
325  << "Cannot remove physics vector. Vector not found."
326  << G4endl;
327 #endif
328 
329  return false;
330  }
331 
332  G4PhysicsVector* physicsVector = (*iter).second;
333 
334  // Deleting key of physics vector from material map
335  dedxMapMaterials.erase(key);
336 
337  // Deleting physics vector
338  delete physicsVector;
339 
340  return true;
341 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
G4bool G4IonStoppingData::RemovePhysicsVector ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)

Definition at line 345 of file G4IonStoppingData.cc.

References G4cerr, and G4endl.

348  {
349  G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
350 
351  G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
352 
353  if(iter == dedxMapElements.end()) {
354 
355 #ifdef G4VERBOSE
356  G4cerr << "G4IonStoppingData::RemovePhysicsVector() Warning: "
357  << "Cannot remove physics vector. Vector not found."
358  << G4endl;
359 #endif
360 
361  return false;
362  }
363 
364  G4PhysicsVector* physicsVector = (*iter).second;
365 
366  // Deleting key of physics vector from material map
367  dedxMapElements.erase(key);
368 
369  // Deleting physics vector
370  delete physicsVector;
371 
372  return true;
373 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

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