source: trunk/source/processes/electromagnetic/lowenergy/src/G4PenelopeBremsstrahlungAngular.cc @ 1348

Last change on this file since 1348 was 1347, checked in by garnier, 14 years ago

geant4 tag 9.4

File size: 7.9 KB
Line 
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: G4PenelopeBremsstrahlungAngular.cc,v 1.10 2010/12/01 15:20:20 pandola Exp $
27// GEANT4 tag $Name: geant4-09-04-ref-00 $
28//
29// --------------------------------------------------------------
30//
31// File name:     G4PenelopeBremsstrahlungAngular
32//
33// Author:        Luciano Pandola
34//
35// Creation date: February 2003
36//
37// History:
38// -----------
39// 04 Feb 2003  L. Pandola       1st implementation
40// 19 Mar 2003  L. Pandola       Bugs fixed
41// 07 Nov 2003  L. Pandola       Added GetAtomicNumber method for testing
42//                               purposes
43//----------------------------------------------------------------
44
45#include "G4PenelopeBremsstrahlungAngular.hh"
46#include "G4PenelopeInterpolator.hh"
47#include "Randomize.hh"
48#include "globals.hh"
49
50G4PenelopeBremsstrahlungAngular::G4PenelopeBremsstrahlungAngular (G4int Zed)
51  : Zmat(Zed)
52{
53  InterpolationTableForZ();
54  InterpolationForK();
55}
56
57
58G4PenelopeBremsstrahlungAngular::~G4PenelopeBremsstrahlungAngular()
59{
60}
61
62G4int G4PenelopeBremsstrahlungAngular::GetAtomicNumber()
63{
64  return Zmat;
65}
66
67void G4PenelopeBremsstrahlungAngular::InterpolationTableForZ()
68{
69  G4double pZ[NumberofZPoints] = {2.0,8.0,13.0,47.0,79.0,92.0};
70  G4double pX[NumberofZPoints],pY[NumberofZPoints];
71  G4double QQ1[NumberofZPoints][NumberofEPoints][NumberofKPoints];
72  G4double QQ2[NumberofZPoints][NumberofEPoints][NumberofKPoints];
73 
74  //Read information from DataBase file
75  char* path = getenv("G4LEDATA");
76  if (!path)
77    {
78      G4String excep = "G4PenelopeBremsstrahlungAngular - G4LEDATA environment variable not set!";
79      G4Exception(excep);
80      return;
81    }
82  G4String pathString(path);
83  G4String pathFile = pathString + "/penelope/br-ang-pen.dat";
84  std::ifstream file(pathFile);
85  std::filebuf* lsdp = file.rdbuf();
86 
87  if (!(lsdp->is_open()))
88    {
89      G4String excep = "G4PenelopeBremsstrahlungAngular - data file " + pathFile + " not found!";
90      G4Exception(excep);
91    }
92  G4int i=0,j=0,k=0; // i=index for Z, j=index for E, k=index for K
93  G4double a1,a2;
94  while(i != -1) {
95    file >> i >> j >> k >> a1 >> a2; 
96    if (i > -1 && j > -1 && k >- 1)
97      {
98        QQ1[i][j][k]=a1;
99        QQ2[i][j][k]=a2;
100      }
101  } 
102  file.close();
103 
104
105  //Interpolation in Z
106  for (i=0;i<NumberofEPoints;i++){
107    for (j=0;j<NumberofKPoints;j++){
108      for (k=0;k<NumberofZPoints;k++){
109        pX[k]=std::log(QQ1[k][i][j]);
110        pY[k]=QQ2[k][i][j];
111      }
112      G4PenelopeInterpolator* interpolator1 = new G4PenelopeInterpolator(pZ,pX,NumberofZPoints);
113      Q1[i][j]=std::exp(interpolator1->CubicSplineInterpolation((G4double) Zmat));
114      delete interpolator1;
115      G4PenelopeInterpolator* interpolator2 = new G4PenelopeInterpolator(pZ,pY,NumberofZPoints);   
116      Q2[i][j]=interpolator2->CubicSplineInterpolation((G4double) Zmat);
117      delete interpolator2;
118    }
119  }
120 
121 
122  //std::ofstream fil("matrice.dat",std::ios::app);
123  //fil << "Numero atomico: " << Zmat << G4endl;
124  //for (i=0;i<NumberofEPoints;i++)
125  //{
126  //  fil << Q1[i][0] << " " << Q1[i][1] << " " << Q1[i][2] << " " << Q1[i][3] << G4endl;
127  //}
128  //fil.close();
129 
130}
131
132void G4PenelopeBremsstrahlungAngular::InterpolationForK()
133{
134  G4double pE[NumberofEPoints] = {1.0e-03,5.0e-03,1.0e-02,5.0e-02,1.0e-01,5.0e-01};
135  G4double pK[NumberofKPoints] = {0.0,0.6,0.8,0.95};
136  G4double ppK[reducedEnergyGrid];
137  G4double pX[NumberofKPoints];
138  G4int i,j;
139
140  for(i=0;i<reducedEnergyGrid;i++){
141    ppK[i]=((G4double) i) * 0.05;
142  }
143
144  for(i=0;i<NumberofEPoints;i++){
145    betas[i]=std::sqrt(pE[i]*(pE[i]+2*electron_mass_c2))/(pE[i]+electron_mass_c2);
146  }
147
148  for (i=0;i<NumberofEPoints;i++){
149    for (j=0;j<NumberofKPoints;j++){
150      Q1[i][j]=Q1[i][j]/((G4double) Zmat);
151    }
152  }
153
154  //Expanded table of distribution parameters
155  for (i=0;i<NumberofEPoints;i++){
156    for (j=0;j<NumberofKPoints;j++){
157      pX[j]=std::log(Q1[i][j]); //logarithmic
158    }
159    G4PenelopeInterpolator* interpolator = new G4PenelopeInterpolator(pK,pX,NumberofKPoints);
160    for (j=0;j<reducedEnergyGrid;j++){
161      Q1E[i][j]=interpolator->CubicSplineInterpolation(ppK[j]);
162    }
163    delete interpolator;
164    for (j=0;j<NumberofKPoints;j++){
165      pX[j]=Q2[i][j];
166    }
167    G4PenelopeInterpolator* interpolator2 = new G4PenelopeInterpolator(pK,pX,NumberofKPoints);
168    for (j=0;j<reducedEnergyGrid;j++){
169      Q2E[i][j]=interpolator2->CubicSplineInterpolation(ppK[j]);
170    }
171    delete interpolator2;
172  }
173}
174
175G4double G4PenelopeBremsstrahlungAngular::ExtractCosTheta(G4double e1,G4double e2)
176{
177  //e1 = kinetic energy of the electron
178  //e2 = energy of the bremsstrahlung photon
179
180  G4double beta = std::sqrt(e1*(e1+2*electron_mass_c2))/(e1+electron_mass_c2);
181 
182
183
184  G4double RK=20.0*e2/e1;
185  G4int ik=std::min((G4int) RK,19);
186 
187  G4double P10=0,P11=0,P1=0;
188  G4double P20=0,P21=0,P2=0;
189  G4double pX[NumberofEPoints];
190  //First coefficient
191  G4int i;
192  G4int j = ik;
193  for (i=0;i<NumberofEPoints;i++){
194    pX[i]=Q1E[i][j];
195  }
196  G4PenelopeInterpolator* interpolator = new G4PenelopeInterpolator(betas,pX,NumberofEPoints);
197  P10=interpolator->CubicSplineInterpolation(beta);
198  delete interpolator;
199  j++; //(j=ik+1)
200  for (i=0;i<NumberofEPoints;i++){
201    pX[i]=Q1E[i][j];
202  }
203  G4PenelopeInterpolator* interpolator2 = new G4PenelopeInterpolator(betas,pX,NumberofEPoints);
204  P11=interpolator2->CubicSplineInterpolation(beta);
205  delete interpolator2;
206  P1=P10+(RK-(G4double) ik)*(P11-P10);
207 
208  //Second coefficient
209  j = ik;
210  for (i=0;i<NumberofEPoints;i++){
211    pX[i]=Q2E[i][j];
212  }
213  G4PenelopeInterpolator* interpolator3 = new G4PenelopeInterpolator(betas,pX,NumberofEPoints);
214  P20=interpolator3->CubicSplineInterpolation(beta);
215  delete interpolator3;
216  j++; //(j=ik+1)
217  for (i=0;i<NumberofEPoints;i++){
218    pX[i]=Q2E[i][j];
219  }
220  G4PenelopeInterpolator* interpolator4 = new G4PenelopeInterpolator(betas,pX,NumberofEPoints);
221  P21=interpolator4->CubicSplineInterpolation(beta);
222  delete interpolator4;
223  P2=P20+(RK-(G4double) ik)*(P21-P20);
224 
225  //Sampling from the Lorenz-trasformed dipole distributions
226  P1=std::min(std::exp(P1)/beta,1.0);
227  G4double betap = std::min(std::max(beta*(1.0+P2/beta),0.0),0.9999);
228 
229  G4double cdt=0,testf=0;
230 
231  if (G4UniformRand() < P1){
232    do{
233      cdt = 2.0*G4UniformRand()-1.0;
234      testf=2.0*G4UniformRand()-(1.0+cdt*cdt);
235    }while(testf>0);
236  }
237  else{
238    do{
239      cdt = 2.0*G4UniformRand()-1.0;
240      testf=G4UniformRand()-(1.0-cdt*cdt);
241    }while(testf>0);
242  }
243  cdt = (cdt+betap)/(1.0+betap*cdt);
244  return cdt;
245}
Note: See TracBrowser for help on using the repository browser.