Main Page   Compound List   File List   Compound Members   File Members  

MyGdDecayModel.cpp

00001 #include <math.h>
00002 #include <iostream.h>
00003 #include "ReactorConstants.hh"
00004 #include "ReactorFortran.hh"
00005 
00006 void MyGdDecayModel(double emax,int& ngamma,double* pgamma){
00007   //
00008   // Ad-hoc model for generating gammas from Gd n-capture.
00009   //
00010   static ReactorConstants k;
00011   double pi = k.pi;
00012   //
00013   // first pick the number of gammas
00014   //
00015   float xgamma = k.GammasPerGd-2;
00016   if(xgamma<0)xgamma=0.1;
00017   int error;
00018   rnpssn_(xgamma,ngamma,error);
00019   ngamma+=2;
00020   //
00021   // Assume recoil nucleus can absorn any momentum imbalance and
00022   // just partition the energy among the gammas with directions 
00023   // thrown isotropically.
00024   //  
00025   double* pgptr = pgamma;
00026   float rv[2*ngamma];
00027   ranlux_(rv,2*ngamma);
00028   for(int i=0;i<ngamma;i++){
00029     double cosg = -1+2*rv[2*i];
00030     double phig = 2*pi*rv[2*i+1];
00031     double t[3];
00032     t[0] = cos(phig)*sqrt(1-cosg*cosg);
00033     t[1] = sin(phig)*sqrt(1-cosg*cosg);
00034     t[2] = cosg;
00035     for(int j=0;j<3;j++)*pgptr++ = t[j];
00036   }
00037   //
00038   // Generate the energies via phase space.
00039   // This involves sampling x(1)*x(2)*..*x(N-1)*(1-x(1)-x(2)-...-x(N-1))
00040   //
00041   double x[ngamma];
00042   bool OK=0;
00043   while (!OK){
00044     ranlux_(rv,ngamma);
00045     double maxvalue=1;
00046     double logweight=0;
00047     for(int i=0;i<ngamma-1;i++){
00048       x[i]=maxvalue*rv[i];
00049       maxvalue-=x[i];
00050       logweight+=log(x[i]);
00051     }
00052     x[ngamma-1]=maxvalue;
00053     logweight+=log(maxvalue);
00054     double logmaxweight = -(ngamma-1)*log(ngamma-1); 
00055     double logtest = log(rv[ngamma-1])+logmaxweight;
00056     OK=(logtest<=logweight);
00057   }
00058   //
00059   // Add energies to gamma 4-vectors
00060   //
00061   pgptr = pgamma;
00062   for(int i=0;i<ngamma;i++){
00063     for(int j=0;j<3;j++){
00064       *pgptr++ *=  emax*x[i];
00065     }
00066   }
00067 }

Generated on Fri Oct 22 13:56:25 2004 for ReactorFsim by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002