Geant4-11
Public Member Functions | Protected Member Functions | Private Attributes
G4eIonisationCrossSectionHandler Class Reference

#include <G4eIonisationCrossSectionHandler.hh>

Inheritance diagram for G4eIonisationCrossSectionHandler:
G4VCrossSectionHandler

Public Member Functions

G4VEMDataSetBuildMeanFreePathForMaterials (const G4DataVector *energyCuts=nullptr)
 
void Clear ()
 
G4double FindValue (G4int Z, G4double e) const
 
G4double FindValue (G4int Z, G4double e, G4int shellIndex) const
 
 G4eIonisationCrossSectionHandler (const G4eIonisationCrossSectionHandler &)=delete
 
 G4eIonisationCrossSectionHandler (const G4VEnergySpectrum *spec, G4VDataSetAlgorithm *alg, G4double emin, G4double emax, G4int nbin)
 
G4double GetCrossSectionAboveThresholdForElement (G4double energy, G4double cutEnergy, G4int Z)
 
void Initialise (G4VDataSetAlgorithm *interpolation=nullptr, G4double minE=250 *CLHEP::eV, G4double maxE=100 *CLHEP::GeV, G4int numberOfBins=200, G4double unitE=CLHEP::MeV, G4double unitData=CLHEP::barn, G4int minZ=1, G4int maxZ=99)
 
void LoadData (const G4String &dataFile)
 
void LoadNonLogData (const G4String &dataFile)
 
void LoadShellData (const G4String &dataFile)
 
G4eIonisationCrossSectionHandleroperator= (const G4eIonisationCrossSectionHandler &right)=delete
 
void PrintData () const
 
G4int SelectRandomAtom (const G4MaterialCutsCouple *couple, G4double e) const
 
const G4ElementSelectRandomElement (const G4MaterialCutsCouple *material, G4double e) const
 
G4int SelectRandomShell (G4int Z, G4double e) const
 
G4double ValueForMaterial (const G4Material *material, G4double e) const
 
 ~G4eIonisationCrossSectionHandler ()
 

Protected Member Functions

void ActiveElements ()
 
std::vector< G4VEMDataSet * > * BuildCrossSectionsForMaterials (const G4DataVector &energyVector, const G4DataVector *energyCuts) override
 
virtual G4VDataSetAlgorithmCreateInterpolation ()
 
const G4VDataSetAlgorithmGetInterpolation () const
 
G4int NumberOfComponents (G4int Z) const
 

Private Attributes

G4DataVector activeZ
 
std::vector< G4VEMDataSet * > * crossSections
 
std::map< G4int, G4VEMDataSet *, std::less< G4int > > dataMap
 
G4double eMax
 
G4double eMin
 
G4VDataSetAlgorithminterp
 
G4VDataSetAlgorithminterpolation
 
G4int nBins
 
const G4VEnergySpectrumtheParam
 
G4double unit1
 
G4double unit2
 
G4int verbose
 
G4int zMax
 
G4int zMin
 

Detailed Description

Definition at line 59 of file G4eIonisationCrossSectionHandler.hh.

Constructor & Destructor Documentation

◆ G4eIonisationCrossSectionHandler() [1/2]

G4eIonisationCrossSectionHandler::G4eIonisationCrossSectionHandler ( const G4VEnergySpectrum spec,
G4VDataSetAlgorithm alg,
G4double  emin,
G4double  emax,
G4int  nbin 
)
explicit

Definition at line 72 of file G4eIonisationCrossSectionHandler.cc.

76 theParam(spec),verbose(0)
77{
80}
static const G4double emax
void Initialise(G4VDataSetAlgorithm *interpolation=nullptr, G4double minE=250 *CLHEP::eV, G4double maxE=100 *CLHEP::GeV, G4int numberOfBins=200, G4double unitE=CLHEP::MeV, G4double unitData=CLHEP::barn, G4int minZ=1, G4int maxZ=99)

References emax, G4VCrossSectionHandler::Initialise(), and interp.

◆ ~G4eIonisationCrossSectionHandler()

G4eIonisationCrossSectionHandler::~G4eIonisationCrossSectionHandler ( )

Definition at line 84 of file G4eIonisationCrossSectionHandler.cc.

85{
86 delete interp;
87}

References interp.

◆ G4eIonisationCrossSectionHandler() [2/2]

G4eIonisationCrossSectionHandler::G4eIonisationCrossSectionHandler ( const G4eIonisationCrossSectionHandler )
delete

Member Function Documentation

◆ ActiveElements()

void G4VCrossSectionHandler::ActiveElements ( )
protectedinherited

Definition at line 658 of file G4VCrossSectionHandler.cc.

659{
660 const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
661 if (materialTable == nullptr)
662 G4Exception("G4VCrossSectionHandler::ActiveElements",
663 "em1001",FatalException,"no MaterialTable found");
664
666
667 for (G4int mLocal2=0; mLocal2<nMaterials; mLocal2++)
668 {
669 const G4Material* material= (*materialTable)[mLocal2];
670 const G4ElementVector* elementVector = material->GetElementVector();
671 const G4int nElements = material->GetNumberOfElements();
672
673 for (G4int iEl=0; iEl<nElements; iEl++)
674 {
675 G4double Z = (*elementVector)[iEl]->GetZ();
676 if (!(activeZ.contains(Z)) && Z >= zMin && Z <= zMax)
677 {
678 activeZ.push_back(Z);
679 }
680 }
681 }
682}
std::vector< const G4Element * > G4ElementVector
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::vector< G4Material * > G4MaterialTable
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
const G4int Z[17]
G4bool contains(const G4double &) const
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:679
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:672
string material
Definition: eplot.py:19

References G4VCrossSectionHandler::activeZ, G4DataVector::contains(), FatalException, G4Exception(), G4Material::GetMaterialTable(), G4Material::GetNumberOfMaterials(), eplot::material, Z, G4VCrossSectionHandler::zMax, and G4VCrossSectionHandler::zMin.

Referenced by G4VCrossSectionHandler::Clear(), and G4VCrossSectionHandler::G4VCrossSectionHandler().

◆ BuildCrossSectionsForMaterials()

std::vector< G4VEMDataSet * > * G4eIonisationCrossSectionHandler::BuildCrossSectionsForMaterials ( const G4DataVector energyVector,
const G4DataVector energyCuts 
)
overrideprotectedvirtual

Implements G4VCrossSectionHandler.

Definition at line 91 of file G4eIonisationCrossSectionHandler.cc.

94{
95 std::vector<G4VEMDataSet*>* set = new std::vector<G4VEMDataSet*>;
96
97 G4DataVector* energies;
98 G4DataVector* cs;
99
100 G4DataVector* log_energies;
101 G4DataVector* log_cs;
102
103 G4int nOfBins = energyVector.size();
104
105 const G4ProductionCutsTable* theCoupleTable=
107 size_t numOfCouples = theCoupleTable->GetTableSize();
108
109 for (size_t mLocal=0; mLocal<numOfCouples; mLocal++) {
110
111 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(mLocal);
112 const G4Material* material= couple->GetMaterial();
113 const G4ElementVector* elementVector = material->GetElementVector();
114 const G4double* nAtomsPerVolume = material->GetAtomicNumDensityVector();
115 G4int nElements = material->GetNumberOfElements();
116
117 if(verbose > 0)
118 {
119 G4cout << "eIonisation CS for " << mLocal << "th material "
120 << material->GetName()
121 << " eEl= " << nElements << G4endl;
122 }
123
124 G4double tcut = (*energyCuts)[mLocal];
125
127 G4VEMDataSet* setForMat = new G4CompositeEMDataSet(algo,1.,1.);
128
129 for (G4int i=0; i<nElements; i++) {
130
131 G4int Z = (G4int) (*elementVector)[i]->GetZ();
132 G4int nShells = NumberOfComponents(Z);
133
134 energies = new G4DataVector;
135 cs = new G4DataVector;
136
137 log_energies = new G4DataVector;
138 log_cs = new G4DataVector;
139
140 G4double density = nAtomsPerVolume[i];
141
142 for (G4int bin=0; bin<nOfBins; bin++) {
143
144 G4double e = energyVector[bin];
145 energies->push_back(e);
146 log_energies->push_back(std::log10(e));
147 G4double value = 0.0;
148 G4double log_value = -300;
149
150 if(e > tcut) {
151 for (G4int n=0; n<nShells; n++) {
152 G4double cross = FindValue(Z, e, n);
153 G4double p = theParam->Probability(Z, tcut, e, e, n);
154 value += cross * p * density;
155
156 if(verbose>0 && mLocal == 0 && e>=1. && e<=0.)
157 {
158 G4cout << "G4eIonCrossSH: e(MeV)= " << e/MeV
159 << " n= " << n
160 << " cross= " << cross
161 << " p= " << p
162 << " value= " << value
163 << " tcut(MeV)= " << tcut/MeV
164 << " rho= " << density
165 << " Z= " << Z
166 << G4endl;
167 }
168 }
169 if (value == 0.) value = 1e-300;
170 log_value = std::log10(value);
171 }
172 cs->push_back(value);
173 log_cs->push_back(log_value);
174 }
175 G4VDataSetAlgorithm* algoLocal = interp->Clone();
176 G4VEMDataSet* elSet = new G4EMDataSet(i,energies,cs,log_energies,log_cs,algoLocal,1.,1.);
177
178 setForMat->AddComponent(elSet);
179 }
180 set->push_back(setForMat);
181 }
182
183 return set;
184}
static constexpr double MeV
Definition: G4SIunits.hh:200
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4Material * GetMaterial() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
G4double FindValue(G4int Z, G4double e) const
G4int NumberOfComponents(G4int Z) const
virtual G4VDataSetAlgorithm * Clone() const =0
virtual void AddComponent(G4VEMDataSet *dataSet)=0
virtual G4double Probability(G4int Z, G4double minKineticEnergy, G4double maxKineticEnergy, G4double kineticEnergy, G4int shell=0, const G4ParticleDefinition *pd=nullptr) const =0

References G4VEMDataSet::AddComponent(), G4VDataSetAlgorithm::Clone(), G4VCrossSectionHandler::FindValue(), G4cout, G4endl, G4MaterialCutsCouple::GetMaterial(), G4ProductionCutsTable::GetMaterialCutsCouple(), G4ProductionCutsTable::GetProductionCutsTable(), G4ProductionCutsTable::GetTableSize(), interp, eplot::material, MeV, CLHEP::detail::n, G4VCrossSectionHandler::NumberOfComponents(), G4VEnergySpectrum::Probability(), theParam, verbose, and Z.

◆ BuildMeanFreePathForMaterials()

G4VEMDataSet * G4VCrossSectionHandler::BuildMeanFreePathForMaterials ( const G4DataVector energyCuts = nullptr)
inherited

Definition at line 441 of file G4VCrossSectionHandler.cc.

442{
443 // Builds a CompositeDataSet containing the mean free path for each material
444 // in the material table
445 G4DataVector energyVector;
446 G4double dBin = std::log10(eMax/eMin) / nBins;
447
448 for (G4int i=0; i<nBins+1; i++)
449 {
450 energyVector.push_back(std::pow(10., std::log10(eMin)+i*dBin));
451 }
452
453 // Factory method to build cross sections in derived classes,
454 // related to the type of physics process
455
456 if (crossSections != nullptr)
457 { // Reset the list of cross sections
458 if (! crossSections->empty())
459 {
460 for (auto mat=crossSections->begin(); mat != crossSections->end(); ++mat)
461 {
462 G4VEMDataSet* set = *mat;
463 delete set;
464 set = nullptr;
465 }
466 crossSections->clear();
467 delete crossSections;
468 crossSections = nullptr;
469 }
470 }
471
472 crossSections = BuildCrossSectionsForMaterials(energyVector,energyCuts);
473
474 if (crossSections == nullptr)
475 {
476 G4Exception("G4VCrossSectionHandler::BuildMeanFreePathForMaterials",
477 "em1010",FatalException,"crossSections = 0");
478 return 0;
479 }
480
482 G4VEMDataSet* materialSet = new G4CompositeEMDataSet(algo);
483
484 G4DataVector* energies;
485 G4DataVector* data;
486 G4DataVector* log_energies;
487 G4DataVector* log_data;
488
489 const G4ProductionCutsTable* theCoupleTable=
491 size_t numOfCouples = theCoupleTable->GetTableSize();
492
493 for (size_t mLocal=0; mLocal<numOfCouples; mLocal++)
494 {
495 energies = new G4DataVector;
496 data = new G4DataVector;
497 log_energies = new G4DataVector;
498 log_data = new G4DataVector;
499 for (G4int bin=0; bin<nBins; bin++)
500 {
501 G4double energy = energyVector[bin];
502 energies->push_back(energy);
503 log_energies->push_back(std::log10(energy));
504 G4VEMDataSet* matCrossSet = (*crossSections)[mLocal];
505 G4double materialCrossSection = 0.0;
506 G4int nElm = matCrossSet->NumberOfComponents();
507 for(G4int j=0; j<nElm; j++) {
508 materialCrossSection += matCrossSet->GetComponent(j)->FindValue(energy);
509 }
510
511 if (materialCrossSection > 0.)
512 {
513 data->push_back(1./materialCrossSection);
514 log_data->push_back(std::log10(1./materialCrossSection));
515 }
516 else
517 {
518 data->push_back(DBL_MAX);
519 log_data->push_back(std::log10(DBL_MAX));
520 }
521 }
523 G4VEMDataSet* dataSet = new G4EMDataSet(mLocal,energies,data,log_energies,log_data,algoLocal,1.,1.);
524 materialSet->AddComponent(dataSet);
525 }
526 return materialSet;
527}
virtual std::vector< G4VEMDataSet * > * BuildCrossSectionsForMaterials(const G4DataVector &energyVector, const G4DataVector *energyCuts=nullptr)=0
std::vector< G4VEMDataSet * > * crossSections
virtual G4VDataSetAlgorithm * CreateInterpolation()
virtual const G4VEMDataSet * GetComponent(G4int componentId) const =0
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
virtual size_t NumberOfComponents(void) const =0
G4double energy(const ThreeVector &p, const G4double m)
#define DBL_MAX
Definition: templates.hh:62

References G4VEMDataSet::AddComponent(), G4VCrossSectionHandler::BuildCrossSectionsForMaterials(), G4VCrossSectionHandler::CreateInterpolation(), G4VCrossSectionHandler::crossSections, DBL_MAX, G4VCrossSectionHandler::eMax, G4VCrossSectionHandler::eMin, G4INCL::KinematicsUtils::energy(), FatalException, G4VEMDataSet::FindValue(), G4Exception(), G4VEMDataSet::GetComponent(), G4ProductionCutsTable::GetProductionCutsTable(), G4ProductionCutsTable::GetTableSize(), G4VCrossSectionHandler::nBins, and G4VEMDataSet::NumberOfComponents().

Referenced by G4LivermoreIonisationModel::Initialise().

◆ Clear()

void G4VCrossSectionHandler::Clear ( )
inherited

Definition at line 345 of file G4VCrossSectionHandler.cc.

346{
347 // Reset the map of data sets: remove the data sets from the map
348 if(! dataMap.empty())
349 {
350 for (auto pos : dataMap)
351 {
352 G4VEMDataSet* dataSet = pos.second;
353 delete dataSet;
354 dataSet = nullptr;
355 G4int i = pos.first;
356 dataMap[i] = nullptr;
357 }
358 dataMap.clear();
359 }
360 activeZ.clear();
362}
static const G4double pos
std::map< G4int, G4VEMDataSet *, std::less< G4int > > dataMap

References G4VCrossSectionHandler::ActiveElements(), G4VCrossSectionHandler::activeZ, G4VCrossSectionHandler::dataMap, and pos.

Referenced by export_G4VCrossSectionHandler(), G4LivermoreIonisationCrossSection::Initialise(), and G4LivermoreIonisationModel::Initialise().

◆ CreateInterpolation()

G4VDataSetAlgorithm * G4VCrossSectionHandler::CreateInterpolation ( )
protectedvirtualinherited

◆ FindValue() [1/2]

G4double G4VCrossSectionHandler::FindValue ( G4int  Z,
G4double  e 
) const
inherited

Definition at line 366 of file G4VCrossSectionHandler.cc.

367{
368 G4double value = 0.;
369
370 auto pos = dataMap.find(Z);
371 if (pos!= dataMap.end())
372 {
373 G4VEMDataSet* dataSet = (*pos).second;
374 value = dataSet->FindValue(energy);
375 }
376 else
377 {
378 G4cout << "WARNING: G4VCrossSectionHandler::FindValue did not find Z = "
379 << Z << G4endl;
380 }
381 return value;
382}

References G4VCrossSectionHandler::dataMap, G4INCL::KinematicsUtils::energy(), G4VEMDataSet::FindValue(), G4cout, G4endl, pos, and Z.

Referenced by BuildCrossSectionsForMaterials(), G4CrossSectionHandler::BuildCrossSectionsForMaterials(), G4LivermoreIonisationModel::ComputeDEDXPerVolume(), G4LivermoreIonisationCrossSection::CrossSection(), GetCrossSectionAboveThresholdForElement(), G4VCrossSectionHandler::SelectRandomShell(), and G4VCrossSectionHandler::ValueForMaterial().

◆ FindValue() [2/2]

G4double G4VCrossSectionHandler::FindValue ( G4int  Z,
G4double  e,
G4int  shellIndex 
) const
inherited

Definition at line 386 of file G4VCrossSectionHandler.cc.

388{
389 G4double value = 0.;
390 auto pos = dataMap.find(Z);
391 if (pos!= dataMap.end())
392 {
393 G4VEMDataSet* dataSet = (*pos).second;
394 if (shellIndex >= 0)
395 {
396 G4int nComponents = dataSet->NumberOfComponents();
397 if(shellIndex < nComponents)
398 value = dataSet->GetComponent(shellIndex)->FindValue(energy);
399 else
400 {
401 G4cout << "WARNING: G4VCrossSectionHandler::FindValue did not find"
402 << " shellIndex= " << shellIndex
403 << " for Z= "
404 << Z << G4endl;
405 }
406 } else {
407 value = dataSet->FindValue(energy);
408 }
409 }
410 else
411 {
412 G4cout << "WARNING: G4VCrossSectionHandler::FindValue did not find Z = "
413 << Z << G4endl;
414 }
415 return value;
416}

References G4VCrossSectionHandler::dataMap, G4INCL::KinematicsUtils::energy(), G4VEMDataSet::FindValue(), G4cout, G4endl, G4VEMDataSet::GetComponent(), G4VEMDataSet::NumberOfComponents(), pos, and Z.

◆ GetCrossSectionAboveThresholdForElement()

G4double G4eIonisationCrossSectionHandler::GetCrossSectionAboveThresholdForElement ( G4double  energy,
G4double  cutEnergy,
G4int  Z 
)

Definition at line 188 of file G4eIonisationCrossSectionHandler.cc.

191{
192 G4int nShells = NumberOfComponents(Z);
193 G4double value = 0.;
194 if(energy > cutEnergy)
195 {
196 for (G4int n=0; n<nShells; n++) {
197 G4double cross = FindValue(Z, energy, n);
198 G4double p = theParam->Probability(Z, cutEnergy, energy, energy, n);
199 value += cross * p;
200 }
201 }
202 return value;
203}

References G4INCL::KinematicsUtils::energy(), G4VCrossSectionHandler::FindValue(), CLHEP::detail::n, G4VCrossSectionHandler::NumberOfComponents(), G4VEnergySpectrum::Probability(), theParam, and Z.

Referenced by G4LivermoreIonisationModel::ComputeCrossSectionPerAtom().

◆ GetInterpolation()

const G4VDataSetAlgorithm * G4VCrossSectionHandler::GetInterpolation ( ) const
inlineprotectedinherited

Definition at line 114 of file G4VCrossSectionHandler.hh.

114{ return interpolation; }
G4VDataSetAlgorithm * interpolation

References G4VCrossSectionHandler::interpolation.

◆ Initialise()

void G4VCrossSectionHandler::Initialise ( G4VDataSetAlgorithm interpolation = nullptr,
G4double  minE = 250*CLHEP::eV,
G4double  maxE = 100*CLHEP::GeV,
G4int  numberOfBins = 200,
G4double  unitE = CLHEP::MeV,
G4double  unitData = CLHEP::barn,
G4int  minZ = 1,
G4int  maxZ = 99 
)
inherited

◆ LoadData()

void G4VCrossSectionHandler::LoadData ( const G4String dataFile)
inherited

Definition at line 185 of file G4VCrossSectionHandler.cc.

186{
187 size_t nZ = activeZ.size();
188 for (size_t i=0; i<nZ; i++)
189 {
190 G4int Z = G4int(activeZ[i]);
191
192 // Build the complete string identifying the file with the data set
193 char* path = std::getenv("G4LEDATA");
194 if (!path)
195 {
196 G4Exception("G4VCrossSectionHandler::LoadData",
197 "em0006",FatalException,"G4LEDATA environment variable not set");
198 return;
199 }
200
201 std::ostringstream ost;
202 ost << path << '/' << fileName << Z << ".dat";
203 std::ifstream file(ost.str().c_str());
204 std::filebuf* lsdp = file.rdbuf();
205
206 if (! (lsdp->is_open()) )
207 {
208 G4String excep = "data file: " + ost.str() + " not found";
209 G4Exception("G4VCrossSectionHandler::LoadData",
210 "em0003",FatalException,excep);
211 }
212 G4double a = 0;
213 G4int k = 0;
214 G4int nColumns = 2;
215
216 G4DataVector* orig_reg_energies = new G4DataVector;
217 G4DataVector* orig_reg_data = new G4DataVector;
218 G4DataVector* log_reg_energies = new G4DataVector;
219 G4DataVector* log_reg_data = new G4DataVector;
220
221 do
222 {
223 file >> a;
224
225 if (a==0.) a=1e-300;
226
227 // The file is organized into four columns:
228 // 1st column contains the values of energy
229 // 2nd column contains the corresponding data value
230 // The file terminates with the pattern: -1 -1
231 // -2 -2
232 //
233 if (a != -1 && a != -2)
234 {
235 if (k%nColumns == 0)
236 {
237 orig_reg_energies->push_back(a*unit1);
238 log_reg_energies->push_back(std::log10(a)+std::log10(unit1));
239 }
240 else if (k%nColumns == 1)
241 {
242 orig_reg_data->push_back(a*unit2);
243 log_reg_data->push_back(std::log10(a)+std::log10(unit2));
244 }
245 k++;
246 }
247 }
248 while (a != -2); // End of File
249
250 file.close();
252 G4VEMDataSet* dataSet = new G4EMDataSet(Z,orig_reg_energies,orig_reg_data,
253 log_reg_energies,log_reg_data,algo);
254 dataMap[Z] = dataSet;
255 }
256}

References G4VCrossSectionHandler::activeZ, G4VDataSetAlgorithm::Clone(), G4VCrossSectionHandler::dataMap, FatalException, geant4_check_module_cycles::file, G4Exception(), G4VCrossSectionHandler::interpolation, G4VCrossSectionHandler::unit1, G4VCrossSectionHandler::unit2, and Z.

Referenced by export_G4VCrossSectionHandler().

◆ LoadNonLogData()

void G4VCrossSectionHandler::LoadNonLogData ( const G4String dataFile)
inherited

Definition at line 260 of file G4VCrossSectionHandler.cc.

261{
262 size_t nZ = activeZ.size();
263 for (size_t i=0; i<nZ; i++)
264 {
265 G4int Z = G4int(activeZ[i]);
266
267 // Build the complete string identifying the file with the data set
268 char* path = std::getenv("G4LEDATA");
269 if (!path)
270 {
271 G4Exception("G4VCrossSectionHandler::LoadNonLogData",
272 "em0006",FatalException,"G4LEDATA environment variable not set");
273 return;
274 }
275
276 std::ostringstream ost;
277 ost << path << '/' << fileName << Z << ".dat";
278 std::ifstream file(ost.str().c_str());
279 std::filebuf* lsdp = file.rdbuf();
280
281 if (! (lsdp->is_open()) )
282 {
283 G4String excep = "data file: " + ost.str() + " not found";
284 G4Exception("G4VCrossSectionHandler::LoadNonLogData",
285 "em0003",FatalException,excep);
286 }
287 G4double a = 0;
288 G4int k = 0;
289 G4int nColumns = 2;
290
291 G4DataVector* orig_reg_energies = new G4DataVector;
292 G4DataVector* orig_reg_data = new G4DataVector;
293
294 do
295 {
296 file >> a;
297
298 // The file is organized into four columns:
299 // 1st column contains the values of energy
300 // 2nd column contains the corresponding data value
301 // The file terminates with the pattern: -1 -1
302 // -2 -2
303 //
304 if (a != -1 && a != -2)
305 {
306 if (k%nColumns == 0)
307 {
308 orig_reg_energies->push_back(a*unit1);
309 }
310 else if (k%nColumns == 1)
311 {
312 orig_reg_data->push_back(a*unit2);
313 }
314 k++;
315 }
316 }
317 while (a != -2); // End of File
318
319 file.close();
321
322 G4VEMDataSet* dataSet = new G4EMDataSet(Z,orig_reg_energies,orig_reg_data,algo);
323 dataMap[Z] = dataSet;
324 }
325}

References G4VCrossSectionHandler::activeZ, G4VDataSetAlgorithm::Clone(), G4VCrossSectionHandler::dataMap, FatalException, geant4_check_module_cycles::file, G4Exception(), G4VCrossSectionHandler::interpolation, G4VCrossSectionHandler::unit1, G4VCrossSectionHandler::unit2, and Z.

◆ LoadShellData()

void G4VCrossSectionHandler::LoadShellData ( const G4String dataFile)
inherited

Definition at line 329 of file G4VCrossSectionHandler.cc.

330{
331 size_t nZ = activeZ.size();
332 for (size_t i=0; i<nZ; i++)
333 {
334 G4int Z = G4int(activeZ[i]);
335
337 G4VEMDataSet* dataSet = new G4ShellEMDataSet(Z, algo);
338 dataSet->LoadData(fileName);
339 dataMap[Z] = dataSet;
340 }
341}
virtual G4bool LoadData(const G4String &fileName)=0

References G4VCrossSectionHandler::activeZ, G4VDataSetAlgorithm::Clone(), G4VCrossSectionHandler::dataMap, G4VCrossSectionHandler::interpolation, G4VEMDataSet::LoadData(), and Z.

Referenced by export_G4VCrossSectionHandler(), G4LivermoreIonisationCrossSection::Initialise(), and G4LivermoreIonisationModel::Initialise().

◆ NumberOfComponents()

G4int G4VCrossSectionHandler::NumberOfComponents ( G4int  Z) const
protectedinherited

Definition at line 694 of file G4VCrossSectionHandler.cc.

695{
696 G4int n = 0;
697
698 auto pos = dataMap.find(Z);
699 if (pos!= dataMap.end())
700 {
701 G4VEMDataSet* dataSet = (*pos).second;
702 n = dataSet->NumberOfComponents();
703 }
704 else
705 {
706 G4cout << "WARNING: G4VCrossSectionHandler::NumberOfComponents did not "
707 << "find Z = "
708 << Z << G4endl;
709 }
710 return n;
711}

References G4VCrossSectionHandler::dataMap, G4cout, G4endl, CLHEP::detail::n, G4VEMDataSet::NumberOfComponents(), pos, and Z.

Referenced by BuildCrossSectionsForMaterials(), and GetCrossSectionAboveThresholdForElement().

◆ operator=()

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

◆ PrintData()

void G4VCrossSectionHandler::PrintData ( void  ) const
inherited

Definition at line 169 of file G4VCrossSectionHandler.cc.

170{
171 for (auto pos : dataMap)
172 {
173 G4int z = pos.first;
174 G4VEMDataSet* dataSet = pos.second;
175 G4cout << "---- Data set for Z = "
176 << z
177 << G4endl;
178 dataSet->PrintData();
179 G4cout << "--------------------------------------------------" << G4endl;
180 }
181}
virtual void PrintData(void) const =0

References G4VCrossSectionHandler::dataMap, G4cout, G4endl, pos, and G4VEMDataSet::PrintData().

Referenced by export_G4VCrossSectionHandler(), and G4LivermoreIonisationModel::Initialise().

◆ SelectRandomAtom()

G4int G4VCrossSectionHandler::SelectRandomAtom ( const G4MaterialCutsCouple couple,
G4double  e 
) const
inherited

Definition at line 531 of file G4VCrossSectionHandler.cc.

533{
534 // Select randomly an element within the material, according to the weight
535 // determined by the cross sections in the data set
536 const G4Material* material = couple->GetMaterial();
537 G4int nElements = material->GetNumberOfElements();
538
539 // Special case: the material consists of one element
540 if (nElements == 1)
541 {
542 G4int Z = (G4int) material->GetZ();
543 return Z;
544 }
545
546 // Composite material
547 const G4ElementVector* elementVector = material->GetElementVector();
548 size_t materialIndex = couple->GetIndex();
549
550 G4VEMDataSet* materialSet = (*crossSections)[materialIndex];
551 G4double materialCrossSection0 = 0.0;
552 G4DataVector cross;
553 cross.clear();
554 for ( G4int i=0; i < nElements; i++ )
555 {
556 G4double cr = materialSet->GetComponent(i)->FindValue(e);
557 materialCrossSection0 += cr;
558 cross.push_back(materialCrossSection0);
559 }
560
561 G4double random = G4UniformRand() * materialCrossSection0;
562 for (G4int k=0 ; k < nElements ; k++ )
563 {
564 if (random <= cross[k]) return (G4int) (*elementVector)[k]->GetZ();
565 }
566 // It should never get here
567 return 0;
568}
#define G4UniformRand()
Definition: Randomize.hh:52

References G4VEMDataSet::FindValue(), G4UniformRand, G4VEMDataSet::GetComponent(), G4MaterialCutsCouple::GetIndex(), G4MaterialCutsCouple::GetMaterial(), eplot::material, and Z.

Referenced by G4LivermoreIonisationModel::SampleSecondaries().

◆ SelectRandomElement()

const G4Element * G4VCrossSectionHandler::SelectRandomElement ( const G4MaterialCutsCouple material,
G4double  e 
) const
inherited

Definition at line 572 of file G4VCrossSectionHandler.cc.

574{
575 // Select randomly an element within the material, according to the weight determined
576 // by the cross sections in the data set
577 const G4Material* material = couple->GetMaterial();
578 G4Element* nullElement = 0;
579 G4int nElements = material->GetNumberOfElements();
580 const G4ElementVector* elementVector = material->GetElementVector();
581
582 // Special case: the material consists of one element
583 if (nElements == 1)
584 {
585 return (*elementVector)[0];
586 }
587 else
588 {
589 // Composite material
590
591 size_t materialIndex = couple->GetIndex();
592
593 G4VEMDataSet* materialSet = (*crossSections)[materialIndex];
594 G4double materialCrossSection0 = 0.0;
595 G4DataVector cross;
596 cross.clear();
597 for (G4int i=0; i<nElements; i++)
598 {
599 G4double cr = materialSet->GetComponent(i)->FindValue(e);
600 materialCrossSection0 += cr;
601 cross.push_back(materialCrossSection0);
602 }
603
604 G4double random = G4UniformRand() * materialCrossSection0;
605
606 for (G4int k=0 ; k < nElements ; k++ )
607 {
608 if (random <= cross[k]) return (*elementVector)[k];
609 }
610 // It should never end up here
611 G4cout << "G4VCrossSectionHandler::SelectRandomElement - no element found" << G4endl;
612 return nullElement;
613 }
614}

References G4VEMDataSet::FindValue(), G4cout, G4endl, G4UniformRand, G4VEMDataSet::GetComponent(), G4MaterialCutsCouple::GetIndex(), G4MaterialCutsCouple::GetMaterial(), and eplot::material.

Referenced by export_G4VCrossSectionHandler().

◆ SelectRandomShell()

G4int G4VCrossSectionHandler::SelectRandomShell ( G4int  Z,
G4double  e 
) const
inherited

Definition at line 618 of file G4VCrossSectionHandler.cc.

619{
620 // Select randomly a shell, according to the weight determined by the cross sections
621 // in the data set
622 // Note for later improvement: it would be useful to add a cache mechanism for already
623 // used shells to improve performance
624 G4int shell = 0;
625
626 G4double totCrossSection = FindValue(Z,e);
627 G4double random = G4UniformRand() * totCrossSection;
628 G4double partialSum = 0.;
629
630 G4VEMDataSet* dataSet = nullptr;
631 auto pos = dataMap.find(Z);
632 if (pos != dataMap.end())
633 dataSet = (*pos).second;
634 else
635 {
636 G4Exception("G4VCrossSectionHandler::SelectRandomShell",
637 "em1011",FatalException,"unable to load the dataSet");
638 return 0;
639 }
640
641 size_t nShells = dataSet->NumberOfComponents();
642 for (size_t i=0; i<nShells; i++)
643 {
644 const G4VEMDataSet* shellDataSet = dataSet->GetComponent(i);
645 if (shellDataSet != nullptr)
646 {
647 G4double value = shellDataSet->FindValue(e);
648 partialSum += value;
649 if (random <= partialSum) return i;
650 }
651 }
652 // It should never get here
653 return shell;
654}

References G4VCrossSectionHandler::dataMap, FatalException, G4VEMDataSet::FindValue(), G4VCrossSectionHandler::FindValue(), G4Exception(), G4UniformRand, G4VEMDataSet::GetComponent(), G4VEMDataSet::NumberOfComponents(), pos, and Z.

Referenced by export_G4VCrossSectionHandler(), and G4LivermoreIonisationModel::SampleSecondaries().

◆ ValueForMaterial()

G4double G4VCrossSectionHandler::ValueForMaterial ( const G4Material material,
G4double  e 
) const
inherited

Definition at line 420 of file G4VCrossSectionHandler.cc.

422{
423 G4double value = 0.;
424 const G4ElementVector* elementVector = material->GetElementVector();
425 const G4double* nAtomsPerVolume = material->GetVecNbOfAtomsPerVolume();
426 G4int nElements = material->GetNumberOfElements();
427
428 for (G4int i=0 ; i<nElements ; i++)
429 {
430 G4int Z = (G4int) (*elementVector)[i]->GetZ();
431 G4double elementValue = FindValue(Z,energy);
432 G4double nAtomsVol = nAtomsPerVolume[i];
433 value += nAtomsVol * elementValue;
434 }
435
436 return value;
437}

References G4INCL::KinematicsUtils::energy(), G4VCrossSectionHandler::FindValue(), eplot::material, and Z.

Referenced by export_G4VCrossSectionHandler().

Field Documentation

◆ activeZ

G4DataVector G4VCrossSectionHandler::activeZ
privateinherited

◆ crossSections

std::vector<G4VEMDataSet*>* G4VCrossSectionHandler::crossSections
privateinherited

◆ dataMap

std::map<G4int,G4VEMDataSet*,std::less<G4int> > G4VCrossSectionHandler::dataMap
privateinherited

◆ eMax

G4double G4VCrossSectionHandler::eMax
privateinherited

◆ eMin

G4double G4VCrossSectionHandler::eMin
privateinherited

◆ interp

G4VDataSetAlgorithm* G4eIonisationCrossSectionHandler::interp
private

◆ interpolation

G4VDataSetAlgorithm* G4VCrossSectionHandler::interpolation
privateinherited

◆ nBins

G4int G4VCrossSectionHandler::nBins
privateinherited

◆ theParam

const G4VEnergySpectrum* G4eIonisationCrossSectionHandler::theParam
private

◆ unit1

G4double G4VCrossSectionHandler::unit1
privateinherited

◆ unit2

G4double G4VCrossSectionHandler::unit2
privateinherited

◆ verbose

G4int G4eIonisationCrossSectionHandler::verbose
private

Definition at line 85 of file G4eIonisationCrossSectionHandler.hh.

Referenced by BuildCrossSectionsForMaterials().

◆ zMax

G4int G4VCrossSectionHandler::zMax
privateinherited

◆ zMin

G4int G4VCrossSectionHandler::zMin
privateinherited

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