Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4JAEAPolarizedElasticScatteringModel.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26/*/
27Authors:
28M. Omer and R. Hajima on 15 November 2019
29contact:
31Publication Information:
321- M. Omer, R. Hajima, Validating polarization effects in gamma-rays elastic scattering by Monte
33Carlo simulation, New J. Phys., vol. 21, 2019, pp. 113006 (1-10),
34https://doi.org/10.1088/1367-2630/ab4d8a
35*/
36
38#include "G4SystemOfUnits.hh"
39
40
41
42using namespace std;
43
44//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
46
47G4LPhysicsFreeVector* G4JAEAPolarizedElasticScatteringModel::dataCS[] = {nullptr};
48G4DataVector* G4JAEAPolarizedElasticScatteringModel::Polarized_ES_Data[] = {nullptr};
49
51 :G4VEmModel("G4JAEAPolarizedElasticScatteringModel"),isInitialised(false)
52{
53 fParticleChange = 0;
54 lowEnergyLimit = 100 * keV; //low energy limit for JAEAElasticScattering cross section data
55 fLinearPolarizationSensitvity1=1;
56 fLinearPolarizationSensitvity2=1;
57 fCircularPolarizationSensitvity=1;
58
59 verboseLevel= 0;
60 // Verbosity scale for debugging purposes:
61 // 0 = nothing
62 // 1 = calculation of cross sections, file openings...
63 // 2 = entering in methods
64
65 if(verboseLevel > 0)
66 {
67 G4cout << "G4JAEAPolarizedElasticScatteringModel is constructed " << G4endl;
68 }
69
70}
71
72//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
73
75{
76 if(IsMaster()) {
77 for(G4int i=0; i<=maxZ; ++i) {
78 if(dataCS[i]) {
79 delete dataCS[i];
80 dataCS[i] = nullptr;
81 }
82 if (Polarized_ES_Data[i]){
83 delete Polarized_ES_Data[i];
84 Polarized_ES_Data[i] = nullptr;
85 }
86 }
87 }
88}
89
90//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
91
93 const G4DataVector& cuts)
94{
95 if (verboseLevel > 1)
96 {
97 G4cout << "Calling Initialise() of G4JAEAPolarizedElasticScatteringModel." << G4endl
98 << "Energy range: "
99 << LowEnergyLimit() / eV << " eV - "
100 << HighEnergyLimit() / GeV << " GeV"
101 << G4endl;
102 }
103
104 if(IsMaster()) {
105
106 // Initialise element selector
107 InitialiseElementSelectors(particle, cuts);
108
109 // Access to elements
110 char* path = std::getenv("G4LEDATA");
111 G4ProductionCutsTable* theCoupleTable =
113 G4int numOfCouples = theCoupleTable->GetTableSize();
114
115 for(G4int i=0; i<numOfCouples; ++i)
116 {
117 const G4MaterialCutsCouple* couple =
118 theCoupleTable->GetMaterialCutsCouple(i);
119 const G4Material* material = couple->GetMaterial();
120 const G4ElementVector* theElementVector = material->GetElementVector();
121 G4int nelm = material->GetNumberOfElements();
122
123 for (G4int j=0; j<nelm; ++j)
124 {
125 G4int Z = G4lrint((*theElementVector)[j]->GetZ());
126 if(Z < 1) { Z = 1; }
127 else if(Z > maxZ) { Z = maxZ; }
128 if( (!dataCS[Z]) ) { ReadData(Z, path); }
129 }
130 }
131 }
132
133 if(isInitialised) { return; }
134 fParticleChange = GetParticleChangeForGamma();
135 isInitialised = true;
136
137}
138
139//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
140
142 G4VEmModel* masterModel)
143{
145}
146
147//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
148
149void G4JAEAPolarizedElasticScatteringModel::ReadData(size_t Z, const char* path)
150{
151
152 if (verboseLevel > 1)
153 {
154 G4cout << "Calling ReadData() of G4JAEAPolarizedElasticScatteringModel"
155 << G4endl;
156 }
157
158 if(dataCS[Z]) { return; }
159
160 const char* datadir = path;
161
162 if(!datadir)
163 {
164 datadir = std::getenv("G4LEDATA");
165 if(!datadir)
166 {
167 G4Exception("G4JAEAPolarizedElasticScatteringModel::ReadData()","em0006",
169 "Environment variable G4LEDATA not defined");
170 return;
171 }
172 }
173
174
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() )
179{
181 ed << "G4JAEAPolarizedElasticScattering Model data file <" << ostCS.str().c_str()
182 << "> is not opened!" << G4endl;
183 G4Exception("G4JAEAPolarizedElasticScatteringModel::ReadData()","em0003",FatalException,
184 ed,"G4LEDATA version should be G4EMLOW7.11 or later. Polarized Elastic Scattering Data are not loaded");
185 return;
186}
187 else
188 {
189 if(verboseLevel > 3) {
190 G4cout << "File " << ostCS.str()
191 << " is opened by G4JAEAPolarizedElasticScatteringModel" << G4endl;
192 }
193 }
194
195
196 if (!Polarized_ES_Data[Z])
197 Polarized_ES_Data[Z] = new G4DataVector();
198
199 G4float buffer_var;
200 while (ES_Data_Buffer.read(reinterpret_cast<char*>(&buffer_var),sizeof(float)))
201 {
202 Polarized_ES_Data[Z]->push_back(buffer_var);
203 }
204
205 dataCS[Z] = new G4LPhysicsFreeVector(300,0.01,3.);
206
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);
209
210
211 // Activation of spline interpolation
212 dataCS[Z] ->SetSpline(true);
213
214
215}
216
217//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
218
221 G4double GammaEnergy,
224{
225
226
227//Select the energy-grid point closest to the photon energy
228// G4double *whichenergy = lower_bound(ESdata[0],ESdata[0]+300,GammaEnergy);
229// int energyindex = max(0,(int)(whichenergy-ESdata[0]-1));
230
231 if (verboseLevel > 1)
232 {
233 G4cout << "G4JAEAPolarizedElasticScatteringModel::ComputeCrossSectionPerAtom()"
234 << G4endl;
235 }
236
237 if(GammaEnergy < lowEnergyLimit) { return 0.0; }
238
239 G4double xs = 0.0;
240
241 G4int intZ = G4lrint(Z);
242
243 if(intZ < 1 || intZ > maxZ) { return xs; }
244
245 G4LPhysicsFreeVector* pv = dataCS[intZ];
246
247 // if element was not initialised
248 // do initialisation safely for MT mode
249 if(!pv) {
250 InitialiseForElement(0, intZ);
251 pv = dataCS[intZ];
252 if(!pv) { return xs; }
253 }
254
255 G4int n = pv->GetVectorLength() - 1;
256
257 G4double e = GammaEnergy;
258 if(e >= pv->Energy(n)) {
259 xs = (*pv)[n];
260 } else if(e >= pv->Energy(0)) {
261 xs = pv->Value(e);
262 }
263
264 if(verboseLevel > 0)
265 {
266 G4cout << "****** DEBUG: tcs value for Z=" << Z << " at energy (MeV)="
267 << e << G4endl;
268 G4cout << " cs (Geant4 internal unit)=" << xs << G4endl;
269 G4cout << " -> first E*E*cs value in CS data file (iu) =" << (*pv)[0]
270 << G4endl;
271 G4cout << " -> last E*E*cs value in CS data file (iu) =" << (*pv)[n]
272 << G4endl;
273 G4cout << "*********************************************************"
274 << G4endl;
275 }
276
277 return (xs);
278}
279
280//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
281
283 std::vector<G4DynamicParticle*>*,
284 const G4MaterialCutsCouple* couple,
285 const G4DynamicParticle* aDynamicGamma,
287{
288 if (verboseLevel > 1) {
289
290 G4cout << "Calling SampleSecondaries() of G4JAEAPolarizedElasticScatteringModel."
291 << G4endl;
292 }
293 G4double photonEnergy0 = aDynamicGamma->GetKineticEnergy();
294
295 // absorption of low-energy gamma
296 if (photonEnergy0 <= lowEnergyLimit)
297 {
298 fParticleChange->ProposeTrackStatus(fStopAndKill);
299 fParticleChange->SetProposedKineticEnergy(0.);
300 fParticleChange->ProposeLocalEnergyDeposit(photonEnergy0);
301 return ;
302 }
303
304 const G4ParticleDefinition* particle = aDynamicGamma->GetDefinition();
305 const G4Element* elm = SelectRandomAtom(couple,particle,photonEnergy0);
306 G4int Z = G4lrint(elm->GetZ());
307
308
309//Getting the corresponding distrbution
310G4int energyindex=round(100*photonEnergy0)-1;
311//G4cout<<"Rounding Photon Energy for element Z = "<<Z<<G4endl;
312//G4cout<<photonEnergy0<<" "<<" "<<round(1000*photonEnergy0)<<" "<<energyindex<<G4endl;
313 G4double a1=0, a2=0, a3=0,a4=0;
314 for (G4int i=0;i<=180;++i)
315 {
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;
321 }
322
323 CLHEP::RandGeneral GenThetaDist(distribution,180);
324 //Intial sampling of the scattering angle. To be updated for the circular polarization
325 G4double theta = CLHEP::pi*GenThetaDist.shoot();
326 //G4double theta =45.*CLHEP::pi/180.;
327 //Theta is in degree to call scattering amplitudes
328 G4int theta_in_degree =round(theta*180./CLHEP::pi);
329
330 //theta_in_degree=45;
331
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;
341
342 G4ThreeVector Direction_Unpolarized(0.,0.,0.);
343 G4ThreeVector Direction_Linear1(0.,0.,0.);
344 G4ThreeVector Direction_Linear2(0.,0.,0.);
345 G4ThreeVector Direction_Circular(0.,0.,0.);
346 G4ThreeVector Polarization_Unpolarized(0.,0.,0.);
347 G4ThreeVector Polarization_Linear1(0.,0.,0.);
348 G4ThreeVector Polarization_Linear2(0.,0.,0.);
349 G4ThreeVector Polarization_Circular(0.,0.,0.);
350
351
352//Stokes parameters for the incoming and outgoing photon
353G4double Xi1=0, Xi2=0, Xi3=0, Xi1_Prime=0,Xi2_Prime=0,Xi3_Prime=0;
354
355//Getting the Stokes parameters for the incoming photon
356G4ThreeVector gammaPolarization0 = aDynamicGamma->GetPolarization();
357Xi1=gammaPolarization0.x();
358Xi2=gammaPolarization0.y();
359Xi3=gammaPolarization0.z();
360
361//Polarization vector must be unit vector (5% tolerance)
362
363if ((gammaPolarization0.mag())>1.05 || (Xi1*Xi1>1.05) || (Xi2*Xi2>1.05) || (Xi3*Xi3>1.05))
364 {
365 G4Exception("G4JAEAPolarizedElasticScatteringModel::SampleSecondaries()","em1006",
367 "WARNING: G4JAEAPolarizedElasticScatteringModel is only compatible with a unit polarization vector.");
368 return;
369}
370//Unpolarized gamma rays
371if (Xi1==0 && Xi2==0 && Xi3==0)
372{
373 G4double Phi_Unpolarized=0;
374 if (fLinearPolarizationSensitvity1)
375 Phi_Unpolarized=GeneratePolarizedPhi(aparaSquare,aperpSquare,0.);
376 else
377 Phi_Unpolarized=CLHEP::twopi*G4UniformRand();
378 Direction_Unpolarized.setX(sin(theta)*cos(Phi_Unpolarized));
379 Direction_Unpolarized.setY(sin(theta)*sin(Phi_Unpolarized));
380 Direction_Unpolarized.setZ(cos(theta));
381 Direction_Unpolarized.rotateUz(aDynamicGamma->GetMomentumDirection());
382 Xi1_Prime=(aparaSquare-aperpSquare)/(aparaSquare+aperpSquare);
383 Polarization_Unpolarized.setX(Xi1_Prime);
384 Polarization_Unpolarized.setY(0.);
385 Polarization_Unpolarized.setZ(0.);
386 fParticleChange->ProposeMomentumDirection(Direction_Unpolarized);
387 fParticleChange->ProposePolarization(Polarization_Unpolarized);
388 return;
389}
390
391//Linear polarization defined by first Stokes parameter
392G4double InitialAzimuth=aDynamicGamma->GetMomentumDirection().phi();
393if(InitialAzimuth<0) InitialAzimuth=InitialAzimuth+CLHEP::twopi;
394
395G4double Phi_Linear1=0.;
396
397Phi_Linear1 = GeneratePolarizedPhi(aparaSquare+aperpSquare+Xi1*(aparaSquare-aperpSquare),
398 aparaSquare+aperpSquare-Xi1*(aparaSquare-aperpSquare),InitialAzimuth);
399
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));
406//Store momentum direction and po;arization
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);
413
414//Set scattered photon polarization sensitivity
415Xi1_Prime=Xi1_Prime*fLinearPolarizationSensitvity1;
416Xi2_Prime=Xi2_Prime*fLinearPolarizationSensitvity2;
417Xi3_Prime=Xi3_Prime*fCircularPolarizationSensitvity;
418
419G4double dsigmaL1=0.0;
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));
422
423//Linear polarization defined by second Stokes parameter
424//G4double IntialAzimuth=aDynamicGamma->GetMomentumDirection().phi();
425
426G4double Phi_Linear2=0.;
427
428InitialAzimuth=InitialAzimuth-CLHEP::pi/4.;
429if(InitialAzimuth<0) InitialAzimuth=InitialAzimuth+CLHEP::twopi;
430
431Phi_Linear2 = GeneratePolarizedPhi(aparaSquare+aperpSquare+Xi1*(aparaSquare-aperpSquare)
432 ,aparaSquare+aperpSquare-Xi1*(aparaSquare-aperpSquare),InitialAzimuth);
433
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));
440//Store momentum direction and polarization
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);
447
448//Set scattered photon polarization sensitivity
449Xi1_Prime=Xi1_Prime*fLinearPolarizationSensitvity1;
450Xi2_Prime=Xi2_Prime*fLinearPolarizationSensitvity2;
451Xi3_Prime=Xi3_Prime*fCircularPolarizationSensitvity;
452
453G4double dsigmaL2=0.0;
454if(abs(Xi2)>0.0)
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));
457
458
459//Circular polarization
460G4double Phi_Circular = CLHEP::twopi*G4UniformRand();
461G4double Theta_Circular = 0;
462
463Xi1_Prime=(aparaSquare-aperpSquare)/(aparaSquare+aperpSquare);
464Xi2_Prime=(-Xi3*img_apara_aper_Asterisk)/(aparaSquare+aperpSquare);
465Xi3_Prime=(Xi3*apara_aper_Asterisk)/(aparaSquare+aperpSquare);
466
467Polarization_Circular.setX(Xi1_Prime);
468Polarization_Circular.setY(Xi2_Prime);
469Polarization_Circular.setZ(Xi3_Prime);
470
471//Set scattered photon polarization sensitivity
472Xi1_Prime=Xi1_Prime*fLinearPolarizationSensitvity1;
473Xi2_Prime=Xi2_Prime*fLinearPolarizationSensitvity2;
474Xi3_Prime=Xi3_Prime*fCircularPolarizationSensitvity;
475
476G4double dsigmaC=0.0;
477if(abs(Xi3)>0.0)
478dsigmaC=0.25*(aparaSquare+aperpSquare+Xi1_Prime*(aparaSquare-aperpSquare)-Xi3*Xi2_Prime*img_apara_aper_Asterisk
479 +Xi3*Xi3_Prime*apara_aper_Asterisk);
480
481if (abs(Xi3)==0.0 && abs(Xi1_Prime)==0.0)
482{
483 Direction_Circular.setX(sin(theta)*cos(Phi_Circular));
484 Direction_Circular.setY(sin(theta)*sin(Phi_Circular));
485 Direction_Circular.setZ(cos(theta));
486}
487else
488{
489G4double c1=0, c2=0, c3=0,c4=0;
490 for (G4int i=0;i<=180;++i)
491 {
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));
498 }
499CLHEP::RandGeneral GenTheta_Circ_Dist(cdistribution,180);
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));
504}
505
506// Sampling scattered photon direction based on asymmetry arising from polarization mixing
507G4double totalSigma= dsigmaL1+dsigmaL2+dsigmaC;
508G4double prob1=dsigmaL1/totalSigma;
509G4double prob2=dsigmaL2/totalSigma;
510G4double probc=1-(prob1+prob2);
511
512//Check the Probability of polarization mixing
513 if (abs(probc - dsigmaC/totalSigma)>=0.0001)
514 {
515 G4Exception("G4JAEAPolarizedElasticScatteringModel::SampleSecondaries()","em1007",
517 "WARNING: Polarization mixing might be incorrect.");
518 }
519
520// Generate outgoing photon direction
521 G4ThreeVector finaldirection(0.0,0.0,0.0);
522 G4ThreeVector outcomingPhotonPolarization(0.0,0.0,0.0);
523
524//Polarization mixing
525G4double polmix=G4UniformRand();
526if (polmix<=prob1)
527{
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());
534}
535else if ((polmix>prob1) && (polmix<=prob1+prob2))
536{
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());
543}
544else if (polmix>prob1+prob2)
545{
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());
552}
553
554 //Sampling the Final State
555 finaldirection.rotateUz(aDynamicGamma->GetMomentumDirection());
556 fParticleChange->ProposeMomentumDirection(finaldirection);
557 fParticleChange->SetProposedKineticEnergy(photonEnergy0);
558 fParticleChange->ProposePolarization(outcomingPhotonPolarization);
559
560}
561
562//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
563
564G4double G4JAEAPolarizedElasticScatteringModel::GeneratePolarizedPhi(G4double Sigma_para,G4double Sigma_perp, G4double initial_Pol_Plane)
565{
566 G4double phi;
567 G4double phiProbability;
568 G4double Probability=Sigma_perp/(Sigma_para+Sigma_perp);
569 if (Probability<=G4UniformRand())
570 {
571 do
572 {
573 phi = CLHEP::twopi * G4UniformRand();
574 phiProbability = cos(phi+initial_Pol_Plane)*cos(phi+initial_Pol_Plane);
575 }
576 while (phiProbability < G4UniformRand());
577
578 }
579 else
580 {
581 do
582 {
583 phi = CLHEP::twopi * G4UniformRand();
584 phiProbability = sin(phi+initial_Pol_Plane)*sin(phi+initial_Pol_Plane);
585 }
586 while (phiProbability < G4UniformRand());
587 }
588 return phi;
589
590}
591//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
592
593#include "G4AutoLock.hh"
594namespace { G4Mutex G4JAEAPolarizedElasticScatteringModelMutex = G4MUTEX_INITIALIZER; }
595
596void
598 G4int Z)
599{
600 G4AutoLock l(&G4JAEAPolarizedElasticScatteringModelMutex);
601 // G4cout << "G4JAEAPolarizedElasticScatteringModel::InitialiseForElement Z= "
602 // << Z << G4endl;
603 if(!dataCS[Z]) { ReadData(Z); }
604 l.unlock();
605}
606
607//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
std::vector< G4Element * > G4ElementVector
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
std::mutex G4Mutex
Definition: G4Threading.hh:81
@ fStopAndKill
float G4float
Definition: G4Types.hh:84
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:52
double z() const
double phi() const
double x() const
void setY(double)
double y() const
void setZ(double)
double mag() const
void setX(double)
Hep3Vector & rotateUz(const Hep3Vector &)
Definition: ThreeVector.cc:33
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4ThreeVector & GetPolarization() const
G4double GetZ() const
Definition: G4Element.hh:130
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel)
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
Definition: G4Material.hh:188
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
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
void SetSpline(G4bool)
std::size_t GetVectorLength() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
void SetElementSelectors(std::vector< G4EmElementSelector * > *)
Definition: G4VEmModel.hh:842
G4ParticleChangeForGamma * GetParticleChangeForGamma()
Definition: G4VEmModel.cc:133
G4double LowEnergyLimit() const
Definition: G4VEmModel.hh:652
std::vector< G4EmElementSelector * > * GetElementSelectors()
Definition: G4VEmModel.hh:834
G4bool IsMaster() const
Definition: G4VEmModel.hh:736
G4double HighEnergyLimit() const
Definition: G4VEmModel.hh:645
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
Definition: G4VEmModel.hh:570
void InitialiseElementSelectors(const G4ParticleDefinition *, const G4DataVector &)
Definition: G4VEmModel.cc:148
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
int G4lrint(double ad)
Definition: templates.hh:134