Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ScreenedCoulombCrossSection Class Referenceabstract

#include <G4ScreenedNuclearRecoil.hh>

Inheritance diagram for G4ScreenedCoulombCrossSection:
Collaboration diagram for G4ScreenedCoulombCrossSection:

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 100 of file G4ScreenedNuclearRecoil.hh.

Member Typedef Documentation

Member Enumeration Documentation

anonymous enum
Enumerator
nMassMapElements 

Definition at line 134 of file G4ScreenedNuclearRecoil.hh.

Constructor & Destructor Documentation

G4ScreenedCoulombCrossSection::G4ScreenedCoulombCrossSection ( )
inline

Definition at line 104 of file G4ScreenedNuclearRecoil.hh.

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

Definition at line 129 of file G4ScreenedNuclearRecoil.cc.

130 {
131  screeningData.clear();
132  MFPTables.clear();
133 }
std::map< G4int, G4_c2_const_ptr > MFPTables

Member Function Documentation

void G4ScreenedCoulombCrossSection::BuildMFPTables ( void  )

Definition at line 247 of file G4ScreenedNuclearRecoil.cc.

248 {
249  const G4int nmfpvals=200;
250 
251  std::vector<G4double> evals(nmfpvals), mfpvals(nmfpvals);
252 
253  // sum up inverse MFPs per element for each material
254  const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
255  if (materialTable == 0) { return; }
256  //G4Exception("G4ScreenedCoulombCrossSection::BuildMFPTables
257  //- no MaterialTable found)");
258 
260 
261  for (G4int matidx=0; matidx < nMaterials; matidx++) {
262 
263  const G4Material* material= (*materialTable)[matidx];
264  const G4ElementVector &elementVector =
265  *(material->GetElementVector());
266  const G4int nMatElements = material->GetNumberOfElements();
267 
268  const G4Element *element=0;
269  const G4double *atomDensities=material->GetVecNbOfAtomsPerVolume();
270 
271  G4double emin=0, emax=0;
272  // find innermost range of cross section functions
273  for (G4int kel=0 ; kel < nMatElements ; kel++ )
274  {
275  element=elementVector[kel];
276  G4int Z=(G4int)std::floor(element->GetZ()+0.5);
277  const G4_c2_function &ifunc=sigmaMap[Z];
278  if(!kel || ifunc.xmin() > emin) emin=ifunc.xmin();
279  if(!kel || ifunc.xmax() < emax) emax=ifunc.xmax();
280  }
281 
282  G4double logint=std::log(emax/emin) / (nmfpvals-1) ;
283  // logarithmic increment for tables
284 
285  // compute energy scale for interpolator. Force exact values at
286  // both ends to avoid range errors
287  for (G4int i=1; i<nmfpvals-1; i++) evals[i]=emin*std::exp(logint*i);
288  evals.front()=emin;
289  evals.back()=emax;
290 
291  // zero out the inverse mfp sums to start
292  for (G4int eidx=0; eidx < nmfpvals; eidx++) mfpvals[eidx] = 0.0;
293 
294  // sum inverse mfp for each element in this material and for each
295  // energy
296  for (G4int kel=0 ; kel < nMatElements ; kel++ )
297  {
298  element=elementVector[kel];
299  G4int Z=(G4int)std::floor(element->GetZ()+0.5);
300  const G4_c2_function &sigma=sigmaMap[Z];
301  G4double ndens = atomDensities[kel];
302  // compute atom fraction for this element in this material
303 
304  for (G4int eidx=0; eidx < nmfpvals; eidx++) {
305  mfpvals[eidx] += ndens*sigma(evals[eidx]);
306  }
307  }
308 
309  // convert inverse mfp to regular mfp
310  for (G4int eidx=0; eidx < nmfpvals; eidx++) {
311  mfpvals[eidx] = 1.0/mfpvals[eidx];
312  }
313  // and make a new interpolating function out of the sum
314  MFPTables[matidx] = c2.log_log_interpolating_function().load(evals,
315  mfpvals,true,0,true,0);
316  }
317 }
static c2_factory< G4double > c2
std::vector< G4Element * > G4ElementVector
G4double GetZ() const
Definition: G4Element.hh:131
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
std::vector< G4Material * > G4MaterialTable
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
string material
Definition: eplot.py:19
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:206
std::map< G4int, G4_c2_const_ptr > MFPTables
std::map< G4int, G4_c2_const_ptr > sigmaMap
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:594
static const G4double emax
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
double G4double
Definition: G4Types.hh:76
float_type xmax() const
Definition: c2_function.hh:390
float_type xmin() const
Definition: c2_function.hh:389

Here is the call graph for this function:

Here is the caller graph for this function:

virtual G4ScreenedCoulombCrossSection* G4ScreenedCoulombCrossSection::create ( )
pure virtual

Implemented in G4NativeScreenedCoulombCrossSection.

Here is the caller graph for this function:

const G4ScreeningTables* G4ScreenedCoulombCrossSection::GetScreening ( G4int  Z)
inline

Definition at line 126 of file G4ScreenedNuclearRecoil.hh.

127  { return &(screeningData[Z]); }

Here is the caller graph for this function:

virtual void G4ScreenedCoulombCrossSection::LoadData ( G4String  screeningKey,
G4int  z1,
G4double  m1,
G4double  recoilCutoff 
)
pure virtual

Implemented in G4NativeScreenedCoulombCrossSection.

Here is the caller graph for this function:

const G4_c2_function* G4ScreenedCoulombCrossSection::operator[] ( G4int  materialIndex)
inline

Definition at line 140 of file G4ScreenedNuclearRecoil.hh.

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

Definition at line 166 of file G4ScreenedNuclearRecoil.cc.

168 {
169  // Select randomly an element within the material, according to number
170  // density only
171  const G4Material* material = couple->GetMaterial();
172  G4int nMatElements = material->GetNumberOfElements();
173  const G4ElementVector* elementVector = material->GetElementVector();
174  const G4Element *element=0;
176 
177  // Special case: the material consists of one element
178  if (nMatElements == 1)
179  {
180  element= (*elementVector)[0];
181  }
182  else
183  {
184  // Composite material
185  G4double random = G4UniformRand() * material->GetTotNbOfAtomsPerVolume();
186  G4double nsum=0.0;
187  const G4double *atomDensities=material->GetVecNbOfAtomsPerVolume();
188 
189  for (G4int k=0 ; k < nMatElements ; k++ )
190  {
191  nsum+=atomDensities[k];
192  element= (*elementVector)[k];
193  if (nsum >= random) break;
194  }
195  }
196 
197  G4int N=0;
198  G4int Z=(G4int)std::floor(element->GetZ()+0.5);
199 
200  G4int nIsotopes=element->GetNumberOfIsotopes();
201  if(!nIsotopes) {
202  if(Z<=92) {
203  // we have no detailed material isotopic info available,
204  // so use G4StableIsotopes table up to Z=92
205  static G4StableIsotopes theIso;
206  // get a stable isotope table for default results
207  nIsotopes=theIso.GetNumberOfIsotopes(Z);
208  G4double random = 100.0*G4UniformRand();
209  // values are expressed as percent, sum is 100
210  G4int tablestart=theIso.GetFirstIsotope(Z);
211  G4double asum=0.0;
212  for(G4int i=0; i<nIsotopes; i++) {
213  asum+=theIso.GetAbundance(i+tablestart);
214  N=theIso.GetIsotopeNucleonCount(i+tablestart);
215  if(asum >= random) break;
216  }
217  } else {
218  // too heavy for stable isotope table, just use mean mass
219  N=(G4int)std::floor(element->GetN()+0.5);
220  }
221  } else {
222  G4int i;
223  const G4IsotopeVector *isoV=element->GetIsotopeVector();
224  G4double random = G4UniformRand();
225  G4double *abundance=element->GetRelativeAbundanceVector();
226  G4double asum=0.0;
227  for(i=0; i<nIsotopes; i++) {
228  asum+=abundance[i];
229  N=(*isoV)[i]->GetN();
230  if(asum >= random) break;
231  }
232  }
233 
234  // get the official definition of this nucleus, to get the correct
235  // value of A note that GetIon is very slow, so we will cache ones
236  // we have already found ourselves.
237  ParticleCache::iterator p=targetMap.find(Z*1000+N);
238  if (p != targetMap.end()) {
239  target=(*p).second;
240  } else{
241  target=G4IonTable::GetIonTable()->GetIon(Z, N, 0.0);
242  targetMap[Z*1000+N]=target;
243  }
244  return target;
245 }
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:159
std::vector< G4Isotope * > G4IsotopeVector
const XML_Char * target
Definition: expat.h:268
std::vector< G4Element * > G4ElementVector
G4double GetN() const
Definition: G4Element.hh:135
G4int GetFirstIsotope(G4int Z)
const char * p
Definition: xmltok.h:285
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
Definition: G4IonTable.cc:503
G4double GetZ() const
Definition: G4Element.hh:131
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
string material
Definition: eplot.py:19
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:206
#define G4UniformRand()
Definition: Randomize.hh:97
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:167
static G4IonTable * GetIonTable()
Definition: G4IonTable.hh:78
G4int GetNumberOfIsotopes(G4int Z)
G4double GetTotNbOfAtomsPerVolume() const
Definition: G4Material.hh:209
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:163
G4int GetIsotopeNucleonCount(G4int number)
**D E S C R I P T I O N
Definition: HEPEvtcom.cc:77
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
G4double GetAbundance(G4int number)
double G4double
Definition: G4Types.hh:76
const G4Material * GetMaterial() const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ScreenedCoulombCrossSection::SetVerbosity ( G4int  v)
inline

Definition at line 128 of file G4ScreenedNuclearRecoil.hh.

Here is the caller graph for this function:

G4double G4ScreenedCoulombCrossSection::standardmass ( G4int  z1)
inline

Definition at line 136 of file G4ScreenedNuclearRecoil.hh.

137  { return z1 <= nMassMapElements ? massmap[z1] : 2.5*z1; }

Here is the caller graph for this function:

Member Data Documentation

std::map<G4int, G4_c2_const_ptr > G4ScreenedCoulombCrossSection::MFPTables
protected

Definition at line 151 of file G4ScreenedNuclearRecoil.hh.

ScreeningMap G4ScreenedCoulombCrossSection::screeningData
protected

Definition at line 146 of file G4ScreenedNuclearRecoil.hh.

std::map<G4int, G4_c2_const_ptr > G4ScreenedCoulombCrossSection::sigmaMap
protected

Definition at line 149 of file G4ScreenedNuclearRecoil.hh.

ParticleCache G4ScreenedCoulombCrossSection::targetMap
protected

Definition at line 147 of file G4ScreenedNuclearRecoil.hh.

G4int G4ScreenedCoulombCrossSection::verbosity
protected

Definition at line 148 of file G4ScreenedNuclearRecoil.hh.


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