34#define INCLXX_IN_GEANT4_MODE 1
48 namespace NuclearDensityFactory {
52 G4ThreadLocal std::map<G4int,NuclearDensity const *> *nuclearDensityCache = NULL;
53 G4ThreadLocal std::map<G4int,InterpolationTable*> *rpCorrelationTableCache = NULL;
54 G4ThreadLocal std::map<G4int,InterpolationTable*> *rCDFTableCache = NULL;
55 G4ThreadLocal std::map<G4int,InterpolationTable*> *pCDFTableCache = NULL;
60 if(!nuclearDensityCache)
61 nuclearDensityCache =
new std::map<G4int,NuclearDensity const *>;
63 const G4int nuclideID = 1000*Z +
A;
64 const std::map<G4int,NuclearDensity const *>::const_iterator mapEntry = nuclearDensityCache->find(nuclideID);
65 if(mapEntry == nuclearDensityCache->end()) {
69 if(!rpCorrelationTableProton || !rpCorrelationTableNeutron || !rpCorrelationTableLambda)
72 (*nuclearDensityCache)[nuclideID] = density;
75 return mapEntry->second;
82 if(!rpCorrelationTableCache)
83 rpCorrelationTableCache =
new std::map<G4int,InterpolationTable*>;
85 const G4int nuclideID = ((t==
Proton) ? 1000 : -1000)*Z +
A;
86 const std::map<G4int,InterpolationTable*>::const_iterator mapEntry = rpCorrelationTableCache->find(nuclideID);
87 if(mapEntry == rpCorrelationTableCache->end()) {
89 INCL_DEBUG(
"Creating r-p correlation function for " << ((t==
Proton) ?
"protons" : ((t==
Neutron) ?
"neutrons" :
"lambdas")) <<
" in A=" <<
A <<
", Z=" << Z << std::endl);
97 INCL_DEBUG(
" ... Woods-Saxon; R0=" << radius <<
", a=" << diffuseness <<
", Rmax=" << maximumRadius << std::endl);
103 INCL_DEBUG(
" ... MHO; param1=" << radius <<
", param2=" << diffuseness <<
", Rmax=" << maximumRadius << std::endl);
108 INCL_DEBUG(
" ... Gaussian; sigma=" << radius <<
", Rmax=" << maximumRadius << std::endl);
110 INCL_ERROR(
"No r-p correlation function for " << ((t==
Proton) ?
"protons" :
"neutrons") <<
" in A = "
111 <<
A <<
" Z = " << Z <<
'\n');
116 delete rpCorrelationFunction;
117 INCL_DEBUG(
" ... here comes the table:\n" << theTable->
print() <<
'\n');
119 (*rpCorrelationTableCache)[nuclideID] = theTable;
122 return mapEntry->second;
130 rCDFTableCache =
new std::map<G4int,InterpolationTable*>;
134 nuclideID = ((t==
antiProton) ? 1000 : -1000)*(-Z) + (-
A);
136 const std::map<G4int,InterpolationTable*>::const_iterator mapEntry = rCDFTableCache->find(nuclideID);
137 if(mapEntry == rCDFTableCache->end()) {
154 }
else if((
A == 2 && Z == 1) || (
A ==-2 && Z==-1)){
157 INCL_ERROR(
"No nuclear density function for target A = "
158 <<
A <<
" Z = " << Z <<
'\n');
163 delete rDensityFunction;
164 INCL_DEBUG(
"Creating inverse position CDF for A=" <<
A <<
", Z=" << Z <<
":" <<
165 '\n' << theTable->
print() <<
'\n');
167 (*rCDFTableCache)[nuclideID] = theTable;
170 return mapEntry->second;
178 pCDFTableCache =
new std::map<G4int,InterpolationTable*>;
182 nuclideID = ((t==
antiProton) ? 1000 : -1000)*(-Z) + (-
A);
184 const std::map<G4int,InterpolationTable*>::const_iterator mapEntry = pCDFTableCache->find(nuclideID);
185 if(mapEntry == pCDFTableCache->end()) {
193 }
else if((
A == 2 && Z == 1) || (
A ==-2 && Z==-1)) {
196 INCL_ERROR(
"No nuclear density function for target A = "
197 <<
A <<
" Z = " << Z <<
'\n');
202 delete pDensityFunction;
203 INCL_DEBUG(
"Creating inverse momentum CDF for A=" <<
A <<
", Z=" << Z <<
":" <<
204 '\n' << theTable->
print() <<
'\n');
206 (*pCDFTableCache)[nuclideID] = theTable;
209 return mapEntry->second;
216 if(!rpCorrelationTableCache)
217 rpCorrelationTableCache =
new std::map<G4int,InterpolationTable*>;
219 const G4int nuclideID = ((t==
Proton) ? 1000 : -1000)*Z +
A;
220 const std::map<G4int,InterpolationTable*>::const_iterator mapEntry = rpCorrelationTableCache->find(nuclideID);
221 if(mapEntry != rpCorrelationTableCache->end())
222 delete mapEntry->second;
224 (*rpCorrelationTableCache)[nuclideID] = table;
228 if(!nuclearDensityCache)
229 nuclearDensityCache =
new std::map<G4int,NuclearDensity const *>;
231 const G4int nuclideID = 1000*Z +
A;
232 const std::map<G4int,NuclearDensity const *>::const_iterator mapEntry = nuclearDensityCache->find(nuclideID);
233 if(mapEntry != nuclearDensityCache->end())
234 delete mapEntry->second;
236 (*nuclearDensityCache)[nuclideID] = density;
241 if(nuclearDensityCache) {
242 for(std::map<G4int,NuclearDensity const *>::const_iterator i = nuclearDensityCache->begin(); i!=nuclearDensityCache->end(); ++i)
244 nuclearDensityCache->clear();
245 delete nuclearDensityCache;
246 nuclearDensityCache = NULL;
249 if(rpCorrelationTableCache) {
250 for(std::map<G4int,InterpolationTable*>::const_iterator i = rpCorrelationTableCache->begin(); i!=rpCorrelationTableCache->end(); ++i)
252 rpCorrelationTableCache->clear();
253 delete rpCorrelationTableCache;
254 rpCorrelationTableCache = NULL;
258 for(std::map<G4int,InterpolationTable*>::const_iterator i = rCDFTableCache->begin(); i!=rCDFTableCache->end(); ++i)
260 rCDFTableCache->clear();
261 delete rCDFTableCache;
262 rCDFTableCache = NULL;
266 for(std::map<G4int,InterpolationTable*>::const_iterator i = pCDFTableCache->begin(); i!=pCDFTableCache->end(); ++i)
268 pCDFTableCache->clear();
269 delete pCDFTableCache;
270 pCDFTableCache = NULL;
G4double S(G4double temp)
Simple interpolation table for the inverse of a IFunction1D functor.
Class for Gaussian density.
NDF* class for the deuteron density according to the HardSphere potential.
Class for modified harmonic oscillator density.
NDF* class for the deuteron density according to the Paris potential.
Class for Woods-Saxon density.
InterpolationTable * inverseCDFTable(ManipulatorFunc fWrap=0, const G4int nNodes=60) const
Return a pointer to the inverse of the CDF of this function.
Class for interpolating the of a 1-dimensional function.
std::string print() const
G4double pow13(G4double x)
const G4double oneOverSqrtThree
InterpolationTable * createRPCorrelationTable(const ParticleType t, const G4int A, const G4int Z)
void addDensityToCache(const G4int A, const G4int Z, NuclearDensity *const density)
InterpolationTable * createPCDFTable(const ParticleType t, const G4int A, const G4int Z)
NuclearDensity const * createDensity(const G4int A, const G4int Z, const G4int S)
void addRPCorrelationToCache(const G4int A, const G4int Z, const ParticleType t, InterpolationTable *const table)
InterpolationTable * createRCDFTable(const ParticleType t, const G4int A, const G4int Z)
G4ThreadLocal FermiMomentumFn getFermiMomentum
G4double getRadiusParameter(const ParticleType t, const G4int A, const G4int Z)
G4double getMaximumNuclearRadius(const ParticleType t, const G4int A, const G4int Z)
G4double getSurfaceDiffuseness(const ParticleType t, const G4int A, const G4int Z)
G4double getMomentumRMS(const G4int A, const G4int Z)
Return the RMS of the momentum distribution (light clusters).