Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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. More...
 
void clearCache ()
 Clear the INuclearPotential cache. More...
 

Function Documentation

void G4INCL::NuclearPotential::clearCache ( )

Clear the INuclearPotential cache.

Definition at line 99 of file G4INCLINuclearPotential.cc.

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

Here is the caller graph for this function:

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 67 of file G4INCLINuclearPotential.cc.

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

Here is the caller graph for this function: