76 : interpolation(algorithm), eMin(minE), eMax(maxE), nBins(bins),
77 unit1(unitE), unit2(unitData), zMin(minZ), zMax(maxZ)
87 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::iterator
pos;
89 for (pos = dataMap.begin(); pos != dataMap.end(); ++
pos)
99 if (crossSections != 0)
101 size_t n = crossSections->size();
102 for (
size_t i=0; i<
n; i++)
104 delete (*crossSections)[i];
106 delete crossSections;
119 delete interpolation;
120 interpolation = algorithm;
129 nBins = numberOfBins;
138 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator
pos;
140 for (pos = dataMap.begin(); pos != dataMap.end(); pos++)
149 G4cout <<
"---- Data set for Z = "
153 G4cout <<
"--------------------------------------------------" <<
G4endl;
159 size_t nZ = activeZ.size();
160 for (
size_t i=0; i<nZ; i++)
166 char* path = getenv(
"G4LEDATA");
169 G4String excep =
"G4LEDATA environment variable not set!";
170 G4Exception(
"G4RDVCrossSectionHandler::LoadData()",
174 std::ostringstream ost;
175 ost << path <<
'/' << fileName << Z <<
".dat";
176 std::ifstream file(ost.str().c_str());
177 std::filebuf* lsdp = file.rdbuf();
179 if (! (lsdp->is_open()) )
181 G4String excep =
"Data file: " + ost.str() +
" not found!";
182 G4Exception(
"G4RDVCrossSectionHandler::LoadData()",
198 if (a == -1 || a == -2)
206 energies->push_back(e);
209 else if (k%nColumns == 0)
212 data->push_back(value);
221 dataMap[
Z] = dataSet;
227 size_t nZ = activeZ.size();
228 for (
size_t i=0; i<nZ; i++)
240 char* path = getenv(
"G4LEDATA");
243 G4String excep =
"G4LEDATA environment variable not set!";
244 G4Exception(
"G4RDVCrossSectionHandler::LoadShellData()",
248 std::ostringstream ost;
250 ost << path <<
'/' << fileName << Z <<
".dat";
252 std::ifstream file(ost.str().c_str());
253 std::filebuf* lsdp = file.rdbuf();
255 if (! (lsdp->is_open()) )
257 G4String excep =
"Data file: " + ost.str() +
" not found!";
258 G4Exception(
"G4RDVCrossSectionHandler::LoadShellData()",
274 if (a == -1 || a == -2)
282 energies->push_back(e);
285 else if (k%nColumns == 0)
288 data->push_back(value);
302 dataMap[
Z] = dataSet;
309 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::iterator
pos;
311 if(! dataMap.empty())
313 for (pos = dataMap.begin(); pos != dataMap.end(); ++
pos)
322 G4int i = (*pos).first;
336 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator
pos;
337 pos = dataMap.find(Z);
338 if (pos!= dataMap.end())
349 G4cout <<
"WARNING: G4RDVCrossSectionHandler::FindValue did not find Z = "
356 G4int shellIndex)
const
360 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator
pos;
361 pos = dataMap.find(Z);
362 if (pos!= dataMap.end())
372 if(shellIndex < nComponents)
377 G4cout <<
"WARNING: G4RDVCrossSectionHandler::FindValue did not find"
378 <<
" shellIndex= " << shellIndex
388 G4cout <<
"WARNING: G4RDVCrossSectionHandler::FindValue did not find Z = "
404 for (
G4int i=0 ; i<nElements ; i++)
408 G4double nAtomsVol = nAtomsPerVolume[i];
409 value += nAtomsVol * elementValue;
422 G4double dBin = std::log10(eMax/eMin) / nBins;
424 for (
G4int i=0; i<nBins+1; i++)
426 energyVector.push_back(std::pow(10., std::log10(eMin)+i*dBin));
432 if (crossSections != 0)
434 std::vector<G4RDVEMDataSet*>::iterator mat;
435 if (! crossSections->empty())
437 for (mat = crossSections->begin(); mat!= crossSections->end(); ++mat)
443 crossSections->clear();
444 delete crossSections;
451 if (crossSections == 0)
452 G4Exception(
"G4RDVCrossSectionHandler::BuildMeanFreePathForMaterials()",
466 for (
size_t m=0;
m<numOfCouples;
m++)
473 energies->push_back(energy);
475 G4double materialCrossSection = 0.0;
477 for(
G4int j=0; j<nElm; j++) {
481 if (materialCrossSection > 0.)
483 data->push_back(1./materialCrossSection);
517 size_t materialIndex = couple->
GetIndex();
520 G4double materialCrossSection0 = 0.0;
523 for (
G4int i=0; i < nElements; i++ )
526 materialCrossSection0 += cr;
527 cross.push_back(materialCrossSection0);
532 for (
G4int k=0 ; k < nElements ; k++ )
534 if (random <= cross[k])
return (
G4int) (*elementVector)[k]->GetZ();
554 G4Element* element = (*elementVector)[0];
561 size_t materialIndex = couple->
GetIndex();
564 G4double materialCrossSection0 = 0.0;
567 for (
G4int i=0; i<nElements; i++)
570 materialCrossSection0 += cr;
571 cross.push_back(materialCrossSection0);
576 for (
G4int k=0 ; k < nElements ; k++ )
578 if (random <= cross[k])
return (*elementVector)[k];
581 G4cout <<
"G4RDVCrossSectionHandler::SelectRandomElement - no element found" <<
G4endl;
601 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator
pos;
602 pos = dataMap.find(Z);
607 if (pos != dataMap.end()) dataSet = (*pos).second;
610 for (
size_t i=0; i<nShells; i++)
613 if (shellDataSet != 0)
617 if (random <= partialSum)
return i;
627 if (materialTable == 0)
628 G4Exception(
"G4RDVCrossSectionHandler::ActiveElements",
639 for (
G4int iEl=0; iEl<nElements; iEl++)
641 G4Element* element = (*elementVector)[iEl];
643 if (!(activeZ.
contains(Z)) && Z >= zMin && Z <= zMax)
645 activeZ.push_back(Z);
661 std::map<G4int,G4RDVEMDataSet*,std::less<G4int> >::const_iterator
pos;
662 pos = dataMap.find(Z);
663 if (pos!= dataMap.end())
670 G4cout <<
"WARNING: G4RDVCrossSectionHandler::NumberOfComponents did not "
G4double ValueForMaterial(const G4Material *material, G4double e) const
virtual G4RDVDataSetAlgorithm * Clone() const =0
std::vector< G4Element * > G4ElementVector
void Initialise(G4RDVDataSetAlgorithm *interpolation=0, 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)
std::vector< ExP01TrackerHit * > a
static G4MaterialTable * GetMaterialTable()
std::vector< G4Material * > G4MaterialTable
void LoadShellData(const G4String &dataFile)
virtual const G4RDVEMDataSet * GetComponent(G4int componentId) const =0
G4double FindValue(G4int Z, G4double e) const
G4RDVEMDataSet * BuildMeanFreePathForMaterials(const G4DataVector *energyCuts=0)
const G4ElementVector * GetElementVector() const
virtual size_t NumberOfComponents(void) const =0
const XML_Char const XML_Char * data
const G4double * GetVecNbOfAtomsPerVolume() const
G4GLOB_DLL std::ostream G4cout
static constexpr double m
const XML_Char int const XML_Char * value
size_t GetTableSize() const
virtual G4RDVDataSetAlgorithm * CreateInterpolation()
G4int SelectRandomShell(G4int Z, G4double e) const
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
virtual void PrintData(void) const =0
static size_t GetNumberOfMaterials()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4ProductionCutsTable * GetProductionCutsTable()
virtual std::vector< G4RDVEMDataSet * > * BuildCrossSectionsForMaterials(const G4DataVector &energyVector, const G4DataVector *energyCuts=0)=0
G4double energy(const ThreeVector &p, const G4double m)
G4int SelectRandomAtom(const G4MaterialCutsCouple *couple, G4double e) const
G4RDVCrossSectionHandler()
void LoadData(const G4String &dataFile)
size_t GetNumberOfElements() const
G4int NumberOfComponents(G4int Z) const
virtual ~G4RDVCrossSectionHandler()
G4bool contains(const G4double &) const
virtual void AddComponent(G4RDVEMDataSet *dataSet)=0
const G4Element * SelectRandomElement(const G4MaterialCutsCouple *material, G4double e) const
static const G4double pos
virtual G4bool LoadData(const G4String &fileName)=0
const G4Material * GetMaterial() const