GENIEGenerator
Loading...
Searching...
No Matches
SPPXSec.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 or see $GENIE/LICENSE
6
7 Authors: Igor Kakorin <kakorin@jinr.ru>, Joint Institute for Nuclear Research
8 Vadim Naumov <vnaumov@theor.jinr.ru >, Joint Institute for Nuclear Research \n
9 based on code of Costas Andreopoulos <c.andreopoulos \at cern.ch>
10 University of Liverpool
11
12 For the class documentation see the corresponding header file.
13
14
15*/
16//____________________________________________________________________________
17
18#include <TMath.h>
19#include <Math/IFunction.h>
20#include <Math/IntegratorMultiDim.h>
21#include <Math/AdaptiveIntegratorMultiDim.h>
22
24#include "Framework/Conventions/GBuild.h"
42
43
44using namespace genie;
45using namespace genie::constants;
46using namespace genie::units;
47
48//____________________________________________________________________________
50SPPXSecWithCache("genie::SPPXSec")
51{
52
53}
54//____________________________________________________________________________
55SPPXSec::SPPXSec(string config) :
56SPPXSecWithCache("genie::SPPXSec", config)
57{
58
59}
60//____________________________________________________________________________
62{
63
64}
65//____________________________________________________________________________
67 const XSecAlgorithmI * model, const Interaction * interaction) const
68{
69 if(!model->ValidProcess(interaction) ) return 0.;
70
71 //-- Get init state and process information
72 const InitialState & init_state = interaction->InitState();
73 const ProcessInfo & proc_info = interaction->ProcInfo();
74 const Target & target = init_state.Tgt();
75
76 const KPhaseSpace& kps = interaction->PhaseSpace();
77
78 double Enu = init_state.ProbeE(kRfHitNucRest);
79
80 //-- Get the requested SPP channel
81 SppChannel_t spp_channel = SppChannel::FromInteraction(interaction);
82
83 if (Enu < kps.Threshold_SPP_iso()) return 0.;
84
86
87 InteractionType_t it = proc_info.InteractionTypeId();
88 int nucleon_pdgc = target.HitNucPdg();
89 int nu_pdgc = init_state.ProbePdg();
90 string nc_nuc = ((pdg::IsNeutrino(nu_pdgc)) ? ";v:" : ";vb:");
91
92 // If the input interaction is off a nuclear target, then chek whether
93 // the corresponding free nucleon cross section already exists at the
94 // cross section spline list.
95 // If yes, calculate the nuclear cross section based on that value.
96 //
98 if(init_state.Tgt().IsNucleus() && !xsl->IsEmpty() )
99 {
100 Interaction * in = new Interaction(*interaction);
101 if(pdg::IsProton(nucleon_pdgc))
103 else
105
106 if(xsl->SplineExists(model,in))
107 {
108 const Spline * spl = xsl->GetSpline(model, in);
109 double xsec = spl->Evaluate(Enu);
110 SLOG("SPPXSec", pNOTICE)
111 << "XSec[Channel/" << SppChannel::AsString(spp_channel) << "/free] (Ev = "
112 << Enu << " GeV) = " << xsec/(1E-38 *cm2)<< " x 1E-38 cm^2";
113 if(! interaction->TestBit(kIAssumeFreeNucleon) )
114 {
115 int NNucl = (SppChannel::InitStateNucleon(spp_channel) == kPdgProton) ? target.Z() : target.N();
116 xsec *= NNucl;
117 }
118 delete in;
119 return xsec;
120 }
121 delete in;
122 }
123
124 // There was no corresponding free nucleon spline saved in XSecSplineList that
125 // could be used to speed up this calculation.
126 // Check whether local caching of free nucleon cross sections is allowed.
127 // If yes, store free nucleon cross sections at a cache branch and use those
128 // at any subsequent call.
129 //
130 bool bare_xsec_pre_calc = RunOpt::Instance()->BareXSecPreCalc();
131 if(bare_xsec_pre_calc && !fUsePauliBlocking)
132 {
133 Cache * cache = Cache::Instance();
134 string key = this->CacheBranchName(spp_channel, it, nu_pdgc);
135 LOG("SPPXSec", pINFO)
136 << "Finding cache branch with key: " << key;
137 CacheBranchFx * cache_branch =
138 dynamic_cast<CacheBranchFx *> (cache->FindCacheBranch(key));
139 if(!cache_branch) {
140 LOG("SPPXSec", pWARN)
141 << "No cached ResSPP v-production data for input neutrino"
142 << " (pdgc: " << nu_pdgc << ")";
143 LOG("SPPXSec", pWARN)
144 << "Wait while computing/caching ResSPP production xsec first...";
145
146 this->CacheResExcitationXSec(interaction);
147
148 LOG("SPPXSec", pINFO) << "Done caching resonance xsec data";
149 LOG("SPPXSec", pINFO)
150 << "Finding newly created cache branch with key: " << key;
151 cache_branch =
152 dynamic_cast<CacheBranchFx *> (cache->FindCacheBranch(key));
153 assert(cache_branch);
154 }
155 const CacheBranchFx & cbranch = (*cache_branch);
156
157 //-- Get cached resonance neutrinoproduction xsec
158 // (If E>Emax, assume xsec = xsec(Emax) - but do not evaluate the
159 // cross section spline at the end of its energy range-)
160 double rxsec = (Enu<fEMax-1) ? cbranch(Enu) : cbranch(fEMax-1);
161
162
163 SLOG("SPPXSec", pNOTICE)
164 << "XSec[Channel: " << SppChannel::AsString(spp_channel) << nc_nuc << nu_pdgc
165 << "/free] (E="<< Enu << " GeV) = " << rxsec/(1E-38 *genie::units::cm2) << " x 1E-38 cm^2";
166
167 if( interaction->TestBit(kIAssumeFreeNucleon) ) return rxsec;
168
169 int NNucl = (pdg::IsProton(nucleon_pdgc)) ? target.Z() : target.N();
170 rxsec*=NNucl; // nuclear xsec
171 return rxsec;
172 } // disable local caching
173
174 // Just go ahead and integrate the input differential cross section for the
175 // specified interaction.
176 else
177 {
178 LOG("SPPXSec", pINFO)
179 << "*** Integrating d^3 XSec/dWdQ^2dCosTheta for Ch: "
180 << SppChannel::AsString(spp_channel) << " at Ev = " << Enu;
181
182 ROOT::Math::IBaseFunctionMultiDim * func= new utils::gsl::d3XSecMK_dWQ2CosTheta_E(model, interaction, fWcut);
183 ROOT::Math::IntegrationMultiDim::Type ig_type = utils::gsl::IntegrationNDimTypeFromString(fGSLIntgType);
184 ROOT::Math::IntegratorMultiDim ig(ig_type,0,fGSLRelTol,fGSLMaxEval);
185 if (ig_type == ROOT::Math::IntegrationMultiDim::kADAPTIVE)
186 {
187 ROOT::Math::AdaptiveIntegratorMultiDim * cast = dynamic_cast<ROOT::Math::AdaptiveIntegratorMultiDim*>( ig.GetIntegrator() );
188 assert(cast);
189 cast->SetMinPts(fGSLMinEval);
190 }
191 ig.SetFunction(*func);
192 double kine_min[3] = { 0., 0., 0.};
193 double kine_max[3] = { 1., 1., 1.};
194 double xsec = ig.Integral(kine_min, kine_max)*(1E-38 * units::cm2);
195 delete func;
196
197 SLOG("SPPXSec", pNOTICE)
198 << "XSec[Channel: " << SppChannel::AsString(spp_channel) << nc_nuc << nu_pdgc
199 << "] (E="<< Enu << " GeV) = " << xsec << " x 1E-38 cm^2";
200 return xsec;
201 }
202 return 0;
203}
204//____________________________________________________________________________
205void SPPXSec::Configure(const Registry & config)
206{
207 Algorithm::Configure(config);
208 this->LoadConfig();
209}
210//____________________________________________________________________________
211void SPPXSec::Configure(string config)
212{
213 Algorithm::Configure(config);
214 this->LoadConfig();
215}
216//____________________________________________________________________________
218{
219
220 bool good_conf = true ;
221
222 // Get GSL integration type & relative tolerance
223 GetParamDef( "gsl-integration-type", fGSLIntgType, string("adaptive") ) ;
224 GetParamDef( "gsl-relative-tolerance", fGSLRelTol, 1e-5 ) ;
225 GetParamDef( "gsl-max-eval", fGSLMaxEval, 1000000 );
226 GetParamDef( "gsl-min-eval", fGSLMinEval, 7500 ) ;
227 GetParam("UsePauliBlockingForRES", fUsePauliBlocking);
228 GetParamDef("Wcut", fWcut, -1.);
229 // Get upper Emax limit on cached free nucleon xsec spline,
230 // after this value it assume that xsec=xsec(Emax)
231 GetParamDef( "ESplineMax", fEMax, 250. ) ;
232
233 if ( fEMax < 20. ) {
234
235 LOG("SPPXSec", pERROR) << "E max is required to be at least 20 GeV, you set " << fEMax << " GeV" ;
236 good_conf = false ;
237 }
238
239 if ( ! good_conf ) {
240 LOG("SPPXSec", pFATAL)
241 << "Invalid configuration: Exiting" ;
242
243 // From the FreeBSD Library Functions Manual
244 //
245 // EX_CONFIG (78) Something was found in an unconfigured or miscon-
246 // figured state.
247
248 exit( 78 ) ;
249
250 }
251
252}
253//____________________________________________________________________________
254
#define pNOTICE
Definition Messenger.h:61
#define pINFO
Definition Messenger.h:62
#define pERROR
Definition Messenger.h:59
#define pFATAL
Definition Messenger.h:56
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define pWARN
Definition Messenger.h:60
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition Messenger.h:84
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils.
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
virtual void Configure(const Registry &config)
Definition Algorithm.cxx:62
bool GetParamDef(const RgKey &name, T &p, const T &def) const
A simple cache branch storing the cached data in a TNtuple.
GENIE Cache Memory.
Definition Cache.h:39
static Cache * Instance(void)
Definition Cache.cxx:67
CacheBranchI * FindCacheBranch(string key)
finding/adding cache branches
Definition Cache.cxx:80
Initial State information.
const Target & Tgt(void) const
int ProbePdg(void) const
double ProbeE(RefFrame_t rf) const
Target * TgtPtr(void) const
Summary information for an interaction.
Definition Interaction.h:56
InitialState * InitStatePtr(void) const
Definition Interaction.h:74
const ProcessInfo & ProcInfo(void) const
Definition Interaction.h:70
const KPhaseSpace & PhaseSpace(void) const
Definition Interaction.h:73
const InitialState & InitState(void) const
Definition Interaction.h:69
Kinematical phase space.
Definition KPhaseSpace.h:33
double Threshold_SPP_iso(void) const
Energy limit for resonance single pion production on isoscalar nucleon.
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition ProcessInfo.h:46
InteractionType_t InteractionTypeId(void) const
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
bool BareXSecPreCalc(void) const
Definition RunOpt.h:53
static RunOpt * Instance(void)
Definition RunOpt.cxx:54
string CacheBranchName(SppChannel_t spp_channel, InteractionType_t it, int nu) const
const XSecAlgorithmI * fSinglePionProductionXSecModel
void CacheResExcitationXSec(const Interaction *interaction) const
void Configure(const Registry &config)
Definition SPPXSec.cxx:205
bool fUsePauliBlocking
account for Pauli blocking?
Definition SPPXSec.h:55
void LoadConfig(void)
Definition SPPXSec.cxx:217
double Integrate(const XSecAlgorithmI *model, const Interaction *i) const
Definition SPPXSec.cxx:66
virtual ~SPPXSec()
Definition SPPXSec.cxx:61
A numeric analysis tool class for interpolating 1-D functions.
Definition Spline.h:58
double Evaluate(double x) const
Definition Spline.cxx:363
static string AsString(SppChannel_t channel)
Definition SppChannel.h:76
static SppChannel_t FromInteraction(const Interaction *interaction)
Definition SppChannel.h:402
static int InitStateNucleon(SppChannel_t channel)
Definition SppChannel.h:103
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition Target.h:40
void SetId(int pdgc)
Definition Target.cxx:149
int HitNucPdg(void) const
Definition Target.cxx:304
int N(void) const
Definition Target.h:69
int Z(void) const
Definition Target.h:68
bool IsNucleus(void) const
Definition Target.cxx:272
Cross Section Calculation Interface.
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
int fGSLMinEval
GSL min evaluations. Ignored by some integrators.
string fGSLIntgType
name of GSL numerical integrator
int fGSLMaxEval
GSL max evaluations.
double fGSLRelTol
required relative tolerance (error)
List of cross section vs energy splines.
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
bool IsEmpty(void) const
static XSecSplineList * Instance()
const double e
double func(double x, double y)
Basic constants.
bool IsNeutrino(int pdgc)
Definition PDGUtils.cxx:110
bool IsProton(int pdgc)
Definition PDGUtils.cxx:336
Physical System of Units.
static constexpr double cm2
Definition Units.h:69
ROOT::Math::IntegrationMultiDim::Type IntegrationNDimTypeFromString(string type)
Definition GSLUtils.cxx:59
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
const int kPdgProton
Definition PDGCodes.h:81
enum genie::EInteractionType InteractionType_t
const int kPdgTgtFreeN
Definition PDGCodes.h:200
enum genie::ESppChannel SppChannel_t
@ kRfHitNucRest
Definition RefFrame.h:30
const int kPdgTgtFreeP
Definition PDGCodes.h:199
const UInt_t kIAssumeFreeNucleon
Definition Interaction.h:49