Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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::G4NeutronHPInterpolator ( )
inline

Definition at line 46 of file G4NeutronHPInterpolator.hh.

46{}

◆ ~G4NeutronHPInterpolator()

G4NeutronHPInterpolator::~G4NeutronHPInterpolator ( )
inline

Definition at line 47 of file G4NeutronHPInterpolator.hh.

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

Member Function Documentation

◆ GetBinIntegral()

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

Definition at line 32 of file G4NeutronHPInterpolator.cc.

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:64

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

◆ GetWeightedBinIntegral()

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

Definition at line 94 of file G4NeutronHPInterpolator.cc.

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 }

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

◆ Interpolate()

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.

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

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

◆ Lin()

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

Definition at line 52 of file G4NeutronHPInterpolator.hh.

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

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


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