53std::vector<G4double>* G4LivermorePolarizedPhotoElectricModel::fParam[] = {
nullptr};
54G4int G4LivermorePolarizedPhotoElectricModel::fNShells[] = {0};
55G4int G4LivermorePolarizedPhotoElectricModel::fNShellsUsed[] = {0};
56G4ElementData* G4LivermorePolarizedPhotoElectricModel::fShellCrossSection =
nullptr;
57G4Material* G4LivermorePolarizedPhotoElectricModel::fWater =
nullptr;
58G4double G4LivermorePolarizedPhotoElectricModel::fWaterEnergyLimit = 0.0;
65 :
G4VEmModel(nam),fParticleChange(nullptr),maxZ(99),
66 nShellLimit(100),fDeexcitationActive(false),isInitialised(false),
67 fAtomDeexcitation(nullptr)
85 G4cout <<
"Livermore PhotoElectric is constructed "
86 <<
" nShellLimit= " << nShellLimit <<
G4endl;
91 fSandiaCof.resize(4,0.0);
101 delete fShellCrossSection;
102 for(
G4int i=0; i<maxZ; ++i) {
105 delete fCrossSection[i];
106 fCrossSection[i] = 0;
107 delete fCrossSectionLE[i];
108 fCrossSectionLE[i] = 0;
119 if (verboseLevel > 2) {
120 G4cout <<
"Calling G4LivermorePolarizedPhotoElectricModel::Initialise()" <<
G4endl;
127 if(fWater) { fWaterEnergyLimit = 13.6*eV; }
130 if(!fShellCrossSection) { fShellCrossSection =
new G4ElementData(); }
132 char* path = std::getenv(
"G4LEDATA");
138 for(
G4int i=0; i<numOfCouples; ++i) {
145 for (
G4int j=0; j<nelm; ++j) {
146 G4int Z = (
G4int)(*theElementVector)[j]->GetZ();
148 else if(Z > maxZ) { Z = maxZ; }
149 if(!fCrossSection[Z]) { ReadData(Z, path); }
154 if (verboseLevel > 2) {
155 G4cout <<
"Loaded cross section files for LivermorePolarizedPhotoElectric model"
159 isInitialised =
true;
164 fDeexcitationActive =
false;
165 if(fAtomDeexcitation) {
166 fDeexcitationActive = fAtomDeexcitation->
IsFluoActive();
169 if (verboseLevel > 0) {
170 G4cout <<
"LivermorePolarizedPhotoElectric model is initialized " <<
G4endl
184 if(fWater && (material == fWater ||
186 if(energy <= fWaterEnergyLimit) {
194 (fSandiaCof[0]/energy + fSandiaCof[1]/energy2 +
195 fSandiaCof[2]/energy3 + fSandiaCof[3]/energy4);
198 if(0.0 == fCurrSection) {
212 if (verboseLevel > 3) {
213 G4cout <<
"G4LivermorePolarizedPhotoElectricModel::ComputeCrossSectionPerAtom():"
214 <<
" Z= " << ZZ <<
" R(keV)= " << energy/keV <<
G4endl;
218 if(Z < 1 || Z >= maxZ) {
return cs; }
222 if(!fCrossSection[Z]) {
224 if(!fCrossSection[Z]) {
return cs; }
227 G4int idx = fNShells[Z]*6 - 4;
228 if (energy < (*(fParam[Z]))[idx-1]) { energy = (*(fParam[Z]))[idx-1]; }
235 if(energy >= (*(fParam[Z]))[0]) {
237 cs = x1*((*(fParam[Z]))[idx] + x1*(*(fParam[Z]))[idx+1]
238 + x2*(*(fParam[Z]))[idx+2] + x3*(*(fParam[Z]))[idx+3]
239 + x4*(*(fParam[Z]))[idx+4]);
241 }
else if(energy >= (*(fParam[Z]))[1]) {
242 cs = x3*(fCrossSection[Z])->
Value(energy);
246 cs = x3*(fCrossSectionLE[Z])->
Value(energy);
248 if (verboseLevel > 1) {
249 G4cout <<
"LivermorePolarizedPhotoElectricModel: E(keV)= " << energy/keV
250 <<
" Z= " << Z <<
" cross(barn)= " << cs/barn <<
G4endl;
259 std::vector<G4DynamicParticle*>* fvect,
266 if (verboseLevel > 3) {
267 G4cout <<
"G4LivermorePolarizedPhotoElectricModel::SampleSecondaries() Egamma(keV)= "
268 << gammaEnergy/keV <<
G4endl;
277 if(fWater && (material == fWater ||
279 if(gammaEnergy <= fWaterEnergyLimit) {
297 if(Z >= maxZ) { Z = maxZ-1; }
300 if(!fCrossSection[Z]) {
307 size_t nn = fNShellsUsed[Z];
310 if(gammaEnergy >= (*(fParam[Z]))[0]) {
315 G4int idx = nn*6 - 4;
319 + x1*(*(fParam[Z]))[idx+1]
320 + x2*(*(fParam[Z]))[idx+2]
321 + x3*(*(fParam[Z]))[idx+3]
322 + x4*(*(fParam[Z]))[idx+4]);
323 for(shellIdx=0; shellIdx<nn; ++shellIdx) {
324 idx = shellIdx*6 + 2;
325 if(gammaEnergy > (*(fParam[Z]))[idx-1]) {
326 G4double cs = (*(fParam[Z]))[idx] + x1*(*(fParam[Z]))[idx+1]
327 + x2*(*(fParam[Z]))[idx+2] + x3*(*(fParam[Z]))[idx+3]
328 + x4*(*(fParam[Z]))[idx+4];
329 if(cs >= cs0) {
break; }
332 if(shellIdx >= nn) { shellIdx = nn-1; }
340 if(gammaEnergy >= (*(fParam[Z]))[1]) {
341 cs *= (fCrossSection[Z])->
Value(gammaEnergy);
343 cs *= (fCrossSectionLE[Z])->
Value(gammaEnergy);
346 for(
size_t j=0; j<nn; ++j) {
348 if(gammaEnergy > (*(fParam[Z]))[6*shellIdx+1]) {
351 if(cs <= 0.0 || j+1 == nn) {
break; }
356 G4double bindingEnergy = (*(fParam[Z]))[shellIdx*6 + 1];
365 if(fDeexcitationActive && shellIdx + 1 < nn) {
372 if(gammaEnergy < bindingEnergy) {
378 G4double eKineticEnergy = gammaEnergy - bindingEnergy;
392 fvect->push_back(electron);
398 G4int nbefore = fvect->size();
401 G4int nafter = fvect->size();
402 if(nafter > nbefore) {
404 for (
G4int j=nbefore; j<nafter; ++j) {
406 G4double e = ((*fvect)[j])->GetKineticEnergy();
407 if(esec + e > edep) {
410 ((*fvect)[j])->SetKineticEnergy(e);
413 for (
G4int jj=nafter-1; jj>j; --jj) {
434G4LivermorePolarizedPhotoElectricModel::ReadData(
G4int Z,
const char* path)
436 if (verboseLevel > 1)
438 G4cout <<
"Calling ReadData() of G4LivermoreGammaConversionModel"
442 if(fCrossSection[Z]) {
return; }
444 const char* datadir = path;
448 datadir = std::getenv(
"G4LEDATA");
451 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
453 "Environment variable G4LEDATA not defined");
462 std::ostringstream ost;
463 ost << datadir <<
"/livermore/phot/pe-cs-" << Z <<
".dat";
464 std::ifstream fin(ost.str().c_str());
465 if( !fin.is_open()) {
467 ed <<
"G4LivermorePolarizedPhotoElectricModel data file <" << ost.str().c_str()
468 <<
"> is not opened!" <<
G4endl;
469 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
471 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
474 if(verboseLevel > 3) {
G4cout <<
"File " << ost.str().c_str()
475 <<
" is opened by G4LivermorePolarizedPhotoElectricModel" <<
G4endl;}
476 fCrossSection[Z]->
Retrieve(fin,
true);
481 fParam[Z] =
new std::vector<G4double>;
487 std::ostringstream ost1;
488 ost1 << datadir <<
"/livermore/phot/pe-" << Z <<
".dat";
489 std::ifstream fin1(ost1.str().c_str());
490 if( !fin1.is_open()) {
492 ed <<
"G4LivermorePolarizedPhotoElectricModel data file <" << ost1.str().c_str()
493 <<
"> is not opened!" <<
G4endl;
494 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
496 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
499 if(verboseLevel > 3) {
500 G4cout <<
"File " << ost1.str().c_str()
501 <<
" is opened by G4LivermorePolarizedPhotoElectricModel" <<
G4endl;
504 if(fin1.fail()) {
return; }
505 if(0 > n1 || n1 >=
INT_MAX) { n1 = 0; }
508 if(fin1.fail()) {
return; }
509 if(0 > n2 || n2 >=
INT_MAX) { n2 = 0; }
512 if(fin1.fail()) {
return; }
515 fParam[Z]->reserve(6*n1+1);
516 fParam[Z]->push_back(x*MeV);
517 for(
G4int i=0; i<n1; ++i) {
518 for(
G4int j=0; j<6; ++j) {
520 if(0 == j) { x *= MeV; }
522 fParam[Z]->push_back(x);
528 if(nShellLimit < n2) { n2 = nShellLimit; }
530 fNShellsUsed[Z] = n2;
533 std::ostringstream ost2;
534 ost2 << datadir <<
"/livermore/phot/pe-ss-cs-" << Z <<
".dat";
535 std::ifstream fin2(ost2.str().c_str());
536 if( !fin2.is_open()) {
538 ed <<
"G4LivermorePolarizedPhotoElectricModel data file <" << ost2.str().c_str()
539 <<
"> is not opened!" <<
G4endl;
540 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
542 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
545 if(verboseLevel > 3) {
546 G4cout <<
"File " << ost2.str().c_str()
547 <<
" is opened by G4LivermorePolarizedPhotoElectricModel" <<
G4endl;
552 for(
G4int i=0; i<n2; ++i) {
553 fin2 >> x >> y >> n3 >> n4;
555 for(
G4int j=0; j<n3; ++j) {
566 if(1 < fNShells[Z]) {
569 std::ostringstream ost3;
570 ost3 << datadir <<
"/livermore/phot/pe-le-cs-" << Z <<
".dat";
571 std::ifstream fin3(ost3.str().c_str());
572 if( !fin3.is_open()) {
574 ed <<
"G4LivermorePolarizedPhotoElectricModel data file <" << ost3.str().c_str()
575 <<
"> is not opened!" <<
G4endl;
576 G4Exception(
"G4LivermorePolarizedPhotoElectricModel::ReadData()",
578 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
581 if(verboseLevel > 3) {
582 G4cout <<
"File " << ost3.str().c_str()
583 <<
" is opened by G4LivermorePolarizedPhotoElectricModel" <<
G4endl;
585 fCrossSectionLE[Z]->
Retrieve(fin3,
true);
600 G4AutoLock l(&LivermorePolarizedPhotoElectricModelMutex);
603 if(!fCrossSection[Z]) { ReadData(Z); }
std::vector< G4Element * > G4ElementVector
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
static G4Electron * Electron()
void InitialiseForComponent(G4int Z, G4int nComponents=0)
G4int GetComponentID(G4int Z, size_t idx)
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
G4double GetValueForComponent(G4int Z, size_t idx, G4double kinEnergy)
void PutValues(std::size_t index, G4double e, G4double dataValue)
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double energy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4LivermorePolarizedPhotoElectricModel(const G4String &nam="LivermorePolarizedPhotoElectric")
virtual ~G4LivermorePolarizedPhotoElectricModel()
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
G4ParticleChangeForGamma * fParticleChange
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double energy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
static G4LossTableManager * Instance()
G4VAtomDeexcitation * AtomDeexcitation()
const G4Material * GetMaterial() const
G4double GetDensity() const
const G4ElementVector * GetElementVector() const
const G4Material * GetBaseMaterial() const
size_t GetNumberOfElements() const
G4SandiaTable * GetSandiaTable() const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
void SetProposedKineticEnergy(G4double proposedKinEnergy)
virtual void ScaleVector(G4double factorE, G4double factorV)
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
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)