65 subDir( leDirectory ) {
79 G4int atomicNumberIon,
80 G4int atomicNumberElem
82 G4bool isApplicable =
true;
83 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
85 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
87 if(iter == dedxMapElements.end()) isApplicable =
false;
95 G4int atomicNumberIon,
98 G4bool isApplicable =
true;
99 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
101 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
103 if(iter == dedxMapMaterials.end()) isApplicable =
false;
111 G4int atomicNumberIon,
112 G4int atomicNumberElem
117 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
119 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
121 if(iter != dedxMapElements.end()) physVector = iter -> second;
129 G4int atomicNumberIon,
135 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
137 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
139 if(iter != dedxMapMaterials.end()) physVector = iter -> second;
148 G4int atomicNumberIon,
149 G4int atomicNumberElem
153 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
155 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
157 if( iter != dedxMapElements.end() ) {
161 dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );
171 G4int atomicNumberIon,
176 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
178 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
180 if(iter != dedxMapMaterials.end()) {
184 dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );
194 G4int atomicNumberIon,
198 if(physicsVector == 0) {
201 G4cerr <<
"G4IonStoppingData::AddPhysicsVector() Error: Pointer to vector"
202 <<
" is null-pointer."
209 if(matIdentifier.empty()) {
212 G4cerr <<
"G4IonStoppingData::AddPhysicsVector() Error: "
213 <<
"Cannot add physics vector. Invalid name."
220 if(atomicNumberIon <= 0) {
223 G4cerr <<
"G4IonStoppingData::AddPhysicsVector() Error: "
224 <<
"Cannot add physics vector. Illegal atomic number."
231 G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier);
233 if(dedxMapMaterials.count(mkey) == 1) {
236 G4cerr <<
"G4IonStoppingData::AddPhysicsVector() Error: "
237 <<
"Vector with Z1 = " << atomicNumberIon <<
", mat = "
239 <<
"already exists. Remove first before replacing."
246 dedxMapMaterials[mkey] = physicsVector;
255 G4int atomicNumberIon,
256 G4int atomicNumberElem
259 if(physicsVector == 0) {
262 G4cerr <<
"G4IonStoppingData::AddPhysicsVector() Error: "
263 <<
"Pointer to vector is null-pointer."
270 if(atomicNumberIon <= 0) {
273 G4cerr <<
"G4IonStoppingData::AddPhysicsVector() Error: "
274 <<
"Cannot add physics vector. Illegal atomic number."
281 if(atomicNumberElem <= 0) {
284 G4cerr <<
"G4IonStoppingData::AddPhysicsVector() Error: "
285 <<
"Atomic number of element < 0."
291 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
293 if(dedxMapElements.count(key) == 1) {
296 G4cerr <<
"G4IonStoppingData::AddPhysicsVector() Error: "
297 <<
"Vector with Z1 = " << atomicNumberIon <<
", Z2 = "
299 <<
" already exists. Remove first before replacing."
305 dedxMapElements[key] = physicsVector;
313 G4int atomicNumberIon,
317 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
319 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
321 if(iter == dedxMapMaterials.end()) {
324 G4cerr <<
"G4IonStoppingData::RemovePhysicsVector() Warning: "
325 <<
"Cannot remove physics vector. Vector not found."
335 dedxMapMaterials.erase(key);
338 delete physicsVector;
346 G4int atomicNumberIon,
347 G4int atomicNumberElem
349 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
351 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
353 if(iter == dedxMapElements.end()) {
356 G4cerr <<
"G4IonStoppingData::RemovePhysicsVector() Warning: "
357 <<
"Cannot remove physics vector. Vector not found."
367 dedxMapElements.erase(key);
370 delete physicsVector;
378 G4int atomicNumberIon,
382 if(
IsApplicable(atomicNumberIon, matIdentifier) )
return true;
384 char* path = getenv(
"G4LEDATA");
386 G4Exception(
"G4IonStoppingData::BuildPhysicsVector()",
"mat521",
391 std::ostringstream file;
393 file << path <<
"/" << subDir <<
"/z"
394 << atomicNumberIon <<
"_" << matIdentifier
399 std::ifstream ifilestream( fileName );
401 if ( !ifilestream.is_open() )
return false;
405 if( !physicsVector -> Retrieve(ifilestream,
true) ) {
411 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
412 physicsVector -> SetSpline(
true );
413 physicsVector -> FillSecondDerivatives();
417 delete physicsVector;
429 G4int atomicNumberIon,
430 G4int atomicNumberElem
433 if(
IsApplicable(atomicNumberIon, atomicNumberElem) )
return true;
435 char* path = getenv(
"G4LEDATA");
437 G4Exception(
"G4IonStoppingData::BuildPhysicsVector()",
"mat522",
441 std::ostringstream file;
443 file << path <<
"/" << subDir <<
"/z"
444 << atomicNumberIon <<
"_" << atomicNumberElem
449 std::ifstream ifilestream( fileName );
451 if ( !ifilestream.is_open() )
return false;
455 if( !physicsVector -> Retrieve(ifilestream,
true) ) {
461 physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) );
462 physicsVector -> SetSpline(
true );
463 physicsVector -> FillSecondDerivatives();
467 delete physicsVector;
480 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
481 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
483 for(;iterMat != iterMat_end; iterMat++) {
487 if(vec != 0)
delete vec;
490 dedxMapMaterials.clear();
492 G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin();
493 G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end();
495 for(;iterElem != iterElem_end; iterElem++) {
499 if(vec != 0)
delete vec;
502 dedxMapElements.clear();
509 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
510 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
512 G4cout << std::setw(15) << std::right
514 << std::setw(25) << std::right
518 for(;iterMat != iterMat_end; iterMat++) {
519 G4IonDEDXKeyMat key = iterMat -> first;
522 G4int atomicNumberIon = key.first;
523 G4String matIdentifier = key.second;
525 if(physicsVector != 0) {
526 G4cout << std::setw(15) << std::right
528 << std::setw(25) << std::right
534 G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin();
535 G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end();
537 G4cout << std::setw(15) << std::right
539 << std::setw(25) << std::right
540 <<
"Atomic nmb material"
543 for(;iterElem != iterElem_end; iterElem++) {
544 G4IonDEDXKeyElem key = iterElem -> first;
547 G4int atomicNumberIon = key.first;
548 G4int atomicNumberElem = key.second;
550 if(physicsVector != 0) {
551 G4cout << std::setw(15) << std::right
553 << std::setw(25) << std::right
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
G4PhysicsVector * GetPhysicsVector(G4int atomicNumberIon, G4int atomicNumberElem)
G4bool IsApplicable(G4int atomicNumberIon, G4int atomicNumberElem)
G4bool RemovePhysicsVector(G4int atomicNumberIon, const G4String &matIdentifier)
G4double GetDEDX(G4double kinEnergyPerNucleon, G4int atomicNumberIon, G4int atomicNumberElem)
G4bool AddPhysicsVector(G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdentifier)
G4bool BuildPhysicsVector(G4int ionZ, const G4String &matName)
G4IonStoppingData(const G4String &leDirectory)
virtual ~G4IonStoppingData()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)