55 G4int G4LivermorePolarizedRayleighModel::maxZ = 100;
57 G4VEMDataSet* G4LivermorePolarizedRayleighModel::formFactorData = 0;
61 :
G4VEmModel(nam),fParticleChange(0),isInitialised(false)
64 lowEnergyLimit = 250 *
eV;
76 if(verboseLevel > 0) {
77 G4cout <<
"Livermore Polarized Rayleigh is constructed " <<
G4endl
90 for(
G4int i=0; i<maxZ; ++i) {
96 delete formFactorData;
114 if (verboseLevel > 3)
115 G4cout <<
"Calling G4LivermorePolarizedRayleighModel::Initialise()" <<
G4endl;
123 G4String formFactorFile =
"rayl/re-ff-";
125 formFactorData->
LoadData(formFactorFile);
131 char* path = getenv(
"G4LEDATA");
136 for(
G4int i=0; i<numOfCouples; ++i)
144 for (
G4int j=0; j<nelm; ++j)
148 else if(Z > maxZ) { Z = maxZ; }
149 if( (!dataCS[Z]) ) { ReadData(Z, path); }
154 if(isInitialised) {
return; }
156 isInitialised =
true;
171 void G4LivermorePolarizedRayleighModel::ReadData(
size_t Z,
const char* path)
173 if (verboseLevel > 1)
175 G4cout <<
"Calling ReadData() of G4LivermoreRayleighModel"
179 if(dataCS[Z]) {
return; }
181 const char* datadir = path;
185 datadir = getenv(
"G4LEDATA");
188 G4Exception(
"G4LivermoreRayleighModelModel::ReadData()",
"em0006",
190 "Environment variable G4LEDATA not defined");
202 std::ostringstream ostCS;
203 ostCS << datadir <<
"/livermore/rayl/re-cs-" << Z <<
".dat";
204 std::ifstream finCS(ostCS.str().c_str());
206 if( !finCS .is_open() )
209 ed <<
"G4LivermorePolarizedRayleighModel data file <" << ostCS.str().c_str()
210 <<
"> is not opened!" <<
G4endl;
212 ed,
"G4LEDATA version should be G4EMLOW6.27 or later.");
217 if(verboseLevel > 3) {
218 G4cout <<
"File " << ostCS.str()
219 <<
" is opened by G4LivermoreRayleighModel" <<
G4endl;
233 if (verboseLevel > 1)
235 G4cout <<
"G4LivermoreRayleighModel::ComputeCrossSectionPerAtom()"
239 if(GammaEnergy < lowEnergyLimit) {
return 0.0; }
245 if(intZ < 1 || intZ > maxZ) {
return xs; }
254 if(!pv) {
return xs; }
261 }
else if(e >= pv->
Energy(0)) {
262 xs = pv->
Value(e)/(e*e);
290 if (verboseLevel > 3)
291 G4cout <<
"Calling SampleSecondaries() of G4LivermorePolarizedRayleighModel" <<
G4endl;
295 if (photonEnergy0 <= lowEnergyLimit)
311 G4double outcomingPhotonCosTheta = GenerateCosTheta(photonEnergy0, Z);
312 G4double outcomingPhotonPhi = GeneratePhi(outcomingPhotonCosTheta);
313 G4double beta=GeneratePolarizationAngle();
333 zDir=outcomingPhotonCosTheta;
334 xDir=std::sqrt(1-outcomingPhotonCosTheta*outcomingPhotonCosTheta);
336 xDir*=std::cos(outcomingPhotonPhi);
337 yDir*=std::sin(outcomingPhotonPhi);
344 G4ThreeVector outcomingPhotonPolarization(xPrime*std::cos(beta) + yPrime*std::sin(beta));
354 G4double G4LivermorePolarizedRayleighModel::GenerateCosTheta(
G4double incomingPhotonEnergy,
G4int zAtom)
const
382 if (incomingPhotonEnergy > 5.*
MeV)
393 fCosTheta = (1.+cosTheta*cosTheta)/2.;
397 x = xFactor*std::sqrt((1.-cosTheta)/2.);
400 fValue = formFactorData->
FindValue(x, zAtom-1);
402 fValue = formFactorData->
FindValue(0., zAtom-1);
415 G4double G4LivermorePolarizedRayleighModel::GeneratePhi(
G4double cosTheta)
const
428 sin2Theta=1.-cosTheta*cosTheta;
433 cosPhi = std::cos(phi);
434 phiProbability= 1. - sin2Theta*cosPhi*cosPhi;
443 G4double G4LivermorePolarizedRayleighModel::GeneratePolarizationAngle(
void)
const
463 if ((!photonPolarization.
isOrthogonal(photonMomentumDirection, 1e-6)) || photonPolarization.
mag()==0.)
476 photonPolarization=e1+e2;
478 else if (photonPolarization.
howOrthogonal(photonMomentumDirection) != 0.)
483 photonPolarization=photonPolarization.
perpPart(photonMomentumDirection);
486 return photonPolarization.
unit();
497 G4AutoLock l(&LivermorePolarizedRayleighModelMutex);
500 if(!dataCS[Z]) { ReadData(Z); }
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
G4double LowEnergyLimit() const
static constexpr double h_Planck
virtual G4double FindValue(G4double x, G4int componentId=0) const =0
std::vector< G4Element * > G4ElementVector
std::ostringstream G4ExceptionDescription
G4double GetKineticEnergy() const
void InitialiseElementSelectors(const G4ParticleDefinition *, const G4DataVector &)
G4double HighEnergyLimit() const
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
static G4double angle[DIM]
G4ParticleDefinition * GetDefinition() const
bool isOrthogonal(const Hep3Vector &v, double epsilon=tolerance) const
size_t GetVectorLength() const
const G4ElementVector * GetElementVector() const
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
#define G4MUTEX_INITIALIZER
double howOrthogonal(const Hep3Vector &v) const
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
static constexpr double twopi
G4GLOB_DLL std::ostream G4cout
size_t GetTableSize() const
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel)
const G4ThreeVector & GetMomentumDirection() const
static constexpr double cm
void ProposePolarization(const G4ThreeVector &dir)
static constexpr double eV
Hep3Vector perpPart() const
G4double Energy(size_t index) const
std::vector< G4EmElementSelector * > * GetElementSelectors()
G4double Value(G4double theEnergy, size_t &lastidx) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4ProductionCutsTable * GetProductionCutsTable()
void SetElementSelectors(std::vector< G4EmElementSelector * > *)
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
static constexpr double c_light
Hep3Vector orthogonal() const
const G4ThreeVector & GetPolarization() const
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
static constexpr double GeV
virtual G4bool LoadData(const G4String &fileName)=0
virtual ~G4LivermorePolarizedRayleighModel()
void SetProposedKineticEnergy(G4double proposedKinEnergy)
static constexpr double MeV
size_t GetNumberOfElements() const
Hep3Vector cross(const Hep3Vector &) const
void ProposeTrackStatus(G4TrackStatus status)
G4LivermorePolarizedRayleighModel(const G4ParticleDefinition *p=0, const G4String &nam="LivermorePolarizedRayleigh")
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
const G4Material * GetMaterial() const