Geant4  10.02
G4LivermorePolarizedGammaConversionModel.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 // $Id: G4LivermorePolarizedGammaConversionModel.hh,v 1.2 2010-11-23 16:42:15 flongo Exp $
27 //
28 // Authors: G.Depaola & F.Longo
29 //
30 //
31 
33 #include "G4PhysicalConstants.hh"
34 #include "G4SystemOfUnits.hh"
35 #include "G4Electron.hh"
36 #include "G4Positron.hh"
38 #include "G4Log.hh"
39 #include "G4Exp.hh"
40 #include "G4ProductionCutsTable.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
43 
44 using namespace std;
45 
46 
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51 
53  const G4ParticleDefinition*, const G4String& nam)
54  :G4VEmModel(nam), isInitialised(false),smallEnergy(2.*MeV)
55 {
56  fParticleChange = 0;
57  lowEnergyLimit = 2*electron_mass_c2;
58  //highEnergyLimit = 100 * GeV;
59  //SetLowEnergyLimit(lowEnergyLimit);
60  //SetHighEnergyLimit(highEnergyLimit);
61 
62  Phi=0.;
63  Psi=0.;
64 
65  verboseLevel= 0;
66  // Verbosity scale:
67  // 0 = nothing
68  // 1 = calculation of cross sections, file openings, samping of atoms
69  // 2 = entering in methods
70 
71  if(verboseLevel > 0) {
72  G4cout << "Livermore Polarized GammaConversion is constructed "
73  << G4endl;
74  }
75 
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
79 
81 {
82  if(IsMaster()) {
83  for(G4int i=0; i<maxZ; ++i) {
84  if(data[i]) {
85  delete data[i];
86  data[i] = 0;
87  }
88  }
89  }
90 }
91 
92 
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
95 
97  const G4DataVector& cuts)
98 {
99  if (verboseLevel > 1)
100  {
101  G4cout << "Calling1 G4LivermorePolarizedGammaConversionModel::Initialise()"
102  << G4endl
103  << "Energy range: "
104  << LowEnergyLimit() / MeV << " MeV - "
105  << HighEnergyLimit() / GeV << " GeV"
106  << G4endl;
107  }
108 
109 
110  if(IsMaster())
111  {
112 
113  // Initialise element selector
114 
115  InitialiseElementSelectors(particle, cuts);
116 
117  // Access to elements
118 
119  char* path = getenv("G4LEDATA");
120 
121  G4ProductionCutsTable* theCoupleTable =
123 
124  G4int numOfCouples = theCoupleTable->GetTableSize();
125 
126  for(G4int i=0; i<numOfCouples; ++i)
127  {
128  const G4Material* material =
129  theCoupleTable->GetMaterialCutsCouple(i)->GetMaterial();
130  const G4ElementVector* theElementVector = material->GetElementVector();
131  G4int nelm = material->GetNumberOfElements();
132 
133  for (G4int j=0; j<nelm; ++j)
134  {
135  G4int Z = (G4int)(*theElementVector)[j]->GetZ();
136  if(Z < 1) { Z = 1; }
137  else if(Z > maxZ) { Z = maxZ; }
138  if(!data[Z]) { ReadData(Z, path); }
139  }
140  }
141  }
142  if(isInitialised) { return; }
144  isInitialised = true;
145 
146 }
147 
148 
149 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
150 
152  const G4ParticleDefinition*, G4VEmModel* masterModel)
153 {
155 }
156 
157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
158 
160  const G4ParticleDefinition*,
161  G4double)
162 {
163  return lowEnergyLimit;
164 }
165 
166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
167 
169 {
170  if (verboseLevel > 1)
171  {
172  G4cout << "Calling ReadData() of G4LivermorePolarizedGammaConversionModel"
173  << G4endl;
174  }
175 
176  if(data[Z]) { return; }
177 
178  const char* datadir = path;
179 
180  if(!datadir)
181  {
182  datadir = getenv("G4LEDATA");
183  if(!datadir)
184  {
185  G4Exception("G4LivermorePolarizedGammaConversionModel::ReadData()",
186  "em0006",FatalException,
187  "Environment variable G4LEDATA not defined");
188  return;
189  }
190  }
191 
192  //
193 
194  data[Z] = new G4LPhysicsFreeVector();
195 
196  //
197 
198  std::ostringstream ost;
199  ost << datadir << "/livermore/pair/pp-cs-" << Z <<".dat";
200  std::ifstream fin(ost.str().c_str());
201 
202  if( !fin.is_open())
203  {
205  ed << "G4LivermorePolarizedGammaConversionModel data file <" << ost.str().c_str()
206  << "> is not opened!" << G4endl;
207  G4Exception("G4LivermorePolarizedGammaConversionModel::ReadData()",
208  "em0003",FatalException,
209  ed,"G4LEDATA version should be G4EMLOW6.27 or later.");
210  return;
211  }
212  else
213  {
214 
215  if(verboseLevel > 3) { G4cout << "File " << ost.str()
216  << " is opened by G4LivermorePolarizedGammaConversionModel" << G4endl;}
217 
218  data[Z]->Retrieve(fin, true);
219  }
220 
221  // Activation of spline interpolation
222  data[Z] ->SetSpline(true);
223 
224 }
225 
226 
227 
228 
229 
230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
231 
233  const G4ParticleDefinition*,
234  G4double GammaEnergy,
235  G4double Z, G4double,
237 {
238  if (verboseLevel > 1) {
239  G4cout << "G4LivermorePolarizedGammaConversionModel::ComputeCrossSectionPerAtom()"
240  << G4endl;
241  }
242  if (GammaEnergy < lowEnergyLimit) { return 0.0; }
243 
244  G4double xs = 0.0;
245 
246  G4int intZ=G4int(Z);
247 
248  if(intZ < 1 || intZ > maxZ) { return xs; }
249 
250  G4LPhysicsFreeVector* pv = data[intZ];
251 
252  // if element was not initialised
253  // do initialisation safely for MT mode
254  if(!pv)
255  {
256  InitialiseForElement(0, intZ);
257  pv = data[intZ];
258  if(!pv) { return xs; }
259  }
260  // x-section is taken from the table
261  xs = pv->Value(GammaEnergy);
262 
263  if(verboseLevel > 0)
264  {
265  G4int n = pv->GetVectorLength() - 1;
266  G4cout << "****** DEBUG: tcs value for Z=" << Z << " at energy (MeV)="
267  << GammaEnergy/MeV << G4endl;
268  G4cout << " cs (Geant4 internal unit)=" << xs << G4endl;
269  G4cout << " -> first cs value in EADL data file (iu) =" << (*pv)[0] << G4endl;
270  G4cout << " -> last cs value in EADL data file (iu) =" << (*pv)[n] << G4endl;
271  G4cout << "*********************************************************" << G4endl;
272  }
273 
274  return xs;
275 }
276 
277 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
278 
279 void
280 G4LivermorePolarizedGammaConversionModel::SampleSecondaries(std::vector<G4DynamicParticle*>* fvect,
281  const G4MaterialCutsCouple* couple,
282  const G4DynamicParticle* aDynamicGamma,
283  G4double,
284  G4double)
285 {
286 
287  // Fluorescence generated according to:
288  // J. Stepanek ,"A program to determine the radiation spectra due to a single atomic
289  // subshell ionisation by a particle or due to deexcitation or decay of radionuclides",
290  // Comp. Phys. Comm. 1206 pp 1-1-9 (1997)
291 
292  if (verboseLevel > 3)
293  G4cout << "Calling SampleSecondaries() of G4LivermorePolarizedGammaConversionModel" << G4endl;
294 
295  G4double photonEnergy = aDynamicGamma->GetKineticEnergy();
296  // Within energy limit?
297 
298  if(photonEnergy <= lowEnergyLimit)
299  {
302  return;
303  }
304 
305 
306  G4ThreeVector gammaPolarization0 = aDynamicGamma->GetPolarization();
307  G4ThreeVector gammaDirection0 = aDynamicGamma->GetMomentumDirection();
308 
309  // Make sure that the polarization vector is perpendicular to the
310  // gamma direction. If not
311 
312  if(!(gammaPolarization0.isOrthogonal(gammaDirection0, 1e-6))||(gammaPolarization0.mag()==0))
313  { // only for testing now
314  gammaPolarization0 = GetRandomPolarization(gammaDirection0);
315  }
316  else
317  {
318  if ( gammaPolarization0.howOrthogonal(gammaDirection0) != 0)
319  {
320  gammaPolarization0 = GetPerpendicularPolarization(gammaDirection0, gammaPolarization0);
321  }
322  }
323 
324  // End of Protection
325 
326 
327  G4double epsilon ;
328  G4double epsilon0Local = electron_mass_c2 / photonEnergy ;
329 
330  // Do it fast if photon energy < 2. MeV
331 
332  if (photonEnergy < smallEnergy )
333  {
334  epsilon = epsilon0Local + (0.5 - epsilon0Local) * G4UniformRand();
335  }
336  else
337  {
338 
339  // Select randomly one element in the current material
340 
341  const G4ParticleDefinition* particle = aDynamicGamma->GetDefinition();
342  const G4Element* element = SelectRandomAtom(couple,particle,photonEnergy);
343 
344 
345  if (element == 0)
346  {
347  G4cout << "G4LivermorePolarizedGammaConversionModel::SampleSecondaries - element = 0" << G4endl;
348  return;
349  }
350 
351 
352  G4IonisParamElm* ionisation = element->GetIonisation();
353 
354  if (ionisation == 0)
355  {
356  G4cout << "G4LivermorePolarizedGammaConversionModel::SampleSecondaries - ionisation = 0" << G4endl;
357  return;
358  }
359 
360  // Extract Coulomb factor for this Element
361 
362  G4double fZ = 8. * (ionisation->GetlogZ3());
363  if (photonEnergy > 50. * MeV) fZ += 8. * (element->GetfCoulomb());
364 
365  // Limits of the screening variable
366  G4double screenFactor = 136. * epsilon0Local / (element->GetIonisation()->GetZ3()) ;
367  G4double screenMax = exp ((42.24 - fZ)/8.368) - 0.952 ;
368  G4double screenMin = std::min(4.*screenFactor,screenMax) ;
369 
370  // Limits of the energy sampling
371  G4double epsilon1 = 0.5 - 0.5 * sqrt(1. - screenMin / screenMax) ;
372  G4double epsilonMin = std::max(epsilon0Local,epsilon1);
373  G4double epsilonRange = 0.5 - epsilonMin ;
374 
375  // Sample the energy rate of the created electron (or positron)
376  G4double screen;
377  G4double gReject ;
378 
379  G4double f10 = ScreenFunction1(screenMin) - fZ;
380  G4double f20 = ScreenFunction2(screenMin) - fZ;
381  G4double normF1 = std::max(f10 * epsilonRange * epsilonRange,0.);
382  G4double normF2 = std::max(1.5 * f20,0.);
383 
384  do {
385  if (normF1 / (normF1 + normF2) > G4UniformRand() )
386  {
387  epsilon = 0.5 - epsilonRange * pow(G4UniformRand(), 0.3333) ;
388  screen = screenFactor / (epsilon * (1. - epsilon));
389  gReject = (ScreenFunction1(screen) - fZ) / f10 ;
390  }
391  else
392  {
393  epsilon = epsilonMin + epsilonRange * G4UniformRand();
394  screen = screenFactor / (epsilon * (1 - epsilon));
395  gReject = (ScreenFunction2(screen) - fZ) / f20 ;
396 
397 
398  }
399  } while ( gReject < G4UniformRand() );
400 
401  } // End of epsilon sampling
402 
403  // Fix charges randomly
404 
405  G4double electronTotEnergy;
406  G4double positronTotEnergy;
407 
408 
409  // if (G4int(2*G4UniformRand()))
410  if (G4UniformRand() > 0.5)
411  {
412  electronTotEnergy = (1. - epsilon) * photonEnergy;
413  positronTotEnergy = epsilon * photonEnergy;
414  }
415  else
416  {
417  positronTotEnergy = (1. - epsilon) * photonEnergy;
418  electronTotEnergy = epsilon * photonEnergy;
419  }
420 
421  // Scattered electron (positron) angles. ( Z - axis along the parent photon)
422  // Universal distribution suggested by L. Urban (Geant3 manual (1993) Phys211),
423  // derived from Tsai distribution (Rev. Mod. Phys. 49, 421 (1977)
424 
425 /*
426  G4double u;
427  const G4double a1 = 0.625;
428  G4double a2 = 3. * a1;
429 
430  if (0.25 > G4UniformRand())
431  {
432  u = - log(G4UniformRand() * G4UniformRand()) / a1 ;
433  }
434  else
435  {
436  u = - log(G4UniformRand() * G4UniformRand()) / a2 ;
437  }
438 */
439 
440  G4double Ene = electronTotEnergy/electron_mass_c2; // Normalized energy
441 
442  G4double cosTheta = 0.;
443  G4double sinTheta = 0.;
444 
445  SetTheta(&cosTheta,&sinTheta,Ene);
446 
447  // G4double theta = u * electron_mass_c2 / photonEnergy ;
448  // G4double phi = twopi * G4UniformRand() ;
449 
450  G4double phi,psi=0.;
451 
452  //corrected e+ e- angular angular distribution //preliminary!
453 
454  // if(photonEnergy>50*MeV)
455  // {
456  phi = SetPhi(photonEnergy);
457  psi = SetPsi(photonEnergy,phi);
458  // }
459  //else
460  // {
461  //psi = G4UniformRand()*2.*pi;
462  //phi = pi; // coplanar
463  // }
464 
465  Psi = psi;
466  Phi = phi;
467  //G4cout << "PHI " << phi << G4endl;
468  //G4cout << "PSI " << psi << G4endl;
469 
470  G4double phie, phip;
471  G4double choice, choice2;
472  choice = G4UniformRand();
473  choice2 = G4UniformRand();
474 
475  if (choice2 <= 0.5)
476  {
477  // do nothing
478  // phi = phi;
479  }
480  else
481  {
482  phi = -phi;
483  }
484 
485  if (choice <= 0.5)
486  {
487  phie = psi; //azimuthal angle for the electron
488  phip = phie+phi; //azimuthal angle for the positron
489  }
490  else
491  {
492  // opzione 1 phie / phip equivalenti
493 
494  phip = psi; //azimuthal angle for the positron
495  phie = phip + phi; //azimuthal angle for the electron
496  }
497 
498 
499  // Electron Kinematics
500 
501  G4double dirX = sinTheta*cos(phie);
502  G4double dirY = sinTheta*sin(phie);
503  G4double dirZ = cosTheta;
504  G4ThreeVector electronDirection(dirX,dirY,dirZ);
505 
506  // Kinematics of the created pair:
507  // the electron and positron are assumed to have a symetric angular
508  // distribution with respect to the Z axis along the parent photon
509 
510  //G4double localEnergyDeposit = 0. ;
511 
512  G4double electronKineEnergy = std::max(0.,electronTotEnergy - electron_mass_c2) ;
513 
514  SystemOfRefChange(gammaDirection0,electronDirection,
515  gammaPolarization0);
516 
518  electronDirection,
519  electronKineEnergy);
520 
521  // The e+ is always created (even with kinetic energy = 0) for further annihilation
522 
523  Ene = positronTotEnergy/electron_mass_c2; // Normalized energy
524 
525  cosTheta = 0.;
526  sinTheta = 0.;
527 
528  SetTheta(&cosTheta,&sinTheta,Ene);
529 
530  // Positron Kinematics
531 
532  dirX = sinTheta*cos(phip);
533  dirY = sinTheta*sin(phip);
534  dirZ = cosTheta;
535  G4ThreeVector positronDirection(dirX,dirY,dirZ);
536 
537  G4double positronKineEnergy = std::max(0.,positronTotEnergy - electron_mass_c2) ;
538  SystemOfRefChange(gammaDirection0,positronDirection,
539  gammaPolarization0);
540 
541  // Create G4DynamicParticle object for the particle2
543  positronDirection, positronKineEnergy);
544 
545 
546  fvect->push_back(particle1);
547  fvect->push_back(particle2);
548 
549 
550 
551  // Kill the incident photon
552 
553 
554 
555  // Create lists of pointers to DynamicParticles (photons and electrons)
556  // (Is the electron vector necessary? To be checked)
557  // std::vector<G4DynamicParticle*>* photonVector = 0;
558  //std::vector<G4DynamicParticle*> electronVector;
559 
563 
564 }
565 
566 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
567 
569 {
570  // Compute the value of the screening function 3*phi1 - phi2
571 
572  G4double value;
573 
574  if (screenVariable > 1.)
575  value = 42.24 - 8.368 * log(screenVariable + 0.952);
576  else
577  value = 42.392 - screenVariable * (7.796 - 1.961 * screenVariable);
578 
579  return value;
580 }
581 
582 
583 
585 {
586  // Compute the value of the screening function 1.5*phi1 - 0.5*phi2
587 
588  G4double value;
589 
590  if (screenVariable > 1.)
591  value = 42.24 - 8.368 * log(screenVariable + 0.952);
592  else
593  value = 41.405 - screenVariable * (5.828 - 0.8945 * screenVariable);
594 
595  return value;
596 }
597 
598 
600 {
601 
602  // to avoid computational errors since Theta could be very small
603  // Energy in Normalized Units (!)
604 
605  G4double Momentum = sqrt(Energy*Energy -1);
606  G4double Rand = G4UniformRand();
607 
608  *p_cosTheta = (Energy*((2*Rand)- 1) + Momentum)/((Momentum*(2*Rand-1))+Energy);
609  *p_sinTheta = (2*sqrt(Rand*(1-Rand)))/(Momentum*(2*Rand-1)+Energy);
610 }
611 
612 
613 
615 {
616 
617 
618  G4double value = 0.;
619  G4double Ene = Energy/MeV;
620 
621  G4double pl[4];
622 
623 
624  G4double pt[2];
625  G4double xi = 0;
626  G4double xe = 0.;
627  G4double n1=0.;
628  G4double n2=0.;
629 
630 
631  if (Ene>=50.)
632  {
633  const G4double ay0=5.6, by0=18.6, aa0=2.9, ba0 = 8.16E-3;
634  const G4double aw = 0.0151, bw = 10.7, cw = -410.;
635 
636  const G4double axc = 3.1455, bxc = -1.11, cxc = 310.;
637 
638  pl[0] = Fln(ay0,by0,Ene);
639  pl[1] = aa0 + ba0*(Ene);
640  pl[2] = Poli(aw,bw,cw,Ene);
641  pl[3] = Poli(axc,bxc,cxc,Ene);
642 
643  const G4double abf = 3.1216, bbf = 2.68;
644  pt[0] = -1.4;
645  pt[1] = abf + bbf/Ene;
646 
647 
648 
649  //G4cout << "PL > 50. "<< pl[0] << " " << pl[1] << " " << pl[2] << " " <<pl[3] << " " << G4endl;
650 
651  xi = 3.0;
652  xe = Encu(pl,pt,xi);
653  //G4cout << "ENCU "<< xe << G4endl;
654  n1 = Fintlor(pl,pi) - Fintlor(pl,xe);
655  n2 = Finttan(pt,xe) - Finttan(pt,0.);
656  }
657  else
658  {
659  const G4double ay0=0.144, by0=0.11;
660  const G4double aa0=2.7, ba0 = 2.74;
661  const G4double aw = 0.21, bw = 10.8, cw = -58.;
662  const G4double axc = 3.17, bxc = -0.87, cxc = -6.;
663 
664  pl[0] = Fln(ay0, by0, Ene);
665  pl[1] = Fln(aa0, ba0, Ene);
666  pl[2] = Poli(aw,bw,cw,Ene);
667  pl[3] = Poli(axc,bxc,cxc,Ene);
668 
669  //G4cout << "PL < 50."<< pl[0] << " " << pl[1] << " " << pl[2] << " " <<pl[3] << " " << G4endl;
670  //G4cout << "ENCU "<< xe << G4endl;
671  n1 = Fintlor(pl,pi) - Fintlor(pl,xe);
672 
673  }
674 
675 
676  G4double n=0.;
677  n = n1+n2;
678 
679  G4double c1 = 0.;
680  c1 = Glor(pl, xe);
681 
682 /*
683  G4double xm = 0.;
684  xm = Flor(pl,pl[3])*Glor(pl,pl[3]);
685 */
686 
687  G4double r1,r2,r3;
688  G4double xco=0.;
689 
690  if (Ene>=50.)
691  {
692  r1= G4UniformRand();
693  if( r1>=n2/n)
694  {
695  do
696  {
697  r2 = G4UniformRand();
698  value = Finvlor(pl,xe,r2);
699  xco = Glor(pl,value)/c1;
700  r3 = G4UniformRand();
701  } while(r3>=xco);
702  }
703  else
704  {
705  value = Finvtan(pt,n,r1);
706  }
707  }
708  else
709  {
710  do
711  {
712  r2 = G4UniformRand();
713  value = Finvlor(pl,xe,r2);
714  xco = Glor(pl,value)/c1;
715  r3 = G4UniformRand();
716  } while(r3>=xco);
717  }
718 
719  // G4cout << "PHI = " <<value << G4endl;
720  return value;
721 }
723 {
724 
725  G4double value = 0.;
726  G4double Ene = Energy/MeV;
727 
728  G4double p0l[4];
729  G4double ppml[4];
730  G4double p0t[2];
731  G4double ppmt[2];
732 
733  G4double xi = 0.;
734  G4double xe0 = 0.;
735  G4double xepm = 0.;
736 
737  if (Ene>=50.)
738  {
739  const G4double ay00 = 3.4, by00 = 9.8, aa00 = 1.34, ba00 = 5.3;
740  const G4double aw0 = 0.014, bw0 = 9.7, cw0 = -2.E4;
741  const G4double axc0 = 3.1423, bxc0 = -2.35, cxc0 = 0.;
742  const G4double ay0p = 1.53, by0p = 3.2, aap = 0.67, bap = 8.5E-3;
743  const G4double awp = 6.9E-3, bwp = 12.6, cwp = -3.8E4;
744  const G4double axcp = 2.8E-3,bxcp = -3.133;
745  const G4double abf0 = 3.1213, bbf0 = 2.61;
746  const G4double abfpm = 3.1231, bbfpm = 2.84;
747 
748  p0l[0] = Fln(ay00, by00, Ene);
749  p0l[1] = Fln(aa00, ba00, Ene);
750  p0l[2] = Poli(aw0, bw0, cw0, Ene);
751  p0l[3] = Poli(axc0, bxc0, cxc0, Ene);
752 
753  ppml[0] = Fln(ay0p, by0p, Ene);
754  ppml[1] = aap + bap*(Ene);
755  ppml[2] = Poli(awp, bwp, cwp, Ene);
756  ppml[3] = Fln(axcp,bxcp,Ene);
757 
758  p0t[0] = -0.81;
759  p0t[1] = abf0 + bbf0/Ene;
760  ppmt[0] = -0.6;
761  ppmt[1] = abfpm + bbfpm/Ene;
762 
763  //G4cout << "P0L > 50"<< p0l[0] << " " << p0l[1] << " " << p0l[2] << " " <<p0l[3] << " " << G4endl;
764  //G4cout << "PPML > 50"<< ppml[0] << " " << ppml[1] << " " << ppml[2] << " " <<ppml[3] << " " << G4endl;
765 
766  xi = 3.0;
767  xe0 = Encu(p0l, p0t, xi);
768  //G4cout << "ENCU1 "<< xe0 << G4endl;
769  xepm = Encu(ppml, ppmt, xi);
770  //G4cout << "ENCU2 "<< xepm << G4endl;
771  }
772  else
773  {
774  const G4double ay00 = 2.82, by00 = 6.35;
775  const G4double aa00 = -1.75, ba00 = 0.25;
776 
777  const G4double aw0 = 0.028, bw0 = 5., cw0 = -50.;
778  const G4double axc0 = 3.14213, bxc0 = -2.3, cxc0 = 5.7;
779  const G4double ay0p = 1.56, by0p = 3.6;
780  const G4double aap = 0.86, bap = 8.3E-3;
781  const G4double awp = 0.022, bwp = 7.4, cwp = -51.;
782  const G4double xcp = 3.1486;
783 
784  p0l[0] = Fln(ay00, by00, Ene);
785  p0l[1] = aa00+pow(Ene, ba00);
786  p0l[2] = Poli(aw0, bw0, cw0, Ene);
787  p0l[3] = Poli(axc0, bxc0, cxc0, Ene);
788  ppml[0] = Fln(ay0p, by0p, Ene);
789  ppml[1] = aap + bap*(Ene);
790  ppml[2] = Poli(awp, bwp, cwp, Ene);
791  ppml[3] = xcp;
792 
793  }
794 
795  G4double a,b=0.;
796 
797  if (Ene>=50.)
798  {
799  if (PhiLocal>xepm)
800  {
801  b = (ppml[0]+2*ppml[1]*ppml[2]*Flor(ppml,PhiLocal));
802  }
803  else
804  {
805  b = Ftan(ppmt,PhiLocal);
806  }
807  if (PhiLocal>xe0)
808  {
809  a = (p0l[0]+2*p0l[1]*p0l[2]*Flor(p0l,PhiLocal));
810  }
811  else
812  {
813  a = Ftan(p0t,PhiLocal);
814  }
815  }
816  else
817  {
818  b = (ppml[0]+2*ppml[1]*ppml[2]*Flor(ppml,PhiLocal));
819  a = (p0l[0]+2*p0l[1]*p0l[2]*Flor(p0l,PhiLocal));
820  }
821  G4double nr =0.;
822 
823  if (b>a)
824  {
825  nr = 1./b;
826  }
827  else
828  {
829  nr = 1./a;
830  }
831 
832  G4double r1,r2=0.;
833  G4double r3 =-1.;
834  do
835  {
836  r1 = G4UniformRand();
837  r2 = G4UniformRand();
838  //value = r2*pi;
839  value = 2.*r2*pi;
840  r3 = nr*(a*cos(value)*cos(value) + b*sin(value)*sin(value));
841  }while(r1>r3);
842 
843  return value;
844 }
845 
846 
849 {
850  G4double value=0.;
851  if(x>0.)
852  {
853  value =(a + b/x + c/(x*x*x));
854  }
855  else
856  {
857  //G4cout << "ERROR in Poli! " << G4endl;
858  }
859  return value;
860 }
863 {
864  G4double value=0.;
865  if(x>0.)
866  {
867  value =(a*log(x)-b);
868  }
869  else
870  {
871  //G4cout << "ERROR in Fln! " << G4endl;
872  }
873  return value;
874 }
875 
876 
878 (G4double* p_p1, G4double* p_p2, G4double x0)
879 {
880  G4int i=0;
881  G4double fx = 1.;
882  G4double x = x0;
883  const G4double xmax = 3.0;
884 
885  for(i=0; i<100; ++i)
886  {
887  fx = (Flor(p_p1,x)*Glor(p_p1,x) - Ftan(p_p2, x))/
888  (Fdlor(p_p1,x) - Fdtan(p_p2,x));
889  x -= fx;
890  if(x > xmax) { return xmax; }
891  // x -= (Flor(p_p1, x)*Glor(p_p1,x) - Ftan(p_p2, x))/
892  // (Fdlor(p_p1,x) - Fdtan(p_p2,x));
893  // fx = Flor(p_p1,x)*Glor(p_p1,x) - Ftan(p_p2, x);
894  // G4cout << std::fabs(fx) << " " << i << " " << x << "dentro ENCU " << G4endl;
895  if(std::fabs(fx) <= x*1.0e-6) { break; }
896  }
897 
898  if(x < 0.0) { x = 0.0; }
899  return x;
900 }
901 
902 
904 {
905  G4double value =0.;
906  // G4double y0 = p_p1[0];
907  // G4double A = p_p1[1];
908  G4double w = p_p1[2];
909  G4double xc = p_p1[3];
910 
911  value = 1./(pi*(w*w + 4.*(x-xc)*(x-xc)));
912  return value;
913 }
914 
915 
917 {
918  G4double value =0.;
919  G4double y0 = p_p1[0];
920  G4double A = p_p1[1];
921  G4double w = p_p1[2];
922  G4double xc = p_p1[3];
923 
924  value = (y0 *pi*(w*w + 4.*(x-xc)*(x-xc)) + 2.*A*w);
925  return value;
926 }
927 
928 
930 {
931  G4double value =0.;
932  //G4double y0 = p_p1[0];
933  G4double A = p_p1[1];
934  G4double w = p_p1[2];
935  G4double xc = p_p1[3];
936 
937  value = (-16.*A*w*(x-xc))/
938  (pi*(w*w+4.*(x-xc)*(x-xc))*(w*w+4.*(x-xc)*(x-xc)));
939  return value;
940 }
941 
942 
944 {
945  G4double value =0.;
946  G4double y0 = p_p1[0];
947  G4double A = p_p1[1];
948  G4double w = p_p1[2];
949  G4double xc = p_p1[3];
950 
951  value = y0*x + A*atan( 2*(x-xc)/w) / pi;
952  return value;
953 }
954 
955 
957 {
958  G4double value = 0.;
959  G4double nor = 0.;
960  //G4double y0 = p_p1[0];
961  // G4double A = p_p1[1];
962  G4double w = p_p1[2];
963  G4double xc = p_p1[3];
964 
965  nor = atan(2.*(pi-xc)/w)/(2.*pi*w) - atan(2.*(x-xc)/w)/(2.*pi*w);
966  value = xc - (w/2.)*tan(-2.*r*nor*pi*w+atan(2*(xc-x)/w));
967 
968  return value;
969 }
970 
971 
973 {
974  G4double value =0.;
975  G4double a = p_p1[0];
976  G4double b = p_p1[1];
977 
978  value = a /(x-b);
979  return value;
980 }
981 
982 
984 {
985  G4double value =0.;
986  G4double a = p_p1[0];
987  G4double b = p_p1[1];
988 
989  value = -1.*a / ((x-b)*(x-b));
990  return value;
991 }
992 
993 
995 {
996  G4double value =0.;
997  G4double a = p_p1[0];
998  G4double b = p_p1[1];
999 
1000 
1001  value = a*log(b-x);
1002  return value;
1003 }
1004 
1005 
1007 {
1008  G4double value =0.;
1009  G4double a = p_p1[0];
1010  G4double b = p_p1[1];
1011 
1012  value = b*(1-exp(r*cnor/a));
1013 
1014  return value;
1015 }
1016 
1017 
1018 
1019 
1020 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1021 
1023 {
1024  G4double dx = a.x();
1025  G4double dy = a.y();
1026  G4double dz = a.z();
1027  G4double x = dx < 0.0 ? -dx : dx;
1028  G4double y = dy < 0.0 ? -dy : dy;
1029  G4double z = dz < 0.0 ? -dz : dz;
1030  if (x < y) {
1031  return x < z ? G4ThreeVector(-dy,dx,0) : G4ThreeVector(0,-dz,dy);
1032  }else{
1033  return y < z ? G4ThreeVector(dz,0,-dx) : G4ThreeVector(-dy,dx,0);
1034  }
1035 }
1036 
1037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1038 
1040 {
1041  G4ThreeVector d0 = direction0.unit();
1042  G4ThreeVector a1 = SetPerpendicularVector(d0); //different orthogonal
1043  G4ThreeVector a0 = a1.unit(); // unit vector
1044 
1045  G4double rand1 = G4UniformRand();
1046 
1047  G4double angle = twopi*rand1; // random polar angle
1048  G4ThreeVector b0 = d0.cross(a0); // cross product
1049 
1050  G4ThreeVector c;
1051 
1052  c.setX(std::cos(angle)*(a0.x())+std::sin(angle)*b0.x());
1053  c.setY(std::cos(angle)*(a0.y())+std::sin(angle)*b0.y());
1054  c.setZ(std::cos(angle)*(a0.z())+std::sin(angle)*b0.z());
1055 
1056  G4ThreeVector c0 = c.unit();
1057 
1058  return c0;
1059 
1060 }
1061 
1062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1063 
1065 (const G4ThreeVector& gammaDirection, const G4ThreeVector& gammaPolarization) const
1066 {
1067 
1068  //
1069  // The polarization of a photon is always perpendicular to its momentum direction.
1070  // Therefore this function removes those vector component of gammaPolarization, which
1071  // points in direction of gammaDirection
1072  //
1073  // Mathematically we search the projection of the vector a on the plane E, where n is the
1074  // plains normal vector.
1075  // The basic equation can be found in each geometry book (e.g. Bronstein):
1076  // p = a - (a o n)/(n o n)*n
1077 
1078  return gammaPolarization - gammaPolarization.dot(gammaDirection)/gammaDirection.dot(gammaDirection) * gammaDirection;
1079 }
1080 
1081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1082 
1083 
1085  (G4ThreeVector& direction0,G4ThreeVector& direction1,
1086  G4ThreeVector& polarization0)
1087 {
1088  // direction0 is the original photon direction ---> z
1089  // polarization0 is the original photon polarization ---> x
1090  // need to specify y axis in the real reference frame ---> y
1091  G4ThreeVector Axis_Z0 = direction0.unit();
1092  G4ThreeVector Axis_X0 = polarization0.unit();
1093  G4ThreeVector Axis_Y0 = (Axis_Z0.cross(Axis_X0)).unit(); // to be confirmed;
1094 
1095  G4double direction_x = direction1.getX();
1096  G4double direction_y = direction1.getY();
1097  G4double direction_z = direction1.getZ();
1098 
1099  direction1 = (direction_x*Axis_X0 + direction_y*Axis_Y0 + direction_z*Axis_Z0).unit();
1100 
1101 }
1102 
1103 
1104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
1105 
1106 #include "G4AutoLock.hh"
1107 namespace { G4Mutex LivermorePolarizedGammaConversionModelMutex = G4MUTEX_INITIALIZER; }
1108 
1110  const G4ParticleDefinition*,
1111  G4int Z)
1112 {
1113  G4AutoLock l(&LivermorePolarizedGammaConversionModelMutex);
1114  // G4cout << "G4LivermorePolarizedGammaConversionModel::InitialiseForElement Z= "
1115  // << Z << G4endl;
1116  if(!data[Z]) { ReadData(Z); }
1117  l.unlock();
1118 }
G4double Poli(G4double, G4double, G4double, G4double)
const G4double a0
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
G4double LowEnergyLimit() const
Definition: G4VEmModel.hh:641
G4LivermorePolarizedGammaConversionModel(const G4ParticleDefinition *p=0, const G4String &nam="LivermorePolarizedGammaConversion")
static const double MeV
Definition: G4SIunits.hh:211
std::vector< G4Element * > G4ElementVector
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetKineticEnergy() const
CLHEP::Hep3Vector G4ThreeVector
void InitialiseElementSelectors(const G4ParticleDefinition *, const G4DataVector &)
Definition: G4VEmModel.cc:148
G4double HighEnergyLimit() const
Definition: G4VEmModel.hh:634
G4double z
Definition: TRTMaterials.hh:39
static const G4double a1
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
const G4double w[NPOINTSGL]
G4bool IsMaster() const
Definition: G4VEmModel.hh:718
G4double GetfCoulomb() const
Definition: G4Element.hh:190
G4ParticleDefinition * GetDefinition() const
G4double a
Definition: TRTMaterials.hh:39
size_t GetVectorLength() const
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:175
void SetSpline(G4bool)
G4ThreeVector GetPerpendicularPolarization(const G4ThreeVector &direction0, const G4ThreeVector &polarization0) const
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
const G4ThreeVector & GetMomentumDirection() const
static const double twopi
Definition: G4SIunits.hh:75
static const double GeV
Definition: G4SIunits.hh:214
const G4int n
static const G4double c1
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel)
std::vector< G4EmElementSelector * > * GetElementSelectors()
Definition: G4VEmModel.hh:802
G4double Value(G4double theEnergy, size_t &lastidx) const
G4double GetlogZ3() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SystemOfRefChange(G4ThreeVector &direction0, G4ThreeVector &direction1, G4ThreeVector &polarization0)
static G4ProductionCutsTable * GetProductionCutsTable()
G4int G4Mutex
Definition: G4Threading.hh:173
static G4Positron * Positron()
Definition: G4Positron.cc:94
void SetElementSelectors(std::vector< G4EmElementSelector * > *)
Definition: G4VEmModel.hh:810
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
static const double pi
Definition: G4SIunits.hh:74
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static const G4double c0
const G4double x[NPOINTSGL]
G4IonisParamElm * GetIonisation() const
Definition: G4Element.hh:198
const G4ThreeVector & GetPolarization() const
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static G4Electron * Electron()
Definition: G4Electron.cc:94
void SetProposedKineticEnergy(G4double proposedKinEnergy)
#define G4endl
Definition: G4ios.hh:61
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
double G4double
Definition: G4Types.hh:76
void ProposeTrackStatus(G4TrackStatus status)
virtual G4double MinPrimaryEnergy(const G4Material *, const G4ParticleDefinition *, G4double)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
static const G4double b0
G4double GetZ3() const
G4ThreeVector GetRandomPolarization(G4ThreeVector &direction0)
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
double epsilon(double density, double temperature)
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
Definition: G4VEmModel.hh:544
G4ParticleChangeForGamma * GetParticleChangeForGamma()
Definition: G4VEmModel.cc:134
const G4Material * GetMaterial() const