106 : interpolation(algorithm), eMin(minE), eMax(maxE),
107 unit1(unitE), unit2(unitData), zMin(minZ), zMax(
maxZ),
130 for (
size_t i=0; i<
n; i++)
132 delete (*crossSections)[i];
147 if (algorithm !=
nullptr)
160 nBins = numberOfBins;
175 G4cout <<
"---- Data set for Z = "
179 G4cout <<
"--------------------------------------------------" <<
G4endl;
188 for (
size_t i=0; i<nZ; i++)
193 char* path = std::getenv(
"G4LEDATA");
201 std::ostringstream ost;
202 ost << path <<
'/' << fileName <<
Z <<
".dat";
203 std::ifstream
file(ost.str().c_str());
204 std::filebuf* lsdp =
file.rdbuf();
206 if (! (lsdp->is_open()) )
208 G4String excep =
"data file: " + ost.str() +
" not found";
233 if (a != -1 && a != -2)
237 orig_reg_energies->push_back(a*
unit1);
238 log_reg_energies->push_back(std::log10(a)+std::log10(
unit1));
240 else if (k%nColumns == 1)
242 orig_reg_data->push_back(a*
unit2);
243 log_reg_data->push_back(std::log10(a)+std::log10(
unit2));
253 log_reg_energies,log_reg_data,algo);
263 for (
size_t i=0; i<nZ; i++)
268 char* path = std::getenv(
"G4LEDATA");
271 G4Exception(
"G4VCrossSectionHandler::LoadNonLogData",
276 std::ostringstream ost;
277 ost << path <<
'/' << fileName <<
Z <<
".dat";
278 std::ifstream
file(ost.str().c_str());
279 std::filebuf* lsdp =
file.rdbuf();
281 if (! (lsdp->is_open()) )
283 G4String excep =
"data file: " + ost.str() +
" not found";
284 G4Exception(
"G4VCrossSectionHandler::LoadNonLogData",
304 if (a != -1 && a != -2)
308 orig_reg_energies->push_back(a*
unit1);
310 else if (k%nColumns == 1)
312 orig_reg_data->push_back(a*
unit2);
332 for (
size_t i=0; i<nZ; i++)
378 G4cout <<
"WARNING: G4VCrossSectionHandler::FindValue did not find Z = "
387 G4int shellIndex)
const
397 if(shellIndex < nComponents)
401 G4cout <<
"WARNING: G4VCrossSectionHandler::FindValue did not find"
402 <<
" shellIndex= " << shellIndex
412 G4cout <<
"WARNING: G4VCrossSectionHandler::FindValue did not find Z = "
428 for (
G4int i=0 ; i<nElements ; i++)
432 G4double nAtomsVol = nAtomsPerVolume[i];
433 value += nAtomsVol * elementValue;
450 energyVector.push_back(std::pow(10., std::log10(
eMin)+i*dBin));
476 G4Exception(
"G4VCrossSectionHandler::BuildMeanFreePathForMaterials",
493 for (
size_t mLocal=0; mLocal<numOfCouples; mLocal++)
502 energies->push_back(
energy);
503 log_energies->push_back(std::log10(
energy));
505 G4double materialCrossSection = 0.0;
507 for(
G4int j=0; j<nElm; j++) {
511 if (materialCrossSection > 0.)
513 data->push_back(1./materialCrossSection);
514 log_data->push_back(std::log10(1./materialCrossSection));
519 log_data->push_back(std::log10(
DBL_MAX));
548 size_t materialIndex = couple->
GetIndex();
550 G4VEMDataSet* materialSet = (*crossSections)[materialIndex];
551 G4double materialCrossSection0 = 0.0;
554 for (
G4int i=0; i < nElements; i++ )
557 materialCrossSection0 += cr;
558 cross.push_back(materialCrossSection0);
562 for (
G4int k=0 ; k < nElements ; k++ )
564 if (random <= cross[k])
return (
G4int) (*elementVector)[k]->GetZ();
585 return (*elementVector)[0];
591 size_t materialIndex = couple->
GetIndex();
593 G4VEMDataSet* materialSet = (*crossSections)[materialIndex];
594 G4double materialCrossSection0 = 0.0;
597 for (
G4int i=0; i<nElements; i++)
600 materialCrossSection0 += cr;
601 cross.push_back(materialCrossSection0);
606 for (
G4int k=0 ; k < nElements ; k++ )
608 if (random <= cross[k])
return (*elementVector)[k];
611 G4cout <<
"G4VCrossSectionHandler::SelectRandomElement - no element found" <<
G4endl;
633 dataSet = (*pos).second;
636 G4Exception(
"G4VCrossSectionHandler::SelectRandomShell",
642 for (
size_t i=0; i<nShells; i++)
645 if (shellDataSet !=
nullptr)
649 if (random <= partialSum)
return i;
661 if (materialTable ==
nullptr)
662 G4Exception(
"G4VCrossSectionHandler::ActiveElements",
667 for (
G4int mLocal2=0; mLocal2<nMaterials; mLocal2++)
673 for (
G4int iEl=0; iEl<nElements; iEl++)
675 G4double Z = (*elementVector)[iEl]->GetZ();
706 G4cout <<
"WARNING: G4VCrossSectionHandler::NumberOfComponents did not "
static const G4double pos
std::vector< const G4Element * > G4ElementVector
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::vector< G4Material * > G4MaterialTable
G4GLOB_DLL std::ostream G4cout
G4bool contains(const G4double &) const
const G4Material * GetMaterial() const
static size_t GetNumberOfMaterials()
static G4MaterialTable * GetMaterialTable()
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
G4double ValueForMaterial(const G4Material *material, G4double e) const
void LoadShellData(const G4String &dataFile)
G4VEMDataSet * BuildMeanFreePathForMaterials(const G4DataVector *energyCuts=nullptr)
G4double FindValue(G4int Z, G4double e) const
virtual ~G4VCrossSectionHandler()
G4VDataSetAlgorithm * interpolation
G4int NumberOfComponents(G4int Z) const
virtual std::vector< G4VEMDataSet * > * BuildCrossSectionsForMaterials(const G4DataVector &energyVector, const G4DataVector *energyCuts=nullptr)=0
void LoadData(const G4String &dataFile)
void LoadNonLogData(const G4String &dataFile)
G4int SelectRandomAtom(const G4MaterialCutsCouple *couple, G4double e) const
std::map< G4int, G4VEMDataSet *, std::less< G4int > > dataMap
G4int SelectRandomShell(G4int Z, G4double e) const
const G4Element * SelectRandomElement(const G4MaterialCutsCouple *material, G4double e) const
std::vector< G4VEMDataSet * > * crossSections
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)
virtual G4VDataSetAlgorithm * CreateInterpolation()
virtual G4VDataSetAlgorithm * Clone() const =0
virtual const G4VEMDataSet * GetComponent(G4int componentId) const =0
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
virtual void AddComponent(G4VEMDataSet *dataSet)=0
virtual size_t NumberOfComponents(void) const =0
virtual G4bool LoadData(const G4String &fileName)=0
virtual void PrintData(void) const =0
G4double energy(const ThreeVector &p, const G4double m)
static const G4double bins[31]