GENIEGenerator
Loading...
Searching...
No Matches
COHXSecAR.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
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"
28
29using namespace genie;
30using namespace genie::constants;
31using namespace genie::controls;
32using namespace genie::utils;
33
34//____________________________________________________________________________
36XSecIntegratorI("genie::COHXSecAR")
37{
38
39}
40//____________________________________________________________________________
42XSecIntegratorI("genie::COHXSecAR", config)
43{
44
45}
46//____________________________________________________________________________
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
111 ROOT::Math::IntegrationMultiDim::Type ig_type =
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//____________________________________________________________________________
131//____________________________________________________________________________
133{
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//_____________________________________________________________________________
#define pINFO
Definition Messenger.h:62
#define pDEBUG
Definition Messenger.h:63
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62
bool GetParamDef(const RgKey &name, T &p, const T &def) const
void Configure(const Registry &config)
virtual ~COHXSecAR()
Definition COHXSecAR.cxx:47
void LoadConfig(void)
double Integrate(const XSecAlgorithmI *model, const Interaction *i) const
Definition COHXSecAR.cxx:52
Initial State information.
double ProbeE(RefFrame_t rf) const
Summary information for an interaction.
Definition Interaction.h:56
const KPhaseSpace & PhaseSpace(void) const
Definition Interaction.h:73
Kinematical phase space.
Definition KPhaseSpace.h:33
bool IsAboveThreshold(void) const
Checks whether the interaction is above the energy threshold.
Range1D_t Limits(KineVar_t kvar) const
Return the kinematical variable limits.
A simple [min,max] interval for doubles.
Definition Range1.h:43
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
Cross Section Calculation Interface.
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
string fGSLIntgType
name of GSL numerical integrator
int fGSLMaxEval
GSL max evaluations.
double fGSLRelTol
required relative tolerance (error)
double func(double x, double y)
Basic constants.
Misc GENIE control constants.
static const double kASmallNum
Definition Controls.h:40
static constexpr double cm2
Definition Units.h:69
Simple functions for loading and reading nucleus dependent keys from config files.
ROOT::Math::IntegrationMultiDim::Type IntegrationNDimTypeFromString(string type)
Definition GSLUtils.cxx:59
Root of GENIE utility namespaces.
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
@ kKVy
Definition KineVar.h:32
@ kRfLab
Definition RefFrame.h:26
const UInt_t kISkipProcessChk
if set, skip process validity checks
Definition Interaction.h:47