Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions
G4NativeScreenedCoulombCrossSection Class Reference

#include <G4ScreenedNuclearRecoil.hh>

Inheritance diagram for G4NativeScreenedCoulombCrossSection:
G4ScreenedCoulombCrossSection G4ScreenedCoulombCrossSectionInfo

Public Types

typedef G4_c2_function &(* ScreeningFunc )(G4int z1, G4int z2, size_t nPoints, G4double rMax, G4double *au)
 
- Public Types inherited from G4ScreenedCoulombCrossSection
enum  { nMassMapElements =116 }
 
typedef std::map< G4int,
G4ScreeningTables
ScreeningMap
 
typedef std::map< G4int, class
G4ParticleDefinition * > 
ParticleCache
 

Public Member Functions

 G4NativeScreenedCoulombCrossSection ()
 
 G4NativeScreenedCoulombCrossSection (const G4NativeScreenedCoulombCrossSection &src)
 
 G4NativeScreenedCoulombCrossSection (const G4ScreenedCoulombCrossSection &src)
 
virtual ~G4NativeScreenedCoulombCrossSection ()
 
virtual void LoadData (G4String screeningKey, G4int z1, G4double m1, G4double recoilCutoff)
 
virtual
G4ScreenedCoulombCrossSection
create ()
 
std::vector< G4StringGetScreeningKeys () const
 
void AddScreeningFunction (G4String name, ScreeningFunc fn)
 
- Public Member Functions inherited from G4ScreenedCoulombCrossSection
 G4ScreenedCoulombCrossSection ()
 
 G4ScreenedCoulombCrossSection (const G4ScreenedCoulombCrossSection &src)
 
virtual ~G4ScreenedCoulombCrossSection ()
 
void BuildMFPTables (void)
 
const G4ScreeningTablesGetScreening (G4int Z)
 
void SetVerbosity (G4int v)
 
G4ParticleDefinitionSelectRandomUnweightedTarget (const G4MaterialCutsCouple *couple)
 
G4double standardmass (G4int z1)
 
const G4_c2_functionoperator[] (G4int materialIndex)
 

Additional Inherited Members

- Protected Attributes inherited from G4ScreenedCoulombCrossSection
ScreeningMap screeningData
 
ParticleCache targetMap
 
G4int verbosity
 
std::map< G4int, G4_c2_const_ptrsigmaMap
 
std::map< G4int, G4_c2_const_ptrMFPTables
 

Detailed Description

Definition at line 353 of file G4ScreenedNuclearRecoil.hh.

Member Typedef Documentation

typedef G4_c2_function&(* G4NativeScreenedCoulombCrossSection::ScreeningFunc)(G4int z1, G4int z2, size_t nPoints, G4double rMax, G4double *au)

Definition at line 370 of file G4ScreenedNuclearRecoil.hh.

Constructor & Destructor Documentation

G4NativeScreenedCoulombCrossSection::G4NativeScreenedCoulombCrossSection ( )

Definition at line 842 of file G4ScreenedNuclearRecoil.cc.

References AddScreeningFunction(), LJScreening(), LJZBLScreening(), MoliereScreening(), and ZBLScreening().

Referenced by create().

842  {
847 }
G4_c2_function & LJScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
G4_c2_function & MoliereScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
G4_c2_function & LJZBLScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
G4_c2_function & ZBLScreening(G4int z1, G4int z2, size_t npoints, G4double rMax, G4double *auval)
void AddScreeningFunction(G4String name, ScreeningFunc fn)
G4NativeScreenedCoulombCrossSection::G4NativeScreenedCoulombCrossSection ( const G4NativeScreenedCoulombCrossSection src)
inline

Definition at line 358 of file G4ScreenedNuclearRecoil.hh.

359  : G4ScreenedCoulombCrossSection(src), phiMap(src.phiMap) { }
G4NativeScreenedCoulombCrossSection::G4NativeScreenedCoulombCrossSection ( const G4ScreenedCoulombCrossSection src)
inline
G4NativeScreenedCoulombCrossSection::~G4NativeScreenedCoulombCrossSection ( )
virtual

Definition at line 839 of file G4ScreenedNuclearRecoil.cc.

839  {
840 }

Member Function Documentation

void G4NativeScreenedCoulombCrossSection::AddScreeningFunction ( G4String  name,
ScreeningFunc  fn 
)
inline

Definition at line 372 of file G4ScreenedNuclearRecoil.hh.

Referenced by G4NativeScreenedCoulombCrossSection().

372  {
373  phiMap[name]=fn;
374  }
const XML_Char * name
virtual G4ScreenedCoulombCrossSection* G4NativeScreenedCoulombCrossSection::create ( )
inlinevirtual
std::vector< G4String > G4NativeScreenedCoulombCrossSection::GetScreeningKeys ( ) const

Definition at line 849 of file G4ScreenedNuclearRecoil.cc.

849  {
850  std::vector<G4String> keys;
851  // find the available screening keys
852  std::map<std::string, ScreeningFunc>::const_iterator sfunciter=phiMap.begin();
853  for(; sfunciter != phiMap.end(); sfunciter++) keys.push_back((*sfunciter).first);
854  return keys;
855 }
void G4NativeScreenedCoulombCrossSection::LoadData ( G4String  screeningKey,
G4int  z1,
G4double  m1,
G4double  recoilCutoff 
)
virtual

Implements G4ScreenedCoulombCrossSection.

Definition at line 874 of file G4ScreenedNuclearRecoil.cc.

References python.hepunit::amu_c2, python.hepunit::angstrom, G4ScreeningTables::au, python.hepunit::elm_coupling, G4ScreeningTables::emin, G4ScreeningTables::EMphiData, G4cout, G4endl, G4Element::GetA(), G4Material::GetElementVector(), G4Material::GetMaterialTable(), G4Material::GetNumberOfElements(), G4Material::GetNumberOfMaterials(), G4Element::GetZ(), python.hepunit::gram, c2_factory< float_type >::inverse_function(), c2_factory< float_type >::linear(), c2_factory< float_type >::log_log_interpolating_function(), G4ScreeningTables::m1, G4ScreeningTables::m2, eplot::material, python.hepunit::mole, python.hepunit::pi, c2_linear_p< float_type >::reset(), G4ScreenedCoulombCrossSection::screeningData, G4ScreenedCoulombCrossSection::sigmaMap, G4ScreenedCoulombCrossSection::standardmass(), G4ScreenedCoulombCrossSection::verbosity, c2_function< float_type >::xmax(), G4ScreeningTables::z1, and G4ScreeningTables::z2.

875 {
876  static const size_t sigLen=200; // since sigma doesn't matter much, a very coarse table will do
877  G4DataVector energies(sigLen);
878  G4DataVector data(sigLen);
879 
880  a1=standardmass(z1); // use standardized values for mass for building tables
881 
882  const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
883  if (materialTable == 0) { return; }
884  //G4Exception("mhmNativeCrossSection::LoadData - no MaterialTable found)");
885 
887 
888  for (G4int im=0; im<nMaterials; im++)
889  {
890  const G4Material* material= (*materialTable)[im];
891  const G4ElementVector* elementVector = material->GetElementVector();
892  const G4int nMatElements = material->GetNumberOfElements();
893 
894  for (G4int iEl=0; iEl<nMatElements; iEl++)
895  {
896  G4Element* element = (*elementVector)[iEl];
897  G4int Z = (G4int) element->GetZ();
898  G4double a2=element->GetA()*(mole/gram);
899 
900  if(sigmaMap.find(Z)!=sigmaMap.end()) continue; // we've already got this element
901 
902  // find the screening function generator we need
903  std::map<std::string, ScreeningFunc>::iterator sfunciter=phiMap.find(screeningKey);
904  if(sfunciter==phiMap.end()) {
905  G4cout << "no such screening key " << screeningKey << G4endl; // FIXME later
906  exit(1);
907  }
908  ScreeningFunc sfunc=(*sfunciter).second;
909 
910  G4double au;
911  G4_c2_ptr screen=sfunc(z1, Z, 200, 50.0*angstrom, &au); // generate the screening data
913 
914  st.EMphiData=screen; //save our phi table
915  st.z1=z1; st.m1=a1; st.z2=Z; st.m2=a2; st.emin=recoilCutoff;
916  st.au=au;
917 
918  // now comes the hard part... build the total cross section tables from the phi table
919  //based on (pi-thetac) = pi*beta*alpha/x0, but noting that alpha is very nearly unity, always
920  //so just solve it wth alpha=1, which makes the solution much easier
921  //this function returns an approximation to (beta/x0)^2=phi(x0)/(eps*x0)-1 ~ ((pi-thetac)/pi)^2
922  //Since we don't need exact sigma values, this is good enough (within a factor of 2 almost always)
923  //this rearranges to phi(x0)/(x0*eps) = 2*theta/pi - theta^2/pi^2
924 
925  c2_linear_p<G4double> &c2eps=c2.linear(0.0, 0.0, 1.0); // will store an appropriate eps inside this in loop
926  G4_c2_ptr phiau=screen(c2.linear(0.0, 0.0, au));
927  G4_c2_ptr x0func(phiau/c2eps); // this will be phi(x)/(x*eps) when c2eps is correctly set
928  x0func->set_domain(1e-6*angstrom/au, 0.9999*screen->xmax()/au); // needed for inverse function
929  // use the c2_inverse_function interface for the root finder... it is more efficient for an ordered
930  // computation of values.
931  G4_c2_ptr x0_solution(c2.inverse_function(x0func));
932 
933  G4double m1c2=a1*amu_c2;
934  G4double escale=z1*Z*elm_coupling/au; // energy at screening distance
935  G4double emax=m1c2; // model is doubtful in very relativistic range
936  G4double eratkin=0.9999*(4*a1*a2)/((a1+a2)*(a1+a2)); // #maximum kinematic ratio possible at 180 degrees
937  G4double cmfact0=st.emin/cm_energy(a1, a2, st.emin);
938  G4double l1=std::log(emax);
939  G4double l0=std::log(st.emin*cmfact0/eratkin);
940 
941  if(verbosity >=1)
942  G4cout << "Native Screening: " << screeningKey << " " << z1 << " " << a1 << " " <<
943  Z << " " << a2 << " " << recoilCutoff << G4endl;
944 
945  for(size_t idx=0; idx<sigLen; idx++) {
946  G4double ee=std::exp(idx*((l1-l0)/sigLen)+l0);
947  G4double gamma=1.0+ee/m1c2;
948  G4double eratio=(cmfact0*st.emin)/ee; // factor by which ee needs to be reduced to get emin
949  G4double theta=thetac(gamma*a1, a2, eratio);
950 
951  G4double eps=cm_energy(a1, a2, ee)/escale; // #make sure lab energy is converted to CM for these calculations
952  c2eps.reset(0.0, 0.0, eps); // set correct slope in this function
953 
954  G4double q=theta/pi;
955  // G4cout << ee << " " << m1c2 << " " << gamma << " " << eps << " " << theta << " " << q << G4endl;
956  // old way using root finder
957  // G4double x0= x0func->find_root(1e-6*angstrom/au, 0.9999*screen.xmax()/au, 1.0, 2*q-q*q);
958  // new way using c2_inverse_function which caches useful information so should be a bit faster
959  // since we are scanning this in strict order.
960  G4double x0=0;
961  try {
962  x0=x0_solution(2*q-q*q);
963  } catch(c2_exception e) {
964  //G4Exception(G4String("G4ScreenedNuclearRecoil: failure in inverse solution to generate MFP Tables: ")+e.what());
965  }
966  G4double betasquared=x0*x0 - x0*phiau(x0)/eps;
967  G4double sigma=pi*betasquared*au*au;
968  energies[idx]=ee;
969  data[idx]=sigma;
970  }
971  screeningData[Z]=st;
972  sigmaMap[Z] = c2.log_log_interpolating_function().load(energies, data, true,0,true,0);
973  }
974  }
975 }
std::vector< G4Element * > G4ElementVector
G4double GetZ() const
Definition: G4Element.hh:131
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
std::vector< G4Material * > G4MaterialTable
tuple elm_coupling
Definition: hepunit.py:286
G4double GetA() const
Definition: G4Element.hh:138
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:188
int G4int
Definition: G4Types.hh:78
string material
Definition: eplot.py:19
G4GLOB_DLL std::ostream G4cout
void reset(float_type x0, float_type y0, float_type slope)
Change the slope and intercepts after construction.
std::map< G4int, G4_c2_const_ptr > sigmaMap
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:571
the exception class for c2_function operations.
Definition: c2_function.hh:65
int angstrom
Definition: hepunit.py:36
#define G4endl
Definition: G4ios.hh:61
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
double G4double
Definition: G4Types.hh:76
G4_c2_function &(* ScreeningFunc)(G4int z1, G4int z2, size_t nPoints, G4double rMax, G4double *au)
float amu_c2
Definition: hepunit.py:277
float_type xmax() const
return the upper bound of the domain for this function as set by set_domain()
Definition: c2_function.hh:299
const XML_Char const XML_Char * data

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