Geant4.10
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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.

References python.hepunit::eV, G4PenelopeOscillatorManager::GetOscillatorManager(), and python.hepunit::GeV.

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 G4PenelopeOscillatorManager * GetOscillatorManager()
double G4double
Definition: G4Types.hh:76
G4PenelopeIonisationXSHandler::~G4PenelopeIonisationXSHandler ( )
virtual

Destructor. Clean all tables.

Definition at line 70 of file G4PenelopeIonisationXSHandler.cc.

References G4cout, G4endl, and tab().

71 {
72  std::map< std::pair<const G4Material*,G4double>, G4PenelopeCrossSection*>::iterator i;
73  if (XSTableElectron)
74  {
75  for (i=XSTableElectron->begin(); i != XSTableElectron->end(); i++)
76  {
77  G4PenelopeCrossSection* tab = i->second;
78  delete tab;
79  }
80  delete XSTableElectron;
81  XSTableElectron = 0;
82  }
83 
84  if (XSTablePositron)
85  {
86  for (i=XSTablePositron->begin(); i != XSTablePositron->end(); i++)
87  {
88  G4PenelopeCrossSection* tab = i->second;
89  delete tab;
90  }
91  delete XSTablePositron;
92  XSTablePositron = 0;
93  }
94 
95  std::map<const G4Material*,G4PhysicsFreeVector*>::iterator k;
96  if (theDeltaTable)
97  {
98  /*
99  for (k=theDeltaTable->begin();k!=theDeltaTable->end();k++)
100  delete k->second;
101  */
102  delete theDeltaTable;
103  theDeltaTable = 0;
104  }
105  /*
106  if (energyGrid)
107  delete energyGrid;
108  */
109  if (verboseLevel > 2)
110  G4cout << "G4PenelopeIonisationXSHandler. Tables have been cleared"
111  << G4endl;
112 }
G4GLOB_DLL std::ostream G4cout
std::ostream & tab(std::ostream &)
Definition: CCalutils.cc:89
#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 166 of file G4PenelopeIonisationXSHandler.cc.

References G4PenelopeCrossSection::AddCrossSectionPoint(), G4PenelopeCrossSection::AddShellCrossSectionPoint(), plottest35::bin, G4Electron::Electron(), energy(), FatalException, G4cout, G4endl, G4Exception(), GetDensityCorrection(), G4PhysicsVector::GetLowEdgeEnergy(), G4Material::GetName(), G4PenelopeOscillator::GetOscillatorStrength(), G4PenelopeOscillatorManager::GetOscillatorTableIonisation(), G4ParticleDefinition::GetParticleName(), G4PhysicsVector::GetVectorLength(), python.hepunit::keV, G4PenelopeCrossSection::NormalizeShellCrossSections(), and G4Positron::Positron().

Referenced by G4PenelopeIonisationModel::ComputeDEDXPerVolume(), G4PenelopeIonisationCrossSection::CrossSection(), G4PenelopeIonisationModel::CrossSectionPerVolume(), and G4PenelopeIonisationModel::Initialise().

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

References G4Electron::Electron(), FatalException, G4endl, G4Exception(), G4ParticleDefinition::GetParticleName(), and G4Positron::Positron().

Referenced by G4PenelopeIonisationModel::ComputeDEDXPerVolume(), G4PenelopeIonisationCrossSection::CrossSection(), and G4PenelopeIonisationModel::CrossSectionPerVolume().

120 {
121  if (part != G4Electron::Electron() && part != G4Positron::Positron())
122  {
124  ed << "Invalid particle: " << part->GetParticleName() << G4endl;
125  G4Exception("G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
126  "em0001",FatalException,ed);
127  return NULL;
128  }
129 
130  if (part == G4Electron::Electron())
131  {
132  if (!XSTableElectron)
133  {
134  G4Exception("G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
135  "em0028",FatalException,
136  "The Cross Section Table for e- was not initialized correctly!");
137  return NULL;
138  }
139  std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
140  if (XSTableElectron->count(theKey)) //table already built
141  return XSTableElectron->find(theKey)->second;
142  else
143  return NULL;
144  }
145 
146  if (part == G4Positron::Positron())
147  {
148  if (!XSTablePositron)
149  {
150  G4Exception("G4PenelopeIonisationXSHandler::GetCrossSectionTableForCouple()",
151  "em0028",FatalException,
152  "The Cross Section Table for e+ was not initialized correctly!");
153  return NULL;
154  }
155  std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
156  if (XSTablePositron->count(theKey)) //table already built
157  return XSTablePositron->find(theKey)->second;
158  else
159  return NULL;
160  }
161  return NULL;
162 }
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
G4double G4PenelopeIonisationXSHandler::GetDensityCorrection ( const G4Material mat,
const G4double  energy 
) const

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

Definition at line 292 of file G4PenelopeIonisationXSHandler.cc.

References python.hepunit::eV, FatalException, G4cout, G4endl, G4Exception(), G4Material::GetName(), and G4PhysicsVector::Value().

Referenced by BuildXSTable().

294 {
295  G4double result = 0;
296  if (!theDeltaTable)
297  {
298  G4Exception("G4PenelopeIonisationXSHandler::GetDensityCorrection()",
299  "em2032",FatalException,
300  "Delta Table not initialized. Was Initialise() run?");
301  return 0;
302  }
303  if (energy <= 0*eV)
304  {
305  G4cout << "G4PenelopeIonisationXSHandler::GetDensityCorrection()" << G4endl;
306  G4cout << "Invalid energy " << energy/eV << " eV " << G4endl;
307  return 0;
308  }
309  G4double logene = std::log(energy);
310 
311  if (theDeltaTable->count(mat))
312  {
313  const G4PhysicsFreeVector* vec = theDeltaTable->find(mat)->second;
314  result = vec->Value(logene); //the table has delta vs. ln(E)
315  }
316  else
317  {
319  ed << "Unable to build table for " << mat->GetName() << G4endl;
320  G4Exception("G4PenelopeIonisationXSHandler::GetDensityCorrection()",
321  "em2033",FatalException,ed);
322  }
323 
324  return result;
325 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4String & GetName() const
Definition: G4Material.hh:176
double precision function energy(A, Z)
Definition: dpm25nuc6.f:4106
G4GLOB_DLL std::ostream G4cout
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
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void G4PenelopeIonisationXSHandler::SetVerboseLevel ( G4int  vl)
inline

Setter for the verbosity level.

Definition at line 79 of file G4PenelopeIonisationXSHandler.hh.

Referenced by G4PenelopeIonisationModel::Initialise().

79 {verboseLevel = vl;};

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