GSLXSecFunc.h
Go to the documentation of this file.
1 //_____________________________________________________________________________________
2 /*!
3 
4 \namespace genie::utils::gsl
5 
6 \brief GENIE differential cross section function wrappers for GSL integrators.
7 
8 \author Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
9  University of Liverpool & STFC Rutherford Appleton Laboratory
10 
11 \created Sep 01, 2009
12 
13 \cpright Copyright (c) 2003-2020, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15 */
16 //_____________________________________________________________________________________
17 
18 #ifndef _GENIE_XSEC_FUNCTION_GSL_WRAPPERS_H_
19 #define _GENIE_XSEC_FUNCTION_GSL_WRAPPERS_H_
20 
21 #include <Math/IFunction.h>
22 #include <Math/IntegratorMultiDim.h>
23 #include "Framework/Utils/Range1.h"
24 
25 #include <string>
26 using std::string;
27 
28 namespace genie {
29 
30 class XSecAlgorithmI;
31 class Interaction;
32 
33 namespace utils {
34 namespace gsl {
35 
36 //.....................................................................................
37 //
38 // genie::utils::gsl::dXSec_dQ2_E
39 // A 1-D cross section function: dxsec/dQ2 = f(Q2)|(fixed E)
40 //
41 class dXSec_dQ2_E: public ROOT::Math::IBaseFunctionOneDim
42 {
43 public:
44  dXSec_dQ2_E(const XSecAlgorithmI * m, const Interaction * i, double scale=1.);
45  ~dXSec_dQ2_E();
46 
47  // ROOT::Math::IBaseFunctionOneDim interface
48  unsigned int NDim (void) const;
49  double DoEval (double xin) const;
50  ROOT::Math::IBaseFunctionOneDim * Clone (void) const;
51 
52 private:
55  double fScale; // can set to -1. for use with GSL minimizer
56 };
57 
58 //.....................................................................................
59 //
60 // genie::utils::gsl::dXSec_dy_E
61 // A 1-D cross section function: dxsec/dy = f(y)|(fixed E)
62 //
63 class dXSec_dy_E: public ROOT::Math::IBaseFunctionOneDim
64 {
65 public:
66  dXSec_dy_E(const XSecAlgorithmI * m, const Interaction * i);
67  ~dXSec_dy_E();
68 
69  // ROOT::Math::IBaseFunctionOneDim interface
70  unsigned int NDim (void) const;
71  double DoEval (double xin) const;
72  ROOT::Math::IBaseFunctionOneDim * Clone (void) const;
73 
74 private:
77 };
78 
79 //.....................................................................................
80 //
81 // genie::utils::gsl::dXSec_dEDNu_E
82 // A 1-D cross section function: dxsec/dEDNu = f(EDNu)|(fixed E)
83 //
84 class dXSec_dEDNu_E: public ROOT::Math::IBaseFunctionOneDim
85 {
86 public:
87  dXSec_dEDNu_E(const XSecAlgorithmI * m, const Interaction * i,
88  double DNuMass, double scale=1.);
89  ~dXSec_dEDNu_E();
90 
91  // ROOT::Math::IBaseFunctionOneDim interface
92  unsigned int NDim (void) const;
93  double DoEval (double xin) const;
94  ROOT::Math::IBaseFunctionOneDim * Clone (void) const;
95  Range1D_t IntegrationRange(void) const;
96 
97 private:
100  double fDNuMass;
101  double fScale; // can set to -1. for use with GSL minimizer
102 };
103 
104 //.....................................................................................
105 //
106 // genie::utils::gsl::d2XSec_dxdy_E
107 // A 2-D cross section function: d2xsec/dxdy = f(x,y)|(fixed E)
108 //
109 class d2XSec_dxdy_E: public ROOT::Math::IBaseFunctionMultiDim
110 {
111 public:
112  d2XSec_dxdy_E(const XSecAlgorithmI * m, const Interaction * i);
113  ~d2XSec_dxdy_E();
114 
115  // ROOT::Math::IBaseFunctionMultiDim interface
116  unsigned int NDim (void) const;
117  double DoEval (const double * xin) const;
118  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
119 
120 private:
123 };
124 
125 //.....................................................................................
126 //
127 // genie::utils::gsl::d2XSec_dlog10xdlog10Q2_E
128 // A 2-D cross section function: d2xsec/dlog10xdQlog102 = f(log10x,log10Q2)|(fixed E)
129 //
130 class d2XSec_dlog10xdlog10Q2_E: public ROOT::Math::IBaseFunctionMultiDim
131 {
132 public:
133  d2XSec_dlog10xdlog10Q2_E(const XSecAlgorithmI * m, const Interaction * i, double scale=1.);
135 
136  // ROOT::Math::IBaseFunctionMultiDim interface
137  unsigned int NDim (void) const;
138  double DoEval (const double * xin) const;
139  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
140 
141 private:
144  double fScale; // can set to -1. for use with GSL minimizer
145 };
146 
147 //.....................................................................................
148 //
149 // genie::utils::gsl::d2XSec_dQ2dy_E
150 // A 2-D cross section function: d2xsec/dQ2dy = f(Q^2,y)|(fixed E)
151 //
152 class d2XSec_dQ2dy_E: public ROOT::Math::IBaseFunctionMultiDim
153 {
154 public:
155  d2XSec_dQ2dy_E(const XSecAlgorithmI * m, const Interaction * i);
156  ~d2XSec_dQ2dy_E();
157 
158  // ROOT::Math::IBaseFunctionMultiDim interface
159  unsigned int NDim (void) const;
160  double DoEval (const double * xin) const;
161  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
162 
163 private:
166 };
167 
168 //.....................................................................................
169 //
170 // genie::utils::gsl::d2XSec_dQ2dydt_E
171 // A 3-D cross section function: d3xsec/dQ2dydt = f(Q^2,y,t)|(fixed E)
172 //
173 class d2XSec_dQ2dydt_E: public ROOT::Math::IBaseFunctionMultiDim
174 {
175 public:
176  d2XSec_dQ2dydt_E(const XSecAlgorithmI * m, const Interaction * i);
177  ~d2XSec_dQ2dydt_E();
178 
179  // ROOT::Math::IBaseFunctionMultiDim interface
180  unsigned int NDim (void) const;
181  double DoEval (const double * xin) const;
182  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
183 
184 private:
187 };
188 
189 //.....................................................................................
190 //
191 // genie::utils::gsl::d3XSec_dxdydt_E
192 // A 3-D cross section function: d3xsec/dxdydt = f(x,y,t)|(fixed E)
193 //
194 class d3XSec_dxdydt_E: public ROOT::Math::IBaseFunctionMultiDim
195 {
196 public:
197  d3XSec_dxdydt_E(const XSecAlgorithmI * m, const Interaction * i);
198  ~d3XSec_dxdydt_E();
199 
200  // ROOT::Math::IBaseFunctionMultiDim interface
201  unsigned int NDim (void) const;
202  double DoEval (const double * xin) const;
203  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
204 
205 private:
208 };
209 
210 //.....................................................................................
211 //
212 // genie::utils::gsl::d2XSec_dWdQ2_E
213 // A 2-D cross section function: d2xsec/dWdQ2 = f(W,Q2)|(fixed E)
214 //
215 class d2XSec_dWdQ2_E: public ROOT::Math::IBaseFunctionMultiDim
216 {
217 public:
218  d2XSec_dWdQ2_E(const XSecAlgorithmI * m, const Interaction * i);
219  ~d2XSec_dWdQ2_E();
220 
221  // ROOT::Math::IBaseFunctionMultiDim interface
222  unsigned int NDim (void) const;
223  double DoEval (const double * xin) const;
224  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
225 
226 private:
229 };
230 
231 //.....................................................................................
232 //
233 // genie::utils::gsl::d2XSec_dxdy_Ex
234 // A 1-D cross section function: d2xsec/dxdy = f(y)|(fixed:E,x)
235 //
236 class d2XSec_dxdy_Ex: public ROOT::Math::IBaseFunctionOneDim
237 {
238 public:
239  d2XSec_dxdy_Ex(const XSecAlgorithmI * m, const Interaction * i, double x);
240  ~d2XSec_dxdy_Ex();
241 
242  // ROOT::Math::IBaseFunctionOneDim interface
243  unsigned int NDim (void) const;
244  double DoEval (double xin) const;
245  ROOT::Math::IBaseFunctionOneDim * Clone (void) const;
246 
247 private:
250  double fx;
251 };
252 
253 //.....................................................................................
254 //
255 // genie::utils::gsl::d2XSec_dxdy_Ey
256 // A 1-D cross section function: d2xsec/dxdy = f(x)|(fixed:E,y)
257 //
258 class d2XSec_dxdy_Ey: public ROOT::Math::IBaseFunctionOneDim
259 {
260 public:
261  d2XSec_dxdy_Ey(const XSecAlgorithmI * m, const Interaction * i, double x);
262  ~d2XSec_dxdy_Ey();
263 
264  // ROOT::Math::IBaseFunctionOneDim interface
265  unsigned int NDim (void) const;
266  double DoEval (double xin) const;
267  ROOT::Math::IBaseFunctionOneDim * Clone (void) const;
268 
269 private:
272  double fy;
273 };
274 
275 //.....................................................................................
276 //
277 // genie::utils::gsl::d2XSec_dWdQ2_EW
278 // A 1-D cross section function: d2xsec/dWdQ2= f(Q2)|(fixed:E,W)
279 //
280 class d2XSec_dWdQ2_EW: public ROOT::Math::IBaseFunctionOneDim
281 {
282 public:
283  d2XSec_dWdQ2_EW( const XSecAlgorithmI * m, const Interaction * i, double W);
284  ~d2XSec_dWdQ2_EW();
285 
286  // ROOT::Math::IBaseFunctionOneDim interface
287  unsigned int NDim (void) const;
288  double DoEval (double xin) const;
289  ROOT::Math::IBaseFunctionOneDim * Clone (void) const;
290 
291 private:
294  double fW;
295 };
296 
297 //.....................................................................................
298 //
299 // genie::utils::gsl::d2XSec_dWdQ2_EQ2
300 // A 1-D cross section function: d2xsec/dWdQ2= f(W)|(fixed:E,Q2)
301 //
302 class d2XSec_dWdQ2_EQ2: public ROOT::Math::IBaseFunctionOneDim
303 {
304 public:
305  d2XSec_dWdQ2_EQ2(const XSecAlgorithmI * m, const Interaction * i, double Q2);
306  ~d2XSec_dWdQ2_EQ2();
307 
308  // ROOT::Math::IBaseFunctionOneDim interface
309  unsigned int NDim (void) const;
310  double DoEval (double xin) const;
311  ROOT::Math::IBaseFunctionOneDim * Clone (void) const;
312 
313 private:
316  double fQ2;
317 };
318 
319 //.....................................................................................
320 
321 //.....................................................................................
322 //
323 //
324 //
325 class d5XSecAR : public ROOT::Math::IBaseFunctionMultiDim
326 {
327 public:
328  d5XSecAR(const XSecAlgorithmI * m, const Interaction * i);
329  ~d5XSecAR();
330  // ROOT::Math::IBaseFunctionMultiDim interface
331  unsigned int NDim (void) const;
332  double DoEval (const double * xin) const;
333  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
334  void SetFlip(bool b) { flip = b; }
335 
336 private:
339  bool flip;
340 };
341 
342 
343 //.....................................................................................
344 //
345 // genie::utils::gsl::d5Xsec_dEldOmegaldOmegapi
346 // A 5-D cross section function (fixed E_nu)
347 //
348 class d5Xsec_dEldOmegaldOmegapi: public ROOT::Math::IBaseFunctionMultiDim
349 {
350 public:
353 
354  // ROOT::Math::IBaseFunctionMultiDim interface
355  unsigned int NDim (void) const;
356  double DoEval (const double * xin) const;
357  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
358 
359 private:
362 };
363 
364 ///.....................................................................................
365 ///
366 /// genie::utils::gsl::d4Xsec_dEldThetaldOmegapi
367 /// A 4-D cross section function (fixed E_nu)
368 /// DANIEL - for the Alvarez-Russo cross-section
369 ///
370 class d4Xsec_dEldThetaldOmegapi: public ROOT::Math::IBaseFunctionMultiDim
371 {
372 public:
375 
376  // ROOT::Math::IBaseFunctionMultiDim interface
377  unsigned int NDim (void) const;
378  double DoEval (const double * xin) const;
379  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
380 
381  double GetFactor() const;
382  void SetFactor(double factor);
383 
384 private:
387  double fFactor;
388 };
389 ///.....................................................................................
390 ///
391 /// genie::utils::gsl::d3Xsec_dOmegaldThetapi
392 /// A 3-D cross section function (fixed E_nu)
393 /// Steve Dennis - for the Alvarez-Russo cross-section
394 ///
395 class d3Xsec_dOmegaldThetapi: public ROOT::Math::IBaseFunctionMultiDim
396 {
397 public:
400 
401  // ROOT::Math::IBaseFunctionMultiDim interface
402  unsigned int NDim (void) const;
403  double DoEval (const double * xin) const;
404  d3Xsec_dOmegaldThetapi * Clone (void) const;
405 
406  // Specific to this class
407  void SetE_lep (double E_lepton) const;
408  // Yes, it's a const setter
409  // Needed because DoEval must be const, but dXSec_dElep_AR::DoEval() must call this
410 
411 private:
414  mutable double fElep;
415 };
416 ///.....................................................................................
417 ///
418 /// genie::utils::gsl::dXSec_dElep_AR
419 /// A 1-D cross section function: dxsec/dElep
420 /// Used for Alvarez-Ruso coherent.
421 ///
422 class dXSec_dElep_AR: public ROOT::Math::IBaseFunctionOneDim
423 {
424 public:
425  dXSec_dElep_AR(const XSecAlgorithmI * m, const Interaction * i,
426  string gsl_nd_integrator_type, double gsl_relative_tolerance,
427  unsigned int max_n_calls);
429  ~dXSec_dElep_AR();
430 
431  // ROOT::Math::IBaseFunctionOneDim interface
432  dXSec_dElep_AR * Clone (void) const;
433  double DoEval (double xin) const;
434 
435 private:
438 
440 
441  mutable ROOT::Math::IntegratorMultiDim integrator;
442 
443  double kine_min[3];
444  double kine_max[3];
445 
447  double fGSLRelTol;
448  unsigned int fGSLMaxCalls;
449 };
450 
451 ///.....................................................................................
452 ///
453 /// dXSec_Log_Wrapper
454 /// Redistributes variables over a range to a e^-x distribution.
455 /// Allows the integrator to use a logarithmic series of points while calling uniformly.
456 class dXSec_Log_Wrapper: public ROOT::Math::IBaseFunctionMultiDim
457 {
458  public:
459  dXSec_Log_Wrapper(const ROOT::Math::IBaseFunctionMultiDim * fn,
460  bool * ifLog, double * min, double * maxes);
462 
463  // ROOT::Math::IBaseFunctionMultiDim interface
464  unsigned int NDim (void) const;
465  double DoEval (const double * xin) const;
466  ROOT::Math::IBaseFunctionMultiDim * Clone (void) const;
467 
468  private:
469  const ROOT::Math::IBaseFunctionMultiDim * fFn;
470  bool * fIfLog;
471  double * fMins;
472  double * fMaxes;
473 };
474 
475 } // gsl namespace
476 } // utils namespace
477 } // genie namespace
478 
479 #endif
Cross Section Calculation Interface.
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:75
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:121
const Interaction * fInteraction
Definition: GSLXSecFunc.h:99
const Interaction * fInteraction
Definition: GSLXSecFunc.h:207
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:1064
dXSec_dQ2_E(const XSecAlgorithmI *m, const Interaction *i, double scale=1.)
Definition: GSLXSecFunc.cxx:37
std::string string
Definition: nybbler.cc:12
A simple [min,max] interval for doubles.
Definition: Range1.h:42
const Interaction * fInteraction
Definition: GSLXSecFunc.h:271
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:53
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:292
const Interaction * fInteraction
Definition: GSLXSecFunc.h:76
const Interaction * fInteraction
Definition: GSLXSecFunc.h:315
double DoEval(double xin) const
Definition: GSLXSecFunc.cxx:54
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:164
unsigned int NDim(void) const
Definition: GSLXSecFunc.cxx:50
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:248
Summary information for an interaction.
Definition: Interaction.h:56
QAsciiDict< Entry > fn
ROOT::Math::IBaseFunctionOneDim * Clone(void) const
Definition: GSLXSecFunc.cxx:70
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:314
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:227
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:206
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:185
const Interaction * fInteraction
Definition: GSLXSecFunc.h:165
const Interaction * fInteraction
Definition: GSLXSecFunc.h:122
const Interaction * fInteraction
Definition: GSLXSecFunc.h:338
const Interaction * fInteraction
Definition: GSLXSecFunc.h:437
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:98
const Interaction * fInteraction
Definition: GSLXSecFunc.h:293
const Interaction * fInteraction
Definition: GSLXSecFunc.h:249
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
const genie::utils::gsl::d3Xsec_dOmegaldThetapi * func
Definition: GSLXSecFunc.h:439
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:337
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:270
Definition: utils.py:1
const Interaction * fInteraction
Definition: GSLXSecFunc.h:186
static bool * b
Definition: config.cpp:1043
const Interaction * fInteraction
Definition: GSLXSecFunc.h:228
list x
Definition: train.py:276
const ROOT::Math::IBaseFunctionMultiDim * fFn
Definition: GSLXSecFunc.h:469
const Interaction * fInteraction
Definition: GSLXSecFunc.h:54
ROOT::Math::IntegratorMultiDim integrator
Definition: GSLXSecFunc.h:441
const XSecAlgorithmI * fModel
Definition: GSLXSecFunc.h:436