Geant4_10
G4NeutronHPFastLegendre.hh
Go to the documentation of this file.
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 //
27 //
28 #ifndef G4NeutronHPFastLegendre_h
29 #define G4NeutronHPFastLegendre_h 1
30 
31 #include "globals.hh"
32 
34 {
35  public:
36 
38  {
39  value = new const G4double * [31];
40  value[0] = l0;
41  value[1] = l1;
42  value[2] = l2;
43  value[3] = l3;
44  value[4] = l4;
45  value[5] = l5;
46  value[6] = l6;
47  value[7] = l7;
48  value[8] = l8;
49  value[9] = l9;
50  value[10] = l10;
51  value[11] = l11;
52  value[12] = l12;
53  value[13] = l13;
54  value[14] = l14;
55  value[15] = l15;
56  value[16] = l16;
57  value[17] = l17;
58  value[18] = l18;
59  value[19] = l19;
60  value[20] = l20;
61  value[21] = l21;
62  value[22] = l22;
63  value[23] = l23;
64  value[24] = l24;
65  value[25] = l25;
66  value[26] = l26;
67  value[27] = l27;
68  value[28] = l28;
69  value[29] = l29;
70  value[30] = l30;
71  integral = new const G4double * [31];
72  integral[0] = i0;
73  integral[1] = i1;
74  integral[2] = i2;
75  integral[3] = i3;
76  integral[4] = i4;
77  integral[5] = i5;
78  integral[6] = i6;
79  integral[7] = i7;
80  integral[8] = i8;
81  integral[9] = i9;
82  integral[10] = i10;
83  integral[11] = i11;
84  integral[12] = i12;
85  integral[13] = i13;
86  integral[14] = i14;
87  integral[15] = i15;
88  integral[16] = i16;
89  integral[17] = i17;
90  integral[18] = i18;
91  integral[19] = i19;
92  integral[20] = i20;
93  integral[21] = i21;
94  integral[22] = i22;
95  integral[23] = i23;
96  integral[24] = i24;
97  integral[25] = i25;
98  integral[26] = i26;
99  integral[27] = i27;
100  integral[28] = i28;
101  integral[29] = i29;
102  integral[30] = i30;
103 
104  G4int i;
105  for(i=0;i<31;i++) theNbin[i]=1+200*(i+1);
106  }
107 
109  {
110  delete [] value;
111  delete [] integral;
112  }
113 
115  {
116  if(l>30) return regularIntegrate(l,costh);
117  G4int bin = GetBin(l, costh);
118  G4double y1, y2;
119 // G4cout <<"Testhpw G4NeutronHPFastLegendre::Integrate "<<l<<" "<<bin<<G4endl;
120  y1 = integral[l][bin];
121  y2 = integral[l][bin+1];
122 // G4cout <<"Testhpw G4NeutronHPFastLegendre::Integrate exit"<<G4endl;
123  return Interpolate(bin, l, y1, y2, costh);
124  }
125 
126  inline G4double Evaluate(G4int l, G4double costh)
127  {
128  if(l>30) return regularEvaluate(l,costh);
130  G4int bin = GetBin(l, costh);
131  if(bin != theNbin[l]-1)
132  {
133  G4double y1, y2;
134  y1 = value[l][bin];
135  y2 = value[l][bin+1];
136  result = Interpolate(bin, l, y1, y2, costh);
137  }
138  else
139  {
140  result = value[l][bin];
141  }
142  return result;
143  }
144 
145  private:
146 
147  G4double regularEvaluate( int l , double x );
148  G4double regularIntegrate( int l , double x );
149 
150 
151  inline G4int GetBin(G4int l, G4double costh)
152  {
153  G4int bin=0;
154  bin = G4int( (theNbin[l]-1)*(costh+1)/2. );
155  if(bin == theNbin[l]-1) bin--;
156  return bin;
157  }
158 
159  inline G4double Interpolate(G4int bin, G4int l, G4double y1, G4double y2, G4double x)
160  {
161  G4double slope = 0, off = 0, x2=0, x1mx2;
162  G4int half = (theNbin[l]-1)/2;
163 // x1 = (bin-half)/G4double(half);
164  x2 = (bin+1-half)/G4double(half);
165  x1mx2 = 1./G4double( (theNbin[l]-1)/2 );
166 // slope = (y2-y1)/(x2-x1);
167  slope = (y2-y1)/x1mx2;
168  off = y2-x2*slope;
169  return x*slope+off;
170  }
171 
172  const G4double ** value;
173  const G4double ** integral;
174  G4int theNbin[31];
175  static const G4double l0[201];
176  static const G4double i0[201];
177  static const G4double l1[401];
178  static const G4double i1[401];
179  static const G4double l2[601];
180  static const G4double i2[601];
181  static const G4double l3[801];
182  static const G4double i3[801];
183  static const G4double l4[1001];
184  static const G4double i4[1001];
185  static const G4double l5[1201];
186  static const G4double i5[1201];
187  static const G4double l6[1401];
188  static const G4double i6[1401];
189  static const G4double l7[1601];
190  static const G4double i7[1601];
191  static const G4double l8[1801];
192  static const G4double i8[1801];
193  static const G4double l9[2001];
194  static const G4double i9[2001];
195  static const G4double l10[2201];
196  static const G4double i10[2201];
197  static const G4double l11[2401];
198  static const G4double i11[2401];
199  static const G4double l12[2601];
200  static const G4double i12[2601];
201  static const G4double l13[2801];
202  static const G4double i13[2801];
203  static const G4double l14[3001];
204  static const G4double i14[3001];
205  static const G4double l15[3201];
206  static const G4double i15[3201];
207  static const G4double l16[3401];
208  static const G4double i16[3401];
209  static const G4double l17[3601];
210  static const G4double i17[3601];
211  static const G4double l18[3801];
212  static const G4double i18[3801];
213  static const G4double l19[4001];
214  static const G4double i19[4001];
215  static const G4double l20[4201];
216  static const G4double i20[4201];
217  static const G4double l21[4401];
218  static const G4double i21[4401];
219  static const G4double l22[4601];
220  static const G4double i22[4601];
221  static const G4double l23[4801];
222  static const G4double i23[4801];
223  static const G4double l24[5001];
224  static const G4double i24[5001];
225  static const G4double l25[5201];
226  static const G4double i25[5201];
227  static const G4double l26[5401];
228  static const G4double i26[5401];
229  static const G4double l27[5601];
230  static const G4double i27[5601];
231  static const G4double l28[5801];
232  static const G4double i28[5801];
233  static const G4double l29[6001];
234  static const G4double i29[6001];
235  static const G4double l30[6201];
236  static const G4double i30[6201];
237 };
238 #endif
Double_t y2[nxs]
Definition: Style.C:21
Double_t y1[nxs]
Definition: Style.C:20
Double_t x2[nxs]
Definition: Style.C:19
float bin[41]
Definition: plottest35.C:14
G4double G4NeutronHPJENDLHEData::G4double result
G4double Evaluate(G4int l, G4double costh)
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4double Integrate(G4int l, G4double costh)
double G4double
Definition: G4Types.hh:76