Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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 41 of file G4NeutronHPInterpolator.hh.

Constructor & Destructor Documentation

G4NeutronHPInterpolator::G4NeutronHPInterpolator ( )
inline

Definition at line 45 of file G4NeutronHPInterpolator.hh.

45 {}
G4NeutronHPInterpolator::~G4NeutronHPInterpolator ( )
inline

Definition at line 46 of file G4NeutronHPInterpolator.hh.

47  {
48  // G4cout <<"deleted the interpolator"<<G4endl;
49  }

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 test::a, test::b, 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().

35  { // inline again later on @@@@
36  G4double result = 0;
37  if(aScheme==HISTO||aScheme==CHISTO||aScheme==UHISTO)
38  {
39  result = y1*(x2-x1);
40  }
41  else if(aScheme==LINLIN||aScheme==CLINLIN||aScheme==ULINLIN)
42  {
43  result = 0.5*(y2+y1)*(x2-x1);
44  }
45  else if(aScheme==LINLOG||aScheme==CLINLOG||aScheme==ULINLOG)
46  {
47  if(x1==0) result = y1;
48  else if(x2==0) result = y2;
49  else
50  {
51  G4double b = (y2-y1)/(std::log(x2)-std::log(x1));
52  G4double a = y1 - b*std::log(x1);
53  result = (a-b)*(x2-x1) + b*(x2*std::log(x2)-x1*std::log(x1));
54  }
55  }
56  else if(aScheme==LOGLIN||aScheme==CLOGLIN||aScheme==ULOGLIN)
57  {
58  if(y1==0||y2==0) result =0;
59  else
60  {
61  G4double b = (std::log(y2)-std::log(y1))/(x2-x1);
62  G4double a = std::log(y1) - b*x1;
63  //***************************************************************
64  //EMendoza:
65  //result = (std::exp(a)/b)*(std::exp(b*x2)-std::exp(b*x1));
66  //***************************************************************
67  if(b!=0){
68  result = (std::exp(a)/b)*(std::exp(b*x2)-std::exp(b*x1));
69  }
70  else{
71  result=y2*(x2-x1);
72  }
73  //***************************************************************
74  }
75  }
76  else if(aScheme==LOGLOG||aScheme==CLOGLOG||aScheme==ULOGLOG)
77  {
78  if(x1==0) result = y1;
79  else if(x2==0) result = y2;
80  else if(y1==0||y2==0) result =0;
81  else
82  {
83  G4double b = (std::log(y2)-std::log(y1))/(std::log(x2)-std::log(x1));
84  G4double a = std::log(y1) - b*std::log(x1);;
85  result = (std::exp(a)/(b+1))*(std::pow(x2,b+1)-std::pow(x1,b+1));
86  }
87  }
88  else
89  {
90  throw G4HadronicException(__FILE__, __LINE__, "Unknown interpolation scheme in G4NeutronHPVector::Integrate");
91  }
92  return result;
93  }
double G4double
Definition: G4Types.hh:76
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 test::a, test::b, CHISTO, CLINLIN, CLINLOG, CLOGLIN, CLOGLOG, HISTO, LINLIN, LINLOG, LOGLIN, LOGLOG, UHISTO, ULINLIN, ULINLOG, ULOGLIN, and ULOGLOG.

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

97  { // inline again later on @@@@
98  G4double result = 0;
99  if(aScheme==HISTO||aScheme==CHISTO||aScheme==UHISTO)
100  {
101  result = 0.5*y1*(x2*x2-x1*x1);
102  }
103  else if(aScheme==LINLIN||aScheme==CLINLIN||aScheme==ULINLIN)
104  {
105  // G4double b = (y2-y1)/(x2-x1);
106  // G4double a = y1 - b*x1;
107  // result = 0.5*a*(x2*x2-x1*x1) + (b/3.)*(x2*x2*x2-x1*x1*x1);
108  // Factor out x2-x1 to avoid divide by zero
109 
110  result = (y1*x2 - y2*x1)*(x2 + x1)/2. + (y2-y1)*(x2*x2 + x2*x1 + x1*x1)/3.;
111  }
112  else if(aScheme==LINLOG||aScheme==CLINLOG||aScheme==ULINLOG)
113  {
114  if(x1==0) result = y1;
115  else if(x2==0) result = y2;
116  else
117  {
118  G4double b = (y2-y1)/(std::log(x2)-std::log(x1));
119  G4double a = y1 - b*std::log(x1);
120  result = ( x2*x2/2. * (a-b/2.+b*std::log(x2)) )
121  -( x1*x1/2. * (a-b/2.+b*std::log(x1)) );
122  }
123  }
124  else if(aScheme==LOGLIN||aScheme==CLOGLIN||aScheme==ULOGLIN)
125  {
126  if(y1==0||y2==0) result = 0;
127  else
128  {
129  G4double b = (std::log(y2)-std::log(y1))/(x2-x1);
130  G4double a = std::log(y1) - b*x1;
131  result = std::exp(a)/(b*b)*( std::exp(b*x2)*(b*x2-1.) - std::exp(b*x1)*(b*x1-1.) );
132  }
133  }
134  else if(aScheme==LOGLOG||aScheme==CLOGLOG||aScheme==ULOGLOG)
135  {
136  if(x1==0) result = y1;
137  else if(x2==0) result = y2;
138  if(y1==0||y2==0) result = 0;
139  else
140  {
141  G4double b = (std::log(y2)-std::log(y1))/(std::log(x2)-std::log(x1));
142  G4double a = std::log(y1) - b*std::log(x1);;
143  result = std::exp(a)/(b+2.)*( std::pow(x2, b+2.) - std::pow(x1, b+2) );
144  }
145  }
146  else
147  {
148  throw G4HadronicException(__FILE__, __LINE__, "Unknown interpolation scheme in G4NeutronHPVector::Integrate");
149  }
150  return result;
151  }
double G4double
Definition: G4Types.hh:76
G4double G4NeutronHPInterpolator::Interpolate ( G4InterpolationScheme  aScheme,
G4double  x,
G4double  x1,
G4double  x2,
G4double  y1,
G4double  y2 
) const
inline

Definition at line 85 of file G4NeutronHPInterpolator.hh.

References CSTART_, G4cout, and G4endl.

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

87 {
88  G4double result(0);
89  G4int theScheme = aScheme;
90  theScheme = theScheme%CSTART_;
91  switch(theScheme)
92  {
93  case 1:
94  //080809
95  //result = Histogram(x, x1, x2, y1, y2);
96  result = LinearLinear(x, x1, x2, y1, y2);
97  break;
98  case 2:
99  result = LinearLinear(x, x1, x2, y1, y2);
100  break;
101  case 3:
102  result = LinearLogarithmic(x, x1, x2, y1, y2);
103  break;
104  case 4:
105  result = LogarithmicLinear(x, x1, x2, y1, y2);
106  break;
107  case 5:
108  result = LogarithmicLogarithmic(x, x1, x2, y1, y2);
109  break;
110  case 6:
111  result = Random(x, x1, x2, y1, y2);
112  break;
113  default:
114  G4cout << "theScheme = "<<theScheme<<G4endl;
115  throw G4HadronicException(__FILE__, __LINE__, "G4NeutronHPInterpolator::Carthesian Invalid InterpolationScheme");
116  break;
117  }
118  return result;
119 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double G4NeutronHPInterpolator::Lin ( G4double  x,
G4double  x1,
G4double  x2,
G4double  y1,
G4double  y2 
)
inline

Definition at line 51 of file G4NeutronHPInterpolator.hh.

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

52  {
53  G4double slope=0, off=0;
54  if(x2-x1==0) return (y2+y1)/2.;
55  slope = (y2-y1)/(x2-x1);
56  off = y2-x2*slope;
57  G4double y = x*slope+off;
58  return y;
59  }
double G4double
Definition: G4Types.hh:76

The documentation for this class was generated from the following files: