GLRESXSec.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Alfonso Garcia <alfonsog \at nikhef.nl>
8  NIKHEF (Amsterdam)
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14 */
15 //____________________________________________________________________________
16 
17 #include <TMath.h>
18 #include <Math/IFunction.h>
19 #include <Math/Integrator.h>
20 
23 #include "Framework/Conventions/GBuild.h"
31 #include "Framework/Utils/RunOpt.h"
32 #include "Framework/Utils/Range1.h"
33 #include "Framework/Utils/Cache.h"
37 
38 using namespace genie;
39 using namespace genie::controls;
40 using namespace genie::constants;
41 
42 //____________________________________________________________________________
44 XSecIntegratorI("genie::GLRESXSec")
45 {
46 
47 }
48 //____________________________________________________________________________
50 XSecIntegratorI("genie::GLRESXSec", config)
51 {
52 
53 }
54 //____________________________________________________________________________
56 {
57 
58 }
59 //____________________________________________________________________________
61  const XSecAlgorithmI * model, const Interaction * in) const
62 {
63  if(! model->ValidProcess(in) ) return 0.;
64 
65  const KPhaseSpace & kps = in->PhaseSpace();
66  if(!kps.IsAboveThreshold()) {
67  LOG("GLRESXSec", pDEBUG) << "*** Below energy threshold";
68  return 0;
69  }
70 
71 
72  const InitialState & init_state = in->InitState();
73  double Ev = init_state.ProbeE(kRfLab);
74 
75  int NNucl = init_state.Tgt().Z();
76 
77  // If the input interaction is off a nuclear target, then chek whether
78  // the corresponding free nucleon cross section already exists at the
79  // cross section spline list.
80  // If yes, calculate the nuclear cross section based on that value.
81  //
83  if( !xsl->IsEmpty() ) {
84  Interaction * interaction = new Interaction(*in);
85  Target * target = interaction->InitStatePtr()->TgtPtr();
86  target->SetId(kPdgTgtFreeP);
87  if(xsl->SplineExists(model,interaction)) {
88  const Spline * spl = xsl->GetSpline(model, interaction);
89  double xsec = spl->Evaluate(Ev);
90  LOG("GLRESXSec", pINFO) << "From XSecSplineList: XSec[ve-,free nucleon] (E = " << Ev << " GeV) = " << xsec;
91  if( !interaction->TestBit(kIAssumeFreeNucleon) ) {
92  xsec *= NNucl;
93  LOG("GLRESXSec", pINFO) << "XSec[ve-] (E = " << Ev << " GeV) = " << xsec;
94  }
95  delete interaction;
96  return xsec;
97  }
98  delete interaction;
99  }
100 
101 
102  Range1D_t yl = kps.Limits(kKVy);
103 
104  LOG("GLRESXSec", pDEBUG) << "y = (" << yl.min << ", " << yl.max << ")";
105 
106  Interaction * interaction = new Interaction(*in);
107  interaction->SetBit(kISkipProcessChk);
108  //interaction->SetBit(kISkipKinematicChk);
109 
110  ROOT::Math::IBaseFunctionOneDim * func =
111  new utils::gsl::dXSec_dy_E(model, interaction);
114  ROOT::Math::Integrator ig(*func,ig_type,1,fGSLRelTol,fGSLMaxEval);
115  double xsec = ig.Integral(yl.min, yl.max) * (1E-38 * units::cm2);
116 
117  LOG("GLRESXSec", pDEBUG) << "*** XSec[ve-] (E=" << interaction->InitState().ProbeE(kRfLab) << ") = " << xsec;
118 
119  delete interaction;
120  delete func;
121  return xsec;
122 }
123 //____________________________________________________________________________
125 {
126  Algorithm::Configure(config);
127  this->LoadConfig();
128 }
129 //____________________________________________________________________________
131 {
132  Algorithm::Configure(config);
133  this->LoadConfig();
134 }
135 //____________________________________________________________________________
137 {
138  // Get GSL integration type & relative tolerance
139  GetParamDef("gsl-integration-type", fGSLIntgType, string("adaptive") ) ;
140  GetParamDef("gsl-relative-tolerance", fGSLRelTol, 1E-2 ) ;
141  int max_eval ;
142  GetParamDef( "gsl-max-eval", max_eval, 500000 ) ;
143  fGSLMaxEval = (unsigned int) max_eval ;
144 }
145 //____________________________________________________________________________
146 
Cross Section Calculation Interface.
const KPhaseSpace & PhaseSpace(void) const
Definition: Interaction.h:73
Basic constants.
ROOT::Math::IntegrationOneDim::Type Integration1DimTypeFromString(string type)
Definition: GSLUtils.cxx:23
string fGSLIntgType
name of GSL numerical integrator
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
Cross Section Integrator Interface.
int Type
Definition: 018_def.c:12
A simple [min,max] interval for doubles.
Definition: Range1.h:42
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
A numeric analysis tool class for interpolating 1-D functions.
Definition: Spline.h:46
Definition: model.py:1
static XSecSplineList * Instance()
double Evaluate(double x) const
Definition: Spline.cxx:361
void Configure(const Registry &config)
Definition: GLRESXSec.cxx:124
void SetId(int pdgc)
Definition: Target.cxx:149
Range1D_t Limits(KineVar_t kvar) const
Return the kinematical variable limits.
virtual ~GLRESXSec()
Definition: GLRESXSec.cxx:55
Summary information for an interaction.
Definition: Interaction.h:56
void LoadConfig(void)
Definition: GLRESXSec.cxx:136
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
bool IsEmpty(void) const
double Integrate(const XSecAlgorithmI *model, const Interaction *i) const
XSecIntegratorI interface implementation.
Definition: GLRESXSec.cxx:60
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 int kPdgTgtFreeP
Definition: PDGCodes.h:199
int Z(void) const
Definition: Target.h:68
#define pINFO
Definition: Messenger.h:62
Misc GENIE control constants.
double max
Definition: Range1.h:53
int fGSLMaxEval
GSL max evaluations.
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
const UInt_t kIAssumeFreeNucleon
Definition: Interaction.h:49
Target * TgtPtr(void) const
Definition: InitialState.h:67
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?
InitialState * InitStatePtr(void) const
Definition: Interaction.h:74
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
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
List of cross section vs energy splines.
double ProbeE(RefFrame_t rf) const
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
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)