48G4DataVector* G4JAEAPolarizedElasticScatteringModel::Polarized_ES_Data[] = {
nullptr};
51 :
G4VEmModel(
"G4JAEAPolarizedElasticScatteringModel"),isInitialised(false)
54 lowEnergyLimit = 100 * keV;
55 fLinearPolarizationSensitvity1=1;
56 fLinearPolarizationSensitvity2=1;
57 fCircularPolarizationSensitvity=1;
67 G4cout <<
"G4JAEAPolarizedElasticScatteringModel is constructed " <<
G4endl;
77 for(
G4int i=0; i<=maxZ; ++i) {
82 if (Polarized_ES_Data[i]){
83 delete Polarized_ES_Data[i];
84 Polarized_ES_Data[i] =
nullptr;
97 G4cout <<
"Calling Initialise() of G4JAEAPolarizedElasticScatteringModel." <<
G4endl
110 char* path = std::getenv(
"G4LEDATA");
115 for(
G4int i=0; i<numOfCouples; ++i)
123 for (
G4int j=0; j<nelm; ++j)
127 else if(Z > maxZ) { Z = maxZ; }
128 if( (!dataCS[Z]) ) { ReadData(Z, path); }
133 if(isInitialised) {
return; }
135 isInitialised =
true;
149void G4JAEAPolarizedElasticScatteringModel::ReadData(
size_t Z,
const char* path)
152 if (verboseLevel > 1)
154 G4cout <<
"Calling ReadData() of G4JAEAPolarizedElasticScatteringModel"
158 if(dataCS[Z]) {
return; }
160 const char* datadir = path;
164 datadir = std::getenv(
"G4LEDATA");
167 G4Exception(
"G4JAEAPolarizedElasticScatteringModel::ReadData()",
"em0006",
169 "Environment variable G4LEDATA not defined");
175std::ostringstream ostCS;
176ostCS << datadir <<
"/JAEAESData/amp_Z_" << Z ;
177std::ifstream ES_Data_Buffer(ostCS.str().c_str(),ios::binary);
178if( !ES_Data_Buffer.is_open() )
181 ed <<
"G4JAEAPolarizedElasticScattering Model data file <" << ostCS.str().c_str()
182 <<
"> is not opened!" <<
G4endl;
184 ed,
"G4LEDATA version should be G4EMLOW7.11 or later. Polarized Elastic Scattering Data are not loaded");
189 if(verboseLevel > 3) {
190 G4cout <<
"File " << ostCS.str()
191 <<
" is opened by G4JAEAPolarizedElasticScatteringModel" <<
G4endl;
196 if (!Polarized_ES_Data[Z])
200 while (ES_Data_Buffer.read(
reinterpret_cast<char*
>(&buffer_var),
sizeof(
float)))
202 Polarized_ES_Data[Z]->push_back(buffer_var);
207 for (
G4int i=0;i<300;++i)
208 dataCS[Z]->PutValue(i,10.*i*1e-3,Polarized_ES_Data[Z]->at(i)*1e-22);
231 if (verboseLevel > 1)
233 G4cout <<
"G4JAEAPolarizedElasticScatteringModel::ComputeCrossSectionPerAtom()"
237 if(GammaEnergy < lowEnergyLimit) {
return 0.0; }
243 if(intZ < 1 || intZ > maxZ) {
return xs; }
252 if(!pv) {
return xs; }
260 }
else if(e >= pv->
Energy(0)) {
266 G4cout <<
"****** DEBUG: tcs value for Z=" << Z <<
" at energy (MeV)="
268 G4cout <<
" cs (Geant4 internal unit)=" << xs <<
G4endl;
269 G4cout <<
" -> first E*E*cs value in CS data file (iu) =" << (*pv)[0]
271 G4cout <<
" -> last E*E*cs value in CS data file (iu) =" << (*pv)[n]
273 G4cout <<
"*********************************************************"
283 std::vector<G4DynamicParticle*>*,
288 if (verboseLevel > 1) {
290 G4cout <<
"Calling SampleSecondaries() of G4JAEAPolarizedElasticScatteringModel."
296 if (photonEnergy0 <= lowEnergyLimit)
310G4int energyindex=round(100*photonEnergy0)-1;
314 for (
G4int i=0;i<=180;++i)
316 a1=Polarized_ES_Data[Z]->at(4*i+300+181*4*(energyindex));
317 a2=Polarized_ES_Data[Z]->at(4*i+1+300+181*4*(energyindex));
318 a3=Polarized_ES_Data[Z]->at(4*i+2+300+181*4*(energyindex));
319 a4=Polarized_ES_Data[Z]->at(4*i+3+300+181*4*(energyindex));
320 distribution[i]=a1*a1+a2*a2+a3*a3+a4*a4;
328 G4int theta_in_degree =round(theta*180./CLHEP::pi);
332 G4double am1=0,am2=0,am3=0,am4=0,aparaSquare=0,aperpSquare=0,apara_aper_Asterisk=0,img_apara_aper_Asterisk=0;
333 am1=Polarized_ES_Data[Z]->at(4*theta_in_degree+300+181*4*(energyindex));
334 am2=Polarized_ES_Data[Z]->at(4*theta_in_degree+1+300+181*4*(energyindex));
335 am3=Polarized_ES_Data[Z]->at(4*theta_in_degree+2+300+181*4*(energyindex));
336 am4=Polarized_ES_Data[Z]->at(4*theta_in_degree+3+300+181*4*(energyindex));
337 aparaSquare=am1*am1+am2*am2;
338 aperpSquare=am3*am3+am4*am4;
339 apara_aper_Asterisk=2*a1*a3+2*a2*a4;
340 img_apara_aper_Asterisk=2*a1*a4-2*a2*a3;
353G4double Xi1=0, Xi2=0, Xi3=0, Xi1_Prime=0,Xi2_Prime=0,Xi3_Prime=0;
357Xi1=gammaPolarization0.
x();
358Xi2=gammaPolarization0.
y();
359Xi3=gammaPolarization0.
z();
363if ((gammaPolarization0.
mag())>1.05 || (Xi1*Xi1>1.05) || (Xi2*Xi2>1.05) || (Xi3*Xi3>1.05))
365 G4Exception(
"G4JAEAPolarizedElasticScatteringModel::SampleSecondaries()",
"em1006",
367 "WARNING: G4JAEAPolarizedElasticScatteringModel is only compatible with a unit polarization vector.");
371if (Xi1==0 && Xi2==0 && Xi3==0)
374 if (fLinearPolarizationSensitvity1)
375 Phi_Unpolarized=GeneratePolarizedPhi(aparaSquare,aperpSquare,0.);
378 Direction_Unpolarized.
setX(sin(theta)*cos(Phi_Unpolarized));
379 Direction_Unpolarized.
setY(sin(theta)*sin(Phi_Unpolarized));
380 Direction_Unpolarized.
setZ(cos(theta));
382 Xi1_Prime=(aparaSquare-aperpSquare)/(aparaSquare+aperpSquare);
383 Polarization_Unpolarized.
setX(Xi1_Prime);
384 Polarization_Unpolarized.
setY(0.);
385 Polarization_Unpolarized.
setZ(0.);
393if(InitialAzimuth<0) InitialAzimuth=InitialAzimuth+CLHEP::twopi;
397Phi_Linear1 = GeneratePolarizedPhi(aparaSquare+aperpSquare+Xi1*(aparaSquare-aperpSquare),
398 aparaSquare+aperpSquare-Xi1*(aparaSquare-aperpSquare),InitialAzimuth);
400Xi1_Prime=((aparaSquare-aperpSquare)+Xi1*(aparaSquare+aperpSquare)*cos(2*Phi_Linear1))/
401 ((aparaSquare+aperpSquare)+Xi1*(aparaSquare-aperpSquare)*cos(2*Phi_Linear1));
402Xi2_Prime=(-Xi1*apara_aper_Asterisk*sin(2*Phi_Linear1))/
403 ((aparaSquare+aperpSquare)+Xi1*(aparaSquare-aperpSquare)*cos(2*Phi_Linear1));
404Xi3_Prime=(-Xi1*img_apara_aper_Asterisk*sin(2*Phi_Linear1))/
405 ((aparaSquare+aperpSquare)+Xi1*(aparaSquare-aperpSquare)*cos(2*Phi_Linear1));
407Direction_Linear1.
setX(sin(theta)*cos(Phi_Linear1));
408Direction_Linear1.
setY(sin(theta)*sin(Phi_Linear1));
409Direction_Linear1.
setZ(cos(theta));
410Polarization_Linear1.
setX(Xi1_Prime);
411Polarization_Linear1.
setY(Xi2_Prime);
412Polarization_Linear1.
setZ(Xi3_Prime);
415Xi1_Prime=Xi1_Prime*fLinearPolarizationSensitvity1;
416Xi2_Prime=Xi2_Prime*fLinearPolarizationSensitvity2;
417Xi3_Prime=Xi3_Prime*fCircularPolarizationSensitvity;
420if(abs(Xi1)>0.0) dsigmaL1=0.25*((aparaSquare+aperpSquare)*(1+Xi1*Xi1_Prime*cos(2*Phi_Linear1))+(aparaSquare-aperpSquare)*(Xi1*cos(2*Phi_Linear1)+Xi1_Prime)
421 -Xi1*Xi2_Prime*apara_aper_Asterisk*sin(2*Phi_Linear1)-Xi1*Xi3_Prime*img_apara_aper_Asterisk*sin(2*Phi_Linear1));
428InitialAzimuth=InitialAzimuth-CLHEP::pi/4.;
429if(InitialAzimuth<0) InitialAzimuth=InitialAzimuth+CLHEP::twopi;
431Phi_Linear2 = GeneratePolarizedPhi(aparaSquare+aperpSquare+Xi1*(aparaSquare-aperpSquare)
432 ,aparaSquare+aperpSquare-Xi1*(aparaSquare-aperpSquare),InitialAzimuth);
434Xi1_Prime=((aparaSquare-aperpSquare)+Xi2*(aparaSquare+aperpSquare)*sin(2*Phi_Linear2))/
435 ((aparaSquare+aperpSquare)+Xi2*(aparaSquare-aperpSquare)*sin(2*Phi_Linear2));
436Xi2_Prime=(Xi2*apara_aper_Asterisk*cos(2*Phi_Linear2))/
437 ((aparaSquare+aperpSquare)+Xi2*(aparaSquare-aperpSquare)*sin(2*Phi_Linear2));
438Xi3_Prime=(Xi2*img_apara_aper_Asterisk*cos(2*Phi_Linear2))/
439 ((aparaSquare+aperpSquare)+Xi2*(aparaSquare-aperpSquare)*sin(2*Phi_Linear2));
441Direction_Linear2.
setX(sin(theta)*cos(Phi_Linear2));
442Direction_Linear2.
setY(sin(theta)*sin(Phi_Linear2));
443Direction_Linear2.
setZ(cos(theta));
444Polarization_Linear2.
setX(Xi1_Prime);
445Polarization_Linear2.
setY(Xi2_Prime);
446Polarization_Linear2.
setZ(Xi3_Prime);
449Xi1_Prime=Xi1_Prime*fLinearPolarizationSensitvity1;
450Xi2_Prime=Xi2_Prime*fLinearPolarizationSensitvity2;
451Xi3_Prime=Xi3_Prime*fCircularPolarizationSensitvity;
455dsigmaL2=0.25*((aparaSquare+aperpSquare)*(1+Xi2*Xi1_Prime*sin(2*Phi_Linear2))+(aparaSquare-aperpSquare)*(Xi2*sin(2*Phi_Linear2)+Xi1_Prime)
456 +Xi2*Xi2_Prime*apara_aper_Asterisk*cos(2*Phi_Linear2)-Xi2*Xi3_Prime*img_apara_aper_Asterisk*cos(2*Phi_Linear2));
463Xi1_Prime=(aparaSquare-aperpSquare)/(aparaSquare+aperpSquare);
464Xi2_Prime=(-Xi3*img_apara_aper_Asterisk)/(aparaSquare+aperpSquare);
465Xi3_Prime=(Xi3*apara_aper_Asterisk)/(aparaSquare+aperpSquare);
467Polarization_Circular.
setX(Xi1_Prime);
468Polarization_Circular.
setY(Xi2_Prime);
469Polarization_Circular.
setZ(Xi3_Prime);
472Xi1_Prime=Xi1_Prime*fLinearPolarizationSensitvity1;
473Xi2_Prime=Xi2_Prime*fLinearPolarizationSensitvity2;
474Xi3_Prime=Xi3_Prime*fCircularPolarizationSensitvity;
478dsigmaC=0.25*(aparaSquare+aperpSquare+Xi1_Prime*(aparaSquare-aperpSquare)-Xi3*Xi2_Prime*img_apara_aper_Asterisk
479 +Xi3*Xi3_Prime*apara_aper_Asterisk);
481if (abs(Xi3)==0.0 && abs(Xi1_Prime)==0.0)
483 Direction_Circular.
setX(sin(theta)*cos(Phi_Circular));
484 Direction_Circular.
setY(sin(theta)*sin(Phi_Circular));
485 Direction_Circular.
setZ(cos(theta));
490 for (
G4int i=0;i<=180;++i)
492 c1=Polarized_ES_Data[Z]->at(4*i+300+181*4*(energyindex));
493 c2=Polarized_ES_Data[Z]->at(4*i+1+300+181*4*(energyindex));
494 c3=Polarized_ES_Data[Z]->at(4*i+2+300+181*4*(energyindex));
495 c4=Polarized_ES_Data[Z]->at(4*i+3+300+181*4*(energyindex));
496 cdistribution[i]=0.25*((c1*c1+c2*c2+c3*c3+c4*c4)+Xi1_Prime*(c1*c1+c2*c2-c3*c3-c4*c4)-Xi3*Xi2_Prime*(2*c1*c4-2*c2*c3)
497 +Xi3*Xi3_Prime*(2*c1*c4-2*c2*c3));
500Theta_Circular=CLHEP::pi*GenTheta_Circ_Dist.
shoot();
501Direction_Circular.
setX(sin(Theta_Circular)*cos(Phi_Circular));
502Direction_Circular.
setY(sin(Theta_Circular)*sin(Phi_Circular));
503Direction_Circular.
setZ(cos(Theta_Circular));
507G4double totalSigma= dsigmaL1+dsigmaL2+dsigmaC;
513 if (abs(probc - dsigmaC/totalSigma)>=0.0001)
515 G4Exception(
"G4JAEAPolarizedElasticScatteringModel::SampleSecondaries()",
"em1007",
517 "WARNING: Polarization mixing might be incorrect.");
528 finaldirection.
setX(Direction_Linear1.
x());
529 finaldirection.
setY(Direction_Linear1.
y());
530 finaldirection.
setZ(Direction_Linear1.
z());
531 outcomingPhotonPolarization.
setX(Polarization_Linear1.
x());
532 outcomingPhotonPolarization.
setY(Polarization_Linear1.
y());
533 outcomingPhotonPolarization.
setZ(Polarization_Linear1.
z());
535else if ((polmix>prob1) && (polmix<=prob1+prob2))
537 finaldirection.
setX(Direction_Linear2.
x());
538 finaldirection.
setY(Direction_Linear2.
y());
539 finaldirection.
setZ(Direction_Linear2.
z());
540 outcomingPhotonPolarization.
setX(Polarization_Linear2.
x());
541 outcomingPhotonPolarization.
setY(Polarization_Linear2.
y());
542 outcomingPhotonPolarization.
setZ(Polarization_Linear2.
z());
544else if (polmix>prob1+prob2)
546 finaldirection.
setX(Direction_Circular.
x());
547 finaldirection.
setY(Direction_Circular.
y());
548 finaldirection.
setZ(Direction_Circular.
z());
549 outcomingPhotonPolarization.
setX(Polarization_Circular.
x());
550 outcomingPhotonPolarization.
setY(Polarization_Circular.
y());
551 outcomingPhotonPolarization.
setZ(Polarization_Circular.
z());
568 G4double Probability=Sigma_perp/(Sigma_para+Sigma_perp);
574 phiProbability = cos(phi+initial_Pol_Plane)*cos(phi+initial_Pol_Plane);
584 phiProbability = sin(phi+initial_Pol_Plane)*sin(phi+initial_Pol_Plane);
600 G4AutoLock l(&G4JAEAPolarizedElasticScatteringModelMutex);
603 if(!dataCS[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
Hep3Vector & rotateUz(const Hep3Vector &)
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4ThreeVector & GetPolarization() const
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel)
G4JAEAPolarizedElasticScatteringModel()
virtual ~G4JAEAPolarizedElasticScatteringModel()
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
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
std::size_t GetVectorLength() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
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)