GENIEGenerator
Loading...
Searching...
No Matches
EvtLibPXSec.cxx
Go to the documentation of this file.
3
5
9
10#include "TFile.h"
11#include "TGraph.h"
12
13using namespace genie;
14using namespace genie::evtlib;
15
16//____________________________________________________________________________
18XSecAlgorithmI("genie::evtlib::EvtLibPXSec")
19{
20
21}
22
23//____________________________________________________________________________
25XSecAlgorithmI("genie::evtlib::EvtLibPXSec", config)
26{
27
28}
29
30//____________________________________________________________________________
35
36//____________________________________________________________________________
37double EvtLibPXSec::XSec(const Interaction* /*in*/,
38 KinePhaseSpace_t /*kps*/) const
39{
40 LOG("ELI", pFATAL) << "This point should not be reached" ;
41 abort();
42}
43
44//____________________________________________________________________________
45double EvtLibPXSec::Integral(const Interaction* in) const
46{
47 TGraph* g = GetXSec(in);
48 if(!g) return 0; // Reason already printed
49
50 const InitialState& init_state = in->InitState();
51 const double E = init_state.ProbeE(kRfLab);
52
53 // Units of the cross-section graph are expected to be 10^-38 cm^2 / nucleus
54 return g->Eval(E) * 1e-38 * genie::units::cm2;
55}
56
57//____________________________________________________________________________
58bool EvtLibPXSec::ValidProcess(const Interaction* /*in*/) const
59{
60 return true;
61}
62
63//____________________________________________________________________________
65{
67 LoadXSecs();
68}
69
70//____________________________________________________________________________
71void EvtLibPXSec::Configure(string config)
72{
74 LoadXSecs();
75}
76
77//____________________________________________________________________________
79{
80 for(auto it: fXSecs) delete it.second;
81 fXSecs.clear();
82}
83
84//____________________________________________________________________________
86{
87 ClearXSecs();
88
89 std::string libPath;
90 GetParam("EventLibraryPath", libPath);
91 Expand(libPath);
92
94
95 TFile fin(libPath.c_str());
96 if(fin.IsZombie()) exit(1);
97
98 TIter next(fin.GetListOfKeys());
99 while(TObject* dir = next()){
100 const std::string& tgtName = dir->GetName();
101 const TParticlePDG* tgtPart = pdglib->DBase()->GetParticle(tgtName.c_str());
102 if(!tgtPart){
103 LOG("ELI", pWARN) << "Unknown nucleus " << tgtName
104 << " found in " << libPath
105 << " -- skipping";
106 continue;
107 }
108
109 for(int pdg: {kPdgNuE, kPdgAntiNuE,
112
113 for(bool iscc: {true, false}){
114 // NCs should be the same for all flavours. Use nu_mu as a convention
115 // internal to this code to index into the xsecs map.
116 if(!iscc && abs(pdg) != kPdgNuMu) continue;
117
118 std::string nuName = pdglib->Find(pdg)->GetName();
119 if(!iscc) nuName = pdg::IsAntiNeutrino(pdg) ? "nu_bar" : "nu";
120
121 const std::string graphName =
122 TString::Format("%s/%s/%s/xsec",
123 tgtName.c_str(),
124 iscc ? "cc" : "nc",
125 nuName.c_str()).Data();
126
127 const Key key(tgtPart->PdgCode(), pdg, iscc);
128
129 TGraph* g = (TGraph*)fin.Get(graphName.c_str());
130 if(!g){
131 LOG("ELI", pINFO) << graphName << " not found in "
132 << libPath << " -- skipping";
133 continue;
134 }
135
136 fXSecs[key] = new TGraph(*g);
137 } // end for iscc
138 } // end for pdg
139 } // end for dir
140}
141
142//____________________________________________________________________________
143TGraph* EvtLibPXSec::GetXSec(const Interaction* in) const
144{
145 const InitialState& init_state = in->InitState();
146
147 const ProcessInfo& proc = in->ProcInfo();
148 if(!proc.IsWeakCC() && !proc.IsWeakNC()){
149 LOG("ELI", pINFO) << "Skipping unknown process " << proc;
150 return 0;
151 }
152
153 int pdg = init_state.ProbePdg();
154 // Use nu_mu for NC as a convention internal to this code to index into the
155 // xsec graphs map.
156 if(proc.IsWeakNC()){
157 if(pdg > 0) pdg = kPdgNuMu; else pdg = kPdgAntiNuMu;
158 }
159
160 const Key key(init_state.TgtPdg(), pdg, proc.IsWeakCC());
161
162 auto it = fXSecs.find(key);
163 if(it == fXSecs.end()){
164 LOG("ELI", pINFO) << "Skipping process without xsec " << key;
165 return 0;
166 }
167
168 return it->second;
169}
string dir
#define pINFO
Definition Messenger.h:62
#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
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
Initial State information.
int TgtPdg(void) const
int ProbePdg(void) const
double ProbeE(RefFrame_t rf) const
Summary information for an interaction.
Definition Interaction.h:56
const ProcessInfo & ProcInfo(void) const
Definition Interaction.h:70
const InitialState & InitState(void) const
Definition Interaction.h:69
Singleton class to load & serve a TDatabasePDG.
Definition PDGLibrary.h:36
static PDGLibrary * Instance(void)
TDatabasePDG * DBase(void)
TParticlePDG * Find(int pdgc, bool must_exist=true)
A class encapsulating an enumeration of interaction types (EM, Weak-CC, Weak-NC) and scattering types...
Definition ProcessInfo.h:46
bool IsWeakNC(void) const
bool IsWeakCC(void) const
A registry. Provides the container for algorithm configuration parameters.
Definition Registry.h:65
std::map< Key, TGraph * > fXSecs
Definition EvtLibPXSec.h:35
TGraph * GetXSec(const Interaction *in) const
double XSec(const Interaction *i, KinePhaseSpace_t k) const
Compute the cross section for the input interaction.
void Configure(const Registry &config)
double Integral(const Interaction *i) const
bool ValidProcess(const Interaction *i) const
Can this cross section algorithm handle the input process?
const double e
void Expand(std::string &s)
Expand env vars/homedirs/wildcards in s.
Definition Utils.cxx:8
Utilities for improving the code readability when using PDG codes.
bool IsAntiNeutrino(int pdgc)
Definition PDGUtils.cxx:118
static constexpr double cm2
Definition Units.h:69
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
const int kPdgAntiNuE
Definition PDGCodes.h:29
const int kPdgAntiNuTau
Definition PDGCodes.h:33
enum genie::EKinePhaseSpace KinePhaseSpace_t
const int kPdgNuE
Definition PDGCodes.h:28
const int kPdgNuTau
Definition PDGCodes.h:32
@ kRfLab
Definition RefFrame.h:26
const int kPdgAntiNuMu
Definition PDGCodes.h:31
const int kPdgNuMu
Definition PDGCodes.h:30