102 G4int atomicNumberIon,
103 G4int atomicNumberElem
106 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
108 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
110 return (iter == dedxMapElements.end()) ? false :
true;
116 G4int atomicNumberIon,
120 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
122 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
124 return (iter == dedxMapMaterials.end()) ? false :
true;
130 G4int atomicNumberIon,
131 G4int atomicNumberElem
134 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
136 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
138 return (iter != dedxMapElements.end()) ? iter->second :
nullptr;
144 G4int atomicNumberIon,
148 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
150 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
152 return (iter != dedxMapMaterials.end()) ? iter->second :
nullptr;
159 G4int atomicNumberIon,
160 G4int atomicNumberElem
163 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
165 G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
167 return ( iter != dedxMapElements.end() ) ?
168 (iter->second)->Value( kinEnergyPerNucleon) : 0.0;
175 G4int atomicNumberIon,
179 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
181 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
183 return (iter != dedxMapMaterials.end()) ?
184 (iter->second)->Value( kinEnergyPerNucleon) : 0.0;
191 G4int atomicNumberIon,
193 G4int atomicNumberElem
196 if(physicsVector ==
nullptr) {
197 G4Exception (
"G4ExtDEDXTable::AddPhysicsVector() for material",
199 "Pointer to vector is null-pointer.");
203 if(matIdentifier.empty()) {
204 G4Exception (
"G4ExtDEDXTable::AddPhysicsVector() for material",
209 if(atomicNumberIon <= 2) {
210 G4Exception (
"G4ExtDEDXTable::AddPhysicsVector() for material",
215 if(atomicNumberElem > 0) {
217 G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
219 if(dedxMapElements.count(key) == 1) {
220 G4Exception (
"G4ExtDEDXTable::AddPhysicsVector() for material",
222 "Vector already exist, remove it before replacing.");
226 dedxMapElements[key] = physicsVector;
229 G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier);
231 if(dedxMapMaterials.count(mkey) == 1) {
232 G4Exception (
"G4ExtDEDXTable::AddPhysicsVector() for material",
234 "Vector already exist, remove it before replacing.");
238 dedxMapMaterials[mkey] = physicsVector;
246 G4int atomicNumberIon,
253 G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
255 G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
257 if(iter == dedxMapMaterials.end()) {
258 G4Exception (
"G4ExtDEDXTable::RemovePhysicsVector() for material",
260 "Pointer to vector is null-pointer.");
264 physicsVector = (*iter).second;
265 dedxMapMaterials.erase(key);
268 G4IonDEDXMapElem::iterator it;
270 for(it=dedxMapElements.begin(); it!=dedxMapElements.end(); ++it) {
272 if( (*it).second == physicsVector ) {
273 dedxMapElements.erase(it);
279 delete physicsVector;
291 std::ofstream ofilestream;
293 ofilestream.open( fileName, std::ios::out );
297 ed <<
"Cannot open file " << fileName;
298 G4Exception (
"G4IonStoppingData::StorePhysicsTable()",
304 size_t nmbMatTables = dedxMapMaterials.size();
308 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
309 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
311 for(;iterMat != iterMat_end; iterMat++) {
312 G4IonDEDXKeyMat key = iterMat -> first;
315 G4int atomicNumberIon = key.first;
316 G4String matIdentifier = key.second;
318 G4int atomicNumberElem = FindAtomicNumberElement(physicsVector);
320 if(physicsVector !=
nullptr) {
321 ofilestream << atomicNumberIon <<
" " << matIdentifier;
323 if(atomicNumberElem > 0) ofilestream <<
" " << atomicNumberElem;
325 ofilestream <<
" # <Atomic number ion> <Material name> ";
327 if(atomicNumberElem > 0) ofilestream <<
"<Atomic number element>";
329 ofilestream <<
G4endl << physicsVector -> GetType() <<
G4endl;
331 physicsVector -> Store(ofilestream,
true);
335 G4Exception (
"G4IonStoppingData::StorePhysicsTable()",
350 std::ifstream ifilestream;
351 ifilestream.open( fileName, std::ios::in|std::ios::binary );
352 if( ! ifilestream ) {
354 ed <<
"Cannot open file " << fileName;
355 G4Exception (
"G4IonStoppingData::RetrievePhysicsTable()",
361 G4int nmbVectors = 0;
362 ifilestream >> nmbVectors;
363 if( ifilestream.fail() || nmbVectors <= 0) {
364 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
365 <<
" File content of " << fileName <<
" ill-formated."
366 <<
" Nvectors= " << nmbVectors
372 for(
G4int i = 0; i<nmbVectors; ++i) {
376 while( line.empty() ) {
378 getline( ifilestream, line );
379 if( ifilestream.fail() ) {
380 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
381 <<
" File content of " << fileName <<
" ill-formated."
387 std::string::size_type pos = line.find_first_of(
"#");
388 if(pos != std::string::npos && pos > 0) {
389 line = line.substr(0, pos);
393 std::istringstream headerstream( line );
395 std::string::size_type atomicNumberIon;
396 headerstream >> atomicNumberIon;
399 headerstream >> materialName;
401 if( headerstream.fail() || std::string::npos == atomicNumberIon) {
402 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
403 <<
" File content of " << fileName <<
" ill-formated "
404 <<
" (vector header)."
410 std::string::size_type atomicNumberMat;
411 headerstream >> atomicNumberMat;
413 if( headerstream.eof() || std::string::npos == atomicNumberMat) {
418 ifilestream >> vectorType;
422 if(physicsVector ==
nullptr) {
423 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable "
424 <<
" illegal physics Vector type " << vectorType
425 <<
" in " << fileName
431 if( !physicsVector -> Retrieve(ifilestream,
true) ) {
432 G4cout <<
"G4ExtDEDXTable::RetrievePhysicsTable() "
433 <<
" File content of " << fileName <<
" ill-formated."
439 physicsVector -> SetSpline(
true);
443 materialName, (
G4int)atomicNumberMat) ) {
445 delete physicsVector;
462 switch (vectorType) {
491 return physicsVector;
496G4int G4ExtDEDXTable::FindAtomicNumberElement(
500 G4int atomicNumber = 0;
502 G4IonDEDXMapElem::iterator iter = dedxMapElements.begin();
503 G4IonDEDXMapElem::iterator iter_end = dedxMapElements.end();
505 for(;iter != iter_end; iter++) {
507 if( (*iter).second == physicsVector ) {
509 G4IonDEDXKeyElem key = (*iter).first;
510 atomicNumber = key.second;
521 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
522 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
524 for(;iterMat != iterMat_end; iterMat++) {
528 if(vec != 0)
delete vec;
531 dedxMapElements.clear();
532 dedxMapMaterials.clear();
539 G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
540 G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
542 G4cout << std::setw(15) << std::right
544 << std::setw(25) << std::right
546 << std::setw(25) << std::right
547 <<
"Atomic nmb material"
550 for(;iterMat != iterMat_end; iterMat++) {
551 G4IonDEDXKeyMat key = iterMat -> first;
554 G4int atomicNumberIon = key.first;
555 G4String matIdentifier = key.second;
557 G4int atomicNumberElem = FindAtomicNumberElement(physicsVector);
559 if(physicsVector != 0) {
560 G4cout << std::setw(15) << std::right
562 << std::setw(25) << std::right
564 << std::setw(25) << std::right;
566 if(atomicNumberElem > 0)
G4cout << atomicNumberElem;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4PhysicsLogVector G4PhysicsLnVector
@ T_G4PhysicsOrderedFreeVector
@ T_G4PhysicsLinearVector
G4GLOB_DLL std::ostream G4cout
virtual G4PhysicsVector * GetPhysicsVector(G4int atomicNumberIon, G4int atomicNumberElem)
virtual G4bool BuildPhysicsVector(G4int ionZ, const G4String &matName)
virtual G4bool IsApplicable(G4int atomicNumberIon, G4int atomicNumberElem)
G4double GetDEDX(G4double kinEnergyPerNucleon, G4int atomicNumberIon, G4int atomicNumberElem)
G4bool StorePhysicsTable(const G4String &fileName)
G4bool RemovePhysicsVector(G4int atomicNumberIon, const G4String &matIdentifier)
G4bool AddPhysicsVector(G4PhysicsVector *physicsVector, G4int atomicNumberIon, const G4String &matIdenfier, G4int atomicNumberElem=0)
virtual ~G4ExtDEDXTable()
G4bool RetrievePhysicsTable(const G4String &fileName)