[968] | 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 "Randomize.hh" |
---|
| 38 | #include "G4Timer.hh" |
---|
| 39 | #include "time.h" |
---|
| 40 | |
---|
| 41 | // All calculations have been done for C12 nucleus |
---|
| 42 | |
---|
| 43 | double anuX(double E, double r, double p) // (E is in GeV, r=Q2/Q2max, p=1+anuE(E)) |
---|
| 44 | { |
---|
| 45 | double E2=E*E; |
---|
| 46 | double y=p-r; |
---|
| 47 | double p3=(13.88+.9373*(1.+.000033*E2)*std::sqrt(E))/(1.+(10.12+1.532/E2)/E); |
---|
| 48 | return std::pow(y,6)*(r+p3)/(p3*r+1.); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | int main() |
---|
| 52 | { |
---|
| 53 | G4double PI=3.14159265; // \pi |
---|
| 54 | G4double A=.5; // half side of the tested cube |
---|
| 55 | G4double R=.5; // radius of the tested sphere |
---|
| 56 | G4double B=1.; // half width of the mother cube |
---|
| 57 | G4double S=6*(B+B)*(B+B); // 6 sides 2x2 |
---|
| 58 | G4double SC=6*(A+A)*(A+A); // The target surface of the test cube |
---|
| 59 | G4double SS=4*PI*R*R; // The target surface of the test sphere |
---|
| 60 | G4double c=0.; // summ for the cube |
---|
| 61 | G4double s=0.; // summ for the sphere |
---|
| 62 | G4double m=0.; // summ for the mother cube |
---|
| 63 | G4double cf=0.; // reversed length summ for the cube |
---|
| 64 | G4double sf=0.; // reversed length summ for the sphere |
---|
| 65 | G4double mf=0.; // reversed length summ for the mother cube |
---|
| 66 | G4double cr=0.; // length summ for the cube |
---|
| 67 | G4double sr=0.; // length summ for the sphere |
---|
| 68 | G4double mr=0.; // length summ for the mother cube |
---|
| 69 | G4double cm=B; // min length for the cube |
---|
| 70 | G4double sm=B; // min length for the sphere |
---|
| 71 | G4double mm=B; // min length for the mother cube |
---|
| 72 | G4int nEv=10000000; // calculation statistics |
---|
| 73 | G4double f=.99; // scale factor |
---|
| 74 | G4double Af=A*f; // Scaled A |
---|
| 75 | G4double Rf=R*f; // Scaled R |
---|
| 76 | G4double Bf=B*f; // Scaled B |
---|
| 77 | G4Timer* timer = new G4Timer(); |
---|
| 78 | timer->Start(); |
---|
| 79 | for(G4int i=0; i<nEv; i++) |
---|
| 80 | { |
---|
| 81 | // Randomize coordinates within (+/-1,+/-1,+/-1) cube (S=6+4=24) |
---|
| 82 | G4double x=G4UniformRand(); |
---|
| 83 | x=B*(1.-x-x); // Can be x=B*x, but B=1 is a hilf width of mother cube |
---|
| 84 | G4double y=G4UniformRand(); |
---|
| 85 | y=B*(1.-y-y); |
---|
| 86 | G4double z=G4UniformRand(); |
---|
| 87 | z=B*(1.-z-z); |
---|
| 88 | G4double r2=x*x+y*y+z*z; |
---|
| 89 | G4double r=std::sqrt(r2); |
---|
| 90 | G4double w=1./r; |
---|
| 91 | G4double ax=std::fabs(x); |
---|
| 92 | G4double ay=std::fabs(y); |
---|
| 93 | G4double az=std::fabs(z); |
---|
| 94 | if(r<R && r>Rf) |
---|
| 95 | { |
---|
| 96 | s+=1.; |
---|
| 97 | sf+=w; |
---|
| 98 | sr+=r; |
---|
| 99 | if(r<sm) sm=r; |
---|
| 100 | } |
---|
| 101 | if(ax<A && ay<A && az<A && (ax>Af || ay>Af || az>Af)) |
---|
| 102 | { |
---|
| 103 | c+=1.; |
---|
| 104 | cf+=w; |
---|
| 105 | cr+=r; |
---|
| 106 | if(r<cm) cm=r; |
---|
| 107 | } |
---|
| 108 | if(ax>Bf || ay>Bf || az>Bf) |
---|
| 109 | { |
---|
| 110 | m+=1.; |
---|
| 111 | mf+=w; |
---|
| 112 | mr+=r; |
---|
| 113 | if(r<mm) mm=r; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | G4double N=S*mm/m; |
---|
| 117 | //G4double N=S*m*m/mf; |
---|
| 118 | //G4double N=S/mf; |
---|
| 119 | timer->Stop(); |
---|
| 120 | G4cout<<"SurfaceCalc: nE="<<nEv<<", time="<<timer->GetUserElapsed()<<" s, f="<<f<<G4endl; |
---|
| 121 | delete timer; |
---|
| 122 | G4cout<<"SurfaceCalculation: Cube="<<N*c/cm/SC<<", Sphere="<<N*s/sm/SS<<G4endl; |
---|
| 123 | //G4cout<<"SurfaceCalculation: Cube="<<N*cf/SC<<", Sphere="<<N*sf/SS<<G4endl; |
---|
| 124 | //G4cout<<"SurfaceCalculation: Cube="<<N*cr/c/c/SC<<", Sphere="<<N*sr/s/s/SS<<G4endl; |
---|
| 125 | } |
---|