Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCL::NuclearPotential Namespace Reference

Classes

class  INuclearPotential
 
class  NuclearPotentialConstant
 
class  NuclearPotentialEnergyIsospin
 
class  NuclearPotentialEnergyIsospinSmooth
 
class  NuclearPotentialIsospin
 

Functions

INuclearPotential const * createPotential (const PotentialType type, const G4int theA, const G4int theZ, const G4bool pionPotential)
 Create an INuclearPotential object.
 
void clearCache ()
 Clear the INuclearPotential cache.
 

Function Documentation

◆ clearCache()

void G4INCL::NuclearPotential::clearCache ( )

Clear the INuclearPotential cache.

Definition at line 102 of file G4INCLINuclearPotential.cc.

102 {
103 if(nuclearPotentialCache) {
104 for(std::map<long,INuclearPotential const *>::const_iterator i = nuclearPotentialCache->begin(), e=nuclearPotentialCache->end(); i!=e; ++i)
105 delete i->second;
106 nuclearPotentialCache->clear();
107 delete nuclearPotentialCache;
108 nuclearPotentialCache = NULL;
109 }
110 }

Referenced by G4INCL::INCL::~INCL().

◆ createPotential()

INuclearPotential const * G4INCL::NuclearPotential::createPotential ( const PotentialType  type,
const G4int  theA,
const G4int  theZ,
const G4bool  pionPotential 
)

Create an INuclearPotential object.

This is the method that should be used to instantiate objects derived from INuclearPotential. It uses a caching mechanism to minimise thrashing and speed up the code.

Parameters
typethe type of the potential to be created
theAmass number of the nucleus
theZcharge number of the nucleus
pionPotentialwhether pions should also feel the potential
Returns
a pointer to the nuclear potential

Definition at line 70 of file G4INCLINuclearPotential.cc.

70 {
71 if(!nuclearPotentialCache)
72 nuclearPotentialCache = new std::map<long,INuclearPotential const *>;
73
74 const long nuclideID = (pionPotential ? 1 : -1) * (1000*theZ + theA + 1000000*type); // MCNP-style nuclide IDs
75 const std::map<long,INuclearPotential const *>::const_iterator mapEntry = nuclearPotentialCache->find(nuclideID);
76 if(mapEntry == nuclearPotentialCache->end()) {
77 INuclearPotential const *thePotential = NULL;
78 switch(type) {
80 thePotential = new NuclearPotentialEnergyIsospinSmooth(theA, theZ, pionPotential);
81 break;
83 thePotential = new NuclearPotentialEnergyIsospin(theA, theZ, pionPotential);
84 break;
86 thePotential = new NuclearPotentialIsospin(theA, theZ, pionPotential);
87 break;
89 thePotential = new NuclearPotentialConstant(theA, theZ, pionPotential);
90 break;
91 default:
92 INCL_FATAL("Unrecognized potential type at Nucleus creation." << '\n');
93 break;
94 }
95 (*nuclearPotentialCache)[nuclideID] = thePotential;
96 return thePotential;
97 } else {
98 return mapEntry->second;
99 }
100 }
#define INCL_FATAL(x)
@ IsospinEnergySmoothPotential
@ IsospinEnergyPotential

Referenced by G4INCL::Nucleus::Nucleus().