103 G4int atomicNumberIon,
104 G4int atomicNumberElem
106 G4bool isApplicable =
true;
107 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
109 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
111 if(iter == dedxMapElements.end()) isApplicable =
false;
119 G4int atomicNumberIon,
122 G4bool isApplicable =
true;
123 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
125 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
127 if(iter == dedxMapMaterials.end()) isApplicable =
false;
135 G4int atomicNumberIon,
136 G4int atomicNumberElem
141 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
143 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
145 if(iter != dedxMapElements.end()) physVector = iter ->
second;
153 G4int atomicNumberIon,
159 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
161 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
163 if(iter != dedxMapMaterials.end()) physVector = iter ->
second;
172 G4int atomicNumberIon,
173 G4int atomicNumberElem
177 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
179 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
181 if( iter != dedxMapElements.end() ) {
185 dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );
195 G4int atomicNumberIon,
200 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
202 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
204 if(iter != dedxMapMaterials.end()) {
208 dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );
218 G4int atomicNumberIon,
220 G4int atomicNumberElem
223 if(physicsVector == 0) {
226 G4cout <<
"G4IonDEDXTable::AddPhysicsVector() Error: Pointer to vector"
227 <<
" is null-pointer."
234 if(matIdentifier.empty()) {
237 G4cout <<
"G4IonDEDXTable::AddPhysicsVector() Error: "
238 <<
"Cannot add physics vector. Invalid name."
245 if(atomicNumberIon <= 2) {
248 G4cout <<
"G4IonDEDXTable::AddPhysicsVector() Error: "
249 <<
"Cannot add physics vector. Illegal atomic number."
256 if(atomicNumberElem > 0) {
258 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
260 if(dedxMapElements.count(key) == 1) {
263 G4cout <<
"G4IonDEDXTable::AddPhysicsVector() Error: "
264 <<
"Vector already exists. Remove first before replacing."
270 dedxMapElements[key] = physicsVector;
273 G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier);
275 if(dedxMapMaterials.count(mkey) == 1) {
278 G4cout <<
"G4IonDEDXTable::AddPhysicsVector() Error: "
279 <<
"Vector already exists. Remove first before replacing."
286 dedxMapMaterials[mkey] = physicsVector;
294 G4int atomicNumberIon,
301 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
303 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
305 if(iter == dedxMapMaterials.end()) {
308 G4cout <<
"G4IonDEDXTable::RemovePhysicsVector() Warning: "
309 <<
"Cannot remove physics vector. Vector not found."
316 physicsVector = (*iter).second;
317 dedxMapMaterials.erase(key);
320 G4IonDEDXMapElem::iterator it;
322 for(it=dedxMapElements.begin(); it!=dedxMapElements.end(); ++it) {
324 if( (*it).second == physicsVector ) {
325 dedxMapElements.erase(it);
331 delete physicsVector;
343 std::ofstream ofilestream;
345 ofilestream.open( fileName, std::ios::out );
350 G4cout <<
"G4ExtDEDXTable::StorePhysicsVector() "
351 <<
" Cannot open file "<< fileName
359 size_t nmbMatTables = dedxMapMaterials.size();
363 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
364 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
366 for(;iterMat != iterMat_end; iterMat++) {
367 G4IonDEDXKeyMat key = iterMat -> first;
370 G4int atomicNumberIon = key.first;
371 G4String matIdentifier = key.second;
373 G4int atomicNumberElem = FindAtomicNumberElement(physicsVector);
375 if(physicsVector != 0) {
376 ofilestream << atomicNumberIon <<
" " << matIdentifier;
378 if(atomicNumberElem > 0) ofilestream <<
" " << atomicNumberElem;
380 ofilestream <<
" # <Atomic number ion> <Material name> ";
382 if(atomicNumberElem > 0) ofilestream <<
"<Atomic number element>";
384 ofilestream << G4endl << physicsVector -> GetType() <<
G4endl;
386 physicsVector -> Store(ofilestream,
true);
393 G4cout <<
"G4ExtDEDXTable::StorePhysicsVector() "
394 <<
" Cannot store physics vector."
411 std::ifstream ifilestream;
412 ifilestream.open( fileName,
std::ios::in|std::ios::binary );
413 if( ! ifilestream ) {
415 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
416 <<
" Cannot open file "<< fileName
424 ifilestream >> nmbVectors;
425 if( ifilestream.fail() ) {
426 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
427 <<
" File content of " << fileName <<
" ill-formated."
444 for(
G4int i = 0; i<nmbVectors; ++i) {
447 while( line.empty() ) {
449 getline( ifilestream, line );
450 if( ifilestream.fail() ) {
452 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
453 <<
" File content of " << fileName <<
" ill-formated."
460 std::string::size_type pos = line.find_first_of(
"#");
461 if(pos != std::string::npos && pos > 0) {
462 line = line.substr(0, pos);
466 std::istringstream headerstream( line );
468 std::string::size_type atomicNumberIon;
469 headerstream >> atomicNumberIon;
472 headerstream >> materialName;
474 if( headerstream.fail() || std::string::npos == atomicNumberIon) {
477 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
478 <<
" File content of " << fileName <<
" ill-formated "
479 <<
" (vector header)."
486 std::string::size_type atomicNumberMat;
487 headerstream >> atomicNumberMat;
489 if( headerstream.eof() || std::string::npos == atomicNumberMat) {
494 ifilestream >> vectorType;
498 if(physicsVector == 0) {
500 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable "
501 <<
" illegal physics Vector type " << vectorType
502 <<
" in " << fileName
509 if( !physicsVector -> Retrieve(ifilestream,
true) ) {
512 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
513 <<
" File content of " << fileName <<
" ill-formated."
520 physicsVector -> SetSpline(
true);
524 materialName, (
G4int)atomicNumberMat) ) {
526 delete physicsVector;
543 switch (vectorType) {
572 return physicsVector;
577 G4int G4ExtDEDXTable::FindAtomicNumberElement(
581 G4int atomicNumber = 0;
583 G4IonDEDXMapElem::iterator iter = dedxMapElements.begin();
584 G4IonDEDXMapElem::iterator iter_end = dedxMapElements.end();
586 for(;iter != iter_end; iter++) {
588 if( (*iter).second == physicsVector ) {
590 G4IonDEDXKeyElem key = (*iter).first;
591 atomicNumber = key.second;
602 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
603 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
605 for(;iterMat != iterMat_end; iterMat++) {
609 if(vec != 0)
delete vec;
612 dedxMapElements.clear();
613 dedxMapMaterials.clear();
620 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
621 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
628 <<
"Atomic nmb material"
631 for(;iterMat != iterMat_end; iterMat++) {
632 G4IonDEDXKeyMat key = iterMat -> first;
635 G4int atomicNumberIon = key.first;
636 G4String matIdentifier = key.second;
638 G4int atomicNumberElem = FindAtomicNumberElement(physicsVector);
640 if(physicsVector != 0) {
647 if(atomicNumberElem > 0)
G4cout << atomicNumberElem;