65 Initialise(0,
"",
"",
"",1.*keV,0.1*GeV,200,MeV,barn,6,92);
81 : interpolation(algorithm), eMin(minE), eMax(maxE), nBins(bins),
82 unit1(unitE), unit2(unitData), zMin(minZ), zMax(maxZ)
86 crossModel.push_back(modelK);
87 crossModel.push_back(modelL);
88 crossModel.push_back(modelM);
101 std::map<G4int,G4IDataSet*,std::less<G4int> >::iterator pos;
103 for (pos = dataMap.begin(); pos != dataMap.end(); ++pos)
113 if (crossSections != 0)
115 size_t n = crossSections->size();
116 for (
size_t i=0; i<n; i++)
118 delete (*crossSections)[i];
120 delete crossSections;
136 delete interpolation;
137 interpolation = algorithm;
141 interpolation = CreateInterpolation();
146 nBins = numberOfBins;
152 crossModel.push_back(modelK);
153 crossModel.push_back(modelL);
154 crossModel.push_back(modelM);
160 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
162 for (pos = dataMap.begin(); pos != dataMap.end(); pos++)
169 G4int z = (*pos).first;
171 G4cout <<
"---- Data set for Z = "
175 G4cout <<
"--------------------------------------------------" <<
G4endl;
181 size_t nZ = activeZ.size();
182 for (
size_t i=0; i<nZ; i++)
198 dataMap[Z] = dataSet;
212 std::map<G4int,G4IDataSet*,std::less<G4int> >::iterator pos;
214 if(! dataMap.empty())
216 for (pos = dataMap.begin(); pos != dataMap.end(); ++pos)
225 G4int i = (*pos).first;
239 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
240 pos = dataMap.find(Z);
241 if (pos!= dataMap.end())
252 G4cout <<
"WARNING: G4PixeCrossSectionHandler::FindValue(Z,e) did not find Z = "
259 G4int shellIndex)
const
263 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
264 pos = dataMap.find(Z);
265 if (pos!= dataMap.end())
275 if(shellIndex < nComponents)
280 G4cout <<
"WARNING: G4PixeCrossSectionHandler::FindValue(Z,e,shell) did not find"
281 <<
" shellIndex= " << shellIndex
291 G4cout <<
"WARNING: G4PixeCrossSectionHandler::FindValue did not find Z = "
307 for (
G4int i=0 ; i<nElements ; i++)
309 G4int Z = (
G4int) (*elementVector)[i]->GetZ();
311 G4double nAtomsVol = nAtomsPerVolume[i];
312 value += nAtomsVol * elementValue;
405void G4PixeCrossSectionHandler::BuildForMaterials()
411 G4double dBin = std::log10(eMax/eMin) / nBins;
413 for (
G4int i=0; i<nBins+1; i++)
415 energyVector.push_back(std::pow(10., std::log10(eMin)+i*dBin));
418 if (crossSections != 0)
420 std::vector<G4IDataSet*>::iterator mat;
421 if (! crossSections->empty())
423 for (mat = crossSections->begin(); mat!= crossSections->end(); ++mat)
429 crossSections->clear();
430 delete crossSections;
435 crossSections = BuildCrossSectionsForMaterials(energyVector);
437 if (crossSections == 0)
438 G4Exception(
"G4PixeCrossSectionHandler::BuildForMaterials",
441 ", crossSections = 0");
465 size_t materialIndex = material->
GetIndex();
467 G4IDataSet* materialSet = (*crossSections)[materialIndex];
468 G4double materialCrossSection0 = 0.0;
471 for (
G4int i=0; i < nElements; i++ )
474 materialCrossSection0 += cr;
475 cross.push_back(materialCrossSection0);
480 for (
G4int k=0 ; k < nElements ; k++ )
482 if (random <= cross[k])
return (
G4int) (*elementVector)[k]->GetZ();
552 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator pos;
553 pos = dataMap.find(Z);
558 if (pos != dataMap.end()) dataSet = (*pos).second;
561 for (
size_t i=0; i<nShells; i++)
564 if (shellDataSet != 0)
568 if (random <= partialSum)
return i;
575void G4PixeCrossSectionHandler::ActiveElements()
578 if (materialTable == 0)
579 G4Exception(
"G4PixeCrossSectionHandler::ActiveElements",
582 "no MaterialTable found");
586 for (
G4int mat=0; mat<nMaterials; mat++)
588 const G4Material* material= (*materialTable)[mat];
592 for (
G4int iEl=0; iEl<nElements; iEl++)
594 G4Element* element = (*elementVector)[iEl];
596 if (!(activeZ.
contains(Z)) && Z >= zMin && Z <= zMax)
598 activeZ.push_back(Z);
610G4int G4PixeCrossSectionHandler::NumberOfComponents(
G4int Z)
const
614 std::map<G4int,G4IDataSet*,std::less<G4int> >::const_iterator
pos;
615 pos = dataMap.find(Z);
616 if (pos!= dataMap.end())
623 G4cout <<
"WARNING: G4PixeCrossSectionHandler::NumberOfComponents did not "
631std::vector<G4IDataSet*>*
632G4PixeCrossSectionHandler::BuildCrossSectionsForMaterials(
const G4DataVector& energyVector)
637 std::vector<G4IDataSet*>* matCrossSections =
new std::vector<G4IDataSet*>;
642 size_t nOfBins = energyVector.size();
646 if (materialTable == 0)
647 G4Exception(
"G4PixeCrossSectionHandler::BuildCrossSectionsForMaterials",
650 "no MaterialTable found");
654 for (
G4int mat=0; mat<nMaterials; mat++)
656 const G4Material* material = (*materialTable)[mat];
665 for (
G4int i=0; i<nElements; i++) {
667 G4int Z = (
G4int) (*elementVector)[i]->GetZ();
668 G4double density = nAtomsPerVolume[i];
674 for (
size_t bin=0; bin<nOfBins; bin++)
677 energies->push_back(e);
679 if (Z >= zMin && Z <= zMax) cross = density*
FindValue(Z,e);
680 data->push_back(cross);
688 matCrossSections->push_back(setForMat);
690 return matCrossSections;
708 G4double energy = kineticEnergy + particleMass;
711 G4double gamma = energy / particleMass;
712 G4double beta2 = 1. - 1. / (gamma * gamma);
713 G4double var = electron_mass_c2 / particleMass;
714 G4double tMax = 2. * electron_mass_c2 * (gamma*gamma - 1.) / (1. + 2.*gamma*var + var*var);
718 if ( tMax > deltaCut )
720 var = deltaCut / tMax;
721 cross = (1. - var * (1. - beta2 * std::log(var))) / deltaCut;
728 cross += 0.5 * (tMax - deltaCut) / (energy*energy);
731 else if (spin > 0.9 )
733 cross += -std::log(var) / (3.*deltaCut) + (tMax-deltaCut) *
734 ((5.+1./var)*0.25 /(energy*energy) - beta2 / (tMax*deltaCut))/3.;
736 cross *= twopi_mc2_rcl2 * Z / beta2 ;
std::vector< 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
virtual const G4IDataSet * GetComponent(G4int componentId) const =0
virtual G4bool LoadData(const G4String &fileName)=0
virtual size_t NumberOfComponents(void) const =0
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
virtual void AddComponent(G4IDataSet *dataSet)=0
virtual void PrintData(void) const =0
virtual G4IInterpolator * Clone() const =0
const G4ElementVector * GetElementVector() const
static size_t GetNumberOfMaterials()
size_t GetNumberOfElements() const
const G4double * GetAtomicNumDensityVector() const
const G4double * GetVecNbOfAtomsPerVolume() const
static G4MaterialTable * GetMaterialTable()
G4double GetPDGMass() const
G4double GetPDGSpin() const
virtual ~G4PixeCrossSectionHandler()
void Initialise(G4IInterpolator *interpolation, const G4String &modelK="ecpssr", const G4String &modelL="ecpssr", const G4String &modelM="ecpssr", G4double minE=1 *CLHEP::keV, G4double maxE=0.1 *CLHEP::GeV, G4int nBins=200, G4double unitE=CLHEP::MeV, G4double unitData=CLHEP::barn, G4int minZ=6, G4int maxZ=92)
G4double MicroscopicCrossSection(const G4ParticleDefinition *particleDef, G4double kineticEnergy, G4double Z, G4double deltaCut) const
G4double FindValue(G4int Z, G4double e) const
G4int SelectRandomShell(G4int Z, G4double e) const
void LoadShellData(const G4String &dataFile)
G4double ValueForMaterial(const G4Material *material, G4double e) const
G4PixeCrossSectionHandler()
G4int SelectRandomAtom(const G4Material *material, G4double e) const