61 :
G4VEmModel(nam),fParticleChange(nullptr),isInitialised(false)
63 lowEnergyLimit = 250 * CLHEP::eV;
73 if(verboseLevel > 0) {
74 G4cout <<
"Livermore Polarized Rayleigh is constructed " <<
G4endl
86 for(
G4int i=0; i<maxZ; ++i) {
90 delete formFactorData[i];
91 formFactorData[i] =
nullptr;
109 if (verboseLevel > 3)
110 G4cout <<
"Calling G4LivermorePolarizedRayleighModel::Initialise()" <<
G4endl;
120 for (
auto const & elm : *elmTable) {
121 G4int Z = std::min(elm->GetZasInt(), maxZ);
122 if(
nullptr == dataCS[
Z] ) { ReadData(
Z, path); }
126 if(isInitialised) {
return; }
128 isInitialised =
true;
142void G4LivermorePolarizedRayleighModel::ReadData(std::size_t
Z,
const char* path)
144 if (verboseLevel > 1) {
145 G4cout <<
"Calling ReadData() of G4LivermoreRayleighModel"
149 if(
nullptr != dataCS[
Z]) {
return; }
151 const char* datadir = path;
153 if(
nullptr == datadir)
156 if(
nullptr == datadir)
158 G4Exception(
"G4LivermoreRayleighModelModel::ReadData()",
"em0006",
160 "Environment variable G4LEDATA not defined");
167 std::ostringstream ostCS;
168 ostCS << datadir <<
"/livermore/rayl/re-cs-" <<
Z <<
".dat";
169 std::ifstream finCS(ostCS.str().c_str());
171 if( !finCS .is_open() ) {
173 ed <<
"G4LivermorePolarizedRayleighModel data file <" << ostCS.str().c_str()
174 <<
"> is not opened!" <<
G4endl;
175 G4Exception(
"G4LivermorePolarizedRayleighModel::ReadData()",
"em0003",
177 ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
180 if(verboseLevel > 3) {
181 G4cout <<
"File " << ostCS.str()
182 <<
" is opened by G4LivermoreRayleighModel" <<
G4endl;
187 std::ostringstream ostFF;
188 ostFF << datadir <<
"/livermore/rayl/re-ff-" <<
Z <<
".dat";
189 std::ifstream finFF(ostFF.str().c_str());
191 if( !finFF.is_open() ) {
193 ed <<
"G4LivermorePolarizedRayleighModel data file <" << ostFF.str().c_str()
194 <<
"> is not opened!" <<
G4endl;
195 G4Exception(
"G4LivermorePolarizedRayleighModel::ReadData()",
"em0003",
197 ed,
"G4LEDATA version should be G4EMLOW8.0 or later.");
200 if(verboseLevel > 3) {
201 G4cout <<
"File " << ostFF.str()
202 <<
" is opened by G4LivermoreRayleighModel" <<
G4endl;
204 formFactorData[
Z]->
Retrieve(finFF,
true);
216 if (verboseLevel > 1) {
217 G4cout <<
"G4LivermoreRayleighModel::ComputeCrossSectionPerAtom()"
221 if(GammaEnergy < lowEnergyLimit) {
return 0.0; }
226 if(intZ < 1 || intZ > maxZ) {
return xs; }
235 if(
nullptr == pv) {
return xs; }
242 }
else if(e >= pv->
Energy(0)) {
243 xs = pv->
Value(e)/(e*e);
251 std::vector<G4DynamicParticle*>*,
256 if (verboseLevel > 3)
257 G4cout <<
"Calling SampleSecondaries() of G4LivermorePolarizedRayleighModel" <<
G4endl;
261 if (photonEnergy0 <= lowEnergyLimit)
276 G4double outcomingPhotonCosTheta = GenerateCosTheta(photonEnergy0,
Z);
277 G4double outcomingPhotonPhi = GeneratePhi(outcomingPhotonCosTheta);
278 G4double beta = GeneratePolarizationAngle();
298 zDir=outcomingPhotonCosTheta;
299 xDir=std::sqrt(1-outcomingPhotonCosTheta*outcomingPhotonCosTheta);
301 xDir*=std::cos(outcomingPhotonPhi);
302 yDir*=std::sin(outcomingPhotonPhi);
310 G4ThreeVector outcomingPhotonPolarization(xPrime*std::cos(beta) + yPrime*std::sin(beta));
338 const G4double xxfact = CLHEP::cm/(CLHEP::h_Planck*CLHEP::c_light);
339 const G4double xFactor = incomingPhotonEnergy*xxfact;
346 if (incomingPhotonEnergy > 5.*CLHEP::MeV)
357 fCosTheta = (1.+cosTheta*cosTheta)/2.;
361 x = xFactor*std::sqrt((1.-cosTheta)/2.);
364 fValue = formFactorData[
Z]->
Value(x);
366 fValue = formFactorData[
Z]->
Value(0.);
379G4double G4LivermorePolarizedRayleighModel::GeneratePhi(
G4double cosTheta)
const
392 sin2Theta=1.-cosTheta*cosTheta;
397 cosPhi = std::cos(phi);
398 phiProbability= 1. - sin2Theta*cosPhi*cosPhi;
407G4double G4LivermorePolarizedRayleighModel::GeneratePolarizationAngle(
void)
const
421 photonPolarization =
photon.GetPolarization();
422 photonMomentumDirection =
photon.GetMomentumDirection();
424 if ((!photonPolarization.
isOrthogonal(photonMomentumDirection, 1e-6)) || photonPolarization.
mag()==0.)
436 photonPolarization=e1+e2;
438 else if (photonPolarization.
howOrthogonal(photonMomentumDirection) != 0.)
442 photonPolarization=photonPolarization.
perpPart(photonMomentumDirection);
445 return photonPolarization.
unit();
453 G4AutoLock l(&LivermorePolarizedRayleighModelMutex);
454 if(
nullptr == dataCS[
Z]) { ReadData(
Z); }
const char * G4FindDataDir(const char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
Hep3Vector orthogonal() const
Hep3Vector cross(const Hep3Vector &) const
bool isOrthogonal(const Hep3Vector &v, double epsilon=tolerance) const
Hep3Vector perpPart() const
double howOrthogonal(const Hep3Vector &v) const
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
static G4ElementTable * GetElementTable()
void InitialiseForElement(const G4ParticleDefinition *, G4int Z) override
virtual ~G4LivermorePolarizedRayleighModel()
G4LivermorePolarizedRayleighModel(const G4ParticleDefinition *p=nullptr, const G4String &nam="LivermorePolarizedRayleigh")
G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX) override
void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy) override
void Initialise(const G4ParticleDefinition *, const G4DataVector &) override
void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel) override
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposePolarization(const G4ThreeVector &dir)
void ProposeMomentumDirection(const G4ThreeVector &Pfinal)
G4double Energy(const std::size_t index) const
G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
G4double Value(const G4double energy, std::size_t &lastidx) const
std::size_t GetVectorLength() const
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 InitialiseElementSelectors(const G4ParticleDefinition *, const G4DataVector &)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)