GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SmithMonizQELCCXSec.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2024, 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  Vadim Naumov <vnaumov@theor.jinr.ru>
15  Joint Institute for Nuclear Research
16 
17  based on code of:
18  Costas Andreopoulos <c.andreopoulos \at cern.ch>
19  University of Liverpool
20 */
21 //____________________________________________________________________________
22 
23 #include <sstream>
24 
25 #include <TMath.h>
26 #include <Math/IFunction.h>
27 #include <Math/Integrator.h>
28 
30 #include "Framework/Conventions/GBuild.h"
37 #include "Framework/Utils/Range1.h"
40 
41 using namespace genie;
42 using std::ostringstream;
43 
44 //____________________________________________________________________________
46 XSecIntegratorI("genie::SmithMonizQELCCXSec")
47 {
48 
49 }
50 //____________________________________________________________________________
52 XSecIntegratorI("genie::SmithMonizQELCCXSec", config)
53 {
54 
55 }
56 //____________________________________________________________________________
58 {
59 
60 }
61 //____________________________________________________________________________
63  const XSecAlgorithmI * model, const Interaction * in) const
64 {
65  LOG("SMQELXSec",pDEBUG) << "Beginning integrate";
66  if(! model->ValidProcess(in)) return 0.;
67 
68  const InitialState & init_state = in -> InitState();
69  const Target & target = init_state.Tgt();
70  if (target.A()<4)
71  {
72  const KPhaseSpace & kps = in->PhaseSpace();
73  if(!kps.IsAboveThreshold()) {
74  LOG("SMQELXSec", pDEBUG) << "*** Below energy threshold";
75  return 0;
76  }
77  Range1D_t rQ2 = kps.Limits(kKVQ2);
78  if(rQ2.min<0 || rQ2.max<0) return 0;
79  Interaction * interaction = new Interaction(*in);
80  interaction->SetBit(kISkipProcessChk);
81  interaction->SetBit(kISkipKinematicChk);
82  ROOT::Math::IBaseFunctionOneDim * func = new utils::gsl::dXSec_dQ2_E(model, interaction);
83  ROOT::Math::IntegrationOneDim::Type ig_type = utils::gsl::Integration1DimTypeFromString(fGSLIntgType);
84  double abstol = 0; //We mostly care about relative tolerance
85  ROOT::Math::Integrator ig(*func,ig_type,abstol,fGSLRelTol,fGSLMaxSizeOfSubintervals, fGSLRule);
86  double xsec = ig.Integral(rQ2.min, rQ2.max) * (1E-38 * units::cm2);
87  delete func;
88  delete interaction;
89  return xsec;
90  }
91  else
92  {
93  Interaction * interaction = new Interaction(*in);
95  if (interaction->InitState().ProbeE(kRfLab)<sm_utils->E_nu_thr_SM())
96  {
97  return 0;
98  }
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 
108  ROOT::Math::IntegrationMultiDim::Type ig_type = utils::gsl::IntegrationNDimTypeFromString(fGSLIntgType2D);
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 
197  double Q2 = (rQ2.max-rQ2.min)*xin[0]+rQ2.min;
198  Range1D_t rv = sm_utils->vQES_SM_lim(Q2);
199  double v = (rv.max-rv.min)*xin[1]+rv.min;
200  double J = (rQ2.max-rQ2.min)*(rv.max-rv.min); // Jacobian for transformation
201 
202  Kinematics * kinematics = fInteraction->KinePtr();
203  kinematics->SetKV(kKVQ2, Q2);
204  kinematics->SetKV(kKVv, v);
205 
206  double xsec=fModel->XSec(fInteraction, kPSQ2vfE);
207 
208  xsec *= J;
209 
210  return xsec/(1E-38 * units::cm2);
211 }
212 //____________________________________________________________________________
213 ROOT::Math::IBaseFunctionMultiDim *
215 {
216  return new genie::utils::gsl::d2Xsec_dQ2dv(fModel, fInteraction);
217 }
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
Cross Section Integrator Interface.
double Q2(const Interaction *const i)
Definition: KineUtils.cxx:1077
ROOT::Math::IntegrationMultiDim::Type IntegrationNDimTypeFromString(string type)
Definition: GSLUtils.cxx:59
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
unsigned int fGSLRule
GSL Gauss-Kronrod integration rule (only for GSL 1D adaptive type)
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
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
double func(double x, double y)
const UInt_t kISkipKinematicChk
if set, skip kinematic validity checks
Definition: Interaction.h:48
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
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
bool IsAboveThreshold(void) const
Checks whether the interaction is above the energy threshold.
double DoEval(const double *xin) const
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
static constexpr double m
Definition: Units.h:71
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