Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4PenelopeIonisationXSHandler Class Reference

#include <G4PenelopeIonisationXSHandler.hh>

Public Member Functions

 G4PenelopeIonisationXSHandler (size_t nBins=200)
 
virtual ~G4PenelopeIonisationXSHandler ()
 Destructor. Clean all tables. More...
 
G4double GetDensityCorrection (const G4Material *, const G4double energy) const
 Returns the density coeection for the material at the given energy. More...
 
const G4PenelopeCrossSectionGetCrossSectionTableForCouple (const G4ParticleDefinition *, const G4Material *, const G4double cut) const
 
void SetVerboseLevel (G4int vl)
 Setter for the verbosity level. More...
 
void BuildXSTable (const G4Material *, G4double cut, const G4ParticleDefinition *, G4bool isMaster=true)
 This can be inkoved only by the master. More...
 

Detailed Description

Definition at line 60 of file G4PenelopeIonisationXSHandler.hh.

Constructor & Destructor Documentation

G4PenelopeIonisationXSHandler::G4PenelopeIonisationXSHandler ( size_t  nBins = 200)

Constructor. nBins is the number of intervals in the energy grid. By default the energy grid goes from 100 eV to 100 GeV.

Definition at line 47 of file G4PenelopeIonisationXSHandler.cc.

48  :XSTableElectron(0),XSTablePositron(0),
49  theDeltaTable(0),energyGrid(0)
50 {
51  nBins = nb;
52  G4double LowEnergyLimit = 100.0*eV;
53  G4double HighEnergyLimit = 100.0*GeV;
55  XSTableElectron = new
56  std::map< std::pair<const G4Material*,G4double>, G4PenelopeCrossSection*>;
57  XSTablePositron = new
58  std::map< std::pair<const G4Material*,G4double>, G4PenelopeCrossSection*>;
59 
60  theDeltaTable = new std::map<const G4Material*,G4PhysicsFreeVector*>;
61  energyGrid = new G4PhysicsLogVector(LowEnergyLimit,
62  HighEnergyLimit,
63  nBins-1); //one hidden bin is added
64 
65  verboseLevel = 0;
66 }
static constexpr double eV
Definition: G4SIunits.hh:215
static G4PenelopeOscillatorManager * GetOscillatorManager()
static constexpr double GeV
Definition: G4SIunits.hh:217
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4PenelopeIonisationXSHandler::~G4PenelopeIonisationXSHandler ( )
virtual

Destructor. Clean all tables.

Definition at line 70 of file G4PenelopeIonisationXSHandler.cc.

71 {
72  if (XSTableElectron)
73  {
74  for (auto& item : (*XSTableElectron))
75  {
76  //G4PenelopeCrossSection* tab = i->second;
77  delete item.second;
78  }
79  delete XSTableElectron;
80  XSTableElectron = nullptr;
81  }
82 
83  if (XSTablePositron)
84  {
85  for (auto& item : (*XSTablePositron))
86  {
87  //G4PenelopeCrossSection* tab = i->second;
88  delete item.second;
89  }
90  delete XSTablePositron;
91  XSTablePositron = nullptr;
92  }
93  if (theDeltaTable)
94  {
95  for (auto& item : (*theDeltaTable))
96  delete item.second;
97  delete theDeltaTable;
98  theDeltaTable = nullptr;
99  }
100  if (energyGrid)
101  delete energyGrid;
102 
103  if (verboseLevel > 2)
104  G4cout << "G4PenelopeIonisationXSHandler. Tables have been cleared"
105  << G4endl;
106 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Member Function Documentation

void G4PenelopeIonisationXSHandler::BuildXSTable ( const G4Material mat,
G4double  cut,
const G4ParticleDefinition part,
G4bool  isMaster = true 
)

This can be inkoved only by the master.

Definition at line 160 of file G4PenelopeIonisationXSHandler.cc.

163 {
164  //Just to check
165  if (!isMaster)
166  G4Exception("G4PenelopeIonisationXSHandler::BuildXSTable()",
167  "em0100",FatalException,"Worker thread in this method");
168 
169  //
170  //This method fills the G4PenelopeCrossSection containers for electrons or positrons
171  //and for the given material/cut couple. The calculation is done as sum over the
172  //individual shells.
173  //Equivalent of subroutines EINaT and PINaT of Penelope
174  //
175  if (verboseLevel > 2)
176  {
177  G4cout << "G4PenelopeIonisationXSHandler: going to build cross section table " << G4endl;
178  G4cout << "for " << part->GetParticleName() << " in " << mat->GetName() << G4endl;
179  G4cout << "Cut= " << cut/keV << " keV" << G4endl;
180  }
181 
182  std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
183  //Check if the table already exists
184  if (part == G4Electron::Electron())
185  {
186  if (XSTableElectron->count(theKey)) //table already built
187  return;
188  }
189  if (part == G4Positron::Positron())
190  {
191  if (XSTablePositron->count(theKey)) //table already built
192  return;
193  }
194 
195  //check if the material has been built
196  if (!(theDeltaTable->count(mat)))
197  BuildDeltaTable(mat);
198 
199 
200  //Tables have been already created (checked by GetCrossSectionTableForCouple)
201  G4PenelopeOscillatorTable* theTable = oscManager->GetOscillatorTableIonisation(mat);
202  size_t numberOfOscillators = theTable->size();
203 
204  if (energyGrid->GetVectorLength() != nBins)
205  {
207  ed << "Energy Grid looks not initialized" << G4endl;
208  ed << nBins << " " << energyGrid->GetVectorLength() << G4endl;
209  G4Exception("G4PenelopeIonisationXSHandler::BuildXSTable()",
210  "em2030",FatalException,ed);
211  }
212 
213  G4PenelopeCrossSection* XSEntry = new G4PenelopeCrossSection(nBins,numberOfOscillators);
214 
215  //loop on the energy grid
216  for (size_t bin=0;bin<nBins;bin++)
217  {
218  G4double energy = energyGrid->GetLowEdgeEnergy(bin);
219  G4double XH0=0, XH1=0, XH2=0;
220  G4double XS0=0, XS1=0, XS2=0;
221 
222  //oscillator loop
223  for (size_t iosc=0;iosc<numberOfOscillators;iosc++)
224  {
225  G4DataVector* tempStorage = 0;
226 
227  G4PenelopeOscillator* theOsc = (*theTable)[iosc];
228  G4double delta = GetDensityCorrection(mat,energy);
229  if (part == G4Electron::Electron())
230  tempStorage = ComputeShellCrossSectionsElectron(theOsc,energy,cut,delta);
231  else if (part == G4Positron::Positron())
232  tempStorage = ComputeShellCrossSectionsPositron(theOsc,energy,cut,delta);
233  //check results are all right
234  if (!tempStorage)
235  {
237  ed << "Problem in calculating the shell XS for shell # "
238  << iosc << G4endl;
239  G4Exception("G4PenelopeIonisationXSHandler::BuildXSTable()",
240  "em2031",FatalException,ed);
241  delete XSEntry;
242  return;
243  }
244  if (tempStorage->size() != 6)
245  {
247  ed << "Problem in calculating the shell XS " << G4endl;
248  ed << "Result has dimension " << tempStorage->size() << " instead of 6" << G4endl;
249  G4Exception("G4PenelopeIonisationXSHandler::BuildXSTable()",
250  "em2031",FatalException,ed);
251  }
252  G4double stre = theOsc->GetOscillatorStrength();
253 
254  XH0 += stre*(*tempStorage)[0];
255  XH1 += stre*(*tempStorage)[1];
256  XH2 += stre*(*tempStorage)[2];
257  XS0 += stre*(*tempStorage)[3];
258  XS1 += stre*(*tempStorage)[4];
259  XS2 += stre*(*tempStorage)[5];
260  XSEntry->AddShellCrossSectionPoint(bin,iosc,energy,stre*(*tempStorage)[0]);
261  if (tempStorage)
262  {
263  delete tempStorage;
264  tempStorage = 0;
265  }
266  }
267  XSEntry->AddCrossSectionPoint(bin,energy,XH0,XH1,XH2,XS0,XS1,XS2);
268  }
269  //Do (only once) the final normalization
270  XSEntry->NormalizeShellCrossSections();
271 
272  //Insert in the appropriate table
273  if (part == G4Electron::Electron())
274  XSTableElectron->insert(std::make_pair(theKey,XSEntry));
275  else if (part == G4Positron::Positron())
276  XSTablePositron->insert(std::make_pair(theKey,XSEntry));
277  else
278  delete XSEntry;
279 
280  return;
281 }
G4PenelopeOscillatorTable * GetOscillatorTableIonisation(const G4Material *)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4String & GetName() const
Definition: G4Material.hh:178
void AddShellCrossSectionPoint(size_t binNumber, size_t shellID, G4double energy, G4double xs)
size_t GetVectorLength() const
G4double GetLowEdgeEnergy(size_t binNumber) const
const G4String & GetParticleName() const
void AddCrossSectionPoint(size_t binNumber, G4double energy, G4double XH0, G4double XH1, G4double XH2, G4double XS0, G4double XS1, G4double XS2)
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4Positron * Positron()
Definition: G4Positron.cc:94
G4double energy(const ThreeVector &p, const G4double m)
std::vector< G4PenelopeOscillator * > G4PenelopeOscillatorTable
G4double GetDensityCorrection(const G4Material *, const G4double energy) const
Returns the density coeection for the material at the given energy.
static G4Electron * Electron()
Definition: G4Electron.cc:94
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static constexpr double keV
Definition: G4SIunits.hh:216

Here is the call graph for this function:

Here is the caller graph for this function:

const G4PenelopeCrossSection * G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple ( const G4ParticleDefinition part,
const G4Material mat,
const G4double  cut 
) const

Returns the table of cross sections for the given particle, given material and given cut as a G4PenelopeCrossSection* pointer.

Definition at line 111 of file G4PenelopeIonisationXSHandler.cc.

114 {
115  if (part != G4Electron::Electron() && part != G4Positron::Positron())
116  {
118  ed << "Invalid particle: " << part->GetParticleName() << G4endl;
119  G4Exception("G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
120  "em0001",FatalException,ed);
121  return nullptr;
122  }
123 
124  if (part == G4Electron::Electron())
125  {
126  if (!XSTableElectron)
127  {
128  G4Exception("G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
129  "em0028",FatalException,
130  "The Cross Section Table for e- was not initialized correctly!");
131  return nullptr;
132  }
133  std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
134  if (XSTableElectron->count(theKey)) //table already built
135  return XSTableElectron->find(theKey)->second;
136  else
137  return nullptr;
138  }
139 
140  if (part == G4Positron::Positron())
141  {
142  if (!XSTablePositron)
143  {
144  G4Exception("G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
145  "em0028",FatalException,
146  "The Cross Section Table for e+ was not initialized correctly!");
147  return nullptr;
148  }
149  std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
150  if (XSTablePositron->count(theKey)) //table already built
151  return XSTablePositron->find(theKey)->second;
152  else
153  return nullptr;
154  }
155  return nullptr;
156 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4String & GetParticleName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4Positron * Positron()
Definition: G4Positron.cc:94
static G4Electron * Electron()
Definition: G4Electron.cc:94
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4PenelopeIonisationXSHandler::GetDensityCorrection ( const G4Material mat,
const G4double  energy 
) const

Returns the density coeection for the material at the given energy.

Definition at line 286 of file G4PenelopeIonisationXSHandler.cc.

288 {
289  G4double result = 0;
290  if (!theDeltaTable)
291  {
292  G4Exception("G4PenelopeIonisationXSHandler::GetDensityCorrection()",
293  "em2032",FatalException,
294  "Delta Table not initialized. Was Initialise() run?");
295  return 0;
296  }
297  if (energy <= 0*eV)
298  {
299  G4cout << "G4PenelopeIonisationXSHandler::GetDensityCorrection()" << G4endl;
300  G4cout << "Invalid energy " << energy/eV << " eV " << G4endl;
301  return 0;
302  }
303  G4double logene = std::log(energy);
304 
305  if (theDeltaTable->count(mat))
306  {
307  const G4PhysicsFreeVector* vec = theDeltaTable->find(mat)->second;
308  result = vec->Value(logene); //the table has delta vs. ln(E)
309  }
310  else
311  {
313  ed << "Unable to build table for " << mat->GetName() << G4endl;
314  G4Exception("G4PenelopeIonisationXSHandler::GetDensityCorrection()",
315  "em2033",FatalException,ed);
316  }
317 
318  return result;
319 }
G4double G4ParticleHPJENDLHEData::G4double result
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4String & GetName() const
Definition: G4Material.hh:178
G4GLOB_DLL std::ostream G4cout
static constexpr double eV
Definition: G4SIunits.hh:215
G4double Value(G4double theEnergy, size_t &lastidx) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double energy(const ThreeVector &p, const G4double m)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void G4PenelopeIonisationXSHandler::SetVerboseLevel ( G4int  vl)
inline

Setter for the verbosity level.

Definition at line 79 of file G4PenelopeIonisationXSHandler.hh.

79 {verboseLevel = vl;};

Here is the caller graph for this function:


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