2323"""
2424
2525import numpy as np
26- from scipy import interpolate as scint
2726
2827from n3fit .backends import operations as op
2928
@@ -40,122 +39,6 @@ class DIS(Observable):
4039 while the input pdf is rank 4 of shape (batch_size, replicas, xgrid, flavours)
4140 """
4241
43- def __init__ (self , fktable_data ,
44- fktable_arr ,
45- dataset_name ,
46- boundary_condition = None ,
47- operation_name = "NULL" ,
48- nfl = 14 ,
49- n_replicas = 1 ,
50- power_corrections = False ,
51- ht_type = None ,
52- exp_kinematics = None ,
53- ** kwargs ):
54- super ().__init__ (fktable_data , fktable_arr , dataset_name , boundary_condition , operation_name , nfl , n_replicas , ** kwargs )
55-
56- self .compute_power_corrections = power_corrections
57- self .power_corrections = None
58-
59- # NOTE
60- # Ratio of SFs are not implemented yet. Work in progress.
61- if self .compute_power_corrections and exp_kinematics is not None :
62- self .exp_kinematics = exp_kinematics
63- if ht_type is None :
64- self .ht_type = 'ABMP'
65- raise NotImplementedError ("This part should be reimplemented." )
66- else :
67- self .ht_type = ht_type
68-
69- if self .ht_type == 'ABMP' :
70- self .power_corrections = self .compute_abmp_parametrisation ()
71- elif self .ht_type == 'custom' :
72- self .power_corrections = self .compute_custom_parametrisation ()
73- else :
74- raise Exception (f"HT type { ht_type } is not implemented." )
75-
76-
77- def compute_abmp_parametrisation (self ):
78- """
79- This function is very similar to `compute_ht_parametrisation` in
80- validphys.theorycovariance.construction.py. However, the latter
81- accounts for shifts in the 5pt prescription. As of now, this function
82- is meant to work only for DIS NC data, using the ABMP16 result.
83- """
84- x_knots = [0.0 , 0.1 , 0.3 , 0.5 , 0.7 , 0.9 , 1 ]
85- y_h2 = [0.023 , - 0.032 , - 0.005 , 0.025 , 0.051 , 0.003 , 0.0 ]
86- y_ht = [- 0.319 , - 0.134 , - 0.052 , 0.071 , 0.030 , 0.003 , 0.0 ]
87- #h2_sigma = [0.019, 0.013, 0.009, 0.006, 0.005, 0.004]
88- #ht_sigma = [0.126, 0.040, 0.030, 0.025, 0.012, 0.007]
89- H_2 = scint .CubicSpline (x_knots , y_h2 )
90- H_T = scint .CubicSpline (x_knots , y_ht )
91-
92- # Reconstruct HL from HT and H2
93- def H_L (x ):
94- return (H_2 (x ) - np .power (x , 0.05 ) * H_T (x ))
95-
96- H_2 = np .vectorize (H_2 )
97- H_L = np .vectorize (H_L )
98-
99- x = self .exp_kinematics ['kin1' ]
100- y = self .exp_kinematics ['kin3' ]
101- Q2 = self .exp_kinematics ['kin2' ]
102- N2 , NL = 1 #compute_normalisation_by_experiment(self.dataname, x, y, Q2)
103-
104- PC_2 = N2 * H_2 (x ) / Q2
105- PC_L = NL * H_L (x ) / Q2
106- power_correction = PC_2 + PC_L
107- power_correction = power_correction .to_numpy ()
108-
109- return power_correction
110-
111-
112- def compute_custom_parametrisation (self ):
113- """
114- This function is very similar to `compute_ht_parametrisation` in
115- validphys.theorycovariance.construction.py. However, the latter
116- accounts for shifts in the 5pt prescription. As of now, this function
117- is meant to work only for DIS NC data, using the ABMP16 result.
118- """
119- # Posteriors from 240812-01-ABMP-large-prior-7k
120- x_knots = [0.0 , 0.1 , 0.3 , 0.5 , 0.7 , 0.9 , 1 ]
121- y_h2_p = [- 0.00441 , 0.11169 , - 0.01632 , 0.00000 , - 0.08742 , - 0.07279 , 0.00000 ]
122- y_hl_p = [0.00000 , - 0.06241 , - 0.08655 , - 0.03306 , 0.00000 , - 0.05987 , 0.0000 ]
123- y_h2_d = [- 0.04117 , 0.00000 , 0.03124 , - 0.01059 , 0.04763 , 0.00000 , 0.00000 ]
124- y_hl_d = [0.00316 , 0.00469 , 0.0000 , 0.0000 , 0.0000 , 0.0000 , 0.0000 ]
125-
126- H_2p = scint .CubicSpline (x_knots , y_h2_p )
127- H_lp = scint .CubicSpline (x_knots , y_hl_p )
128- H_2d = scint .CubicSpline (x_knots , y_h2_d )
129- H_ld = scint .CubicSpline (x_knots , y_hl_d )
130-
131- H_2p = np .vectorize (H_2p )
132- H_lp = np .vectorize (H_lp )
133- H_2d = np .vectorize (H_2d )
134- H_ld = np .vectorize (H_ld )
135-
136- x = self .exp_kinematics ['kin1' ]
137- y = self .exp_kinematics ['kin3' ]
138- Q2 = self .exp_kinematics ['kin2' ]
139- N2 , NL = compute_normalisation_by_experiment (self .dataname , x , y , Q2 )
140-
141- if "_P_" in self .dataname or "HERA" in self .dataname :
142- PC_2 = N2 * H_2p (x ) / Q2
143- PC_L = NL * H_lp (x ) / Q2
144- elif "_D_" in self .dataname :
145- PC_2 = N2 * H_2d (x ) / Q2
146- PC_L = NL * H_ld (x ) / Q2
147- else :
148- # TODO
149- # Need to implement this
150- PC_2 = 0 / Q2 #N2 * H_2d(x) / Q2
151- PC_L = 0 / Q2 #NL * H_ld(x) / Q2
152-
153- power_correction = PC_2 + PC_L
154- power_correction = power_correction .to_numpy ()
155-
156- return power_correction
157-
158-
15942 def gen_mask (self , basis ):
16043 """
16144 Receives a list of active flavours and generates a boolean mask tensor
@@ -202,11 +85,7 @@ def build(self, input_shape):
20285 if self .num_replicas > 1 :
20386 self .compute_observable = compute_dis_observable_many_replica
20487 else :
205- # Currying the function so that the `Observable` does not need
206- # to get modified
207- def compute_dis_observable_one_replica_w_pc (pdf , padded_fk ):
208- return compute_dis_observable_one_replica (pdf , padded_fk , power_corrections = self .power_corrections )
209- self .compute_observable = compute_dis_observable_one_replica_w_pc
88+ self .compute_observable = compute_dis_observable_one_replica
21089
21190
21291def compute_dis_observable_many_replica (pdf , padded_fk ):
@@ -228,14 +107,9 @@ def compute_dis_observable_many_replica(pdf, padded_fk):
228107 return op .einsum ('brxf, nxf -> brn' , pdf [0 ], padded_fk )
229108
230109
231- def compute_dis_observable_one_replica (pdf , padded_fk , power_corrections = None ):
110+ def compute_dis_observable_one_replica (pdf , padded_fk ):
232111 """
233112 Same operations as above but a specialized implementation that is more efficient for 1 replica,
234113 masking the PDF rather than the fk table.
235114 """
236- if power_corrections is None :
237-
238- return op .tensor_product (pdf [0 ], padded_fk , axes = [(2 , 3 ), (1 , 2 )])
239- else :
240-
241- return op .tensor_product (pdf [0 ], padded_fk , axes = [(2 , 3 ), (1 , 2 )]) + power_corrections
115+ return op .tensor_product (pdf [0 ], padded_fk , axes = [(2 , 3 ), (1 , 2 )])
0 commit comments