Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ParticleHPInterpolator.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // neutron_hp -- source file
27 // J.P. Wellisch, Nov-1996
28 // A prototype of the low energy neutron transport model.
29 //
30 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
31 //
33 #include "G4Pow.hh"
34 
37  const G4double x1,const G4double x2,const G4double y1,const G4double y2)
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  }
98  const G4double x1,const G4double x2,const G4double y1,const G4double y2)
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 G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
G4InterpolationScheme
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
G4double G4Log(G4double x)
Definition: G4Log.hh:230
Float_t y2[n_points_geant4]
Definition: compare.C:26
double G4double
Definition: G4Types.hh:76
static G4Pow * GetInstance()
Definition: G4Pow.cc:57
G4double GetWeightedBinIntegral(const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
G4double powA(G4double A, G4double y) const
Definition: G4Pow.hh:242
G4double GetBinIntegral(const G4InterpolationScheme &aScheme, const G4double x1, const G4double x2, const G4double y1, const G4double y2)
G4double G4ParticleHPJENDLHEData::G4double result
Float_t x2[n_points_geant4]
Definition: compare.C:26