Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PenelopeIonisationXSHandler Class Reference

#include <G4PenelopeIonisationXSHandler.hh>

Public Member Functions

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

Detailed Description

Definition at line 59 of file G4PenelopeIonisationXSHandler.hh.

Constructor & Destructor Documentation

◆ G4PenelopeIonisationXSHandler()

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 46 of file G4PenelopeIonisationXSHandler.cc.

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

◆ ~G4PenelopeIonisationXSHandler()

G4PenelopeIonisationXSHandler::~G4PenelopeIonisationXSHandler ( )
virtual

Destructor. Clean all tables.

Definition at line 69 of file G4PenelopeIonisationXSHandler.cc.

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

Member Function Documentation

◆ BuildXSTable()

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 159 of file G4PenelopeIonisationXSHandler.cc.

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

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

◆ GetCrossSectionTableForCouple()

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 110 of file G4PenelopeIonisationXSHandler.cc.

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

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

◆ GetDensityCorrection()

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

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

Definition at line 285 of file G4PenelopeIonisationXSHandler.cc.

287{
288 G4double result = 0;
289 if (!theDeltaTable)
290 {
291 G4Exception("G4PenelopeIonisationXSHandler::GetDensityCorrection()",
292 "em2032",FatalException,
293 "Delta Table not initialized. Was Initialise() run?");
294 return 0;
295 }
296 if (energy <= 0*eV)
297 {
298 G4cout << "G4PenelopeIonisationXSHandler::GetDensityCorrection()" << G4endl;
299 G4cout << "Invalid energy " << energy/eV << " eV " << G4endl;
300 return 0;
301 }
302 G4double logene = G4Log(energy);
303
304 if (theDeltaTable->count(mat))
305 {
306 const G4PhysicsFreeVector* vec = theDeltaTable->find(mat)->second;
307 result = vec->Value(logene); //the table has delta vs. ln(E)
308 }
309 else
310 {
312 ed << "Unable to build table for " << mat->GetName() << G4endl;
313 G4Exception("G4PenelopeIonisationXSHandler::GetDensityCorrection()",
314 "em2033",FatalException,ed);
315 }
316
317 return result;
318}
G4double G4Log(G4double x)
Definition: G4Log.hh:226
G4double Value(G4double theEnergy, std::size_t &lastidx) const

Referenced by BuildXSTable().

◆ SetVerboseLevel()

void G4PenelopeIonisationXSHandler::SetVerboseLevel ( G4int  vl)
inline

Setter for the verbosity level.

Definition at line 78 of file G4PenelopeIonisationXSHandler.hh.

78{verboseLevel = vl;};

Referenced by G4PenelopeIonisationModel::Initialise().


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