Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Functions
G4INCL::NuclearPotential Namespace Reference

Data Structures

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. More...
 
void clearCache ()
 Clear the INuclearPotential cache. More...
 

Function Documentation

void G4INCL::NuclearPotential::clearCache ( )

Clear the INuclearPotential cache.

Definition at line 98 of file G4INCLINuclearPotential.cc.

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

98  {
99  if(nuclearPotentialCache) {
100  for(std::map<long,INuclearPotential const *>::const_iterator i = nuclearPotentialCache->begin(), e=nuclearPotentialCache->end(); i!=e; ++i)
101  delete i->second;
102  nuclearPotentialCache->clear();
103  delete nuclearPotentialCache;
104  nuclearPotentialCache = NULL;
105  }
106  }
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 66 of file G4INCLINuclearPotential.cc.

References G4INCL::ConstantPotential, INCL_FATAL, G4INCL::IsospinEnergyPotential, G4INCL::IsospinEnergySmoothPotential, and G4INCL::IsospinPotential.

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

66  {
67  if(!nuclearPotentialCache)
68  nuclearPotentialCache = new std::map<long,INuclearPotential const *>;
69 
70  const long nuclideID = (pionPotential ? 1 : -1) * (1000*theZ + theA + 1000000*type); // MCNP-style nuclide IDs
71  const std::map<long,INuclearPotential const *>::const_iterator mapEntry = nuclearPotentialCache->find(nuclideID);
72  if(mapEntry == nuclearPotentialCache->end()) {
73  INuclearPotential const *thePotential = NULL;
74  switch(type) {
76  thePotential = new NuclearPotentialEnergyIsospinSmooth(theA, theZ, pionPotential);
77  break;
79  thePotential = new NuclearPotentialEnergyIsospin(theA, theZ, pionPotential);
80  break;
81  case IsospinPotential:
82  thePotential = new NuclearPotentialIsospin(theA, theZ, pionPotential);
83  break;
84  case ConstantPotential:
85  thePotential = new NuclearPotentialConstant(theA, theZ, pionPotential);
86  break;
87  default:
88  INCL_FATAL("Unrecognized potential type at Nucleus creation." << std::endl);
89  break;
90  }
91  (*nuclearPotentialCache)[nuclideID] = thePotential;
92  return thePotential;
93  } else {
94  return mapEntry->second;
95  }
96  }
#define INCL_FATAL(x)