4242NC_SIGMARED_P_EAVG = ['HERA_NC_318GEV_EAVG_CHARM-SIGMARED' , 'HERA_NC_318GEV_EAVG_BOTTOM-SIGMARED' ]
4343
4444
45- # TODO This function will be deleted in the future
46- def step_function (a : npt .ArrayLike , y_shift : npt .ArrayLike , bin_edges : npt .ArrayLike ) -> np .ndarray :
47- """
48- This function defines the step function used to construct the prior. The bins of the step
49- function are constructed using pairs of consecutive points. For instance, given the set of
50- points [0.0, 0.1, 0.3, 0.5], there will be three bins with edges [[0.0, 0.1], [0.1, 0.3],
51- 0.3, 0.5]]. Each bin is coupled with a shift, which correspond to the y-value of the bin.
52-
53- Parameters
54- ----------
55- a: ArrayLike of float
56- A one-dimensional array of points at which the function is evaluated.
57- y_shift: ArrayLike of float
58- A one-dimensional array whose elements represent the y-value of each bin
59- bin_edges: ArrayLike of float
60- A one-dimensional array containing the edges of the bins. The bins are
61- constructed using pairs of consecutive points.
62-
63- Return
64- ------
65- A one-dimensional array containing the function values evaluated at the points
66- specified in `a`.
67- """
68- res = np .zeros_like (a )
69- for shift_pos , shift in enumerate (y_shift ):
70- bin_low = bin_edges [shift_pos ]
71- bin_high = bin_edges [shift_pos + 1 ]
72- condition = np .multiply (
73- a >= bin_low , a < bin_high if shift_pos != len (y_shift ) - 1 else a <= bin_high
74- )
75- res = np .add (res , [shift if cond else 0.0 for cond in condition ])
76- return res
77-
78-
79- # TODO This function will be deleted in the future
80- def cubic_spline_function (
81- a : npt .ArrayLike , y_shift : npt .ArrayLike , nodes : npt .ArrayLike
82- ) -> np .ndarray :
83- """
84- This function defines the cubic spline function used to construct the prior. The spline
85- is constructed using the nodes specified in `nodes` and the y-values in `y_shift`. The
86- spline is evaluated at the points specified in `a`.
87-
88- Parameters
89- ----------
90- a: ArrayLike of float
91- A one-dimensional array of points at which the function is evaluated.
92- y_shift: ArrayLike of float
93- A one-dimensional array whose elements represent the y-value of each bin
94- nodes: ArrayLike of float
95- A one-dimensional array containing the nodes used to construct the spline.
96-
97- Return
98- ------
99- A one-dimensional array containing the function values evaluated at the points
100- specified in `a`.
101- """
102- from scipy .interpolate import CubicSpline
103-
104- cs = CubicSpline (nodes , y_shift )
105- return cs (a )
106-
107-
10845def linear_bin_function (
10946 a : npt .ArrayLike , y_shift : npt .ArrayLike , bin_edges : npt .ArrayLike
11047) -> np .ndarray :
@@ -166,14 +103,13 @@ def dis_pc_func(
166103 nodes : npt .ArrayLike ,
167104 x : npt .ArrayLike ,
168105 Q2 : npt .ArrayLike ,
169- pc_func_type : str = "step" ,
170106) -> npt .ArrayLike :
171107 """
172108 This function builds the functional form of the power corrections for DIS-like processes.
173- Power corrections are modelled using a step- function. The edges of the bins used in the
174- step-function are specified by the list of nodes . The y-values for each bin are given
109+ Power corrections are modelled using a linear function, which interpolates between the nodes
110+ of the parameterisation . The y-values for each node are given
175111 by the array `delta_h`. The power corrections will be computed for the pairs (xb, Q2),
176- where `xb` is the Bjorken x. The power correction for DIS processes are rescaled by Q2.
112+ where `xb` is the Bjorken x. The power correction for DIS processes is divided by Q2.
177113
178114 Parameters
179115 ----------
@@ -191,15 +127,7 @@ def dis_pc_func(
191127 A one-dimensional array of power corrections for DIS-like processes where each point is
192128 evaluated at the kinematic pair (x,Q2).
193129 """
194- if pc_func_type == "step" :
195- PC = step_function (x , delta_h , nodes ) / Q2
196- elif pc_func_type == "linear" :
197- PC = linear_bin_function (x , delta_h , nodes ) / Q2
198- elif pc_func_type == "cubic" :
199- PC = cubic_spline_function (x , delta_h , nodes ) / Q2
200- else :
201- raise ValueError (f"Invalid function type: { pc_func_type } is not supported." )
202-
130+ PC = linear_bin_function (x , delta_h , nodes ) / Q2
203131 return PC
204132
205133
@@ -208,7 +136,6 @@ def jets_pc_func(
208136 nodes : npt .ArrayLike ,
209137 pT : npt .ArrayLike ,
210138 rap : npt .ArrayLike ,
211- pc_func_type : str = "step" ,
212139) -> npt .ArrayLike :
213140 """
214141 Same as `dis_pc_func`, but for jet data. Here, the kinematic pair consists of the rapidity
@@ -230,14 +157,7 @@ def jets_pc_func(
230157 A one-dimensional array of power corrections for jet processes where each point is
231158 evaluated at the kinematic pair (y, pT).
232159 """
233- if pc_func_type == "step" :
234- PC = step_function (rap , delta_h , nodes ) / pT
235- elif pc_func_type == "linear" :
236- PC = linear_bin_function (rap , delta_h , nodes ) / pT
237- elif pc_func_type == "cubic" :
238- PC = cubic_spline_function (rap , delta_h , nodes ) / pT
239- else :
240- raise ValueError (f"Invalid function type: { pc_func_type } is not supported." )
160+ PC = linear_bin_function (rap , delta_h , nodes ) / pT
241161 return PC
242162
243163
@@ -265,7 +185,7 @@ def jets_pc_func(
265185# return func
266186
267187
268- def mult_dis_pc (nodes , x , q2 , dataset_sp , pdf , pc_func_type : str = "step" ):
188+ def mult_dis_pc (nodes , x , q2 , dataset_sp , pdf ):
269189 """
270190 Returns the function that computes the shift to observables due to
271191 power corrections. Power corrections are treated as multiplicative
@@ -279,21 +199,20 @@ def mult_dis_pc(nodes, x, q2, dataset_sp, pdf, pc_func_type: str = "step"):
279199
280200 This function returns a function that computes the shift
281201 given the y-values of the nodes used to define the power corrections.
282- The interpolation between the nodes is specified by `pc_func_type`.
283202 """
284203 cuts = dataset_sp .cuts
285204 (fkspec ,) = dataset_sp .fkspecs
286205 fk = fkspec .load_with_cuts (cuts )
287206 th_preds = central_fk_predictions (fk , pdf )
288207
289208 def func (y_values ):
290- result = dis_pc_func (y_values , nodes , x , q2 , pc_func_type )
209+ result = dis_pc_func (y_values , nodes , x , q2 )
291210 return np .multiply (result , th_preds .to_numpy ()[:, 0 ])
292211
293212 return func
294213
295214
296- def mult_dis_ratio_pc (p_nodes , d_nodes , x , q2 , dataset_sp , pdf , pc_func_type : str = "step" ):
215+ def mult_dis_ratio_pc (p_nodes , d_nodes , x , q2 , dataset_sp , pdf ):
297216 """
298217 Returns the function that computes the shift for the ratio of structure
299218 functions F2_d / F2_p. For this observable, power corrections are defined
@@ -344,16 +263,16 @@ def mult_dis_ratio_pc(p_nodes, d_nodes, x, q2, dataset_sp, pdf, pc_func_type: st
344263 F2_ratio = operator .truediv (F2D , F2P )
345264
346265 def func (y_values_p , y_values_d ):
347- h2d = dis_pc_func (y_values_d , d_nodes , x , q2 , pc_func_type )
348- h2p = dis_pc_func (y_values_p , p_nodes , x , q2 , pc_func_type )
266+ h2d = dis_pc_func (y_values_d , d_nodes , x , q2 )
267+ h2p = dis_pc_func (y_values_p , p_nodes , x , q2 )
349268 num = np .sum ([h2d , - h2p ], axis = 0 )
350269 denom = np .sum ([np .ones_like (h2p ), h2p ], axis = 0 )
351270 result = np .multiply (operator .truediv (num , denom ), F2_ratio )
352271 return result
353272
354273 return func
355274
356- def mult_jet_pc (nodes , pT , rap , dataset_sp , pdf , pc_func_type : str = "step" ):
275+ def mult_jet_pc (nodes , pT , rap , dataset_sp , pdf ):
357276 """
358277 As `mult_dis_pc`, but for jet data. The power corrections are defined as
359278
@@ -371,7 +290,7 @@ def mult_jet_pc(nodes, pT, rap, dataset_sp, pdf, pc_func_type: str = "step"):
371290 xsec = central_fk_predictions (fk , pdf )
372291
373292 def func (y_values ):
374- result = jets_pc_func (y_values , nodes , pT , rap , pc_func_type )
293+ result = jets_pc_func (y_values , nodes , pT , rap )
375294 return np .multiply (result , xsec .to_numpy ()[:, 0 ])
376295
377296 return func
@@ -416,8 +335,7 @@ def construct_pars_combs(parameters_dict):
416335
417336 return combinations
418337
419- # TODO `pc_func_type` will be removed
420- def compute_deltas_pc (dataset_sp : DataSetSpec , pdf : PDF , pc_dict : dict , pc_func_type : str ):
338+ def compute_deltas_pc (dataset_sp : DataSetSpec , pdf : PDF , pc_dict : dict ):
421339 """
422340 Computes the shifts due to power corrections for a single dataset given
423341 the set of parameters that model the power corrections. The result is
@@ -454,19 +372,19 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict, pc_func_
454372
455373 # F2 ratio
456374 if exp_name == "NMC_NC_NOTFIXED_EM-F2" :
457- pc_func_ratio = mult_dis_ratio_pc (f2_p_nodes , f2_d_nodes , x , q2 , dataset_sp , pdf , pc_func_type )
375+ pc_func_ratio = mult_dis_ratio_pc (f2_p_nodes , f2_d_nodes , x , q2 , dataset_sp , pdf )
458376 for pars_pc in pars_combs :
459377 deltas [pars_pc ['label' ]] = pc_func_ratio (pars_pc ['comb' ]['f2p' ], pars_pc ['comb' ]['f2d' ])
460378
461379 # F2 proton traget
462380 elif exp_name in F2P_exps :
463- pc_func = mult_dis_pc (f2_p_nodes , x , q2 , dataset_sp , pdf , pc_func_type )
381+ pc_func = mult_dis_pc (f2_p_nodes , x , q2 , dataset_sp , pdf )
464382 for pars_pc in pars_combs :
465383 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['f2p' ])
466384
467385 # F2 deuteron traget
468386 elif exp_name in F2D_exps :
469- pc_func = mult_dis_pc (f2_d_nodes , x , q2 , dataset_sp , pdf , pc_func_type )
387+ pc_func = mult_dis_pc (f2_d_nodes , x , q2 , dataset_sp , pdf )
470388 for pars_pc in pars_combs :
471389 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['f2d' ])
472390
@@ -479,25 +397,25 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict, pc_func_
479397
480398 # HERA NC xsec
481399 elif exp_name in np .concatenate ([NC_SIGMARED_P_EM , NC_SIGMARED_P_EP , NC_SIGMARED_P_EAVG ]):
482- pc_func = mult_dis_pc (f2_p_nodes , x , q2 , dataset_sp , pdf , pc_func_type )
400+ pc_func = mult_dis_pc (f2_p_nodes , x , q2 , dataset_sp , pdf )
483401 for pars_pc in pars_combs :
484402 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['f2p' ])
485403
486404 # CHORUS
487405 elif exp_name .startswith ('CHORUS_CC' ):
488- pc_func = mult_dis_pc (dis_cc_nodes , x , q2 , dataset_sp , pdf , pc_func_type )
406+ pc_func = mult_dis_pc (dis_cc_nodes , x , q2 , dataset_sp , pdf )
489407 for pars_pc in pars_combs :
490408 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['dis_cc' ])
491409
492410 # NuTeV
493411 elif exp_name .startswith ('NUTEV_CC' ):
494- pc_func = mult_dis_pc (dis_cc_nodes , x , q2 , dataset_sp , pdf , pc_func_type )
412+ pc_func = mult_dis_pc (dis_cc_nodes , x , q2 , dataset_sp , pdf )
495413 for pars_pc in pars_combs :
496414 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['dis_cc' ])
497415
498416 # HERA_CC
499417 elif exp_name .startswith ('HERA_CC' ):
500- pc_func = mult_dis_pc (dis_cc_nodes , x , q2 , dataset_sp , pdf , pc_func_type )
418+ pc_func = mult_dis_pc (dis_cc_nodes , x , q2 , dataset_sp , pdf )
501419 for pars_pc in pars_combs :
502420 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['dis_cc' ])
503421
@@ -511,7 +429,7 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict, pc_func_
511429 eta = dataset_sp .commondata .metadata .load_kinematics ()['y' ].to_numpy ().reshape (- 1 )[cuts ]
512430 pT = dataset_sp .commondata .metadata .load_kinematics ()['pT' ].to_numpy ().reshape (- 1 )[cuts ]
513431
514- pc_func = mult_jet_pc (pc_jet_nodes , pT , eta , dataset_sp , pdf , pc_func_type )
432+ pc_func = mult_jet_pc (pc_jet_nodes , pT , eta , dataset_sp , pdf )
515433 for pars_pc in pars_combs :
516434 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['Hj' ])
517435
@@ -530,7 +448,7 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict, pc_func_
530448 .to_numpy ()
531449 .reshape (- 1 )[cuts ]
532450 )
533- pc_func = mult_jet_pc (pc_jet_nodes , m_jj , eta_star , dataset_sp , pdf , pc_func_type )
451+ pc_func = mult_jet_pc (pc_jet_nodes , m_jj , eta_star , dataset_sp , pdf )
534452 for pars_pc in pars_combs :
535453 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['H2j_ATLAS' ] if pc_dict .get ("H2j_ATLAS" ) else pars_pc ['comb' ]['H2j' ])
536454
@@ -546,7 +464,7 @@ def compute_deltas_pc(dataset_sp: DataSetSpec, pdf: PDF, pc_dict: dict, pc_func_
546464 .to_numpy ()
547465 .reshape (- 1 )[cuts ]
548466 )
549- pc_func = mult_jet_pc (pc_jet_nodes , m_jj , eta_diff , dataset_sp , pdf , pc_func_type )
467+ pc_func = mult_jet_pc (pc_jet_nodes , m_jj , eta_diff , dataset_sp , pdf )
550468 for pars_pc in pars_combs :
551469 deltas [pars_pc ['label' ]] = pc_func (pars_pc ['comb' ]['H2j_CMS' ] if pc_dict .get ("H2j_CMS" ) else pars_pc ['comb' ]['H2j' ])
552470
0 commit comments