45std::vector<G4double>* G4LivermorePolarizedPhotoElectricGDModel::fParam[] = {0};
46G4int G4LivermorePolarizedPhotoElectricGDModel::fNShells[] = {0};
47G4int G4LivermorePolarizedPhotoElectricGDModel::fNShellsUsed[] = {0};
48G4ElementData* G4LivermorePolarizedPhotoElectricGDModel::fShellCrossSection =
nullptr;
49G4Material* G4LivermorePolarizedPhotoElectricGDModel::fWater =
nullptr;
50G4double G4LivermorePolarizedPhotoElectricGDModel::fWaterEnergyLimit = 0.0;
61 :
G4VEmModel(nam),fParticleChange(nullptr),maxZ(99),
62 nShellLimit(100), fDeexcitationActive(false), isInitialised(false),
63 fAtomDeexcitation(nullptr)
77 fSandiaCof.resize(4,0.0);
80 if (verboseLevel > 0) {
81 G4cout <<
"Livermore Polarized PhotoElectric is constructed "
92 delete fShellCrossSection;
93 for(
G4int i=0; i<maxZ; ++i) {
96 delete fCrossSection[i];
98 delete fCrossSectionLE[i];
99 fCrossSectionLE[i] = 0;
111 if (verboseLevel > 2) {
112 G4cout <<
"Calling G4LivermorePolarizedPhotoElectricGDModel::Initialise()" <<
G4endl;
119 if(fWater) { fWaterEnergyLimit = 13.6*eV; }
122 if(!fShellCrossSection) { fShellCrossSection =
new G4ElementData(); }
124 char* path = std::getenv(
"G4LEDATA");
130 for(
G4int i=0; i<numOfCouples; ++i) {
137 for (
G4int j=0; j<nelm; ++j) {
138 G4int Z = (
G4int)(*theElementVector)[j]->GetZ();
140 else if(Z > maxZ) { Z = maxZ; }
141 if(!fCrossSection[Z]) { ReadData(Z, path); }
146 if (verboseLevel > 2) {
147 G4cout <<
"Loaded cross section files for LivermorePhotoElectric model"
151 isInitialised =
true;
156 fDeexcitationActive =
false;
157 if(fAtomDeexcitation) {
158 fDeexcitationActive = fAtomDeexcitation->
IsFluoActive();
161 if (verboseLevel > 0) {
162 G4cout <<
"LivermorePolarizedPhotoElectric model is initialized " <<
G4endl
175 if (verboseLevel > 3) {
176 G4cout <<
"G4LivermorePolarizedPhotoElectricGDModel::ComputeCrossSectionPerAtom():"
177 <<
" Z= " << ZZ <<
" R(keV)= " << GammaEnergy/keV <<
G4endl;
181 if(Z < 1 || Z >= maxZ) {
return cs; }
185 if(!fCrossSection[Z]) {
187 if(!fCrossSection[Z]) {
return cs; }
190 G4int idx = fNShells[Z]*6 - 4;
191 if (GammaEnergy < (*(fParam[Z]))[idx-1]) { GammaEnergy = (*(fParam[Z]))[idx-1]; }
198 if(GammaEnergy >= (*(fParam[Z]))[0]) {
200 cs = x1*((*(fParam[Z]))[idx] + x1*(*(fParam[Z]))[idx+1]
201 + x2*(*(fParam[Z]))[idx+2] + x3*(*(fParam[Z]))[idx+3]
202 + x4*(*(fParam[Z]))[idx+4]);
204 }
else if (GammaEnergy >= (*(fParam[Z]))[1]) {
205 cs = x3*(fCrossSection[Z])->
Value(GammaEnergy);
209 cs = x3*(fCrossSectionLE[Z])->
Value(GammaEnergy);
211 if (verboseLevel > 1) {
212 G4cout <<
"LivermorePolarizedPhotoElectricGDModel: E(keV)= " << GammaEnergy/keV
213 <<
" Z= " << Z <<
" cross(barn)= " << cs/barn <<
G4endl;
222 std::vector<G4DynamicParticle*>* fvect,
228 if (verboseLevel > 3) {
229 G4cout <<
"Calling SampleSecondaries() of G4LivermorePolarizedPhotoElectricGDModel"
234 if (verboseLevel > 3) {
235 G4cout <<
"G4LivermorePolarizedPhotoElectricGDModel::SampleSecondaries() Egamma(keV)= "
236 << photonEnergy/keV <<
G4endl;
249 if(fWater && (material == fWater ||
251 if(photonEnergy <= fWaterEnergyLimit) {
264 if(!(gammaPolarization0.
isOrthogonal(photonDirection, 1e-6))||(gammaPolarization0.
mag()==0))
266 gammaPolarization0 = GetRandomPolarization(photonDirection);
272 gammaPolarization0 = GetPerpendicularPolarization(photonDirection, gammaPolarization0);
292 if(Z >= maxZ) { Z = maxZ-1; }
295 if(!fCrossSection[Z]) {
302 size_t nn = fNShellsUsed[Z];
305 if(photonEnergy >= (*(fParam[Z]))[0]) {
310 G4int idx = nn*6 - 4;
314 + x1*(*(fParam[Z]))[idx+1]
315 + x2*(*(fParam[Z]))[idx+2]
316 + x3*(*(fParam[Z]))[idx+3]
317 + x4*(*(fParam[Z]))[idx+4]);
318 for(shellIdx=0; shellIdx<nn; ++shellIdx) {
319 idx = shellIdx*6 + 2;
320 if(photonEnergy > (*(fParam[Z]))[idx-1]) {
321 G4double cs = (*(fParam[Z]))[idx] + x1*(*(fParam[Z]))[idx+1]
322 + x2*(*(fParam[Z]))[idx+2] + x3*(*(fParam[Z]))[idx+3]
323 + x4*(*(fParam[Z]))[idx+4];
324 if(cs >= cs0) {
break; }
327 if(shellIdx >= nn) { shellIdx = nn-1; }
335 if(photonEnergy >= (*(fParam[Z]))[1]) {
336 cs *= (fCrossSection[Z])->
Value(photonEnergy);
338 cs *= (fCrossSectionLE[Z])->
Value(photonEnergy);
341 for(
size_t j=0; j<nn; ++j) {
343 if(photonEnergy > (*(fParam[Z]))[6*shellIdx+1]) {
346 if(cs <= 0.0 || j+1 == nn) {
break; }
351 G4double bindingEnergy = (*(fParam[Z]))[shellIdx*6 + 1];
360 if(fDeexcitationActive && shellIdx + 1 < nn) {
367 if(photonEnergy < bindingEnergy) {
375 G4double eKineticEnergy = photonEnergy - bindingEnergy;
378 G4double costheta = SetCosTheta(eKineticEnergy);
379 G4double sintheta = sqrt(1. - costheta*costheta);
380 G4double phi = SetPhi(photonEnergy,eKineticEnergy,costheta);
385 SystemOfRefChange(photonDirection, electronDirection, gammaPolarization0);
389 fvect->push_back(electron);
396 G4int nbefore = fvect->size();
399 G4int nafter = fvect->size();
400 if(nafter > nbefore) {
402 for (
G4int j=nbefore; j<nafter; ++j) {
404 G4double e = ((*fvect)[j])->GetKineticEnergy();
405 if(esec + e > edep) {
408 ((*fvect)[j])->SetKineticEnergy(e);
411 for (
G4int jj=nafter-1; jj>j; --jj) {
431void G4LivermorePolarizedPhotoElectricGDModel::ReadData(
G4int Z,
const char* path)
433 if (verboseLevel > 1)
435 G4cout <<
"Calling ReadData() of G4LivermorePolarizedPhotoElectricGDModel"
439 if(fCrossSection[Z]) {
return; }
441 const char* datadir = path;
445 datadir = std::getenv(
"G4LEDATA");
448 G4Exception(
"G4LivermorePhotoElectricModel::ReadData()",
450 "Environment variable G4LEDATA not defined");
459 std::ostringstream ost;
460 ost << datadir <<
"/livermore/phot/pe-cs-" << Z <<
".dat";
461 std::ifstream fin(ost.str().c_str());
462 if( !fin.is_open()) {
464 ed <<
"G4LivermorePolarizedPhotoElectricGDModel data file <" << ost.str().c_str()
465 <<
"> is not opened!" <<
G4endl;
466 G4Exception(
"G4LivermorePolarizedPhotoElectricGDModel::ReadData()",
468 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
471 if(verboseLevel > 3) {
G4cout <<
"File " << ost.str().c_str()
472 <<
" is opened by G4LivermorePolarizedPhotoElectricGDModel" <<
G4endl;}
473 fCrossSection[Z]->
Retrieve(fin,
true);
478 fParam[Z] =
new std::vector<G4double>;
484 std::ostringstream ost1;
485 ost1 << datadir <<
"/livermore/phot/pe-" << Z <<
".dat";
486 std::ifstream fin1(ost1.str().c_str());
487 if( !fin1.is_open()) {
489 ed <<
"G4LivermorePolarizedPhotoElectricGDModel data file <" << ost1.str().c_str()
490 <<
"> is not opened!" <<
G4endl;
491 G4Exception(
"G4LivermorePolarizedPhotoElectricGDModel::ReadData()",
493 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
496 if(verboseLevel > 3) {
497 G4cout <<
"File " << ost1.str().c_str()
498 <<
" is opened by G4LivermorePolarizedPhotoElectricGDModel" <<
G4endl;
501 if(fin1.fail()) {
return; }
502 if(0 > n1 || n1 >=
INT_MAX) { n1 = 0; }
505 if(fin1.fail()) {
return; }
506 if(0 > n2 || n2 >=
INT_MAX) { n2 = 0; }
509 if(fin1.fail()) {
return; }
512 fParam[Z]->reserve(6*n1+1);
513 fParam[Z]->push_back(x*MeV);
514 for(
G4int i=0; i<n1; ++i) {
515 for(
G4int j=0; j<6; ++j) {
517 if(0 == j) { x *= MeV; }
519 fParam[Z]->push_back(x);
525 if(nShellLimit < n2) { n2 = nShellLimit; }
527 fNShellsUsed[Z] = n2;
530 std::ostringstream ost2;
531 ost2 << datadir <<
"/livermore/phot/pe-ss-cs-" << Z <<
".dat";
532 std::ifstream fin2(ost2.str().c_str());
533 if( !fin2.is_open()) {
535 ed <<
"G4LivermorePolarizedPhotoElectricGDModel data file <" << ost2.str().c_str()
536 <<
"> is not opened!" <<
G4endl;
537 G4Exception(
"G4LivermorePolarizedPhotoElectricGDModel::ReadData()",
539 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
542 if(verboseLevel > 3) {
543 G4cout <<
"File " << ost2.str().c_str()
544 <<
" is opened by G4LivermorePolarizedPhotoElectricGDModel" <<
G4endl;
549 for(
G4int i=0; i<n2; ++i) {
550 fin2 >> x >> y >> n3 >> n4;
552 for(
G4int j=0; j<n3; ++j) {
563 if(1 < fNShells[Z]) {
566 std::ostringstream ost3;
567 ost3 << datadir <<
"/livermore/phot/pe-le-cs-" << Z <<
".dat";
568 std::ifstream fin3(ost3.str().c_str());
569 if( !fin3.is_open()) {
571 ed <<
"G4LivermorePolarizedPhotoElectricGDModel data file <" << ost3.str().c_str()
572 <<
"> is not opened!" <<
G4endl;
573 G4Exception(
"G4LivermorePolarizedPhotoElectricGDModel::ReadData()",
575 ed,
"G4LEDATA version should be G4EMLOW6.32 or later.");
578 if(verboseLevel > 3) {
579 G4cout <<
"File " << ost3.str().c_str()
580 <<
" is opened by G4LivermorePolarizedPhotoElectricGDModel" <<
G4endl;
582 fCrossSectionLE[Z]->
Retrieve(fin3,
true);
592G4double G4LivermorePolarizedPhotoElectricGDModel::SetCosTheta(
G4double energyE)
594 G4double rand1,rand2,onemcost,greject;
597 G4double gamma = 1. + energyE/masarep;
600 G4double beta = sqrt((gamma2 - 1.)/gamma2);
604 G4double g1 = 0.5*beta*gamma*(gamma-1.)*(gamma-2.);
608 G4double grejectmax = 2.*(g1+1./alfa);
613 onemcost = 2.*alfa*(2.*rand1 + alfap2 * sqrt(rand1))/
614 (alfap2*alfap2 - 4.*rand1);
615 greject = (2. - onemcost)*(g1+1./(alfa+onemcost));
618 while (rand2*grejectmax > greject);
624G4double G4LivermorePolarizedPhotoElectricGDModel::SetPhi(
G4double Ph_energy,
629 G4double k = Ph_energy/electron_mass_c2;
632 G4double beta = sqrt((gamma2 - 1.)/gamma2);
634 G4double d = (2./(k*gamma*(1-beta*costheta))-1)*(1/k);
647 phiprob = 1 +2*d*cos(phi)*cos(phi);
649 while (rnd2*norm_factor > phiprob);
686 c.
setX(std::cos(angle)*(
a0.x())+std::sin(angle)*b0.
x());
687 c.
setY(std::cos(angle)*(
a0.y())+std::sin(angle)*b0.
y());
688 c.
setZ(std::cos(angle)*(
a0.z())+std::sin(angle)*b0.
z());
698G4ThreeVector G4LivermorePolarizedPhotoElectricGDModel::GetPerpendicularPolarization
713 return gammaPolarization - gammaPolarization.
dot(gammaDirection)/gammaDirection.
dot(gammaDirection) * gammaDirection;
720void G4LivermorePolarizedPhotoElectricGDModel::SystemOfRefChange
735 direction1 = (direction_x*Axis_X0 + direction_y*Axis_Y0 + direction_z*Axis_Z0).unit();
747 G4AutoLock l(&LivermorePolarizedPhotoElectricGDModelMutex);
750 if(!fCrossSection[Z]) { ReadData(Z); }
double epsilon(double density, double temperature)
std::vector< G4Element * > G4ElementVector
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
Hep3Vector cross(const Hep3Vector &) const
double dot(const Hep3Vector &) const
bool isOrthogonal(const Hep3Vector &v, double epsilon=tolerance) const
double howOrthogonal(const Hep3Vector &v) const
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
const G4ThreeVector & GetPolarization() 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 void Initialise(const G4ParticleDefinition *, const G4DataVector &)
G4ParticleChangeForGamma * fParticleChange
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
G4LivermorePolarizedPhotoElectricGDModel(const G4String &nam="LivermorePolarizedPhotoElectric")
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
virtual ~G4LivermorePolarizedPhotoElectricGDModel()
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
static G4LossTableManager * Instance()
G4VAtomDeexcitation * AtomDeexcitation()
const G4Material * GetMaterial() const
const G4ElementVector * GetElementVector() const
const G4Material * GetBaseMaterial() const
size_t GetNumberOfElements() 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()
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
G4ParticleChangeForGamma * GetParticleChangeForGamma()
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 ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)