SmithMonizQELCCXSec.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6  Igor Kakorin <kakorin@jinr.ru>
7  Joint Institute for Nuclear Research
8 
9  adapted from fortran code provided by:
10 
11  Konstantin Kuzmin <kkuzmin@theor.jinr.ru>
12  Joint Institute for Nuclear Research
13 
14  Vladimir Lyubushkin
15  Joint Institute for Nuclear Research
16 
17  Vadim Naumov <vnaumov@theor.jinr.ru>
18  Joint Institute for Nuclear Research
19 
20  based on code of:
21  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
22  University of Liverpool & STFC Rutherford Appleton Laboratory
23 */
24 //____________________________________________________________________________
25 
26 #include <sstream>
27 
28 #include <TMath.h>
29 #include <Math/IFunction.h>
30 #include <Math/Integrator.h>
31 
33 #include "Framework/Conventions/GBuild.h"
40 #include "Framework/Utils/Range1.h"
43 
44 using namespace genie;
45 using std::ostringstream;
46 
47 //____________________________________________________________________________
49 XSecIntegratorI("genie::SmithMonizQELCCXSec")
50 {
51 
52 }
53 //____________________________________________________________________________
55 XSecIntegratorI("genie::SmithMonizQELCCXSec", config)
56 {
57 
58 }
59 //____________________________________________________________________________
61 {
62 
63 }
64 //____________________________________________________________________________
66  const XSecAlgorithmI * model, const Interaction * in) const
67 {
68  LOG("SMQELXSec",pDEBUG) << "Beginning integrate";
69  if(! model->ValidProcess(in)) return 0.;
70 
71  const InitialState & init_state = in -> InitState();
72  const Target & target = init_state.Tgt();
73  if (target.A()<3)
74  {
75  const KPhaseSpace & kps = in->PhaseSpace();
76  if(!kps.IsAboveThreshold()) {
77  LOG("SMQELXSec", pDEBUG) << "*** Below energy threshold";
78  return 0;
79  }
80  Range1D_t rQ2 = kps.Limits(kKVQ2);
81  if(rQ2.min<0 || rQ2.max<0) return 0;
82  Interaction * interaction = new Interaction(*in);
83  interaction->SetBit(kISkipProcessChk);
84  interaction->SetBit(kISkipKinematicChk);
85  ROOT::Math::IBaseFunctionOneDim * func = new utils::gsl::dXSec_dQ2_E(model, interaction);
87  double abstol = 0; //We mostly care about relative tolerance
88  ROOT::Math::Integrator ig(*func,ig_type,abstol,fGSLRelTol,fGSLMaxSizeOfSubintervals, fGSLRule);
89  double xsec = ig.Integral(rQ2.min, rQ2.max) * (1E-38 * units::cm2);
90  delete func;
91  delete interaction;
92  return xsec;
93  }
94  else
95  {
96  Interaction * interaction = new Interaction(*in);
98  if (interaction->InitState().ProbeE(kRfLab)<sm_utils->E_nu_thr_SM()) return 0;
99  interaction->SetBit(kISkipProcessChk);
100  interaction->SetBit(kISkipKinematicChk);
101  double xsec = 0;
102 
103 
104  ROOT::Math::IBaseFunctionMultiDim * func = new utils::gsl::d2Xsec_dQ2dv(model, interaction);
105  double kine_min[2] = { 0, 0};
106  double kine_max[2] = { 1, 1};
107 
109 
110  double abstol = 0; //We mostly care about relative tolerance.
111  ROOT::Math::IntegratorMultiDim ig(*func, ig_type, abstol, fGSLRelTol2D, fGSLMaxEval);
112 
113  xsec = ig.Integral(kine_min, kine_max) * (1E-38 * units::cm2);
114  delete func;
115  delete interaction;
116 
117  return xsec;
118 
119  }
120 
121 }
122 //____________________________________________________________________________
124 {
125  Algorithm::Configure(config);
126  this->LoadConfig();
127 }
128 //____________________________________________________________________________
130 {
131  Algorithm::Configure(config);
132 
133  Registry r("SmithMonizQELCCXSec_specific", false ) ;
134  r.Set("sm_utils_algo", RgAlg("genie::SmithMonizUtils","Default") ) ;
135 
137 
138  this->LoadConfig();
139 }
140 //____________________________________________________________________________
142 {
143 
144  // Get GSL integration type & relative tolerance
145  GetParamDef( "gsl-integration-type", fGSLIntgType, string("gauss") );
146  GetParamDef( "gsl-relative-tolerance", fGSLRelTol, 1e-3 );
147  int max_size_of_subintervals;
148  GetParamDef( "gsl-max-size-of-subintervals", max_size_of_subintervals, 40000);
149  fGSLMaxSizeOfSubintervals = (unsigned int) max_size_of_subintervals;
150  int rule;
151  GetParamDef( "gsl-rule", rule, 3);
152  fGSLRule = (unsigned int) rule;
153  if (fGSLRule>6) fGSLRule=3;
154  GetParamDef( "gsl-integration-type-2D", fGSLIntgType2D, string("adaptive") );
155  GetParamDef( "gsl-relative-tolerance-2D", fGSLRelTol2D, 1e-7);
156  GetParamDef( "gsl-max-eval", fGSLMaxEval, 1000000000);
157 
158  sm_utils = const_cast<genie::SmithMonizUtils *>(
159  dynamic_cast<const genie::SmithMonizUtils *>(
160  this -> SubAlg("sm_utils_algo") ) );
161 }
162 
163 
164 //_____________________________________________________________________________
165 // GSL wrappers
166 //____________________________________________________________________________
168 ROOT::Math::IBaseFunctionMultiDim(),
169 fModel(m),
170 fInteraction(interaction)
171 {
172  AlgFactory * algf = AlgFactory::Instance();
173  sm_utils = const_cast<genie::SmithMonizUtils *>(dynamic_cast<const genie::SmithMonizUtils *>(algf->GetAlgorithm("genie::SmithMonizUtils","Default")));
174  sm_utils->SetInteraction(interaction);
176 }
177 //____________________________________________________________________________
179 {
180 
181 }
182 //____________________________________________________________________________
184 {
185  return 2;
186 }
187 //____________________________________________________________________________
188 double genie::utils::gsl::d2Xsec_dQ2dv::DoEval(const double * xin) const
189 {
190 // inputs:
191 // normalized Q2 from 0 to 1
192 // normalized v from 0 to 1
193 // outputs:
194 // differential cross section [10^-38 cm^2]
195 //
196 
198  double Q2 = (rQ2.max-rQ2.min)*xin[0]+rQ2.min;
199  Range1D_t rv = sm_utils->vQES_SM_lim(Q2);
200  double v = (rv.max-rv.min)*xin[1]+rv.min;
201  double J = (rQ2.max-rQ2.min)*(rv.max-rv.min); // Jacobian for transformation
202 
203  Kinematics * kinematics = fInteraction->KinePtr();
204  kinematics->SetKV(kKVQ2, Q2);
205  kinematics->SetKV(kKVv, v);
206 
207  double xsec=fModel->XSec(fInteraction, kPSQ2vfE);
208 
209  xsec *= J;
210 
211  return xsec/(1E-38 * units::cm2);
212 }
213 //____________________________________________________________________________
214 ROOT::Math::IBaseFunctionMultiDim *
216 {
218 }
void SetInteraction(const Interaction *i)
Cross Section Calculation Interface.
Range1D_t Q2QES_SM_lim(void) const
const KPhaseSpace & PhaseSpace(void) const
Definition: Interaction.h:73
ROOT::Math::IntegrationOneDim::Type Integration1DimTypeFromString(string type)
Definition: GSLUtils.cxx:23
string fGSLIntgType
name of GSL numerical integrator
double J(double q0, double q3, double Enu, double ml)
Definition: MECUtils.cxx:147
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
Cross Section Integrator Interface.
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:1064
ROOT::Math::IntegrationMultiDim::Type IntegrationNDimTypeFromString(string type)
Definition: GSLUtils.cxx:59
int Type
Definition: 018_def.c:12
Kinematics * KinePtr(void) const
Definition: Interaction.h:76
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
double E_nu_thr_SM(void) const
int A(void) const
Definition: Target.h:70
A simple [min,max] interval for doubles.
Definition: Range1.h:42
double fGSLRelTol2D
required relative tolerance (error) for 2D integrator
Generated/set kinematical variables for an event.
Definition: Kinematics.h:39
Definition: model.py:1
unsigned int fGSLRule
GSL Gauss-Kronrod integration rule (only for GSL 1D adaptive type)
Range1D_t vQES_SM_lim(double Q2) const
Range1D_t Limits(KineVar_t kvar) const
Return the kinematical variable limits.
string fGSLIntgType2D
name of GSL 2D numerical integrator
void Configure(const Registry &config)
Summary information for an interaction.
Definition: Interaction.h:56
const double e
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static constexpr double cm2
Definition: Units.h:69
static Config * config
Definition: config.cpp:1054
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition: Target.h:40
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
Kinematical phase space.
Definition: KPhaseSpace.h:33
const Algorithm * GetAlgorithm(const AlgId &algid)
Definition: AlgFactory.cxx:75
const UInt_t kISkipKinematicChk
if set, skip kinematic validity checks
Definition: Interaction.h:48
void SetKV(KineVar_t kv, double value)
Definition: Kinematics.cxx:335
double max
Definition: Range1.h:53
int fGSLMaxEval
GSL max evaluations.
Contains auxiliary functions for Smith-Moniz model. .
static AlgFactory * Instance()
Definition: AlgFactory.cxx:64
unsigned int fGSLMaxSizeOfSubintervals
GSL maximum number of sub-intervals for 1D integrator.
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
def func()
Definition: docstring.py:7
bool IsAboveThreshold(void) const
Checks whether the interaction is above the energy threshold.
double DoEval(const double *xin) const
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
const InitialState & InitState(void) const
Definition: Interaction.h:69
double min
Definition: Range1.h:52
bool GetParamDef(const RgKey &name, T &p, const T &def) const
const Target & Tgt(void) const
Definition: InitialState.h:66
ROOT::Math::IBaseFunctionMultiDim * Clone(void) const
The GENIE Algorithm Factory.
Definition: AlgFactory.h:39
void Set(RgIMapPair entry)
Definition: Registry.cxx:267
double ProbeE(RefFrame_t rf) const
const UInt_t kISkipProcessChk
if set, skip process validity checks
Definition: Interaction.h:47
Initial State information.
Definition: InitialState.h:48
#define pDEBUG
Definition: Messenger.h:63
double Integrate(const XSecAlgorithmI *model, const Interaction *i) const
XSecIntegratorI interface implementation.
double fGSLRelTol
required relative tolerance (error)
d2Xsec_dQ2dv(const XSecAlgorithmI *m, const Interaction *i)
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345