Geant4  10.00.p02
G4Physics2DVector.icc
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 // $Id:$
28 //
29 //
30 //---------------------------------------------------------------
31 // GEANT 4 class inline source file
32 //
33 // G4Physics2DVector.icc
34 
35 //---------------------------------------------------------------
36 
37 inline
38  G4double G4Physics2DVector::Value(G4double x, G4double y) const
39 {
40  size_t idx = 0;
41  size_t idy = 0;
42  return Value(x, y, idx, idy);
43 }
44 
45 inline void G4Physics2DVector::PutX(size_t idx, G4double val)
46 {
47  xVector[idx] = val;
48 }
49 
50 inline void G4Physics2DVector::PutY(size_t idy, G4double val)
51 {
52  yVector[idy] = val;
53 }
54 
55 inline void
56  G4Physics2DVector::PutValue(size_t idx, size_t idy, G4double val)
57 {
58  (*(value[idy]))[idx] = val;
59 }
60 
61 inline G4double G4Physics2DVector::GetX(size_t index) const
62 {
63  return xVector[index];
64 }
65 
66 inline G4double G4Physics2DVector::GetY(size_t index) const
67 {
68  return yVector[index];
69 }
70 
71 inline
72  G4double G4Physics2DVector::GetValue(size_t idx, size_t idy) const
73 {
74  return (*(value[idy]))[idx];
75 }
76 
77 inline
78  G4double G4Physics2DVector::FindLinearX(G4double rand, G4double y) const
79 {
80  size_t idy = 0;
81  return FindLinearX(rand, y, idy);
82 }
83 
84 inline size_t G4Physics2DVector::GetLengthX() const
85 {
86  return numberOfXNodes;
87 }
88 
89 inline size_t G4Physics2DVector::GetLengthY() const
90 {
91  return numberOfYNodes;
92 }
93 
94 inline G4PhysicsVectorType G4Physics2DVector::GetType() const
95 {
96  return type;
97 }
98 
99 inline void G4Physics2DVector::SetBicubicInterpolation(G4bool val)
100 {
101  useBicubic = val;
102 }
103 
104 inline size_t G4Physics2DVector::FindBin(G4double z,
105  const G4PV2DDataVector& v,
106  size_t idx,
107  size_t idxmax) const
108 {
109  size_t id = idx;
110  if(z < v[1]) {
111  id = 0;
112  } else if(z >= v[idxmax-2]) {
113  id = idxmax - 2;
114  } else if(z < v[idx] || z >= v[idx+1]) {
115  id = FindBinLocation(z, v);
116  }
117  return id;
118 }
119 
120 inline size_t
121 G4Physics2DVector::FindBinLocationX(G4double x, size_t lastidx) const
122 {
123  return FindBin(x, xVector, lastidx, numberOfXNodes);
124 }
125 
126 inline size_t
127 G4Physics2DVector::FindBinLocationY(G4double y, size_t lastidy) const
128 {
129  return FindBin(y, yVector, lastidy, numberOfYNodes);
130 }
131 
132 inline void G4Physics2DVector::SetVerboseLevel(G4int val)
133 {
134  verboseLevel = val;
135 }
136 
137 inline G4int G4Physics2DVector::GetVerboseLevel() const
138 {
139  return verboseLevel;
140 }
141 
142 inline G4double
143 G4Physics2DVector::DerivativeX(size_t idx, size_t idy, G4double fac) const
144 {
145  size_t i1 = idx;
146  if(i1 > 0) { --i1; }
147  size_t i2 = idx;
148  if(i2+1 < numberOfXNodes) { ++i2; }
149  return fac*(GetValue(i2, idy) - GetValue(i1, idy))/(GetX(i2) - GetX(i1));
150 }
151 
152 inline G4double
153 G4Physics2DVector::DerivativeY(size_t idx, size_t idy, G4double fac) const
154 {
155  size_t i1 = idy;
156  if(i1 > 0) { --i1; }
157  size_t i2 = idy;
158  if(i2+1 < numberOfYNodes) { ++i2; }
159  return fac*(GetValue(idx, i2) - GetValue(idx, i1))/(GetY(i2) - GetY(i1));
160 }
161 
162 inline G4double
163 G4Physics2DVector::DerivativeXY(size_t idx, size_t idy, G4double fac) const
164 {
165  size_t i1 = idx;
166  if(i1 > 0) { --i1; }
167  size_t i2 = idx;
168  if(i2+1 < numberOfXNodes) { ++i2; }
169  size_t j1 = idy;
170  if(j1 > 0) { --j1; }
171  size_t j2 = idy;
172  if(j2+1 < numberOfYNodes) { ++j2; }
173  return fac*(GetValue(i2, j2) - GetValue(i1, j2) - GetValue(i2, j1)
174  + GetValue(i1, j1))/((GetX(i2) - GetX(i1))*(GetY(j2) - GetY(j1)));
175 }