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
423 G4int nmbVectors = 0;
424 ifilestream >> nmbVectors;
425 if( ifilestream.fail() || nmbVectors <= 0) {
426 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
427 <<
" File content of " << fileName <<
" ill-formated."
428 <<
" Nvectors= " << nmbVectors
434 for(
G4int i = 0; i<nmbVectors; ++i) {
437 while( line.empty() ) {
439 getline( ifilestream, line );
440 if( ifilestream.fail() ) {
442 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
443 <<
" File content of " << fileName <<
" ill-formated."
450 std::string::size_type pos = line.find_first_of(
"#");
451 if(pos != std::string::npos && pos > 0) {
452 line = line.substr(0, pos);
456 std::istringstream headerstream( line );
458 std::string::size_type atomicNumberIon;
459 headerstream >> atomicNumberIon;
462 headerstream >> materialName;
464 if( headerstream.fail() || std::string::npos == atomicNumberIon) {
467 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
468 <<
" File content of " << fileName <<
" ill-formated "
469 <<
" (vector header)."
476 std::string::size_type atomicNumberMat;
477 headerstream >> atomicNumberMat;
479 if( headerstream.eof() || std::string::npos == atomicNumberMat) {
484 ifilestream >> vectorType;
488 if(physicsVector == 0) {
490 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable "
491 <<
" illegal physics Vector type " << vectorType
492 <<
" in " << fileName
499 if( !physicsVector -> Retrieve(ifilestream,
true) ) {
502 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
503 <<
" File content of " << fileName <<
" ill-formated."
510 physicsVector -> SetSpline(
true);
514 materialName, (
G4int)atomicNumberMat) ) {
516 delete physicsVector;
533 switch (vectorType) {
562 return physicsVector;
567 G4int G4ExtDEDXTable::FindAtomicNumberElement(
571 G4int atomicNumber = 0;
573 G4IonDEDXMapElem::iterator iter = dedxMapElements.begin();
574 G4IonDEDXMapElem::iterator iter_end = dedxMapElements.end();
576 for(;iter != iter_end; iter++) {
578 if( (*iter).second == physicsVector ) {
580 G4IonDEDXKeyElem key = (*iter).first;
581 atomicNumber = key.second;
592 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
593 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
595 for(;iterMat != iterMat_end; iterMat++) {
599 if(vec != 0)
delete vec;
602 dedxMapElements.clear();
603 dedxMapMaterials.clear();
610 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
611 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
618 <<
"Atomic nmb material"
621 for(;iterMat != iterMat_end; iterMat++) {
622 G4IonDEDXKeyMat key = iterMat ->
first;
625 G4int atomicNumberIon = key.first;
626 G4String matIdentifier = key.second;
628 G4int atomicNumberElem = FindAtomicNumberElement(physicsVector);
630 if(physicsVector != 0) {
637 if(atomicNumberElem > 0)
G4cout << atomicNumberElem;
G4double GetDEDX(G4double kinEnergyPerNucleon, G4int atomicNumberIon, G4int atomicNumberElem)
G4bool RetrievePhysicsTable(const G4String &fileName)
G4bool RemovePhysicsVector(G4int atomicNumberIon, const G4String &matIdentifier)
G4GLOB_DLL std::ostream G4cout
G4bool AddPhysicsVector(G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdenfier, G4int atomicNumberElem=0)
G4PhysicsVector * GetPhysicsVector(G4int atomicNumberIon, G4int atomicNumberElem)
G4bool StorePhysicsTable(const G4String &fileName)
G4bool BuildPhysicsVector(G4int ionZ, const G4String &matName)
virtual ~G4ExtDEDXTable()
G4bool IsApplicable(G4int atomicNumberIon, G4int atomicNumberElem)