@@ -26,11 +26,22 @@ def run(self):
2626 ) as o :
2727 self .runcard = yaml .safe_load (o )
2828
29+ def read_kinematics (self ):
30+ """Read kinematics from runcard."""
31+ if "kinematics" in self .runcard :
32+ kinematics = self .runcard ["kinematics" ]
33+ xgrid = np .array ([point ["x" ] for point in kinematics ])
34+ q2grid = np .array ([point ["q2" ] for point in kinematics ])
35+ else :
36+ xgrid = np .array (self .runcard ["xgrid" ])
37+ q2 = self .runcard ["q2" ]
38+ q2grid = np .full_like (xgrid , q2 )
39+ return xgrid , q2grid
40+
2941 def generate_pineappl (self ):
3042 """Generate grid."""
31- self .xgrid = np . array ( self .runcard [ "xgrid" ] )
43+ self .xgrid , self . q2grid = self .read_kinematics ( )
3244 self .pid = self .runcard ["pid" ]
33- self .q2 = self .runcard ["q2" ]
3445 self .hadron_pid = self .runcard ["hadron_pid" ]
3546 self .convolution_type = self .runcard .get ("convolution_type" , "UnpolPDF" )
3647
@@ -92,16 +103,16 @@ def generate_pineappl(self):
92103
93104 limits = []
94105 # add each point as a bin
95- for bin_ , x in enumerate (self .xgrid ):
106+ for bin_ , ( x , q2 ) in enumerate (zip ( self .xgrid , self . q2grid ) ):
96107 # keep DIS bins
97- limits .append ([(self . q2 , self . q2 ), (x , x )])
108+ limits .append ([(q2 , q2 ), (x , x )])
98109 # Fill the subgrid with delta functions
99110 array_subgrid = np .zeros ((1 , self .xgrid .size ))
100111 array_subgrid [0 ][bin_ ] = x
101112 # create and set the subgrid
102113 subgrid = pineappl .subgrid .ImportSubgridV1 (
103114 array = array_subgrid ,
104- node_values = [[self . q2 ], self .xgrid ],
115+ node_values = [[q2 ], self .xgrid ],
105116 )
106117 grid .set_subgrid (0 , bin_ , 0 , subgrid .into ())
107118 # set the correct observables
@@ -125,27 +136,29 @@ def results(self):
125136
126137 pdf = lhapdf .mkPDF (self .pdf )
127138 d = {
128- "result" : [pdf .xfxQ2 (self .pid , x , self .q2 ) for x in self .xgrid ],
139+ "result" : [
140+ pdf .xfxQ2 (self .pid , x , q2 ) for (x , q2 ) in zip (self .xgrid , self .q2grid )
141+ ],
129142 "error" : [1e-15 ] * len (self .xgrid ),
130143 "sv_min" : [
131144 np .amin (
132145 [
133- pdf .xfxQ2 (self .pid , x , 0.25 * self . q2 ),
134- pdf .xfxQ2 (self .pid , x , self . q2 ),
135- pdf .xfxQ2 (self .pid , x , 4.0 * self . q2 ),
146+ pdf .xfxQ2 (self .pid , x , 0.25 * q2 ),
147+ pdf .xfxQ2 (self .pid , x , q2 ),
148+ pdf .xfxQ2 (self .pid , x , 4.0 * q2 ),
136149 ]
137150 )
138- for x in self .xgrid
151+ for ( x , q2 ) in zip ( self .xgrid , self . q2grid )
139152 ],
140153 "sv_max" : [
141154 np .amax (
142155 [
143- pdf .xfxQ2 (self .pid , x , 0.25 * self . q2 ),
144- pdf .xfxQ2 (self .pid , x , self . q2 ),
145- pdf .xfxQ2 (self .pid , x , 4.0 * self . q2 ),
156+ pdf .xfxQ2 (self .pid , x , 0.25 * q2 ),
157+ pdf .xfxQ2 (self .pid , x , q2 ),
158+ pdf .xfxQ2 (self .pid , x , 4.0 * q2 ),
146159 ]
147160 )
148- for x in self .xgrid
161+ for ( x , q2 ) in zip ( self .xgrid , self . q2grid )
149162 ],
150163 }
151164 results = pd .DataFrame (data = d )
0 commit comments