Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ParticleHPInterpolator Class Reference

#include <G4ParticleHPInterpolator.hh>

Public Member Functions

 G4ParticleHPInterpolator ()
 
 ~G4ParticleHPInterpolator ()
 
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 Interpolate2 (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 44 of file G4ParticleHPInterpolator.hh.

Constructor & Destructor Documentation

G4ParticleHPInterpolator::G4ParticleHPInterpolator ( )
inline

Definition at line 48 of file G4ParticleHPInterpolator.hh.

48 {}
G4ParticleHPInterpolator::~G4ParticleHPInterpolator ( )
inline

Definition at line 49 of file G4ParticleHPInterpolator.hh.

50  {
51  // G4cout <<"deleted the interpolator"<<G4endl;
52  }

Member Function Documentation

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

Definition at line 36 of file G4ParticleHPInterpolator.cc.

38  { // inline again later on @@@@
39  G4double result = 0;
40  if(aScheme==HISTO||aScheme==CHISTO||aScheme==UHISTO)
41  {
42  result = y1*(x2-x1);
43  }
44  else if(aScheme==LINLIN||aScheme==CLINLIN||aScheme==ULINLIN)
45  {
46  result = 0.5*(y2+y1)*(x2-x1);
47  }
48  else if(aScheme==LINLOG||aScheme==CLINLOG||aScheme==ULINLOG)
49  {
50  if(x1==0) result = y1;
51  else if(x2==0) result = y2;
52  else
53  {
54  G4double b = (y2-y1)/(G4Log(x2)-G4Log(x1));
55  G4double a = y1 - b*G4Log(x1);
56  result = (a-b)*(x2-x1) + b*(x2*G4Log(x2)-x1*G4Log(x1));
57  }
58  }
59  else if(aScheme==LOGLIN||aScheme==CLOGLIN||aScheme==ULOGLIN)
60  {
61  if ( y1==0||y2==0 ) {
62  result =0;
63  } else {
64  // G4double b = (std::log(y2)-std::log(y1))/(x2-x1);
65  // G4double a = std::log(y1) - b*x1;
66  //***************************************************************
67  //EMendoza:
68  //result = (std::exp(a)/b)*(std::exp(b*x2)-std::exp(b*x1));
69  //***************************************************************
70  if ( y1!=y2 ) {
71  result = (x2-x1)*(y2-y1)/G4Log(y2/y1);
72  } else {
73  result = y2*(x2-x1);
74  }
75  //***************************************************************
76  }
77  }
78  else if(aScheme==LOGLOG||aScheme==CLOGLOG||aScheme==ULOGLOG)
79  {
80  if(x1==0) result = y1;
81  else if(x2==0) result = y2;
82  else if(y1==0||y2==0) result =0;
83  else
84  {
85  G4double b = (G4Log(y2)-G4Log(y1))/(G4Log(x2)-G4Log(x1));
86  G4double a = G4Log(y1) - b*G4Log(x1);;
87  result = (G4Exp(a)/(b+1))*(G4Pow::GetInstance()->powA(x2,b+1)-G4Pow::GetInstance()->powA(x1,b+1));
88  }
89  }
90  else
91  {
92  throw G4HadronicException(__FILE__, __LINE__, "Unknown interpolation scheme in G4ParticleHPVector::Integrate");
93  }
94  return result;
95  }
G4double G4ParticleHPJENDLHEData::G4double result
static G4Pow * GetInstance()
Definition: G4Pow.cc:55
G4double powA(G4double A, G4double y) const
Definition: G4Pow.hh:259
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
tuple b
Definition: test.py:12
G4double G4Log(G4double x)
Definition: G4Log.hh:230
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 97 of file G4ParticleHPInterpolator.cc.

99  { // inline again later on @@@@
100  G4double result = 0;
101  if(aScheme==HISTO||aScheme==CHISTO||aScheme==UHISTO)
102  {
103  result = 0.5*y1*(x2*x2-x1*x1);
104  }
105  else if(aScheme==LINLIN||aScheme==CLINLIN||aScheme==ULINLIN)
106  {
107  // G4double b = (y2-y1)/(x2-x1);
108  // G4double a = y1 - b*x1;
109  // result = 0.5*a*(x2*x2-x1*x1) + (b/3.)*(x2*x2*x2-x1*x1*x1);
110  // Factor out x2-x1 to avoid divide by zero
111 
112  result = (y1*x2 - y2*x1)*(x2 + x1)/2. + (y2-y1)*(x2*x2 + x2*x1 + x1*x1)/3.;
113  }
114  else if(aScheme==LINLOG||aScheme==CLINLOG||aScheme==ULINLOG)
115  {
116  if(x1==0) result = y1;
117  else if(x2==0) result = y2;
118  else
119  {
120  G4double b = (y2-y1)/(G4Log(x2)-G4Log(x1));
121  G4double a = y1 - b*G4Log(x1);
122  result = ( x2*x2/2. * (a-b/2.+b*G4Log(x2)) )
123  -( x1*x1/2. * (a-b/2.+b*G4Log(x1)) );
124  }
125  }
126  else if(aScheme==LOGLIN||aScheme==CLOGLIN||aScheme==ULOGLIN)
127  {
128  if(y1==0||y2==0) result = 0;
129  else
130  {
131  G4double b = (G4Log(y2)-G4Log(y1))/(x2-x1);
132  G4double a = G4Log(y1) - b*x1;
133  result = G4Exp(a)/(b*b)*( G4Exp(b*x2)*(b*x2-1.) - G4Exp(b*x1)*(b*x1-1.) );
134  }
135  }
136  else if(aScheme==LOGLOG||aScheme==CLOGLOG||aScheme==ULOGLOG)
137  {
138  if(x1==0) result = y1;
139  else if(x2==0) result = y2;
140  else if(y1==0||y2==0) result = 0;
141  else
142  {
143  G4double b = (G4Log(y2)-G4Log(y1))/(G4Log(x2)-G4Log(x1));
144  G4double a = G4Log(y1) - b*G4Log(x1);;
145  result = G4Exp(a)/(b+2.)*( G4Pow::GetInstance()->powA(x2, b+2.) - G4Pow::GetInstance()->powA(x1, b+2) );
146  }
147  }
148  else
149  {
150  throw G4HadronicException(__FILE__, __LINE__, "Unknown interpolation scheme in G4ParticleHPVector::Integrate");
151  }
152  return result;
153  }
G4double G4ParticleHPJENDLHEData::G4double result
static G4Pow * GetInstance()
Definition: G4Pow.cc:55
G4double powA(G4double A, G4double y) const
Definition: G4Pow.hh:259
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
tuple b
Definition: test.py:12
G4double G4Log(G4double x)
Definition: G4Log.hh:230
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4ParticleHPInterpolator::Interpolate ( G4InterpolationScheme  aScheme,
G4double  x,
G4double  x1,
G4double  x2,
G4double  y1,
G4double  y2 
) const
inline

Definition at line 91 of file G4ParticleHPInterpolator.hh.

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

Here is the caller graph for this function:

G4double G4ParticleHPInterpolator::Interpolate2 ( G4InterpolationScheme  aScheme,
G4double  x,
G4double  x1,
G4double  x2,
G4double  y1,
G4double  y2 
) const
inline

Definition at line 128 of file G4ParticleHPInterpolator.hh.

130 {
131  G4double result(0);
132  G4int theScheme = aScheme;
133  theScheme = theScheme%CSTART_;
134  switch(theScheme)
135  {
136  case 1:
137  result = Histogram(x, x1, x2, y1, y2);
138  break;
139  case 2:
140  result = LinearLinear(x, x1, x2, y1, y2);
141  break;
142  case 3:
143  result = LinearLogarithmic(x, x1, x2, y1, y2);
144  break;
145  case 4:
146  result = LogarithmicLinear(x, x1, x2, y1, y2);
147  break;
148  case 5:
149  result = LogarithmicLogarithmic(x, x1, x2, y1, y2);
150  break;
151  case 6:
152  result = Random(x, x1, x2, y1, y2);
153  break;
154  default:
155  G4cout << "theScheme = "<<theScheme<<G4endl;
156  throw G4HadronicException(__FILE__, __LINE__, "G4ParticleHPInterpolator::Carthesian Invalid InterpolationScheme");
157  break;
158  }
159  return result;
160 }
G4double G4ParticleHPJENDLHEData::G4double result
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

Here is the caller graph for this function:

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

Definition at line 54 of file G4ParticleHPInterpolator.hh.

55  {
56  G4double slope=0, off=0;
57  if(x2-x1==0) return (y2+y1)/2.;
58  slope = (y2-y1)/(x2-x1);
59  off = y2-x2*slope;
60  G4double y = x*slope+off;
61  return y;
62  }
tuple x
Definition: test.py:50
double G4double
Definition: G4Types.hh:76

Here is the caller graph for this function:


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