GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HELeptonXSec.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  Alfonso Garcia <aagarciasoto \at km3net.de>
7  IFIC & Harvard University
8 */
9 //____________________________________________________________________________
10 
11 #include <TMath.h>
12 #include <Math/IFunction.h>
13 #include <Math/Integrator.h>
14 
17 #include "Framework/Conventions/GBuild.h"
25 #include "Framework/Utils/RunOpt.h"
26 #include "Framework/Utils/Range1.h"
27 #include "Framework/Utils/Cache.h"
31 
32 using namespace genie;
33 using namespace genie::controls;
34 using namespace genie::constants;
35 
36 //____________________________________________________________________________
38 XSecIntegratorI("genie::HELeptonXSec")
39 {
40 
41 }
42 //____________________________________________________________________________
44 XSecIntegratorI("genie::HELeptonXSec", config)
45 {
46 
47 }
48 //____________________________________________________________________________
50 {
51 
52 }
53 //____________________________________________________________________________
55  const XSecAlgorithmI * model, const Interaction * in) const
56 {
57  if(! model->ValidProcess(in) ) return 0.;
58 
59  const KPhaseSpace & kps = in->PhaseSpace();
60  if(!kps.IsAboveThreshold()) {
61  LOG("HELeptonXSec", pDEBUG) << "*** Below energy threshold";
62  return 0;
63  }
64 
65 
66  const ProcessInfo & proc_info = in->ProcInfo();
67  const InitialState & init_state = in->InitState();
68  double Ev = init_state.ProbeE(kRfLab);
69 
70  // If the input interaction is off a nuclear target, then chek whether
71  // the corresponding free nucleon cross section already exists at the
72  // cross section spline list.
73  // If yes, calculate the nuclear cross section based on that value.
74  //
76  if( !xsl->IsEmpty() && !proc_info.IsPhotonCoherent() ) {
77 
78  Interaction * interaction = new Interaction(*in);
79  Target * target = interaction->InitStatePtr()->TgtPtr();
80 
81  int NNucl = 0;
82  bool skip = false;
83  if ( proc_info.IsGlashowResonance() ) {
84  NNucl = init_state.Tgt().Z();
85  target->SetId(kPdgTgtFreeP);
86  }
87  else if ( proc_info.IsPhotonResonance() ) {
88  int nucpdgc = init_state.Tgt().HitNucPdg();
89  if (pdg::IsProton(nucpdgc)) {
90  NNucl = init_state.Tgt().Z();
91  target->SetId(kPdgTgtFreeP);
92  }
93  else {
94  NNucl = init_state.Tgt().N();
95  target->SetId(kPdgTgtFreeN);
96  }
97  }
98 
99  if( xsl->SplineExists(model,interaction) ) {
100  const Spline * spl = xsl->GetSpline(model, interaction);
101  double xsec = spl->Evaluate(Ev);
102  LOG("HELeptonXSec", pINFO) << "From XSecSplineList: XSec["<<init_state.ProbePdg()<<","<<proc_info.ScatteringTypeAsString()<<","<<interaction->ExclTag().FinalLeptonPdg()<< ",free nucleon] (E = " << Ev << " GeV) = " << xsec;
103  if( !interaction->TestBit(kIAssumeFreeNucleon) ) {
104  xsec *= NNucl;
105  LOG("HELeptonXSec", pINFO) << "XSec["<<init_state.ProbePdg()<<","<<proc_info.ScatteringTypeAsString()<<","<<interaction->ExclTag().FinalLeptonPdg()<< "] (E = " << Ev << " GeV) = " << xsec;
106  }
107  delete interaction;
108  return xsec;
109  }
110  delete interaction;
111 
112  }
113 
114  Interaction * interaction = new Interaction(*in);
115  interaction->SetBit(kISkipProcessChk);
116 
117  ROOT::Math::IntegrationMultiDim::Type ig_type = utils::gsl::IntegrationNDimTypeFromString(fGSLIntgType);
118 
119  double xsec = 0.;
120  ROOT::Math::IBaseFunctionMultiDim * func;
121  if ( proc_info.IsPhotonCoherent() ) {
122  double kine_min[3] = { -1., 0., 0. };
123  double kine_max[3] = { 1., 1., 1. };
124  func = new utils::gsl::d2Xsec_dn1dn2dn3_E(model, interaction);
125  ROOT::Math::IntegratorMultiDim ig(*func,ig_type,0,0,fGSLMaxEval);
126  xsec = ig.Integral(kine_min, kine_max);
127  }
128  else {
129  double kine_min[2] = { -1., 0. };
130  double kine_max[2] = { 1., 1. };
131  func = new utils::gsl::d2Xsec_dn1dn2_E(model, interaction);
132  ROOT::Math::IntegratorMultiDim ig(*func,ig_type,0,0,fGSLMaxEval);
133  xsec = ig.Integral(kine_min, kine_max);
134  }
135 
136  delete func;
137 
138  xsec *= (1E-38 * units::cm2);
139 
140  LOG("HELeptonXSec", pDEBUG) << "*** XSec["<<init_state.ProbePdg()<<","<<proc_info.ScatteringTypeAsString()<<","<<interaction->ExclTag().FinalLeptonPdg()<< "] (E=" << interaction->InitState().ProbeE(kRfLab) << ") = " << xsec / (1E-38 * units::cm2);
141 
142  delete interaction;
143  return xsec;
144 }
145 //____________________________________________________________________________
146 void HELeptonXSec::Configure(const Registry & config)
147 {
148  Algorithm::Configure(config);
149  this->LoadConfig();
150 }
151 //____________________________________________________________________________
152 void HELeptonXSec::Configure(string config)
153 {
154  Algorithm::Configure(config);
155  this->LoadConfig();
156 }
157 //____________________________________________________________________________
159 {
160  // Get GSL integration type & relative tolerance
161  GetParamDef("gsl-integration-type", fGSLIntgType, string("vegas") ) ;
162 
163  int max_eval ;
164  GetParamDef( "gsl-max-eval", max_eval, 500000 ) ;
165  fGSLMaxEval = (unsigned int) max_eval ;
166 }
167 //____________________________________________________________________________
168 
Cross Section Calculation Interface.
bool IsPhotonResonance(void) const
const KPhaseSpace & PhaseSpace(void) const
Definition: Interaction.h:73
int FinalLeptonPdg(void) const
Definition: XclsTag.h:74
string fGSLIntgType
name of GSL numerical integrator
string ScatteringTypeAsString(void) const
Cross Section Integrator Interface.
ROOT::Math::IntegrationMultiDim::Type IntegrationNDimTypeFromString(string type)
Definition: GSLUtils.cxx:59
int HitNucPdg(void) const
Definition: Target.cxx:304
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
A numeric analysis tool class for interpolating 1-D functions.
Definition: Spline.h:58
void Configure(const Registry &config)
static XSecSplineList * Instance()
double Evaluate(double x) const
Definition: Spline.cxx:363
void SetId(int pdgc)
Definition: Target.cxx:149
Summary information for an interaction.
Definition: Interaction.h:56
bool IsProton(int pdgc)
Definition: PDGUtils.cxx:336
#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.
static constexpr double cm2
Definition: Units.h:69
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition: ProcessInfo.h:46
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
int ProbePdg(void) const
Definition: InitialState.h:64
Kinematical phase space.
Definition: KPhaseSpace.h:33
const int kPdgTgtFreeN
Definition: PDGCodes.h:200
const int kPdgTgtFreeP
Definition: PDGCodes.h:199
double func(double x, double y)
int Z(void) const
Definition: Target.h:68
#define pINFO
Definition: Messenger.h:62
bool IsPhotonCoherent(void) const
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
int fGSLMaxEval
GSL max evaluations.
int N(void) const
Definition: Target.h:69
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
const UInt_t kIAssumeFreeNucleon
Definition: Interaction.h:49
const XclsTag & ExclTag(void) const
Definition: Interaction.h:72
Target * TgtPtr(void) const
Definition: InitialState.h:67
bool IsAboveThreshold(void) const
Checks whether the interaction is above the energy threshold.
InitialState * InitStatePtr(void) const
Definition: Interaction.h:74
const InitialState & InitState(void) const
Definition: Interaction.h:69
const ProcessInfo & ProcInfo(void) const
Definition: Interaction.h:70
bool GetParamDef(const RgKey &name, T &p, const T &def) const
const Target & Tgt(void) const
Definition: InitialState.h:66
bool IsGlashowResonance(void) const
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