G4NeutronHPInterpolator Class Reference

#include <G4NeutronHPInterpolator.hh>


Public Member Functions

 G4NeutronHPInterpolator ()
 ~G4NeutronHPInterpolator ()
G4double Lin (G4double x, G4double x1, G4double x2, G4double y1, G4double y2)
G4double Interpolate (G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const
G4double GetBinIntegral (const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
G4double GetWeightedBinIntegral (const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)


Detailed Description

Definition at line 42 of file G4NeutronHPInterpolator.hh.


Constructor & Destructor Documentation

G4NeutronHPInterpolator::G4NeutronHPInterpolator (  )  [inline]

Definition at line 46 of file G4NeutronHPInterpolator.hh.

00046 {}

G4NeutronHPInterpolator::~G4NeutronHPInterpolator (  )  [inline]

Definition at line 47 of file G4NeutronHPInterpolator.hh.

00048    {
00049     //  G4cout <<"deleted the interpolator"<<G4endl;
00050    }


Member Function Documentation

G4double G4NeutronHPInterpolator::GetBinIntegral ( const G4InterpolationScheme aScheme,
const G4double  x1,
const G4double  x2,
const G4double  y1,
const G4double  y2 
)

Definition at line 33 of file G4NeutronHPInterpolator.cc.

References CHISTO, CLINLIN, CLINLOG, CLOGLIN, CLOGLOG, HISTO, LINLIN, LINLOG, LOGLIN, LOGLOG, UHISTO, ULINLIN, ULINLOG, ULOGLIN, and ULOGLOG.

Referenced by G4NeutronHPVector::GetMeanX(), G4NeutronHPVector::IntegrateAndNormalise(), and G4NeutronHPContAngularPar::Sample().

00035   { // inline again later on @@@@
00036     G4double result = 0;
00037     if(aScheme==HISTO||aScheme==CHISTO||aScheme==UHISTO)
00038     {
00039       result = y1*(x2-x1);
00040     }
00041     else if(aScheme==LINLIN||aScheme==CLINLIN||aScheme==ULINLIN)
00042     {
00043       result = 0.5*(y2+y1)*(x2-x1);
00044     }
00045     else if(aScheme==LINLOG||aScheme==CLINLOG||aScheme==ULINLOG)
00046     {
00047       if(x1==0) result = y1;
00048       else if(x2==0) result = y2;
00049       else
00050       {
00051         G4double b = (y2-y1)/(std::log(x2)-std::log(x1));
00052         G4double a = y1 - b*std::log(x1);
00053         result = (a-b)*(x2-x1) + b*(x2*std::log(x2)-x1*std::log(x1));
00054       }
00055     }
00056     else if(aScheme==LOGLIN||aScheme==CLOGLIN||aScheme==ULOGLIN)
00057     {
00058       if(y1==0||y2==0) result =0;
00059       else
00060       {
00061         G4double b = (std::log(y2)-std::log(y1))/(x2-x1);
00062         G4double a = std::log(y1) - b*x1;
00063         //***************************************************************
00064         //EMendoza:
00065         //result = (std::exp(a)/b)*(std::exp(b*x2)-std::exp(b*x1));
00066         //***************************************************************
00067         if(b!=0){
00068           result = (std::exp(a)/b)*(std::exp(b*x2)-std::exp(b*x1));
00069         }
00070         else{
00071           result=y2*(x2-x1);
00072         }
00073         //***************************************************************
00074       }
00075     }
00076     else if(aScheme==LOGLOG||aScheme==CLOGLOG||aScheme==ULOGLOG)
00077     {
00078       if(x1==0) result = y1;
00079       else if(x2==0) result = y2;
00080       else if(y1==0||y2==0) result =0;
00081       else
00082       {      
00083         G4double b = (std::log(y2)-std::log(y1))/(std::log(x2)-std::log(x1));
00084         G4double a = std::log(y1) - b*std::log(x1);;
00085         result = (std::exp(a)/(b+1))*(std::pow(x2,b+1)-std::pow(x1,b+1));
00086       }
00087     }
00088     else
00089     {
00090       throw G4HadronicException(__FILE__, __LINE__, "Unknown interpolation scheme in G4NeutronHPVector::Integrate");
00091     }
00092     return result;
00093   }

G4double G4NeutronHPInterpolator::GetWeightedBinIntegral ( const G4InterpolationScheme aScheme,
const G4double  x1,
const G4double  x2,
const G4double  y1,
const G4double  y2 
)

Definition at line 95 of file G4NeutronHPInterpolator.cc.

References CHISTO, CLINLIN, CLINLOG, CLOGLIN, CLOGLOG, HISTO, LINLIN, LINLOG, LOGLIN, LOGLOG, UHISTO, ULINLIN, ULINLOG, ULOGLIN, and ULOGLOG.

Referenced by G4NeutronHPVector::GetMeanX(), and G4NeutronHPContAngularPar::Sample().

00097   { // inline again later on @@@@
00098     G4double result = 0;
00099     if(aScheme==HISTO||aScheme==CHISTO||aScheme==UHISTO)
00100     {
00101       result = 0.5*y1*(x2*x2-x1*x1);
00102     }
00103     else if(aScheme==LINLIN||aScheme==CLINLIN||aScheme==ULINLIN)
00104     {
00105       //        G4double b = (y2-y1)/(x2-x1);
00106       //        G4double a = y1 - b*x1;
00107       //        result = 0.5*a*(x2*x2-x1*x1) + (b/3.)*(x2*x2*x2-x1*x1*x1);
00108       //  Factor out x2-x1 to avoid divide by zero
00109       
00110       result = (y1*x2 - y2*x1)*(x2 + x1)/2. + (y2-y1)*(x2*x2 + x2*x1 + x1*x1)/3.;
00111     }
00112     else if(aScheme==LINLOG||aScheme==CLINLOG||aScheme==ULINLOG)
00113     {
00114       if(x1==0) result = y1;
00115       else if(x2==0) result = y2;
00116       else
00117       {
00118         G4double b = (y2-y1)/(std::log(x2)-std::log(x1));
00119         G4double a = y1 - b*std::log(x1);
00120         result = ( x2*x2/2. * (a-b/2.+b*std::log(x2)) )
00121                 -( x1*x1/2. * (a-b/2.+b*std::log(x1)) );
00122       }
00123     }
00124     else if(aScheme==LOGLIN||aScheme==CLOGLIN||aScheme==ULOGLIN)
00125     {
00126       if(y1==0||y2==0) result = 0;
00127       else
00128       {
00129         G4double b = (std::log(y2)-std::log(y1))/(x2-x1);
00130         G4double a = std::log(y1) - b*x1;
00131         result = std::exp(a)/(b*b)*( std::exp(b*x2)*(b*x2-1.) - std::exp(b*x1)*(b*x1-1.) );
00132       }
00133     }
00134     else if(aScheme==LOGLOG||aScheme==CLOGLOG||aScheme==ULOGLOG)
00135     {
00136       if(x1==0) result = y1;
00137       else if(x2==0) result = y2;
00138       if(y1==0||y2==0) result = 0;
00139       else
00140       {
00141         G4double b = (std::log(y2)-std::log(y1))/(std::log(x2)-std::log(x1));
00142         G4double a = std::log(y1) - b*std::log(x1);;
00143         result = std::exp(a)/(b+2.)*( std::pow(x2, b+2.) - std::pow(x1, b+2) );
00144       }
00145     }
00146     else
00147     {
00148       throw G4HadronicException(__FILE__, __LINE__, "Unknown interpolation scheme in G4NeutronHPVector::Integrate");
00149     }
00150     return result;
00151   }

G4double G4NeutronHPInterpolator::Interpolate ( G4InterpolationScheme  aScheme,
G4double  x,
G4double  x1,
G4double  x2,
G4double  y1,
G4double  y2 
) const [inline]

Definition at line 86 of file G4NeutronHPInterpolator.hh.

References CSTART_, G4cout, and G4endl.

Referenced by G4NeutronHPAngularP::GetCosTh(), G4NeutronHPVector::GetXsec(), G4NeutronHPPartial::GetY(), G4NeutronHPVector::Merge(), G4NeutronHPContAngularPar::Merge(), G4NeutronHPPartial::Sample(), G4NeutronHPLegendreStore::Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), G4NeutronHPContAngularPar::Sample(), G4NeutronHPLegendreStore::SampleDiscreteTwoBody(), G4NeutronHPLegendreStore::SampleElastic(), and G4NeutronHPLegendreStore::SampleMax().

00088 {
00089   G4double result(0);
00090   G4int theScheme = aScheme;
00091   theScheme = theScheme%CSTART_;
00092   switch(theScheme)
00093   {
00094     case 1:
00095       //080809
00096       //result = Histogram(x, x1, x2, y1, y2);
00097       result = LinearLinear(x, x1, x2, y1, y2);
00098       break;
00099     case 2:
00100       result = LinearLinear(x, x1, x2, y1, y2);
00101       break;
00102     case 3:
00103       result = LinearLogarithmic(x, x1, x2, y1, y2);
00104       break;
00105     case 4:
00106       result = LogarithmicLinear(x, x1, x2, y1, y2);
00107       break;
00108     case 5:
00109       result = LogarithmicLogarithmic(x, x1, x2, y1, y2);
00110       break;
00111     case 6:
00112       result = Random(x, x1, x2, y1, y2);
00113       break;
00114     default:
00115       G4cout << "theScheme = "<<theScheme<<G4endl;
00116       throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPInterpolator::Carthesian Invalid InterpolationScheme");
00117       break;
00118   }
00119   return result;
00120 }

G4double G4NeutronHPInterpolator::Lin ( G4double  x,
G4double  x1,
G4double  x2,
G4double  y1,
G4double  y2 
) [inline]

Definition at line 52 of file G4NeutronHPInterpolator.hh.

Referenced by G4NeutronHPVector::Get50percentBorder(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPVector::SampleLin(), and G4NeutronHPVector::ThinOut().

00053   {
00054     G4double slope=0, off=0;
00055     if(x2-x1==0) return (y2+y1)/2.;
00056     slope = (y2-y1)/(x2-x1);
00057     off = y2-x2*slope;
00058     G4double y = x*slope+off;
00059     return y;
00060   }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:38 2013 for Geant4 by  doxygen 1.4.7