Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Attributes
G4ScreenedCoulombCrossSection Class Referenceabstract

#include <G4ScreenedNuclearRecoil.hh>

Inheritance diagram for G4ScreenedCoulombCrossSection:
G4ScreenedCoulombCrossSectionInfo G4NativeScreenedCoulombCrossSection

Public Types

enum  { nMassMapElements =116 }
 
typedef std::map< G4int,
G4ScreeningTables
ScreeningMap
 
typedef std::map< G4int, class
G4ParticleDefinition * > 
ParticleCache
 

Public Member Functions

 G4ScreenedCoulombCrossSection ()
 
 G4ScreenedCoulombCrossSection (const G4ScreenedCoulombCrossSection &src)
 
virtual ~G4ScreenedCoulombCrossSection ()
 
virtual void LoadData (G4String screeningKey, G4int z1, G4double m1, G4double recoilCutoff)=0
 
void BuildMFPTables (void)
 
virtual
G4ScreenedCoulombCrossSection
create ()=0
 
const G4ScreeningTablesGetScreening (G4int Z)
 
void SetVerbosity (G4int v)
 
G4ParticleDefinitionSelectRandomUnweightedTarget (const G4MaterialCutsCouple *couple)
 
G4double standardmass (G4int z1)
 
const G4_c2_functionoperator[] (G4int materialIndex)
 

Protected Attributes

ScreeningMap screeningData
 
ParticleCache targetMap
 
G4int verbosity
 
std::map< G4int, G4_c2_const_ptrsigmaMap
 
std::map< G4int, G4_c2_const_ptrMFPTables
 

Additional Inherited Members

Detailed Description

Definition at line 95 of file G4ScreenedNuclearRecoil.hh.

Member Typedef Documentation

Definition at line 107 of file G4ScreenedNuclearRecoil.hh.

Definition at line 104 of file G4ScreenedNuclearRecoil.hh.

Member Enumeration Documentation

anonymous enum
Enumerator
nMassMapElements 

Definition at line 123 of file G4ScreenedNuclearRecoil.hh.

Constructor & Destructor Documentation

G4ScreenedCoulombCrossSection::G4ScreenedCoulombCrossSection ( )
inline

Definition at line 99 of file G4ScreenedNuclearRecoil.hh.

G4ScreenedCoulombCrossSection::G4ScreenedCoulombCrossSection ( const G4ScreenedCoulombCrossSection src)
inline
G4ScreenedCoulombCrossSection::~G4ScreenedCoulombCrossSection ( )
virtual

Definition at line 125 of file G4ScreenedNuclearRecoil.cc.

References MFPTables, and screeningData.

126 {
127  screeningData.clear();
128  MFPTables.clear();
129 }
std::map< G4int, G4_c2_const_ptr > MFPTables

Member Function Documentation

void G4ScreenedCoulombCrossSection::BuildMFPTables ( void  )

Definition at line 224 of file G4ScreenedNuclearRecoil.cc.

References G4Material::GetElementVector(), G4Material::GetMaterialTable(), G4Material::GetNumberOfElements(), G4Material::GetNumberOfMaterials(), G4Material::GetVecNbOfAtomsPerVolume(), G4Element::GetZ(), c2_factory< float_type >::log_log_interpolating_function(), eplot::material, MFPTables, sigmaMap, c2_function< float_type >::xmax(), and c2_function< float_type >::xmin().

Referenced by G4ScreenedNuclearRecoil::GetMeanFreePath().

225 {
226  const G4int nmfpvals=200;
227 
228  std::vector<G4double> evals(nmfpvals), mfpvals(nmfpvals);
229 
230  // sum up inverse MFPs per element for each material
231  const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
232  if (materialTable == 0) { return; }
233  //G4Exception("G4ScreenedCoulombCrossSection::BuildMFPTables - no MaterialTable found)");
234 
236 
237  for (G4int matidx=0; matidx < nMaterials; matidx++) {
238 
239  const G4Material* material= (*materialTable)[matidx];
240  const G4ElementVector &elementVector = *(material->GetElementVector());
241  const G4int nMatElements = material->GetNumberOfElements();
242 
243  const G4Element *element=0;
244  const G4double *atomDensities=material->GetVecNbOfAtomsPerVolume();
245 
246  G4double emin=0, emax=0; // find innermost range of cross section functions
247  for (G4int kel=0 ; kel < nMatElements ; kel++ )
248  {
249  element=elementVector[kel];
250  G4int Z=(G4int)std::floor(element->GetZ()+0.5);
251  const G4_c2_function &ifunc=sigmaMap[Z];
252  if(!kel || ifunc.xmin() > emin) emin=ifunc.xmin();
253  if(!kel || ifunc.xmax() < emax) emax=ifunc.xmax();
254  }
255 
256  G4double logint=std::log(emax/emin) / (nmfpvals-1) ; // logarithmic increment for tables
257 
258  // compute energy scale for interpolator. Force exact values at both ends to avoid range errors
259  for (G4int i=1; i<nmfpvals-1; i++) evals[i]=emin*std::exp(logint*i);
260  evals.front()=emin;
261  evals.back()=emax;
262 
263  // zero out the inverse mfp sums to start
264  for (G4int eidx=0; eidx < nmfpvals; eidx++) mfpvals[eidx] = 0.0;
265 
266  // sum inverse mfp for each element in this material and for each energy
267  for (G4int kel=0 ; kel < nMatElements ; kel++ )
268  {
269  element=elementVector[kel];
270  G4int Z=(G4int)std::floor(element->GetZ()+0.5);
271  const G4_c2_function &sigma=sigmaMap[Z];
272  G4double ndens = atomDensities[kel]; // compute atom fraction for this element in this material
273 
274  for (G4int eidx=0; eidx < nmfpvals; eidx++) {
275  mfpvals[eidx] += ndens*sigma(evals[eidx]);
276  }
277  }
278 
279  // convert inverse mfp to regular mfp
280  for (G4int eidx=0; eidx < nmfpvals; eidx++) {
281  mfpvals[eidx] = 1.0/mfpvals[eidx];
282  }
283  // and make a new interpolating function out of the sum
284  MFPTables[matidx] = c2.log_log_interpolating_function().load(evals, mfpvals,true,0,true,0);
285  }
286 }
std::vector< G4Element * > G4ElementVector
G4double GetZ() const
Definition: G4Element.hh:131
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
std::vector< G4Material * > G4MaterialTable
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:188
int G4int
Definition: G4Types.hh:78
string material
Definition: eplot.py:19
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:204
std::map< G4int, G4_c2_const_ptr > MFPTables
std::map< G4int, G4_c2_const_ptr > sigmaMap
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:571
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
double G4double
Definition: G4Types.hh:76
float_type xmax() const
return the upper bound of the domain for this function as set by set_domain()
Definition: c2_function.hh:299
float_type xmin() const
return the lower bound of the domain for this function as set by set_domain()
Definition: c2_function.hh:297
virtual G4ScreenedCoulombCrossSection* G4ScreenedCoulombCrossSection::create ( )
pure virtual
const G4ScreeningTables* G4ScreenedCoulombCrossSection::GetScreening ( G4int  Z)
inline

Definition at line 117 of file G4ScreenedNuclearRecoil.hh.

References screeningData.

Referenced by G4ScreenedCoulombClassicalKinematics::DoCollisionStep().

117 { return &(screeningData[Z]); }
virtual void G4ScreenedCoulombCrossSection::LoadData ( G4String  screeningKey,
G4int  z1,
G4double  m1,
G4double  recoilCutoff 
)
pure virtual
const G4_c2_function* G4ScreenedCoulombCrossSection::operator[] ( G4int  materialIndex)
inline

Definition at line 128 of file G4ScreenedNuclearRecoil.hh.

References MFPTables.

128  {
129  return MFPTables.find(materialIndex)!=MFPTables.end() ? &(MFPTables[materialIndex].get()) : (G4_c2_function *)0;
130  }
std::map< G4int, G4_c2_const_ptr > MFPTables
G4ParticleDefinition * G4ScreenedCoulombCrossSection::SelectRandomUnweightedTarget ( const G4MaterialCutsCouple couple)

Definition at line 148 of file G4ScreenedNuclearRecoil.cc.

References G4UniformRand, G4StableIsotopes::GetAbundance(), G4Material::GetElementVector(), G4StableIsotopes::GetFirstIsotope(), G4ParticleTable::GetIon(), G4StableIsotopes::GetIsotopeNucleonCount(), G4Element::GetIsotopeVector(), G4MaterialCutsCouple::GetMaterial(), G4Element::GetN(), G4Material::GetNumberOfElements(), G4StableIsotopes::GetNumberOfIsotopes(), G4Element::GetNumberOfIsotopes(), G4ParticleTable::GetParticleTable(), G4Element::GetRelativeAbundanceVector(), G4Material::GetTotNbOfAtomsPerVolume(), G4Material::GetVecNbOfAtomsPerVolume(), G4Element::GetZ(), eplot::material, N, and targetMap.

Referenced by G4ScreenedNuclearRecoil::PostStepDoIt().

149 {
150  // Select randomly an element within the material, according to number density only
151  const G4Material* material = couple->GetMaterial();
152  G4int nMatElements = material->GetNumberOfElements();
153  const G4ElementVector* elementVector = material->GetElementVector();
154  const G4Element *element=0;
156 
157  // Special case: the material consists of one element
158  if (nMatElements == 1)
159  {
160  element= (*elementVector)[0];
161  }
162  else
163  {
164  // Composite material
165  G4double random = G4UniformRand() * material->GetTotNbOfAtomsPerVolume();
166  G4double nsum=0.0;
167  const G4double *atomDensities=material->GetVecNbOfAtomsPerVolume();
168 
169  for (G4int k=0 ; k < nMatElements ; k++ )
170  {
171  nsum+=atomDensities[k];
172  element= (*elementVector)[k];
173  if (nsum >= random) break;
174  }
175  }
176 
177  G4int N=0;
178  G4int Z=(G4int)std::floor(element->GetZ()+0.5);
179 
180  G4int nIsotopes=element->GetNumberOfIsotopes();
181  if(!nIsotopes) {
182  if(Z<=92) {
183  // we have no detailed material isotopic info available,
184  // so use G4StableIsotopes table up to Z=92
185  static G4StableIsotopes theIso; // get a stable isotope table for default results
186  nIsotopes=theIso.GetNumberOfIsotopes(Z);
187  G4double random = 100.0*G4UniformRand(); // values are expressed as percent, sum is 100
188  G4int tablestart=theIso.GetFirstIsotope(Z);
189  G4double asum=0.0;
190  for(G4int i=0; i<nIsotopes; i++) {
191  asum+=theIso.GetAbundance(i+tablestart);
192  N=theIso.GetIsotopeNucleonCount(i+tablestart);
193  if(asum >= random) break;
194  }
195  } else {
196  // too heavy for stable isotope table, just use mean mass
197  N=(G4int)std::floor(element->GetN()+0.5);
198  }
199  } else {
200  G4int i;
201  const G4IsotopeVector *isoV=element->GetIsotopeVector();
202  G4double random = G4UniformRand();
203  G4double *abundance=element->GetRelativeAbundanceVector();
204  G4double asum=0.0;
205  for(i=0; i<nIsotopes; i++) {
206  asum+=abundance[i];
207  N=(*isoV)[i]->GetN();
208  if(asum >= random) break;
209  }
210  }
211 
212  // get the official definition of this nucleus, to get the correct value of A
213  // note that GetIon is very slow, so we will cache ones we have already found ourselves.
214  ParticleCache::iterator p=targetMap.find(Z*1000+N);
215  if (p != targetMap.end()) {
216  target=(*p).second;
217  } else{
218  target=G4ParticleTable::GetParticleTable()->GetIon(Z, N, 0.0);
219  targetMap[Z*1000+N]=target;
220  }
221  return target;
222 }
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
std::vector< G4Isotope * > G4IsotopeVector
std::vector< G4Element * > G4ElementVector
G4double GetN() const
Definition: G4Element.hh:134
G4ParticleDefinition * GetIon(G4int atomicNumber, G4int atomicMass, G4double excitationEnergy)
G4int GetFirstIsotope(G4int Z)
const char * p
Definition: xmltok.h:285
G4double GetZ() const
Definition: G4Element.hh:131
const XML_Char * target
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:188
int G4int
Definition: G4Types.hh:78
string material
Definition: eplot.py:19
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:204
#define G4UniformRand()
Definition: Randomize.hh:87
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:166
G4int GetNumberOfIsotopes(G4int Z)
G4double GetTotNbOfAtomsPerVolume() const
Definition: G4Material.hh:207
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:162
G4int GetIsotopeNucleonCount(G4int number)
static G4ParticleTable * GetParticleTable()
**D E S C R I P T I O N
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
G4double GetAbundance(G4int number)
double G4double
Definition: G4Types.hh:76
const G4Material * GetMaterial() const
void G4ScreenedCoulombCrossSection::SetVerbosity ( G4int  v)
inline
G4double G4ScreenedCoulombCrossSection::standardmass ( G4int  z1)
inline

Field Documentation

std::map<G4int, G4_c2_const_ptr > G4ScreenedCoulombCrossSection::MFPTables
protected
ScreeningMap G4ScreenedCoulombCrossSection::screeningData
protected
std::map<G4int, G4_c2_const_ptr > G4ScreenedCoulombCrossSection::sigmaMap
protected
ParticleCache G4ScreenedCoulombCrossSection::targetMap
protected

Definition at line 134 of file G4ScreenedNuclearRecoil.hh.

Referenced by SelectRandomUnweightedTarget().

G4int G4ScreenedCoulombCrossSection::verbosity
protected

The documentation for this class was generated from the following files: