COHXSecAR.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  Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
7  University of Liverpool & STFC Rutherford Appleton Laboratory
8 */
9 //____________________________________________________________________________
10 
11 #include <TMath.h>
12 #include <Math/IFunction.h>
13 #include <Math/Integrator.h>
14 #include <Math/IntegratorMultiDim.h>
15 #include "Math/AdaptiveIntegratorMultiDim.h"
16 
17 #include "Framework/Conventions/GBuild.h"
26 #include "Framework/Utils/Range1.h"
28 
29 using namespace genie;
30 using namespace genie::constants;
31 using namespace genie::controls;
32 using namespace genie::utils;
33 
34 //____________________________________________________________________________
36 XSecIntegratorI("genie::COHXSecAR")
37 {
38 
39 }
40 //____________________________________________________________________________
42 XSecIntegratorI("genie::COHXSecAR", config)
43 {
44 
45 }
46 //____________________________________________________________________________
48 {
49 
50 }
51 //____________________________________________________________________________
53  const XSecAlgorithmI * model, const Interaction * in) const
54 {
55  const InitialState & init_state = in -> InitState();
56 
57  if(! model->ValidProcess(in) ) return 0.;
58 
59  const KPhaseSpace & kps = in->PhaseSpace();
60  if(!kps.IsAboveThreshold()) {
61  LOG("COHXSecAR", pDEBUG) << "*** Below energy threshold";
62  return 0;
63  }
64 
65  Range1D_t y_lim = kps.Limits(kKVy);
66 
67  // Check this
68  double Enu = init_state.ProbeE(kRfLab);
69  double Elep_min = (1.-y_lim.max) * Enu;
70  double Elep_max = (1.-y_lim.min) * Enu;
71 
72  LOG("COHXSecAR", pINFO)
73  << "Lepton energy integration range = [" << Elep_min << ", " << Elep_max << "]";
74 
75  Interaction * interaction = new Interaction(*in);
76  interaction->SetBit(kISkipProcessChk);
77  //interaction->SetBit(kISkipKinematicChk);
78 
79  double xsec = 0;
80  if (fSplitIntegral) {
83 
84  //~ ROOT::Math::IntegrationOneDim::Type ig_type = ROOT::Math::IntegrationOneDim::kNONADAPTIVE;
85  ROOT::Math::IntegrationOneDim::Type ig_type = ROOT::Math::IntegrationOneDim::kADAPTIVE;
86 
87  double abstol = 1; // Pretty sure this parameter is unused by ROOT.
88  int size = 1000; // Max number of subintervals, won't reach nearly this.
89  int rule = 2; // See https://www.gnu.org/software/gsl/manual/gsl-ref_17.html#SEC283
90  // Rule 2 is 21 points min
91  ROOT::Math::Integrator ig(*func,ig_type,abstol,fGSLRelTol,size,rule);
92 
93  xsec = ig.Integral(Elep_min, Elep_max) * (1E-38 * units::cm2);
94  delete func;
95  }
96  else {
97  double zero = kASmallNum;
98  double pi = kPi-kASmallNum ;
99  double twopi = 2*kPi-kASmallNum ;
100 
101  //~ ROOT::Math::IBaseFunctionMultiDim * func =
102  //~ new utils::gsl::wrap::d5Xsec_dEldOmegaldOmegapi(model, interaction);
103  //~ double kine_min[5] = { Elep_min, zero , zero , zero, zero };
104  //~ double kine_max[5] = { Elep_max, pi , twopi , pi , twopi};
105 
106  ROOT::Math::IBaseFunctionMultiDim * func =
107  new utils::gsl::d4Xsec_dEldThetaldOmegapi(model, interaction);
108  double kine_min[4] = { Elep_min, zero , zero , zero };
109  double kine_max[4] = { Elep_max, pi , pi , twopi };
110 
113 
114  double abstol = 1; //We mostly care about relative tolerance.
115  ROOT::Math::IntegratorMultiDim ig(*func, ig_type, abstol, fGSLRelTol, fGSLMaxEval);
116 
117  xsec = ig.Integral(kine_min, kine_max) * (1E-38 * units::cm2);
118  delete func;
119  }
120 
121  delete interaction;
122 
123  return xsec;
124 }
125 //____________________________________________________________________________
127 {
128  Algorithm::Configure(config);
129  this->LoadConfig();
130 }
131 //____________________________________________________________________________
133 {
134  Algorithm::Configure(config);
135  this->LoadConfig();
136 }
137 //____________________________________________________________________________
139 {
140  // Get GSL integration type & relative tolerance
141  GetParamDef( "gsl-integration-type", fGSLIntgType, string("vegas") ) ;
142 
143  int max_eval;
144  GetParamDef( "gsl-max-eval", max_eval, 4000 ) ;
145  fGSLMaxEval = (unsigned int) max_eval ;
146 
147  GetParamDef( "gsl-relative-tolerance", fGSLRelTol, 0.01) ;
148  GetParamDef( "split-integral", fSplitIntegral, true ) ;
149 
150 }
151 //_____________________________________________________________________________
Cross Section Calculation Interface.
const KPhaseSpace & PhaseSpace(void) const
Definition: Interaction.h:73
Basic constants.
string fGSLIntgType
name of GSL numerical integrator
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
Cross Section Integrator Interface.
ROOT::Math::IntegrationMultiDim::Type IntegrationNDimTypeFromString(string type)
Definition: GSLUtils.cxx:59
int Type
Definition: 018_def.c:12
A simple [min,max] interval for doubles.
Definition: Range1.h:42
double Integrate(const XSecAlgorithmI *model, const Interaction *i) const
Definition: COHXSecAR.cxx:52
Definition: model.py:1
Range1D_t Limits(KineVar_t kvar) const
Return the kinematical variable limits.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
void Configure(const Registry &config)
Definition: COHXSecAR.cxx:126
Summary information for an interaction.
Definition: Interaction.h:56
#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
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
Kinematical phase space.
Definition: KPhaseSpace.h:33
static const double kASmallNum
Definition: Controls.h:40
#define pINFO
Definition: Messenger.h:62
bool fSplitIntegral
Definition: COHXSecAR.h:41
Misc GENIE control constants.
int twopi
Definition: units.py:12
double max
Definition: Range1.h:53
int fGSLMaxEval
GSL max evaluations.
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
void LoadConfig(void)
Definition: COHXSecAR.cxx:138
def func()
Definition: docstring.py:7
bool IsAboveThreshold(void) const
Checks whether the interaction is above the energy threshold.
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
double min
Definition: Range1.h:52
float pi
Definition: units.py:11
bool GetParamDef(const RgKey &name, T &p, const T &def) const
virtual ~COHXSecAR()
Definition: COHXSecAR.cxx:47
double ProbeE(RefFrame_t rf) const
static const double kPi
Definition: Constants.h:37
Root of GENIE utility namespaces.
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 fGSLRelTol
required relative tolerance (error)