Geant4 11.1.1
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.
 
G4PenelopeIonisationXSHandleroperator= (const G4PenelopeIonisationXSHandler &right)=delete
 
 G4PenelopeIonisationXSHandler (const G4PenelopeIonisationXSHandler &)=delete
 

Detailed Description

Definition at line 59 of file G4PenelopeIonisationXSHandler.hh.

Constructor & Destructor Documentation

◆ G4PenelopeIonisationXSHandler() [1/2]

G4PenelopeIonisationXSHandler::G4PenelopeIonisationXSHandler ( size_t  nBins = 200)
explicit

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 :fXSTableElectron(nullptr),fXSTablePositron(nullptr),
48 fDeltaTable(nullptr),fEnergyGrid(nullptr)
49{
50 fNBins = nb;
51 G4double LowEnergyLimit = 100.0*eV;
52 G4double HighEnergyLimit = 100.0*GeV;
54 fXSTableElectron = new
55 std::map< std::pair<const G4Material*,G4double>, G4PenelopeCrossSection*>;
56 fXSTablePositron = new
57 std::map< std::pair<const G4Material*,G4double>, G4PenelopeCrossSection*>;
58
59 fDeltaTable = new std::map<const G4Material*,G4PhysicsFreeVector*>;
60 fEnergyGrid = new G4PhysicsLogVector(LowEnergyLimit,
61 HighEnergyLimit,
62 fNBins-1); //one hidden bin is added
63 fVerboseLevel = 0;
64}
double G4double
Definition: G4Types.hh:83
static G4PenelopeOscillatorManager * GetOscillatorManager()

◆ ~G4PenelopeIonisationXSHandler()

G4PenelopeIonisationXSHandler::~G4PenelopeIonisationXSHandler ( )
virtual

Destructor. Clean all tables.

Definition at line 68 of file G4PenelopeIonisationXSHandler.cc.

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

◆ G4PenelopeIonisationXSHandler() [2/2]

G4PenelopeIonisationXSHandler::G4PenelopeIonisationXSHandler ( const G4PenelopeIonisationXSHandler )
delete

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

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

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

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

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

Referenced by BuildXSTable().

◆ operator=()

G4PenelopeIonisationXSHandler & G4PenelopeIonisationXSHandler::operator= ( const G4PenelopeIonisationXSHandler right)
delete

◆ SetVerboseLevel()

void G4PenelopeIonisationXSHandler::SetVerboseLevel ( G4int  vl)
inline

Setter for the verbosity level.

Definition at line 77 of file G4PenelopeIonisationXSHandler.hh.

77{fVerboseLevel = vl;};

Referenced by G4PenelopeIonisationModel::Initialise().


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