forked from yuxunguo/GUMP-Global-GPDs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Predictions.py
289 lines (230 loc) · 8.05 KB
/
Predictions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
from Parameters import ParaManager_Unp, ParaManager_Pol
from Observables import GPDobserv
from DVCS_xsec import dsigma_TOT, dsigma_DVCS_HERA, M
import numpy as np
import pandas as pd
import csv
from Minimizer import PDF_theo, tPDF_theo, GFF_theo, CFF_theo
from Minimizer import DVCSxsec_theo, DVCSxsec_cost_xBtQ, DVCSxsec_HERA_theo
from multiprocessing import Pool
df_Para = pd.read_csv('GUMP_Params/params.csv', index_col=0)
para_list_unp = df_Para['value'][:38].to_numpy()
para_list_pol = df_Para['value'][38:].to_numpy()
Para_Unp = ParaManager_Unp(para_list_unp)
Para_Pol = ParaManager_Pol(para_list_pol)
Para_All = np.concatenate([Para_Unp, Para_Pol], axis=0)
def PDF(x, t, Q, flv, spe):
'''
Return parton distribution function (PDF) at a given point.
Args:
x: numpy float array.
t: numpy float array.
Q: numpy float array.
flv: an array of string.
flv is the flavor. It can be 'u', 'd', 'g', 'NS', or 'S'
spe: numpy integer array
spe is the "species."
0 means H
1 means E
2 means Ht
3 means Et
Returns:
_pdf: numpy float array.
Parton distribution function.
'''
x = np.array(x)
t = np.array(t)
Q = np.array(Q)
flv = np.array(flv)
spe = np.array(spe)
xi = 0
p = np.where(spe<=1, 1, -1)
'''
if(spe == 0 or spe == 1):
p = 1
if(spe == 2 or spe == 3):
p = -1
'''
# Para: (4, 2, 5, 1, 4)
Para_spe = Para_All[spe] # fancy indexing. Output (N, 3, 5, 1, 5)
_PDF_theo = GPDobserv(x, xi, t, Q, p)
_pdf = _PDF_theo.tPDF(flv, Para_spe) # array length N
return _pdf
tPDF = PDF
def GPD(x, xi, t, Q, flv, spe):
'''
Return parton distribution function (PDF) at a given point.
Args:
x: numpy float array.
t: numpy float array.
Q: numpy float array.
flv: an array of string.
flv is the flavor. It can be 'u', 'd', 'g', 'NS', or 'S'
spe: numpy integer array
spe is the "species."
0 means H
1 means E
2 means Ht
3 means Et
Returns:
_pdf: numpy float array.
Parton distribution function.
'''
x = np.array(x)
xi = np.array(xi)
t = np.array(t)
Q = np.array(Q)
flv = np.array(flv)
spe = np.array(spe)
p = np.where(spe<=1, 1, -1)
'''
if(spe == 0 or spe == 1):
p = 1
if(spe == 2 or spe == 3):
p = -1
'''
# Para: (4, 2, 5, 1, 4)
Para_spe = Para_All[spe] # fancy indexing. Output (N, 3, 5, 1, 5)
_GPD_theo = GPDobserv(x, xi, t, Q, p)
_GPD = _GPD_theo.GPD(flv, Para_spe) # array length N
return _GPD
def GFF(j, t, Q, flv, spe):
'''
Return Generalized Form Factors
Args:
j: numpy int array
t: numpy float array
Q: numpy float array
flv: an array of string.
flv is the flavor. It can be 'u', 'd', 'g', 'NS', or 'S'
spe: numpy array of integer
spe is the "species."
0 means H
1 means E
2 means Ht
3 means Et
Returns:
_gff: generalized form factors. numpy float array
'''
j = np.array(j)
t = np.array(t)
Q = np.array(Q)
flv = np.array(flv)
spe = np.array(spe)
x = 0
xi = 0
'''
if(spe == 0 or spe == 1):
p = 1
if(spe == 2 or spe == 3):
p = -1
'''
p = np.where(spe<=1, 1, -1)
Para_spe = Para_All[spe] # fancy indexing. Output (N, 3, 5, 1, 5)
_GFF_theo = GPDobserv(x, xi, t, Q, p)
_gff = _GFF_theo.GFFj0(j, flv, Para_spe) # (N)
return _gff
def CFF(xB, t, Q):
'''
CFF
Args
xB: numpy float array
t: numpy float array
Q: numpy float array
Returns
[ HCFF, ECFF, HtCFF, EtCFF ], each of which is a numpy array
'''
xB = np.array(xB)
t = np.array(t)
Q = np.array(Q)
return CFF_theo(xB, t, Q, np.expand_dims(Para_Unp, axis=0), np.expand_dims(Para_Pol, axis=0))
def DVCSxsec(y, xB, t, Q, phi, pol):
'''
DVCS cross section
Args
y: numpy float array
xB: numpy float array
t: numpy float array
Q: numpy float array
phi: numpy float array
pol: a numpy array of str
pol can be 'UU', 'LU', 'UL', 'LL',
'UTin', 'LTin', 'UTout', or 'LTout'
Returns
The DVCS cross section. Float or numpy array
'''
y = np.array(y)
xB = np.array(xB)
t = np.array(t)
Q = np.array(Q)
phi = np.array(phi)
pol = np.array(pol)
[HCFF, ECFF, HtCFF, EtCFF] = CFF(xB, t, Q)
return dsigma_TOT(y, xB, t, Q, phi, pol, HCFF, ECFF, HtCFF, EtCFF)
if __name__ == '__main__':
pool = Pool()
'''
x = 0.1
xi = 0.3
t = -0.5
print(GPD([x,-x],[xi],[t],[2.0],['u'],[0]))
print(GPD([x,-x],[xi],[t],[2.0],['d'],[0]))
print(GPD([x,-x],[xi],[t],[2.0],['u'],[2]))
print(GPD([x,-x],[xi],[t],[2.0],['d'],[2]))
print(GPD([x,-x],[xi],[t],[2.0],['u'],[1]))
print(GPD([x,-x],[xi],[t],[2.0],['d'],[1]))
print(GPD([x,-x],[xi],[t],[2.0],['u'],[3]))
print(GPD([x,-x],[xi],[t],[2.0],['d'],[3]))
'''
x = np.exp(np.linspace(np.log(0.005), np.log(0.6), 100, dtype = float))
uhPDF = PDF(x,[0.0],[2.0],['u'],[0])
ubarhPDF = -PDF(-x,[0.0],[2.0],['u'],[0])
dhPDF = PDF(x,[0.0],[2.0],['d'],[0])
dbarhPDF = -PDF(-x,[0.0],[2.0],['d'],[0])
with open("GUMP_Results/H_PDF.csv","w",newline='') as my_csv:
csvWriter = csv.writer(my_csv,delimiter=',')
csvWriter.writerows(np.transpose([x,uhPDF,ubarhPDF,dhPDF,dbarhPDF]))
uePDF = PDF(x,[0.0],[2.0],['u'],[1])
ubarePDF = -PDF(-x,[0.0],[2.0],['u'],[1])
dePDF = PDF(x,[0.0],[2.0],['d'],[1])
dbarePDF = -PDF(-x,[0.0],[2.0],['d'],[1])
with open("GUMP_Results/E_PDF.csv","w",newline='') as my_csv:
csvWriter = csv.writer(my_csv,delimiter=',')
csvWriter.writerows(np.transpose([x,uePDF,ubarePDF,dePDF,dbarePDF]))
uhtPDF = PDF(x,[0.0],[2.0],['u'],[2])
ubarhtPDF = PDF(-x,[0.0],[2.0],['u'],[2])
dhtPDF = PDF(x,[0.0],[2.0],['d'],[2])
dbarhtPDF = PDF(-x,[0.0],[2.0],['d'],[2])
with open("GUMP_Results/Ht_PDF.csv","w",newline='') as my_csv:
csvWriter = csv.writer(my_csv,delimiter=',')
csvWriter.writerows(np.transpose([x,uhtPDF,ubarhtPDF,dhtPDF,dbarhtPDF]))
uetPDF = PDF(x,[0.0],[2.0],['u'],[3])
ubaretPDF = PDF(-x,[0.0],[2.0],['u'],[3])
detPDF = PDF(x,[0.0],[2.0],['d'],[3])
dbaretPDF = PDF(-x,[0.0],[2.0],['d'],[3])
with open("GUMP_Results/Et_PDF.csv","w",newline='') as my_csv:
csvWriter = csv.writer(my_csv,delimiter=',')
csvWriter.writerows(np.transpose([x,uetPDF,ubaretPDF,detPDF,dbaretPDF]))
'''
xgpd = np.concatenate((np.linspace(-0.6,-0.33,28,dtype = float),np.linspace(-0.32,0.32,66,dtype = float),np.linspace(0.33,0.6,28,dtype = float)))
uhGPD = GPD(xgpd,[0.33],[-0.5],[2.0],['u'],[0])
dhGPD = GPD(xgpd,[0.33],[-0.5],[2.0],['d'],[0])
with open("GUMP_Results/H_GPD.csv","w",newline='') as my_csv:
csvWriter = csv.writer(my_csv,delimiter=',')
csvWriter.writerows(np.transpose([xgpd,uhGPD,dhGPD]))
ueGPD = GPD(xgpd,[0.33],[-0.5],[2.0],['u'],[1])
deGPD = GPD(xgpd,[0.33],[-0.5],[2.0],['d'],[1])
with open("GUMP_Results/E_GPD.csv","w",newline='') as my_csv:
csvWriter = csv.writer(my_csv,delimiter=',')
csvWriter.writerows(np.transpose([xgpd,ueGPD,deGPD]))
uhtGPD = GPD(xgpd,[0.33],[-0.5],[2.0],['u'],[2])
dhtGPD = GPD(xgpd,[0.33],[-0.5],[2.0],['d'],[2])
with open("GUMP_Results/Ht_GPD.csv","w",newline='') as my_csv:
csvWriter = csv.writer(my_csv,delimiter=',')
csvWriter.writerows(np.transpose([xgpd,uhtGPD,dhtGPD]))
uetGPD = GPD(xgpd,[0.33],[-0.5],[2.0],['u'],[3])
detGPD = GPD(xgpd,[0.33],[-0.5],[2.0],['d'],[3])
with open("GUMP_Results/Et_GPD.csv","w",newline='') as my_csv:
csvWriter = csv.writer(my_csv,delimiter=',')
csvWriter.writerows(np.transpose([xgpd,uetGPD,detGPD]))
'''