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 ()

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.

00064                                                                 :
00065   subDir( leDirectory ) {
00066 
00067 }

G4IonStoppingData::~G4IonStoppingData (  )  [virtual]

Definition at line 71 of file G4IonStoppingData.cc.

References ClearTable().

00071                                       {
00072 
00073   ClearTable();
00074 }


Member Function Documentation

G4bool G4IonStoppingData::AddPhysicsVector ( G4PhysicsVector physicsVector,
G4int  atomicNumberIon,
G4int  atomicNumberElem 
)

Definition at line 253 of file G4IonStoppingData.cc.

References G4cerr, and G4endl.

00257                                         {
00258 
00259   if(physicsVector == 0) {
00260 
00261 #ifdef G4VERBOSE
00262      G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
00263             << "Pointer to vector is null-pointer."
00264             << G4endl;
00265 #endif
00266 
00267      return false;
00268   }
00269 
00270   if(atomicNumberIon <= 0) {
00271 
00272 #ifdef G4VERBOSE
00273      G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
00274             << "Cannot add physics vector. Illegal atomic number."
00275             << G4endl;
00276 #endif
00277 
00278      return false;
00279   }
00280 
00281   if(atomicNumberElem <= 0) {
00282 
00283 #ifdef G4VERBOSE
00284         G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
00285                << "Atomic number of element < 0."
00286                << G4endl;
00287 #endif
00288         return false;
00289   }
00290 
00291   G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
00292 
00293   if(dedxMapElements.count(key) == 1) {
00294 
00295 #ifdef G4VERBOSE
00296      G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
00297             << "Vector with Z1 = " << atomicNumberIon << ", Z2 = " 
00298             << atomicNumberElem
00299             << " already exists. Remove first before replacing."
00300             << G4endl;
00301 #endif
00302       return false;
00303   }
00304 
00305   dedxMapElements[key] = physicsVector;
00306 
00307   return true;
00308 }

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().

00196                                         {
00197 
00198   if(physicsVector == 0) {
00199 
00200 #ifdef G4VERBOSE
00201      G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: Pointer to vector"
00202             << " is null-pointer."
00203             << G4endl;
00204 #endif
00205 
00206      return false;
00207   }
00208 
00209   if(matIdentifier.empty()) {
00210 
00211 #ifdef G4VERBOSE
00212      G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
00213             << "Cannot add physics vector. Invalid name."
00214             << G4endl;
00215 #endif
00216 
00217      return false;
00218   }
00219 
00220   if(atomicNumberIon <= 0) {
00221 
00222 #ifdef G4VERBOSE
00223      G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
00224             << "Cannot add physics vector. Illegal atomic number."
00225             << G4endl;
00226 #endif
00227 
00228      return false;
00229   }
00230 
00231   G4IonDEDXKeyMat mkey = std::make_pair(atomicNumberIon, matIdentifier);
00232 
00233   if(dedxMapMaterials.count(mkey) == 1) {
00234 
00235 #ifdef G4VERBOSE
00236      G4cerr << "G4IonStoppingData::AddPhysicsVector() Error: "
00237             << "Vector with Z1 = " << atomicNumberIon << ", mat = " 
00238             << matIdentifier
00239             << "already exists. Remove first before replacing."
00240             << G4endl;
00241 #endif
00242 
00243      return false;
00244   }
00245 
00246   dedxMapMaterials[mkey] = physicsVector;
00247 
00248   return true;
00249 }

G4bool G4IonStoppingData::BuildPhysicsVector ( G4int  ionZ,
G4int  matZ 
) [virtual]

Implements G4VIonDEDXTable.

Definition at line 428 of file G4IonStoppingData.cc.

References AddPhysicsVector(), FatalException, G4Exception(), and IsApplicable().

00431                                                        {
00432 
00433   if( IsApplicable(atomicNumberIon, atomicNumberElem) ) return true;
00434 
00435   char* path = getenv("G4LEDATA");
00436   if ( !path ) {
00437     G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat522",
00438                 FatalException, "G4LEDATA environment variable not set");
00439     return false;
00440   }
00441   std::ostringstream file;
00442  
00443   file << path << "/" << subDir << "/z" 
00444        << atomicNumberIon << "_" << atomicNumberElem
00445        << ".dat";
00446                       
00447   G4String fileName = G4String( file.str().c_str() );
00448 
00449   std::ifstream ifilestream( fileName );
00450 
00451   if ( !ifilestream.is_open() ) return false;
00452   
00453   G4LPhysicsFreeVector* physicsVector = new G4LPhysicsFreeVector(); 
00454 
00455   if( !physicsVector -> Retrieve(ifilestream, true) ) {
00456  
00457      ifilestream.close();
00458      return false;
00459   }
00460 
00461   physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) ); 
00462   physicsVector -> SetSpline( true );
00463   physicsVector -> FillSecondDerivatives();
00464 
00465   // Retrieved vector is added to material store
00466   if( !AddPhysicsVector(physicsVector, atomicNumberIon, atomicNumberElem) ) {
00467      delete physicsVector;
00468      ifilestream.close();
00469      return false;
00470   }
00471 
00472   ifilestream.close();
00473   return true;
00474 }

G4bool G4IonStoppingData::BuildPhysicsVector ( G4int  ionZ,
const G4String matName 
) [virtual]

Implements G4VIonDEDXTable.

Definition at line 377 of file G4IonStoppingData.cc.

References AddPhysicsVector(), FatalException, G4Exception(), and IsApplicable().

00380                                                        {
00381 
00382   if( IsApplicable(atomicNumberIon, matIdentifier) ) return true;
00383 
00384   char* path = getenv("G4LEDATA");
00385   if ( !path ) {
00386     G4Exception("G4IonStoppingData::BuildPhysicsVector()", "mat521",
00387                 FatalException, "G4LEDATA environment variable not set");
00388     return false;
00389   }
00390   
00391   std::ostringstream file;
00392  
00393   file << path << "/" << subDir << "/z" 
00394        << atomicNumberIon << "_" << matIdentifier 
00395        << ".dat";
00396                       
00397   G4String fileName = G4String( file.str().c_str() );
00398 
00399   std::ifstream ifilestream( fileName );
00400 
00401   if ( !ifilestream.is_open() ) return false;
00402   
00403   G4LPhysicsFreeVector* physicsVector = new G4LPhysicsFreeVector(); 
00404 
00405   if( !physicsVector -> Retrieve(ifilestream, true) ) {
00406  
00407      ifilestream.close();
00408      return false;
00409   }
00410 
00411   physicsVector -> ScaleVector( MeV, MeV * cm2 /( 0.001 * g) ); 
00412   physicsVector -> SetSpline( true );
00413   physicsVector -> FillSecondDerivatives();
00414 
00415   // Retrieved vector is added to material store
00416   if( !AddPhysicsVector(physicsVector, atomicNumberIon, matIdentifier) ) {
00417      delete physicsVector;
00418      ifilestream.close();
00419      return false;
00420   }
00421 
00422   ifilestream.close();
00423   return true;
00424 }

void G4IonStoppingData::ClearTable (  ) 

Definition at line 478 of file G4IonStoppingData.cc.

Referenced by ~G4IonStoppingData().

00478                                    {
00479 
00480   G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
00481   G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
00482 
00483   for(;iterMat != iterMat_end; iterMat++) { 
00484 
00485     G4PhysicsVector* vec = iterMat -> second;
00486 
00487     if(vec != 0) delete vec;
00488   }
00489 
00490   dedxMapMaterials.clear();
00491 
00492   G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin();
00493   G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end();
00494 
00495   for(;iterElem != iterElem_end; iterElem++) { 
00496 
00497     G4PhysicsVector* vec = iterElem -> second;
00498 
00499     if(vec != 0) delete vec;
00500   }
00501 
00502   dedxMapElements.clear();
00503 }

void G4IonStoppingData::DumpMap (  ) 

Definition at line 507 of file G4IonStoppingData.cc.

References G4cout, and G4endl.

00507                                 {
00508 
00509   G4IonDEDXMapMat::iterator iterMat = dedxMapMaterials.begin();
00510   G4IonDEDXMapMat::iterator iterMat_end = dedxMapMaterials.end();
00511 
00512   G4cout << std::setw(15) << std::right
00513          << "Atomic nmb ion"
00514          << std::setw(25) << std::right
00515          << "Material name"
00516          << G4endl;
00517 
00518   for(;iterMat != iterMat_end; iterMat++) {
00519       G4IonDEDXKeyMat key = iterMat -> first;
00520       G4PhysicsVector* physicsVector = iterMat -> second; 
00521 
00522       G4int atomicNumberIon = key.first;
00523       G4String matIdentifier = key.second;
00524 
00525       if(physicsVector != 0) {
00526          G4cout << std::setw(15) << std::right
00527                 << atomicNumberIon
00528                 << std::setw(25) << std::right
00529                 << matIdentifier
00530                 << G4endl;
00531       }
00532   }
00533 
00534   G4IonDEDXMapElem::iterator iterElem = dedxMapElements.begin();
00535   G4IonDEDXMapElem::iterator iterElem_end = dedxMapElements.end();
00536 
00537   G4cout << std::setw(15) << std::right
00538          << "Atomic nmb ion"
00539          << std::setw(25) << std::right
00540          << "Atomic nmb material"
00541          << G4endl;
00542 
00543   for(;iterElem != iterElem_end; iterElem++) { 
00544       G4IonDEDXKeyElem key = iterElem -> first;
00545       G4PhysicsVector* physicsVector = iterElem -> second; 
00546 
00547       G4int atomicNumberIon = key.first;
00548       G4int atomicNumberElem = key.second;
00549 
00550       if(physicsVector != 0) {
00551          G4cout << std::setw(15) << std::right
00552                 << atomicNumberIon
00553                 << std::setw(25) << std::right
00554                 << atomicNumberElem
00555                 << G4endl;
00556       }
00557   }
00558 
00559 }

G4double G4IonStoppingData::GetDEDX ( G4double  kinEnergyPerNucleon,
G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 169 of file G4IonStoppingData.cc.

00173                                     {
00174   G4double dedx = 0;
00175 
00176   G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
00177 
00178   G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
00179 
00180   if(iter != dedxMapMaterials.end()) {
00181      G4PhysicsVector* physicsVector = iter -> second; 
00182 
00183      G4bool b;
00184      dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );   
00185   }
00186 
00187   return dedx; 
00188 }

G4double G4IonStoppingData::GetDEDX ( G4double  kinEnergyPerNucleon,
G4int  atomicNumberIon,
G4int  atomicNumberElem 
)

Definition at line 146 of file G4IonStoppingData.cc.

00150                                     {
00151   G4double dedx = 0;
00152 
00153   G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
00154 
00155   G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
00156 
00157   if( iter != dedxMapElements.end() ) {
00158      G4PhysicsVector* physicsVector = iter -> second; 
00159 
00160      G4bool b;
00161      dedx = physicsVector -> GetValue( kinEnergyPerNucleon, b );   
00162   }
00163 
00164   return dedx; 
00165 }

G4PhysicsVector * G4IonStoppingData::GetPhysicsVector ( G4int  atomicNumberIon,
const G4String matIdenfier 
) [virtual]

Implements G4VIonDEDXTable.

Definition at line 128 of file G4IonStoppingData.cc.

00131                                       {
00132 
00133   G4PhysicsVector* physVector = 0;
00134 
00135   G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
00136 
00137   G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
00138 
00139   if(iter != dedxMapMaterials.end()) physVector = iter -> second; 
00140 
00141   return physVector; 
00142 }

G4PhysicsVector * G4IonStoppingData::GetPhysicsVector ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
) [virtual]

Implements G4VIonDEDXTable.

Definition at line 110 of file G4IonStoppingData.cc.

00113                                       {
00114 
00115   G4PhysicsVector* physVector = 0;
00116 
00117   G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
00118 
00119   G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
00120 
00121   if(iter != dedxMapElements.end()) physVector = iter -> second; 
00122 
00123   return physVector; 
00124 }

G4bool G4IonStoppingData::IsApplicable ( G4int  atomicNumberIon,
const G4String matIdentifier 
) [virtual]

Implements G4VIonDEDXTable.

Definition at line 94 of file G4IonStoppingData.cc.

00097                                       {
00098   G4bool isApplicable = true; 
00099   G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
00100 
00101   G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
00102 
00103   if(iter == dedxMapMaterials.end()) isApplicable = false; 
00104 
00105   return isApplicable; 
00106 }

G4bool G4IonStoppingData::IsApplicable ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
) [virtual]

Implements G4VIonDEDXTable.

Definition at line 78 of file G4IonStoppingData.cc.

Referenced by BuildPhysicsVector().

00081                                       {
00082   G4bool isApplicable = true; 
00083   G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
00084 
00085   G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
00086 
00087   if(iter == dedxMapElements.end()) isApplicable = false; 
00088 
00089   return isApplicable; 
00090 }

G4bool G4IonStoppingData::RemovePhysicsVector ( G4int  atomicNumberIon,
G4int  atomicNumberElem 
)

Definition at line 345 of file G4IonStoppingData.cc.

References G4cerr, and G4endl.

00348                                         {
00349   G4IonDEDXKeyElem key = std::make_pair(atomicNumberIon, atomicNumberElem);
00350 
00351   G4IonDEDXMapElem::iterator iter = dedxMapElements.find(key);
00352 
00353   if(iter == dedxMapElements.end()) {
00354 
00355 #ifdef G4VERBOSE
00356      G4cerr << "G4IonStoppingData::RemovePhysicsVector() Warning: "
00357             << "Cannot remove physics vector. Vector not found."
00358             << G4endl;
00359 #endif
00360 
00361      return false;
00362   }
00363 
00364   G4PhysicsVector* physicsVector = (*iter).second;
00365 
00366   // Deleting key of physics vector from material map
00367   dedxMapElements.erase(key);
00368 
00369   // Deleting physics vector
00370   delete physicsVector;
00371 
00372   return true;
00373 }

G4bool G4IonStoppingData::RemovePhysicsVector ( G4int  atomicNumberIon,
const G4String matIdentifier 
)

Definition at line 312 of file G4IonStoppingData.cc.

References G4cerr, and G4endl.

00315                                         {
00316 
00317   G4IonDEDXKeyMat key = std::make_pair(atomicNumberIon, matIdentifier);
00318 
00319   G4IonDEDXMapMat::iterator iter = dedxMapMaterials.find(key);
00320 
00321   if(iter == dedxMapMaterials.end()) {
00322 
00323 #ifdef G4VERBOSE
00324      G4cerr << "G4IonStoppingData::RemovePhysicsVector() Warning: "
00325             << "Cannot remove physics vector. Vector not found."
00326             << G4endl;
00327 #endif
00328 
00329      return false;
00330   }
00331 
00332   G4PhysicsVector* physicsVector = (*iter).second;
00333 
00334   // Deleting key of physics vector from material map
00335   dedxMapMaterials.erase(key);
00336 
00337   // Deleting physics vector
00338   delete physicsVector;
00339 
00340   return true;
00341 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:18 2013 for Geant4 by  doxygen 1.4.7