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 | // |
---|
27 | // G4 Tools program: NuMu DIS(Q2) fixed step integration |
---|
28 | // ..................................................... |
---|
29 | // Created: M.V. Kossov, CERN/ITEP(Moscow), 20-Dec-2005 |
---|
30 | // |
---|
31 | //===================================================================== |
---|
32 | #include "globals.hh" |
---|
33 | #include <iostream> |
---|
34 | #include <fstream> |
---|
35 | #include <vector> |
---|
36 | #include "G4ios.hh" |
---|
37 | //#include <CLHEP/GenericFunctions/LogGamma.hh> |
---|
38 | |
---|
39 | // Calculation of electron spectra integrals for randomization of bound mu->e+nu+nu decay |
---|
40 | |
---|
41 | double espec(double Z , double T) // T=E_kin in MeV |
---|
42 | { |
---|
43 | static double mZ=0.,mp,mc,mep,mem,me,mpp; |
---|
44 | if(Z!=mZ) |
---|
45 | { |
---|
46 | double Z2=Z*Z; |
---|
47 | double Z4=Z2*Z2; |
---|
48 | double az=std::log(Z); |
---|
49 | mZ=Z; |
---|
50 | mp=(11.65+330./Z)/(1.+7.6e-17*Z4*Z4); |
---|
51 | mc=52.83-.2257*az*az; |
---|
52 | mep=.674; |
---|
53 | mem=.1431+Z2/15080.; |
---|
54 | me=5.54*std::exp(-.0327*std::pow(Z,1.241)); |
---|
55 | mpp=2.253*std::exp(-Z2/8922.7); |
---|
56 | G4cout<<"z="<<Z<<":p="<<mp<<",c="<<mc<<",ep="<<mep<<",em="<<mem<<",e="<<me<<",pp="<<mpp |
---|
57 | <<G4endl; |
---|
58 | } |
---|
59 | double p=mp; |
---|
60 | double c=mc; |
---|
61 | double ep=mep; |
---|
62 | double em=mem; |
---|
63 | double e=me; |
---|
64 | double pp=mpp; |
---|
65 | double res=std::pow(T,pp)/(1.+e*std::exp(em*std::pow(T,ep)))/(1.+std::pow(T/c,p)); |
---|
66 | //G4cout<<"T="<<T<<", R="<<.0001389*res<<G4endl; |
---|
67 | return res; |
---|
68 | } |
---|
69 | int main() |
---|
70 | { |
---|
71 | const int niX=201; // number of points for randomization table |
---|
72 | const int liX=niX-1; // the last index for randomization table (?) |
---|
73 | //const int niE=1000000; // number of points for integration table |
---|
74 | const int niE=1000; // number of points for integration table |
---|
75 | // ********************************************************************** |
---|
76 | double Z=20.; // Z of the Element ********************** |
---|
77 | // ********************************************************************** |
---|
78 | double X[niX]; // randomization table |
---|
79 | double in[niE]; // integration table |
---|
80 | double Emax=80.; // Max kin E in MeV |
---|
81 | double dE=Emax/niE; // Step in the integration table |
---|
82 | double spP=0.; // Previous spectrum value [sp(0)=0] |
---|
83 | in[0]=0.; // Not yet normed collected integrals |
---|
84 | double e=0.; // running value of energy |
---|
85 | double inv=0.; // Integral cumulative value |
---|
86 | for(int i=1; i<niE; i++) |
---|
87 | { |
---|
88 | e+=dE; |
---|
89 | double sp=espec(Z,e); |
---|
90 | inv+=spP+sp; // integrate with the Gauss method |
---|
91 | in[i]=inv; |
---|
92 | //G4cout<<"sp="<<sp<<",in[="<<i<<"]="<<inv<<G4endl; |
---|
93 | spP=sp; |
---|
94 | } // End of the big loop over log(E) |
---|
95 | for(int j=1; j<niE; j++) in[j]/=inv; // Normalize the integrals by a unit |
---|
96 | //for(int n=1; n<niE; n++) G4cout<<"1-in["<<n<<"]="<<1.-in[n]<<G4endl; |
---|
97 | double dx=1./liX; // The last in the table is MAXE by definition |
---|
98 | double d=dx; // Start searching with 1, because x(0)=0 |
---|
99 | int m=1; // index in the randomization table |
---|
100 | double oi=0.; // previouse integral value |
---|
101 | X[0]=0.; // Interpolated randomization table (energy) |
---|
102 | e=0.; |
---|
103 | for(int k=1; k<niE; k++) |
---|
104 | { |
---|
105 | e+=dE; |
---|
106 | double ci=in[k]; |
---|
107 | if(ci>=d) |
---|
108 | { |
---|
109 | if(ci==d) X[m]=e; |
---|
110 | else X[m]=e-(ci-d)*dE/(ci-oi); |
---|
111 | m++; |
---|
112 | d+=dx; // start searching for another point |
---|
113 | } |
---|
114 | oi=ci; |
---|
115 | } |
---|
116 | for(int k=0; k<liX; k++) |
---|
117 | { |
---|
118 | G4cout<<X[k]<<","; |
---|
119 | if(!((k+1)%10))G4cout<<G4endl; |
---|
120 | } |
---|
121 | return 0; |
---|
122 | } |
---|