52std::vector<G4double>* G4LivermorePhotoElectricModel::fParamHigh[] = {
nullptr};
53std::vector<G4double>* G4LivermorePhotoElectricModel::fParamLow[] = {
nullptr};
54G4int G4LivermorePhotoElectricModel::fNShells[] = {0};
55G4int G4LivermorePhotoElectricModel::fNShellsUsed[] = {0};
56G4ElementData* G4LivermorePhotoElectricModel::fShellCrossSection =
nullptr;
57G4Material* G4LivermorePhotoElectricModel::fWater =
nullptr;
58G4double G4LivermorePhotoElectricModel::fWaterEnergyLimit = 0.0;
59G4String G4LivermorePhotoElectricModel::fDataDirectory =
"";
70 :
G4VEmModel(nam),fParticleChange(nullptr), fAtomDeexcitation(nullptr),
71 maxZ(100),nShellLimit(100),fDeexcitationActive(false),isInitialised(false)
88 G4cout <<
"Livermore PhotoElectric is constructed "
89 <<
" nShellLimit= " << nShellLimit <<
G4endl;
94 fSandiaCof.resize(4,0.0);
104 delete fShellCrossSection;
105 fShellCrossSection =
nullptr;
106 for(
G4int i = 0; i <= maxZ; ++i)
109 delete fParamHigh[i];
110 fParamHigh[i] =
nullptr;
114 fParamLow[i] =
nullptr;
116 if(fCrossSection[i]){
117 delete fCrossSection[i];
118 fCrossSection[i] =
nullptr;
120 if(fCrossSectionLE[i]){
121 delete fCrossSectionLE[i];
122 fCrossSectionLE[i] =
nullptr;
135 if (verboseLevel > 2) {
136 G4cout <<
"Calling G4LivermorePhotoElectricModel::Initialise() " <<
G4endl;
141 if(fWater ==
nullptr) {
144 if(fWater) { fWaterEnergyLimit = 13.6*eV; }
147 if(fShellCrossSection ==
nullptr) { fShellCrossSection =
new G4ElementData(); }
150 std::size_t numElems = (*elemTable).size();
151 for(std::size_t ie = 0; ie < numElems; ++ie)
154 const G4int Z = std::min(maxZ,
elem->GetZasInt());
155 if(fCrossSection[
Z] ==
nullptr)
162 if (verboseLevel > 2) {
163 G4cout <<
"Loaded cross section files for new LivermorePhotoElectric model"
167 isInitialised =
true;
172 fDeexcitationActive =
false;
173 if(fAtomDeexcitation) {
174 fDeexcitationActive = fAtomDeexcitation->
IsFluoActive();
177 if (verboseLevel > 0) {
178 G4cout <<
"LivermorePhotoElectric model is initialized " <<
G4endl
192 if(fWater && (material == fWater ||
194 if(energy <= fWaterEnergyLimit) {
202 (fSandiaCof[0]/energy + fSandiaCof[1]/energy2 +
203 fSandiaCof[2]/energy3 + fSandiaCof[3]/energy4);
206 if(0.0 == fCurrSection) {
220 if (verboseLevel > 3) {
221 G4cout <<
"\n G4LivermorePhotoElectricModel::ComputeCrossSectionPerAtom():"
222 <<
" Z= " << ZZ <<
" R(keV)= " << energy/keV <<
G4endl;
226 if(
Z > maxZ) {
return cs; }
233 G4int idx = fNShells[
Z]*7 - 5;
235 energy = std::max(energy, (*(fParamHigh[
Z]))[idx-1]);
242 if(energy >= (*(fParamHigh[
Z]))[0]) {
247 cs = x1*((*(fParamHigh[
Z]))[idx] + x1*(*(fParamHigh[
Z]))[idx+1]
248 + x2*(*(fParamHigh[
Z]))[idx+2] + x3*(*(fParamHigh[
Z]))[idx+3]
249 + x4*(*(fParamHigh[
Z]))[idx+4]+ x5*(*(fParamHigh[
Z]))[idx+5]);
253 else if(energy >= (*(fParamLow[
Z]))[0]) {
257 cs = x1*((*(fParamLow[
Z]))[idx] + x1*(*(fParamLow[
Z]))[idx+1]
258 + x2*(*(fParamLow[
Z]))[idx+2] + x3*(*(fParamLow[
Z]))[idx+3]
259 + x4*(*(fParamLow[
Z]))[idx+4]+ x5*(*(fParamLow[
Z]))[idx+5]);
263 else if(energy >= (*(fParamHigh[
Z]))[1]) {
264 cs = x3*(fCrossSection[
Z])->
Value(energy);
269 cs = x3*(fCrossSectionLE[
Z])->
Value(energy);
271 if (verboseLevel > 1) {
272 G4cout <<
"G4LivermorePhotoElectricModel: E(keV)= " << energy/keV
273 <<
" Z= " <<
Z <<
" cross(barn)= " << cs/barn <<
G4endl;
282 std::vector<G4DynamicParticle*>* fvect,
288 if (verboseLevel > 3) {
289 G4cout <<
"G4LivermorePhotoElectricModel::SampleSecondaries() Egamma(keV)= "
290 << gammaEnergy/keV <<
G4endl;
299 if(fWater && (material == fWater ||
301 if(gammaEnergy <= fWaterEnergyLimit) {
317 if(
Z > maxZ) {
Z = maxZ; }
320 if(fCrossSection[
Z] ==
nullptr) {
326 std::size_t shellIdx = 0;
327 std::size_t nn = fNShellsUsed[
Z];
330 if(gammaEnergy >= (*(fParamHigh[
Z]))[0])
337 std::size_t idx = nn*7 - 5;
342 G4double cs0 = rand*( (*(fParamHigh[
Z]))[idx]
343 + x1*(*(fParamHigh[
Z]))[idx+1]
344 + x2*(*(fParamHigh[
Z]))[idx+2]
345 + x3*(*(fParamHigh[
Z]))[idx+3]
346 + x4*(*(fParamHigh[
Z]))[idx+4]
347 + x5*(*(fParamHigh[
Z]))[idx+5]);
349 for(shellIdx=0; shellIdx<nn; ++shellIdx)
351 idx = shellIdx*7 + 2;
352 if(gammaEnergy > (*(fParamHigh[
Z]))[idx-1])
355 (*(fParamHigh[
Z]))[idx]
356 + x1*(*(fParamHigh[
Z]))[idx+1]
357 + x2*(*(fParamHigh[
Z]))[idx+2]
358 + x3*(*(fParamHigh[
Z]))[idx+3]
359 + x4*(*(fParamHigh[
Z]))[idx+4]
360 + x5*(*(fParamHigh[
Z]))[idx+5];
362 if(cs >= cs0) {
break; }
365 if(shellIdx >= nn) { shellIdx = nn-1; }
367 else if(gammaEnergy >= (*(fParamLow[
Z]))[0])
374 std::size_t idx = nn*7 - 5;
378 + x1*(*(fParamLow[
Z]))[idx+1]
379 + x2*(*(fParamLow[
Z]))[idx+2]
380 + x3*(*(fParamLow[
Z]))[idx+3]
381 + x4*(*(fParamLow[
Z]))[idx+4]
382 + x5*(*(fParamLow[
Z]))[idx+5]);
383 for(shellIdx=0; shellIdx<nn; ++shellIdx)
385 idx = shellIdx*7 + 2;
386 if(gammaEnergy > (*(fParamLow[
Z]))[idx-1])
388 G4double cs = (*(fParamLow[
Z]))[idx] + x1*(*(fParamLow[
Z]))[idx+1]
389 + x2*(*(fParamLow[
Z]))[idx+2] + x3*(*(fParamLow[
Z]))[idx+3]
390 + x4*(*(fParamLow[
Z]))[idx+4]+ x5*(*(fParamLow[
Z]))[idx+5];
391 if(cs >= cs0) {
break; }
394 if(shellIdx >= nn) {shellIdx = nn-1;}
402 if(gammaEnergy >= (*(fParamHigh[
Z]))[1]) {
404 cs*= (fCrossSection[
Z])->
Value(gammaEnergy);
409 cs *= (fCrossSectionLE[
Z])->
Value(gammaEnergy);
415 if(gammaEnergy > (*(fParamLow[
Z]))[7*shellIdx+1]) {
418 if(cs <= 0.0 || j+1 == (
G4int)nn) {
break;}
424 G4double bindingEnergy = (*(fParamHigh[
Z]))[shellIdx*7 + 1];
428 if(fDeexcitationActive && shellIdx + 1 < nn) {
435 if(gammaEnergy < bindingEnergy) {
441 G4double eKineticEnergy = gammaEnergy - bindingEnergy;
455 fvect->push_back(electron);
461 std::size_t nbefore = fvect->size();
464 std::size_t nafter = fvect->size();
465 if(nafter > nbefore) {
467 for (std::size_t j=nbefore; j<nafter; ++j) {
469 G4double e = ((*fvect)[j])->GetKineticEnergy();
470 if(esec + e > edep) {
473 ((*fvect)[j])->SetKineticEnergy(e);
476 for (std::size_t jj=nafter-1; jj>j; --jj) {
496const G4String& G4LivermorePhotoElectricModel::FindDirectoryPath()
500 if(fDataDirectory.empty()) {
503 std::ostringstream ost;
505 ost << path <<
"/livermore/phot_epics2014/";
507 ost << path <<
"/epics2017/phot/";
510 fDataDirectory = ost.str();
512 G4Exception(
"G4SeltzerBergerModel::FindDirectoryPath()",
"em0006",
514 "Environment variable G4LEDATA not defined");
517 return fDataDirectory;
522void G4LivermorePhotoElectricModel::ReadData(
G4int Z)
524 if (verboseLevel > 1)
526 G4cout <<
"Calling ReadData() of G4LivermorePhotoElectricModel"
530 if(fCrossSection[
Z]!=
nullptr) {
return; }
540 std::ostringstream ost;
541 ost << FindDirectoryPath() <<
"pe-cs-" <<
Z <<
".dat";
542 std::ifstream fin(ost.str().c_str());
543 if( !fin.is_open()) {
545 ed <<
"G4LivermorePhotoElectricModel data file <" << ost.str().c_str()
546 <<
"> is not opened!" <<
G4endl;
547 G4Exception(
"G4LivermorePhotoElectricModel::ReadData()",
549 ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
552 if(verboseLevel > 3) {
553 G4cout <<
"File " << ost.str().c_str()
554 <<
" is opened by G4LivermorePhotoElectricModel" <<
G4endl;
562 fParamHigh[
Z] =
new std::vector<G4double>;
566 std::ostringstream ost1;
567 ost1 << fDataDirectory <<
"pe-high-" <<
Z <<
".dat";
568 std::ifstream fin1(ost1.str().c_str());
569 if( !fin1.is_open()) {
571 ed <<
"G4LivermorePhotoElectricModel data file <" << ost1.str().c_str()
572 <<
"> is not opened!" <<
G4endl;
573 G4Exception(
"G4LivermorePhotoElectricModel::ReadData()",
575 ed,
"G4LEDATA version should be G4EMLOW7.2 or later.");
578 if(verboseLevel > 3) {
579 G4cout <<
"File " << ost1.str().c_str()
580 <<
" is opened by G4LivermorePhotoElectricModel" <<
G4endl;
583 if(fin1.fail()) {
return; }
584 if(0 > n1 || n1 >=
INT_MAX) { n1 = 0; }
587 if(fin1.fail()) {
return; }
588 if(0 > n2 || n2 >=
INT_MAX) { n2 = 0; }
591 if(fin1.fail()) {
return; }
594 fParamHigh[
Z]->reserve(7*n1+1);
595 fParamHigh[
Z]->push_back(x*MeV);
596 for(
G4int i=0; i<n1; ++i) {
597 for(
G4int j=0; j<7; ++j) {
599 if(0 == j) { x *= MeV; }
601 fParamHigh[
Z]->push_back(x);
607 fParamLow[
Z] =
new std::vector<G4double>;
611 std::ostringstream ost1_low;
612 ost1_low << fDataDirectory <<
"pe-low-" <<
Z <<
".dat";
613 std::ifstream fin1_low(ost1_low.str().c_str());
614 if( !fin1_low.is_open()) {
616 ed <<
"G4LivermorePhotoElectricModel data file <" << ost1_low.str().c_str()
617 <<
"> is not opened!" <<
G4endl;
618 G4Exception(
"G4LivermorePhotoElectricModel::ReadData()",
620 ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
623 if(verboseLevel > 3) {
624 G4cout <<
"File " << ost1_low.str().c_str()
625 <<
" is opened by G4LivermorePhotoElectricModel" <<
G4endl;
628 if(fin1_low.fail()) {
return; }
629 if(0 > n1_low || n1_low >=
INT_MAX) { n1_low = 0; }
632 if(fin1_low.fail()) {
return; }
633 if(0 > n2_low || n2_low >=
INT_MAX) { n2_low = 0; }
636 if(fin1_low.fail()) {
return; }
638 fNShells[
Z] = n1_low;
639 fParamLow[
Z]->reserve(7*n1_low+1);
640 fParamLow[
Z]->push_back(x_low*MeV);
641 for(
G4int i=0; i<n1_low; ++i) {
642 for(
G4int j=0; j<7; ++j) {
644 if(0 == j) { x_low *= MeV; }
645 else { x_low *= barn; }
646 fParamLow[
Z]->push_back(x_low);
652 if(nShellLimit < n2) { n2 = nShellLimit; }
654 fNShellsUsed[
Z] = n2;
657 std::ostringstream ost2;
658 ost2 << fDataDirectory <<
"pe-ss-cs-" <<
Z <<
".dat";
659 std::ifstream fin2(ost2.str().c_str());
660 if( !fin2.is_open()) {
662 ed <<
"G4LivermorePhotoElectricModel data file <" << ost2.str().c_str()
663 <<
"> is not opened!" <<
G4endl;
664 G4Exception(
"G4LivermorePhotoElectricModel::ReadData()",
666 ed,
"G4LEDATA version should be G4EMLOW7.2 or later.");
669 if(verboseLevel > 3) {
670 G4cout <<
"File " << ost2.str().c_str()
671 <<
" is opened by G4LivermorePhotoElectricModel" <<
G4endl;
676 for(
G4int i=0; i<n2; ++i) {
677 fin2 >> x >> y >> n3 >> n4;
679 for(
G4int j=0; j<n3; ++j) {
689 if(1 < fNShells[
Z]) {
691 std::ostringstream ost3;
692 ost3 << fDataDirectory <<
"pe-le-cs-" <<
Z <<
".dat";
693 std::ifstream fin3(ost3.str().c_str());
694 if( !fin3.is_open()) {
696 ed <<
"G4LivermorePhotoElectricModel data file <" << ost3.str().c_str()
697 <<
"> is not opened!" <<
G4endl;
698 G4Exception(
"G4LivermorePhotoElectricModel::ReadData()",
700 ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
703 if(verboseLevel > 3) {
704 G4cout <<
"File " << ost3.str().c_str()
705 <<
" is opened by G4LivermorePhotoElectricModel" <<
G4endl;
707 fCrossSectionLE[
Z]->
Retrieve(fin3,
true);
717 if(Z < 1 || Z > maxZ) {
return -1;}
720 if(fCrossSection[
Z] ==
nullptr || shell < 0 || shell >= fNShellsUsed[
Z]) {
return -1; }
725 return fCrossSection[
Z]->
Energy(0);
733 if (fCrossSection[
Z] ==
nullptr) {
734#ifdef G4MULTITHREADED
736 if (fCrossSection[
Z] ==
nullptr) {
739#ifdef G4MULTITHREADED
std::vector< G4Element * > G4ElementTable
const char * G4FindDataDir(const char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
#define G4MUTEXLOCK(mutex)
#define G4MUTEXUNLOCK(mutex)
G4GLOB_DLL std::ostream G4cout
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
static G4Electron * Electron()
G4PhysicsVector * GetComponentDataByIndex(G4int Z, G4int idx)
void InitialiseForComponent(G4int Z, G4int nComponents=0)
G4double GetValueForComponent(G4int Z, G4int idx, G4double kinEnergy)
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
G4int GetComponentID(G4int Z, G4int idx)
static G4ElementTable * GetElementTable()
static G4EmParameters * Instance()
G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double energy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX) override
G4ParticleChangeForGamma * fParticleChange
G4double GetBindingEnergy(G4int Z, G4int shell)
void InitialiseForElement(const G4ParticleDefinition *, G4int Z) override
void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy) override
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
virtual ~G4LivermorePhotoElectricModel()
G4LivermorePhotoElectricModel(const G4String &nam="LivermorePhElectric")
G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double energy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX) override
static G4LossTableManager * Instance()
G4VAtomDeexcitation * AtomDeexcitation()
const G4Material * GetMaterial() const
G4double GetDensity() const
const G4Material * GetBaseMaterial() const
G4SandiaTable * GetSandiaTable() const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void PutValues(const std::size_t index, const G4double energy, const G4double value)
void ScaleVector(const G4double factorE, const G4double factorV)
G4double Energy(const std::size_t index) const
G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
void FillSecondDerivatives(const G4SplineType=G4SplineType::Base, const G4double dir1=0.0, const G4double dir2=0.0)
void GetSandiaCofWater(G4double energy, std::vector< G4double > &coeff) const
G4bool CheckDeexcitationActiveRegion(G4int coupleIndex)
virtual const G4AtomicShell * GetAtomicShell(G4int Z, G4AtomicShellEnumerator shell)=0
void GenerateParticles(std::vector< G4DynamicParticle * > *secVect, const G4AtomicShell *, G4int Z, G4int coupleIndex)
G4bool IsFluoActive() const
virtual G4ThreeVector & SampleDirection(const G4DynamicParticle *dp, G4double finalTotalEnergy, G4int Z, const G4Material *)=0
G4VEmAngularDistribution * GetAngularDistribution()
G4ParticleChangeForGamma * GetParticleChangeForGamma()
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
virtual G4double Value(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy)
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void SetDeexcitationFlag(G4bool val)
void SetAngularDistribution(G4VEmAngularDistribution *)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)