[819] | 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 | // All calculations have been done for C12 nucleus |
---|
| 40 | |
---|
| 41 | double nuE(double E) { return .9673/(1.+.323/E/E)/std::pow(E,.78);} // (E is in GeV) |
---|
| 42 | |
---|
| 43 | double nuX(double E, double r, double p) // (E is in GeV, r=Q2/Q2max, p=1.+nuE(E)) |
---|
| 44 | { |
---|
| 45 | double y=p-r; |
---|
| 46 | double p3=(.3088+.0012352*E)/(1.+1.836/E/E); |
---|
| 47 | return std::pow(y,6)*(r+p3)/(p3*r+1.); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | double anuE(double E) { return .875/(1.+.2977/E/E)/std::pow(E,.78);} // (E is in GeV) |
---|
| 51 | |
---|
| 52 | double anuX(double E, double r, double p) // (E is in GeV, r=Q2/Q2max, p=1+anuE(E)) |
---|
| 53 | { |
---|
| 54 | double E2=E*E; |
---|
| 55 | double y=p-r; |
---|
| 56 | double p3=(13.88+.9373*(1.+.000033*E2)*std::sqrt(E))/(1.+(10.12+1.532/E2)/E); |
---|
| 57 | return std::pow(y,6)*(r+p3)/(p3*r+1.); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | int main() |
---|
| 61 | { |
---|
| 62 | const double eps=.00000001; // relative accuracy of the integral calculation |
---|
| 63 | const double mmu=.105658369; // mu meson mass in GeV |
---|
| 64 | const double mmu2=mmu*mmu; // m_mu^2 in GeV^2 |
---|
| 65 | const double MN=.931494043; // Nucleon mass (inside nucleus, atomic mass unit, GeV) |
---|
| 66 | const double Emin=mmu+mmu2/(MN+MN); // the threshold energy in GeV |
---|
| 67 | const double Emax=390.; // the maximum energy in GeV |
---|
| 68 | const double lEmi=std::log(Emin); // logarithm of the threshold energy in GeV |
---|
| 69 | const double lEma=std::log(Emax); // logarithm of the maximum energy in GeV |
---|
| 70 | const int power=7; // power for the magic variable (E-dependent) |
---|
| 71 | const double pconv=1./power; // conversion power for the magic variable |
---|
| 72 | // ========= |
---|
| 73 | const int niX=20; // number of points for X table |
---|
| 74 | const int liX=niX-1; // the last index for X table |
---|
| 75 | const int niE=20; // number of points for E table |
---|
| 76 | double Xl[niE][niX]; // reversed table |
---|
| 77 | double inl[niE][niX]; // direct table |
---|
| 78 | // ----------------- nu/anu switch ------------------------------ |
---|
| 79 | //bool nu=true; |
---|
| 80 | bool nu=false; |
---|
| 81 | // -------------------------------------------------------------- |
---|
| 82 | double dE=(lEma-lEmi)/niE; |
---|
| 83 | double hE=dE/2; |
---|
| 84 | int ne=0; |
---|
| 85 | for(double len=lEmi+hE; len<lEma; len+=dE) |
---|
| 86 | { |
---|
| 87 | //G4cout<<"log(E)="<<len<<G4endl; |
---|
| 88 | double en=std::exp(len); |
---|
| 89 | double shift=0.; |
---|
| 90 | if(nu) shift=1.+nuE(en); |
---|
| 91 | else shift=1.+anuE(en); |
---|
| 92 | double Xma=std::pow(shift,power); |
---|
| 93 | double Xmi=std::pow((shift-1.),power); |
---|
| 94 | int nX=8; |
---|
| 95 | double DISmsig=0.; |
---|
| 96 | double DIStsig=1.; |
---|
| 97 | while(std::fabs(DIStsig-DISmsig)/DIStsig>eps) |
---|
| 98 | { |
---|
| 99 | DISmsig=DIStsig; |
---|
| 100 | DIStsig=0.; |
---|
| 101 | nX*=2; |
---|
| 102 | double dX=(Xma-Xmi)/nX; |
---|
| 103 | double hX=dX/2; |
---|
| 104 | for(double X=Xmi+hX; X<Xma; X+=dX) |
---|
| 105 | { |
---|
| 106 | double r=shift-std::pow(X,pconv); // the same for nu and anu |
---|
| 107 | if(nu) DIStsig+=nuX(en,r,shift); // neutrino |
---|
| 108 | else DIStsig+=anuX(en,r,shift); // anti-neutrino |
---|
| 109 | } |
---|
| 110 | DIStsig*=dX; |
---|
| 111 | //G4cout<<"E="<<en<<",nX="<<nX<<",i="<<DIStsig<<",m="<<DISmsig<<",r=" |
---|
| 112 | // <<(DIStsig-DISmsig)/DIStsig<<G4endl; |
---|
| 113 | } |
---|
| 114 | //G4cout<<"E="<<en<<", Total: nX="<<nX<<", Int="<<DIStsig<<G4endl; |
---|
| 115 | // ***************** Calculate the reversed table ***************** |
---|
| 116 | double dInt=DIStsig/niX; // Step for the integral |
---|
| 117 | DIStsig=0.; |
---|
| 118 | DISmsig=0.; |
---|
| 119 | nX*=2; |
---|
| 120 | double dX=(Xma-Xmi)/nX; // New step for the multiplied number of nodes |
---|
| 121 | dInt/=dX; // To avoid multiplication (nX is fixed) |
---|
| 122 | double sum=dInt; |
---|
| 123 | int nn=0; |
---|
| 124 | double hX=dX/2; |
---|
| 125 | G4cout<<"E="<<en<<", Xl_min="<<Xmi<<G4endl; |
---|
| 126 | for(double X=Xmi+hX; X<Xma; X+=dX) |
---|
| 127 | { |
---|
| 128 | double r=shift-std::pow(X,pconv); // the same for nu and anu |
---|
| 129 | if(nu) DIStsig+=nuX(en,r,shift); // neutrino |
---|
| 130 | else DIStsig+=anuX(en,r,shift); // anti-neutrino |
---|
| 131 | if(DIStsig>sum+eps) |
---|
| 132 | { |
---|
| 133 | inl[ne][nn]=sum*dX; |
---|
| 134 | Xl[ne][nn]=X-(DIStsig-sum)*dX/(DIStsig-DISmsig); |
---|
| 135 | G4cout<<"E="<<en<<", sum="<<inl[ne][nn]<<", Xl["<<nn<<"]="<<Xl[ne][nn]<<G4endl; |
---|
| 136 | nn++; |
---|
| 137 | sum+=dInt; |
---|
| 138 | } |
---|
| 139 | DISmsig=DIStsig; |
---|
| 140 | } |
---|
| 141 | inl[ne][nn]=sum*dX; |
---|
| 142 | Xl[ne][nn]=Xma; |
---|
| 143 | G4cout<<"E="<<en<<", sum="<<inl[ne][nn]<<", Xl["<<nn<<"]="<<Xma<<G4endl; |
---|
| 144 | // ************* The following is just a test (better than .5%) ************ |
---|
| 145 | //for(int i=1; i<niX; i++) |
---|
| 146 | //{ |
---|
| 147 | // DIStsig=0.; |
---|
| 148 | // double Xm=Xl[ne][i]; |
---|
| 149 | // double dX=(Xm-Xmi)/nX; |
---|
| 150 | // double hX=dX/2; |
---|
| 151 | // for(double X=Xmi+hX; X<Xm; X+=dX) |
---|
| 152 | // { |
---|
| 153 | // double r=shift-pow(X,pconv); // the same for nu and anu |
---|
| 154 | // if(nu) DIStsig+=nuX(en,r,shift); // neutrino |
---|
| 155 | // else DIStsig+=anuX(en,r,shift); // anti-neutrino |
---|
| 156 | // } |
---|
| 157 | // DIStsig*=dX; |
---|
| 158 | // G4cout<<"i="<<i<<", v="<<DIStsig<<", d="<<fabs(DIStsig-inl[ne][i])/DIStsig<<G4endl; |
---|
| 159 | //} |
---|
| 160 | // ***************** Calculate the direct table ***************** |
---|
| 161 | dX=(Xma-Xmi)/niX; |
---|
| 162 | double nor=inl[ne][liX]/niX; |
---|
| 163 | //G4cout<<"E="<<en<<", i=0, Xm="<<Xmi<<", I=0."<<G4endl; |
---|
| 164 | for(int i=1; i<=niX; i++) |
---|
| 165 | { |
---|
| 166 | DIStsig=0.; |
---|
| 167 | double Xm=Xmi+dX*i; |
---|
| 168 | double rX=(Xm-Xmi)/nX; |
---|
| 169 | double hX=rX/2; |
---|
| 170 | for(double X=Xmi+hX; X<Xm; X+=rX) |
---|
| 171 | { |
---|
| 172 | double r=shift-std::pow(X,pconv); // the same for nu and anu |
---|
| 173 | if(nu) DIStsig+=nuX(en,r,shift); // neutrino |
---|
| 174 | else DIStsig+=anuX(en,r,shift); // anti-neutrino |
---|
| 175 | } |
---|
| 176 | DIStsig*=rX/nor; |
---|
| 177 | //////////G4cout<<"E="<<en<<", i="<<i<<", Xm="<<Xm<<", I="<<DIStsig<<G4endl; |
---|
| 178 | } |
---|
| 179 | ne++; |
---|
| 180 | } // End of the big loop over log(E) |
---|
| 181 | G4cout<<"End"<<G4endl; |
---|
| 182 | return 0; |
---|
| 183 | } |
---|