EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
partonx6.F
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file partonx6.F
1 
2  Function partonx6 (IPRTN, XX, QQ)
3 
4 c Given the parton distribution function in the array U in
5 c COMMON / PEVLDT / , this routine interpolates to find
6 c the parton distribution at an arbitray point in x and q.
7 c
8  Implicit Double Precision (a-h,o-z)
9 
10  parameter(mxx = 96, mxq = 20, mxf = 5)
11  parameter(mxqx= mxq * mxx, mxpqx = mxqx * (mxf+3))
12 
13  Common
14  > / ctqpar1 / al, xv(0:mxx), tv(0:mxq), upd(mxpqx)
15  > / ctqpar2 / nx, nt, nfmx
16  > / xqrange / qini, qmax, xmin
17 
18  dimension fvec(4), fij(4)
19  dimension xvpow(0:mxx)
20  Data onep / 1.00001 /
21  Data xpow / 0.3d0 / !**** choice of interpolation variable
22  Data nqvec / 4 /
23  Data ientry / 0 /
24  Save ientry,xvpow
25 
26 c store the powers used for interpolation on first call...
27  if(ientry .eq. 0) then
28  ientry = 1
29 
30  xvpow(0) = 0d0
31  do i = 1, nx
32  xvpow(i) = xv(i)**xpow
33  enddo
34  endif
35 
36  x = xx
37  q = qq
38  tt = log(log(q/al))
39 
40 c ------------- find lower end of interval containing x, i.e.,
41 c get jx such that xv(jx) .le. x .le. xv(jx+1)...
42  jlx = -1
43  ju = nx+1
44  11 If (ju-jlx .GT. 1) Then
45  jm = (ju+jlx) / 2
46  If (x .Ge. xv(jm)) Then
47  jlx = jm
48  Else
49  ju = jm
50  Endif
51  goto 11
52  Endif
53 C Ix 0 1 2 Jx JLx Nx-2 Nx
54 C |---|---|---|...|---|-x-|---|...|---|---|
55 C x 0 Xmin x 1
56 C
57  If (jlx .LE. -1) Then
58  print '(A,1pE12.4)', 'Severe error: x <= 0 in PartonX6! x = ', x
59  stop
60  ElseIf (jlx .Eq. 0) Then
61  jx = 0
62  Elseif (jlx .LE. nx-2) Then
63 
64 C For interrior points, keep x in the middle, as shown above
65  jx = jlx - 1
66  Elseif (jlx.Eq.nx-1 .or. x.LT.onep) Then
67 
68 C We tolerate a slight over-shoot of one (OneP=1.00001),
69 C perhaps due to roundoff or whatever, but not more than that.
70 C Keep at least 4 points >= Jx
71  jx = jlx - 2
72  Else
73  print '(A,1pE12.4)', 'Severe error: x > 1 in PartonX6! x = ', x
74  stop
75  Endif
76 C ---------- Note: JLx uniquely identifies the x-bin; Jx does not.
77 
78 C This is the variable to be interpolated in
79  ss = x**xpow
80 
81  If (jlx.Ge.2 .and. jlx.Le.nx-2) Then
82 
83 c initiation work for "interior bins": store the lattice points in s...
84  svec1 = xvpow(jx)
85  svec2 = xvpow(jx+1)
86  svec3 = xvpow(jx+2)
87  svec4 = xvpow(jx+3)
88 
89  s12 = svec1 - svec2
90  s13 = svec1 - svec3
91  s23 = svec2 - svec3
92  s24 = svec2 - svec4
93  s34 = svec3 - svec4
94 
95  sy2 = ss - svec2
96  sy3 = ss - svec3
97 
98 c constants needed for interpolating in s at fixed t lattice points...
99  const1 = s13/s23
100  const2 = s12/s23
101  const3 = s34/s23
102  const4 = s24/s23
103  s1213 = s12 + s13
104  s2434 = s24 + s34
105  sdet = s12*s34 - s1213*s2434
106  tmp = sy2*sy3/sdet
107  const5 = (s34*sy2-s2434*sy3)*tmp/s12
108  const6 = (s1213*sy2-s12*sy3)*tmp/s34
109 
110  EndIf
111 
112 c --------------Now find lower end of interval containing Q, i.e.,
113 c get jq such that qv(jq) .le. q .le. qv(jq+1)...
114  jlq = -1
115  ju = nt+1
116  12 If (ju-jlq .GT. 1) Then
117  jm = (ju+jlq) / 2
118  If (tt .GE. tv(jm)) Then
119  jlq = jm
120  Else
121  ju = jm
122  Endif
123  goto 12
124  Endif
125 
126  If (jlq .LE. 0) Then
127  jq = 0
128  Elseif (jlq .LE. nt-2) Then
129 C keep q in the middle, as shown above
130  jq = jlq - 1
131  Else
132 C JLq .GE. Nt-1 case: Keep at least 4 points >= Jq.
133  jq = nt - 3
134 
135  Endif
136 C This is the interpolation variable in Q
137 
138  If (jlq.GE.1 .and. jlq.LE.nt-2) Then
139 c store the lattice points in t...
140  tvec1 = tv(jq)
141  tvec2 = tv(jq+1)
142  tvec3 = tv(jq+2)
143  tvec4 = tv(jq+3)
144 
145  t12 = tvec1 - tvec2
146  t13 = tvec1 - tvec3
147  t23 = tvec2 - tvec3
148  t24 = tvec2 - tvec4
149  t34 = tvec3 - tvec4
150 
151  ty2 = tt - tvec2
152  ty3 = tt - tvec3
153 
154  tmp1 = t12 + t13
155  tmp2 = t24 + t34
156 
157  tdet = t12*t34 - tmp1*tmp2
158 
159  EndIf
160 
161 
162 c get the pdf function values at the lattice points...
163 
164  If (iprtn .GE. 3) Then
165  ip = - iprtn
166  Else
167  ip = iprtn
168  EndIf
169  jtmp = ((ip + nfmx)*(nt+1)+(jq-1))*(nx+1)+jx+1
170 
171  Do it = 1, nqvec
172 
173  j1 = jtmp + it*(nx+1)
174 
175  If (jx .Eq. 0) Then
176 C For the first 4 x points, interpolate x^2*f(x,Q)
177 C This applies to the two lowest bins JLx = 0, 1
178 C We can not put the JLx.eq.1 bin into the "interrior" section
179 C (as we do for q), since Upd(J1) is undefined.
180  fij(1) = 0
181  fij(2) = upd(j1+1) * xv(1)**2
182  fij(3) = upd(j1+2) * xv(2)**2
183  fij(4) = upd(j1+3) * xv(3)**2
184 C
185 C Use Polint6 which allows x to be anywhere w.r.t. the grid
186 
187  Call polint6(xvpow(0), fij(1), 4, ss, fx, dfx)
188 
189  If (x .GT. 0d0) fvec(it) = fx / x**2
190 C Pdf is undefined for x.eq.0
191  ElseIf (jlx .Eq. nx-1) Then
192 C This is the highest x bin:
193 
194  Call polint6(xvpow(nx-3), upd(j1), 4, ss, fx, dfx)
195 
196  fvec(it) = fx
197 
198  Else
199 C for all interior points, use Jon's in-line function
200 C This applied to (JLx.Ge.2 .and. JLx.Le.Nx-2)
201  sf2 = upd(j1+1)
202  sf3 = upd(j1+2)
203 
204  g1 = sf2*const1 - sf3*const2
205  g4 = -sf2*const3 + sf3*const4
206 
207  fvec(it) = (const5*(upd(j1)-g1)
208  & + const6*(upd(j1+3)-g4)
209  & + sf2*sy3 - sf3*sy2) / s23
210 
211  Endif
212 
213  enddo
214 C We now have the four values Fvec(1:4)
215 c interpolate in t...
216 
217  If (jlq .LE. 0) Then
218 C 1st Q-bin, as well as extrapolation to lower Q
219  Call polint6(tv(0), fvec(1), 4, tt, ff, dfq)
220 
221  ElseIf (jlq .GE. nt-1) Then
222 C Last Q-bin, as well as extrapolation to higher Q
223  Call polint6(tv(nt-3), fvec(1), 4, tt, ff, dfq)
224  Else
225 C Interrior bins : (JLq.GE.1 .and. JLq.LE.Nt-2)
226 C which include JLq.Eq.1 and JLq.Eq.Nt-2, since Upd is defined for
227 C the full range QV(0:Nt) (in contrast to XV)
228  tf2 = fvec(2)
229  tf3 = fvec(3)
230 
231  g1 = ( tf2*t13 - tf3*t12) / t23
232  g4 = (-tf2*t34 + tf3*t24) / t23
233 
234  h00 = ((t34*ty2-tmp2*ty3)*(fvec(1)-g1)/t12
235  & + (tmp1*ty2-t12*ty3)*(fvec(4)-g4)/t34)
236 
237  ff = (h00*ty2*ty3/tdet + tf2*ty3 - tf3*ty2) / t23
238  EndIf
239 
240  partonx6 = ff
241 
242  Return
243 C ********************
244  End