54 std::vector<G4double>* G4LivermorePolarizedPhotoElectricModel::fParam[] = {
nullptr};
55 G4int G4LivermorePolarizedPhotoElectricModel::fNShells[] = {0};
56 G4int G4LivermorePolarizedPhotoElectricModel::fNShellsUsed[] = {0};
57 G4ElementData* G4LivermorePolarizedPhotoElectricModel::fShellCrossSection =
nullptr;
58 G4Material* G4LivermorePolarizedPhotoElectricModel::fWater =
nullptr;
59 G4double G4LivermorePolarizedPhotoElectricModel::fWaterEnergyLimit = 0.0;
66 :
G4VEmModel(nam),fParticleChange(nullptr),maxZ(99),
67 nShellLimit(100),fDeexcitationActive(false),isInitialised(false),
68 fAtomDeexcitation(nullptr)
86 G4cout <<
"Livermore PhotoElectric is constructed "
87 <<
" nShellLimit= " << nShellLimit <<
G4endl;
92 fSandiaCof.resize(4,0.0);
102 delete fShellCrossSection;
103 for(
G4int i=0; i<maxZ; ++i) {
106 delete fCrossSection[i];
107 fCrossSection[i] = 0;
108 delete fCrossSectionLE[i];
109 fCrossSectionLE[i] = 0;
120 if (verboseLevel > 2) {
121 G4cout <<
"Calling G4LivermorePolarizedPhotoElectricModel::Initialise()" <<
G4endl;
128 if(fWater) { fWaterEnergyLimit = 13.6*
eV; }
131 if(!fShellCrossSection) { fShellCrossSection =
new G4ElementData(); }
133 char* path = getenv(
"G4LEDATA");
139 for(
G4int i=0; i<numOfCouples; ++i) {
146 for (
G4int j=0; j<nelm; ++j) {
149 else if(Z > maxZ) { Z = maxZ; }
150 if(!fCrossSection[Z]) { ReadData(Z, path); }
155 if (verboseLevel > 2) {
156 G4cout <<
"Loaded cross section files for LivermorePolarizedPhotoElectric model"
160 isInitialised =
true;
165 fDeexcitationActive =
false;
166 if(fAtomDeexcitation) {
167 fDeexcitationActive = fAtomDeexcitation->
IsFluoActive();
170 if (verboseLevel > 0) {
171 G4cout <<
"LivermorePolarizedPhotoElectric model is initialized " <<
G4endl
185 if(fWater && (material == fWater ||
187 if(energy <= fWaterEnergyLimit) {
195 (fSandiaCof[0]/energy + fSandiaCof[1]/energy2 +
196 fSandiaCof[2]/energy3 + fSandiaCof[3]/energy4);
199 if(0.0 == fCurrSection) {
213 if (verboseLevel > 3) {
214 G4cout <<
"G4LivermorePolarizedPhotoElectricModel::ComputeCrossSectionPerAtom():"
215 <<
" Z= " << ZZ <<
" R(keV)= " << energy/
keV <<
G4endl;
219 if(Z < 1 || Z >= maxZ) {
return cs; }
223 if(!fCrossSection[Z]) {
225 if(!fCrossSection[Z]) {
return cs; }
228 G4int idx = fNShells[
Z]*6 - 4;
229 if (energy < (*(fParam[Z]))[idx-1]) { energy = (*(fParam[
Z]))[idx-1]; }
236 if(energy >= (*(fParam[Z]))[0]) {
238 cs = x1*((*(fParam[
Z]))[idx] + x1*(*(fParam[
Z]))[idx+1]
239 + x2*(*(fParam[
Z]))[idx+2] + x3*(*(fParam[
Z]))[idx+3]
240 + x4*(*(fParam[
Z]))[idx+4]);
242 }
else if(energy >= (*(fParam[Z]))[1]) {
243 cs = x3*(fCrossSection[
Z])->
Value(energy);
247 cs = x3*(fCrossSectionLE[
Z])->
Value(energy);
249 if (verboseLevel > 1) {
250 G4cout <<
"LivermorePolarizedPhotoElectricModel: E(keV)= " << energy/
keV
251 <<
" Z= " << Z <<
" cross(barn)= " << cs/
barn <<
G4endl;
260 std::vector<G4DynamicParticle*>* fvect,
267 if (verboseLevel > 3) {
268 G4cout <<
"G4LivermorePolarizedPhotoElectricModel::SampleSecondaries() Egamma(keV)= "
278 if(fWater && (material == fWater ||
280 if(gammaEnergy <= fWaterEnergyLimit) {
298 if(Z >= maxZ) { Z = maxZ-1; }
301 if(!fCrossSection[Z]) {
308 size_t nn = fNShellsUsed[
Z];
311 if(gammaEnergy >= (*(fParam[Z]))[0]) {
316 G4int idx = nn*6 - 4;
320 + x1*(*(fParam[
Z]))[idx+1]
321 + x2*(*(fParam[
Z]))[idx+2]
322 + x3*(*(fParam[
Z]))[idx+3]
323 + x4*(*(fParam[
Z]))[idx+4]);
324 for(shellIdx=0; shellIdx<
nn; ++shellIdx) {
325 idx = shellIdx*6 + 2;
326 if(gammaEnergy > (*(fParam[Z]))[idx-1]) {
327 G4double cs = (*(fParam[
Z]))[idx] + x1*(*(fParam[
Z]))[idx+1]
328 + x2*(*(fParam[
Z]))[idx+2] + x3*(*(fParam[
Z]))[idx+3]
329 + x4*(*(fParam[
Z]))[idx+4];
330 if(cs >= cs0) {
break; }
333 if(shellIdx >= nn) { shellIdx = nn-1; }
341 if(gammaEnergy >= (*(fParam[Z]))[1]) {
342 cs *= (fCrossSection[
Z])->
Value(gammaEnergy);
344 cs *= (fCrossSectionLE[
Z])->
Value(gammaEnergy);
347 for(
size_t j=0; j<
nn; ++j) {
349 if(gammaEnergy > (*(fParam[Z]))[6*shellIdx+1]) {
352 if(cs <= 0.0 || j+1 == nn) {
break; }
366 if(fDeexcitationActive && shellIdx + 1 < nn) {
373 if(gammaEnergy < bindingEnergy) {
393 fvect->push_back(electron);
399 G4int nbefore = fvect->size();
402 G4int nafter = fvect->size();
403 if(nafter > nbefore) {
405 for (
G4int j=nbefore; j<nafter; ++j) {
407 G4double e = ((*fvect)[j])->GetKineticEnergy();
408 if(esec + e > edep) {
411 ((*fvect)[j])->SetKineticEnergy(e);
414 for (
G4int jj=nafter-1; jj>j; --jj) {
435 G4LivermorePolarizedPhotoElectricModel::ReadData(
G4int Z,
const char* path)
437 if (verboseLevel > 1)
439 G4cout <<
"Calling ReadData() of G4LivermoreGammaConversionModel"
443 if(fCrossSection[Z]) {
return; }
445 const char* datadir = path;
449 datadir = getenv(
"G4LEDATA");
452 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
454 "Environment variable G4LEDATA not defined");
463 std::ostringstream ost;
464 ost << datadir <<
"/livermore/phot/pe-cs-" << Z <<
".dat";
465 std::ifstream fin(ost.str().c_str());
466 if( !fin.is_open()) {
468 ed <<
"G4LivermorePolarizedPhotoElectricModel data file <" << ost.str().c_str()
469 <<
"> is not opened!" <<
G4endl;
470 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
472 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
475 if(verboseLevel > 3) {
G4cout <<
"File " << ost.str().c_str()
476 <<
" is opened by G4LivermorePolarizedPhotoElectricModel" <<
G4endl;}
482 fParam[
Z] =
new std::vector<G4double>;
488 std::ostringstream ost1;
489 ost1 << datadir <<
"/livermore/phot/pe-" << Z <<
".dat";
490 std::ifstream fin1(ost1.str().c_str());
491 if( !fin1.is_open()) {
493 ed <<
"G4LivermorePolarizedPhotoElectricModel data file <" << ost1.str().c_str()
494 <<
"> is not opened!" <<
G4endl;
495 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
497 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
500 if(verboseLevel > 3) {
501 G4cout <<
"File " << ost1.str().c_str()
502 <<
" is opened by G4LivermorePolarizedPhotoElectricModel" <<
G4endl;
505 if(fin1.fail()) {
return; }
506 if(0 > n1 || n1 >=
INT_MAX) { n1 = 0; }
509 if(fin1.fail()) {
return; }
510 if(0 > n2 || n2 >=
INT_MAX) { n2 = 0; }
513 if(fin1.fail()) {
return; }
516 fParam[
Z]->reserve(6*n1+1);
517 fParam[
Z]->push_back(x*
MeV);
518 for(
G4int i=0; i<n1; ++i) {
519 for(
G4int j=0; j<6; ++j) {
521 if(0 == j) { x *=
MeV; }
523 fParam[
Z]->push_back(x);
529 if(nShellLimit < n2) { n2 = nShellLimit; }
531 fNShellsUsed[
Z] = n2;
534 std::ostringstream ost2;
535 ost2 << datadir <<
"/livermore/phot/pe-ss-cs-" << Z <<
".dat";
536 std::ifstream fin2(ost2.str().c_str());
537 if( !fin2.is_open()) {
539 ed <<
"G4LivermorePolarizedPhotoElectricModel data file <" << ost2.str().c_str()
540 <<
"> is not opened!" <<
G4endl;
541 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
543 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
546 if(verboseLevel > 3) {
547 G4cout <<
"File " << ost2.str().c_str()
548 <<
" is opened by G4LivermorePolarizedPhotoElectricModel" <<
G4endl;
553 for(
G4int i=0; i<n2; ++i) {
554 fin2 >> x >> y >> n3 >> n4;
556 for(
G4int j=0; j<n3; ++j) {
567 if(1 < fNShells[Z]) {
570 std::ostringstream ost3;
571 ost3 << datadir <<
"/livermore/phot/pe-le-cs-" << Z <<
".dat";
572 std::ifstream fin3(ost3.str().c_str());
573 if( !fin3.is_open()) {
575 ed <<
"G4LivermorePolarizedPhotoElectricModel data file <" << ost3.str().c_str()
576 <<
"> is not opened!" <<
G4endl;
577 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
579 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
582 if(verboseLevel > 3) {
583 G4cout <<
"File " << ost3.str().c_str()
584 <<
" is opened by G4LivermorePolarizedPhotoElectricModel" <<
G4endl;
586 fCrossSectionLE[
Z]->
Retrieve(fin3,
true);
601 G4AutoLock l(&LivermorePolarizedPhotoElectricModelMutex);
604 if(!fCrossSection[Z]) { ReadData(Z); }
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4bool CheckDeexcitationActiveRegion(G4int coupleIndex)
static G4LossTableManager * Instance()
G4bool IsFluoActive() const
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
std::vector< G4Element * > G4ElementVector
std::ostringstream G4ExceptionDescription
G4double GetKineticEnergy() const
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
G4VEmAngularDistribution * GetAngularDistribution()
G4double GetDensity() const
const G4ElementVector * GetElementVector() const
#define G4MUTEX_INITIALIZER
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double energy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
G4SandiaTable * GetSandiaTable() const
virtual const G4AtomicShell * GetAtomicShell(G4int Z, G4AtomicShellEnumerator shell)=0
G4int GetComponentID(G4int Z, size_t idx)
G4ParticleChangeForGamma * fParticleChange
G4LivermorePolarizedPhotoElectricModel(const G4String &nam="LivermorePolarizedPhotoElectric")
G4GLOB_DLL std::ostream G4cout
virtual G4ThreeVector & SampleDirection(const G4DynamicParticle *dp, G4double finalTotalEnergy, G4int Z, const G4Material *)=0
size_t GetTableSize() const
const G4ThreeVector & GetMomentumDirection() const
static constexpr double eV
virtual void ScaleVector(G4double factorE, G4double factorV)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4ProductionCutsTable * GetProductionCutsTable()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
G4double energy(const ThreeVector &p, const G4double m)
void SetAngularDistribution(G4VEmAngularDistribution *)
virtual ~G4LivermorePolarizedPhotoElectricModel()
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
G4double GetValueForComponent(G4int Z, size_t idx, G4double kinEnergy)
const G4Material * GetBaseMaterial() const
static G4Electron * Electron()
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void PutValues(size_t index, G4double e, G4double dataValue)
static constexpr double MeV
size_t GetNumberOfElements() const
G4VAtomDeexcitation * AtomDeexcitation()
void GetSandiaCofWater(G4double energy, std::vector< G4double > &coeff) const
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double energy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
void ProposeTrackStatus(G4TrackStatus status)
void GenerateParticles(std::vector< G4DynamicParticle * > *secVect, const G4AtomicShell *, G4int Z, G4int coupleIndex)
void SetDeexcitationFlag(G4bool val)
static constexpr double barn
G4double bindingEnergy(G4int A, G4int Z)
void InitialiseForComponent(G4int Z, G4int nComponents=0)
static constexpr double keV
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
virtual G4double Value(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy)
const G4Material * GetMaterial() const