59G4int G4LivermorePolarizedComptonModel::maxZ = 99;
61G4ShellData* G4LivermorePolarizedComptonModel::shellData = 0;
81 G4cout <<
"Livermore Polarized Compton is constructed " <<
G4endl;
87 fAtomDeexcitation = 0;
99 delete scatterFunctionData;
100 scatterFunctionData = 0;
101 for(
G4int i=0; i<maxZ; ++i) {
115 if (verboseLevel > 1)
116 G4cout <<
"Calling G4LivermorePolarizedComptonModel::Initialise()" <<
G4endl;
124 char* path = std::getenv(
"G4LEDATA");
131 for(
G4int i=0; i<numOfCouples; ++i) {
137 for (
G4int j=0; j<nelm; ++j) {
140 else if(Z > maxZ){ Z = maxZ; }
142 if( (!data[Z]) ) { ReadData(Z, path); }
150 G4String file =
"/doppler/shell-doppler";
157 if(!scatterFunctionData)
161 G4String scatterFile =
"comp/ce-sf-";
163 scatterFunctionData->
LoadData(scatterFile);
169 if (verboseLevel > 2) {
173 if( verboseLevel>1 ) {
174 G4cout <<
"G4LivermoreComptonModel is initialized " <<
G4endl
181 if(isInitialised) {
return; }
185 isInitialised =
true;
197void G4LivermorePolarizedComptonModel::ReadData(
size_t Z,
const char* path)
199 if (verboseLevel > 1)
201 G4cout <<
"G4LivermorePolarizedComptonModel::ReadData()"
204 if(data[Z]) {
return; }
205 const char* datadir = path;
208 datadir = std::getenv(
"G4LEDATA");
211 G4Exception(
"G4LivermorePolarizedComptonModel::ReadData()",
213 "Environment variable G4LEDATA not defined");
223 std::ostringstream ost;
224 ost << datadir <<
"/livermore/comp/ce-cs-" << Z <<
".dat";
225 std::ifstream fin(ost.str().c_str());
230 ed <<
"G4LivermorePolarizedComptonModel data file <" << ost.str().c_str()
231 <<
"> is not opened!" <<
G4endl;
234 ed,
"G4LEDATA version should be G4EMLOW6.34 or later");
237 if(verboseLevel > 3) {
238 G4cout <<
"File " << ost.str()
239 <<
" is opened by G4LivermorePolarizedComptonModel" <<
G4endl;
258 if (verboseLevel > 3)
259 G4cout <<
"Calling ComputeCrossSectionPerAtom() of G4LivermorePolarizedComptonModel" <<
G4endl;
267 if(intZ < 1 || intZ > maxZ) {
return cs; }
277 if(!pv) {
return cs; }
284 if(GammaEnergy <= e1) { cs = GammaEnergy/(e1*e1)*pv->
Value(e1); }
285 else if(GammaEnergy <= e2) { cs = pv->
Value(GammaEnergy)/GammaEnergy; }
286 else if(GammaEnergy > e2) { cs = pv->
Value(e2)/GammaEnergy; }
306 if (verboseLevel > 3)
307 G4cout <<
"Calling SampleSecondaries() of G4LivermorePolarizedComptonModel" <<
G4endl;
328 if(!(gammaPolarization0.
isOrthogonal(gammaDirection0, 1e-6))||(gammaPolarization0.
mag()==0))
330 gammaPolarization0 = GetRandomPolarization(gammaDirection0);
336 gammaPolarization0 = GetPerpendicularPolarization(gammaDirection0, gammaPolarization0);
342 G4double E0_m = gammaEnergy0 / electron_mass_c2 ;
354 G4double epsilon0Local = 1./(1. + 2*E0_m);
355 G4double epsilon0Sq = epsilon0Local*epsilon0Local;
357 G4double alpha2 = 0.5*(1.- epsilon0Sq);
359 G4double wlGamma = h_Planck*c_light/gammaEnergy0;
372 epsilon = std::sqrt(epsilonSq);
376 sinThetaSqr = onecost*(2.-onecost);
379 if (sinThetaSqr > 1.)
382 <<
" -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
383 <<
"sin(theta)**2 = "
389 if (sinThetaSqr < 0.)
392 <<
" -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
393 <<
"sin(theta)**2 = "
401 G4double x = std::sqrt(onecost/2.) / (wlGamma/cm);;
403 greject = (1. -
epsilon*sinThetaSqr/(1.+ epsilonSq))*scatteringFunction;
425 <<
" -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
435 <<
" -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
445 G4double sinTheta = std::sqrt (sinThetaSqr);
451 <<
" -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
461 <<
" -- Warning -- G4LivermorePolarizedComptonModel::SampleSecondaries "
471 G4double dirx = sinTheta*std::cos(phi);
472 G4double diry = sinTheta*std::sin(phi);
485 static G4int maxDopplerIterations = 1000;
494 if (verboseLevel > 3) {
505 if (verboseLevel > 3) {
506 G4cout <<
"Shell ID= " << shellIdx
507 <<
" Ebind(keV)= " << bindingE/keV <<
G4endl;
509 eMax = gammaEnergy0 - bindingE;
514 if (verboseLevel > 3) {
518 G4double pDoppler = pSample * fine_structure_const;
519 G4double pDoppler2 = pDoppler * pDoppler;
520 G4double var2 = 1. + onecost * E0_m;
521 G4double var3 = var2*var2 - pDoppler2;
522 G4double var4 = var2 - pDoppler2 * cosTheta;
523 G4double var = var4*var4 - var3 + pDoppler2 * var3;
527 G4double scale = gammaEnergy0 / var3;
529 if (
G4UniformRand() < 0.5) photonE = (var4 - varSqrt) * scale;
530 else photonE = (var4 + varSqrt) * scale;
536 }
while ( iteration <= maxDopplerIterations &&
537 (photonE < 0. || photonE > eMax || photonE < eMax*
G4UniformRand()) );
543 if (iteration >= maxDopplerIterations)
545 photonE = photonEoriginal;
549 gammaEnergy1 = photonE;
569 gammaDirection1 = tmpDirection1;
573 SystemOfRefChange(gammaDirection0,gammaDirection1,
574 gammaPolarization0,gammaPolarization1);
576 if (gammaEnergy1 > 0.)
593 G4double ElecKineEnergy = gammaEnergy0 - gammaEnergy1 -bindingE;
597 if(ElecKineEnergy < 0.0) {
604 G4double ElecMomentum = std::sqrt(ElecKineEnergy*(ElecKineEnergy+2.*electron_mass_c2));
606 G4ThreeVector ElecDirection((gammaEnergy0 * gammaDirection0 -
607 gammaEnergy1 * gammaDirection1) * (1./ElecMomentum));
610 fvect->push_back(dp);
615 if (verboseLevel > 3) {
616 G4cout <<
"Started atomic de-excitation " << fAtomDeexcitation <<
G4endl;
619 if(fAtomDeexcitation && iteration < maxDopplerIterations) {
622 size_t nbefore = fvect->size();
626 size_t nafter = fvect->size();
627 if(nafter > nbefore) {
628 for (
size_t i=nbefore; i<nafter; ++i) {
630 if (bindingE >= ((*fvect)[i])->GetKineticEnergy())
633 bindingE -= ((*fvect)[i])->GetKineticEnergy();
648 G4Exception(
"G4LivermoreComptonModel::SampleSecondaries()",
674 b = energyRate + 1/energyRate;
676 phiProbability = 1 - (a/b)*(std::cos(phi)*std::cos(phi));
681 while ( rand2 > phiProbability );
718 c.
setX(std::cos(angle)*(
a0.x())+std::sin(angle)*b0.
x());
719 c.
setY(std::cos(angle)*(
a0.y())+std::sin(angle)*b0.
y());
720 c.
setZ(std::cos(angle)*(
a0.z())+std::sin(angle)*b0.
z());
730G4ThreeVector G4LivermorePolarizedComptonModel::GetPerpendicularPolarization
744 return gammaPolarization - gammaPolarization.
dot(gammaDirection)/gammaDirection.
dot(gammaDirection) * gammaDirection;
758 G4double sinTheta = std::sqrt(sinSqrTh);
762 G4double normalisation = std::sqrt(1. - cosSqrPhi*sinSqrTh);
816 G4double sinBeta = std::sqrt(1-cosBeta*cosBeta);
820 G4double xParallel = normalisation*cosBeta;
821 G4double yParallel = -(sinSqrTh*cosPhi*sinPhi)*cosBeta/normalisation;
822 G4double zParallel = -(costheta*sinTheta*cosPhi)*cosBeta/normalisation;
824 G4double yPerpendicular = (costheta)*sinBeta/normalisation;
825 G4double zPerpendicular = -(sinTheta*sinPhi)*sinBeta/normalisation;
827 G4double xTotal = (xParallel + xPerpendicular);
828 G4double yTotal = (yParallel + yPerpendicular);
829 G4double zTotal = (zParallel + zPerpendicular);
831 gammaPolarization1.
setX(xTotal);
832 gammaPolarization1.
setY(yTotal);
833 gammaPolarization1.
setZ(zTotal);
835 return gammaPolarization1;
841void G4LivermorePolarizedComptonModel::SystemOfRefChange(
G4ThreeVector& direction0,
857 direction1 = (direction_x*Axis_X0 + direction_y*Axis_Y0 + direction_z*Axis_Z0).unit();
862 polarization1 = (polarization_x*Axis_X0 + polarization_y*Axis_Y0 + polarization_z*Axis_Z0).unit();
877 G4AutoLock l(&LivermorePolarizedComptonModelMutex);
880 if(!data[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
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4double G4Log(G4double x)
#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
virtual G4double FindValue(G4double x, G4int componentId=0) const
virtual G4bool LoadData(const G4String &fileName)
G4double RandomSelectMomentum(G4int Z, G4int shellIndex) const
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4ThreeVector & GetPolarization() const
static G4Electron * Electron()
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
G4LivermorePolarizedComptonModel(const G4ParticleDefinition *p=0, const G4String &nam="LivermorePolarizedCompton")
virtual ~G4LivermorePolarizedComptonModel()
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel)
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
static G4LossTableManager * Instance()
G4VAtomDeexcitation * AtomDeexcitation()
const G4Material * GetMaterial() const
const G4ElementVector * GetElementVector() const
size_t GetNumberOfElements() const
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposePolarization(const G4ThreeVector &dir)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
G4double Energy(std::size_t index) const
G4double Value(G4double theEnergy, std::size_t &lastidx) const
virtual void ScaleVector(G4double factorE, G4double factorV)
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
std::size_t GetVectorLength() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
G4double BindingEnergy(G4int Z, G4int shellIndex) const
void LoadData(const G4String &fileName)
G4int SelectRandomShell(G4int Z) 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)
void SetElementSelectors(std::vector< G4EmElementSelector * > *)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
G4double LowEnergyLimit() const
std::vector< G4EmElementSelector * > * GetElementSelectors()
G4double HighEnergyLimit() const
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void SetDeexcitationFlag(G4bool val)
void InitialiseElementSelectors(const G4ParticleDefinition *, const G4DataVector &)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)