00001 #include <math.h> 00002 #include <iostream.h> 00003 #include "ReactorConstants.hh" 00004 #include "ReactorFortran.hh" 00005 #include "ReactorXC.hh" 00006 #include "ReactorEvent.hh" 00007 00008 ReactorEvent::ReactorEvent(double newRmaxgen, 00009 double newEmin, 00010 double newEmax, 00011 int newXCorder){ 00012 Rmaxgen = newRmaxgen; 00013 Emin = newEmin; 00014 Emax = newEmax; 00015 XCorder = newXCorder; 00016 00017 XCWeight = 1; 00018 00019 double XCmax = InverseBeta(Emax,-1); 00020 double FluxMax = RMPflux(Emin); 00021 00022 double Enu,z,phi; 00023 double R,zR,phiR; 00024 bool passed=0; 00025 00026 00027 while(!passed){ 00028 float r[7]; 00029 int len = 7; 00030 ranlux_(r,len); 00031 Enu = Emin+(Emax-Emin)*r[0]; 00032 z = -1+2*r[1]; 00033 phi = 2*k.pi*r[2]; 00034 00035 R = Rmaxgen*exp(log(r[3])/3); 00036 zR = -1+2*r[4]; 00037 phiR = 2*k.pi*r[5]; 00038 00039 float XCtest = XCmax*FluxMax*r[6]; 00040 XCWeight = InverseBeta(Enu,z); 00041 FluxWeight=RMPflux(Enu); 00042 passed= XCWeight*FluxWeight>XCtest; 00043 } 00044 00045 00046 double E0 = Enu - k.Delta; 00047 double p0 = sqrt(E0*E0-k.Melectron*k.Melectron); 00048 double v0 = p0/E0; 00049 double Ysquared = (k.Delta*k.Delta-k.Melectron*k.Melectron)/2; 00050 double E1 = E0*(1-Enu/k.Mproton*(1-v0*z))-Ysquared/k.Mproton; 00051 double p1 = sqrt(E1*E1-k.Melectron*k.Melectron); 00052 00053 Pnubar[0] = Enu; 00054 Pnubar[1] = 0; 00055 Pnubar[2] = 0; 00056 Pnubar[3] = Enu; 00057 Pnubar[4] = Enu; 00058 Pnubar[5] = Enu; 00059 00060 Ppositron[0] = E1; 00061 Ppositron[1] = p1*sqrt(1-z*z)*cos(phi); 00062 Ppositron[2] = p1*sqrt(1-z*z)*sin(phi); 00063 Ppositron[3] = p1*z; 00064 Ppositron[4] = E1-k.Melectron; 00065 Ppositron[5] = p1; 00066 00067 Pneutron[0] = Enu+k.Mproton-E1; 00068 Pneutron[1] = -Ppositron[1]; 00069 Pneutron[2] = -Ppositron[2]; 00070 Pneutron[3] = Pnubar[3]-Ppositron[3]; 00071 Pneutron[4] = Pneutron[0]-k.Mproton-k.Delta; 00072 Pneutron[5] = sqrt(Pneutron[0]*Pneutron[0]- 00073 (k.Mproton+k.Delta)*(k.Mproton+k.Delta)); 00074 00075 Rnubar[0] = 0; 00076 Rnubar[1] = R*sqrt(1-zR*zR)*cos(phiR); 00077 Rnubar[2] = R*sqrt(1-zR*zR)*sin(phiR); 00078 Rnubar[3] = R*zR; 00079 Rnubar[4] = R; 00080 Rnubar[5] = zR; 00081 Rnubar[6] = phiR; 00082 00083 for(int n=0;n<Rdim;n++){ 00084 Rneutron[n] = Rnubar[n]; 00085 Rpositron[n] = Rnubar[n]; 00086 } 00087 } 00088 00089 ReactorEvent::~ReactorEvent(){ 00090 ; 00091 } 00092 00093 ReactorEvent::ReactorEvent(const ReactorEvent& Event){ 00094 00095 XCorder = Event.XCorder; 00096 Emin = Event.Emin; 00097 Emax = Event.Emax; 00098 Rmaxgen = Event.Rmaxgen; 00099 00100 XCWeight = Event.XCWeight; 00101 FluxWeight = Event.FluxWeight; 00102 00103 for(int n=0;n<Pdim;n++){ 00104 Pnubar[n]=Event.Pnubar[n]; 00105 Pneutron[n]=Event.Pneutron[n]; 00106 Ppositron[n]=Event.Ppositron[n]; 00107 } 00108 for(int n=0;n<Rdim;n++){ 00109 Rnubar[n]=Event.Rnubar[n]; 00110 Rneutron[n]=Event.Rneutron[n]; 00111 Rpositron[n]=Event.Rpositron[n]; 00112 } 00113 } 00114 00115 ReactorEvent& ReactorEvent::operator=(const ReactorEvent& rhs){ 00116 00117 if(this == &rhs)return *this; 00118 00119 XCorder = rhs.XCorder; 00120 Emin = rhs.Emin; 00121 Emax = rhs.Emax; 00122 Rmaxgen = rhs.Rmaxgen; 00123 00124 XCWeight = rhs.XCWeight; 00125 FluxWeight = rhs.FluxWeight; 00126 00127 for(int n=0;n<Pdim;n++){ 00128 Pnubar[n]=rhs.Pnubar[n]; 00129 Pneutron[n]=rhs.Pneutron[n]; 00130 Ppositron[n]=rhs.Ppositron[n]; 00131 } 00132 for(int n=0;n<Rdim;n++){ 00133 Rnubar[n]=rhs.Rnubar[n]; 00134 Rneutron[n]=rhs.Rneutron[n]; 00135 Rpositron[n]=rhs.Rpositron[n]; 00136 } 00137 return *this; 00138 00139 } 00140 00141 00142 00143 00144 00145 00146