GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IBDXSecMap.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  Corey Reed <cjreed \at nikhef.nl>
7  Nikhef
8 */
9 //____________________________________________________________________________
10 
11 #include "IBDXSecMap.h"
12 
17 
18 #include <sstream>
19 
20 using namespace genie;
21 
23 
24 //____________________________________________________________________________
26  XSecAlgorithmI("genie::IBDXSecMap"),
27  fDefaultModel(0)
28 {
29 
30 }
31 //____________________________________________________________________________
32 IBDXSecMap::IBDXSecMap(string config) :
33  XSecAlgorithmI("genie::IBDXSecMap", config),
34  fDefaultModel(0)
35 {
36 
37 }
38 //____________________________________________________________________________
40 {
41 
42 }
43 
44 //____________________________________________________________________________
45 void IBDXSecMap::Configure(const Registry & config)
46 {
47  Algorithm::Configure(config);
48  this->LoadConfig();
49 }
50 //____________________________________________________________________________
51 void IBDXSecMap::Configure(string config)
52 {
53  Algorithm::Configure(config);
54  this->LoadConfig();
55 }
56 //____________________________________________________________________________
58 {
59  // build the default xsec model according to the options contained
60  // in IBDXSecMap.xml and/or UserPhysicsOptions.xml
61 
62  // load default global model (should work for all nuclei)
63  RgAlg dgmodel ;
64  GetParam( "IBDNucXSecModel", dgmodel ) ;
65  LOG("IBD", pINFO)
66  << "Default IBD cross section model: " << dgmodel;
67 
69  dynamic_cast<const XSecAlgorithmI*>( this -> SubAlg("IBDNucXSecModel") );
70  assert(fDefaultModel!=0);
71 
72  // check whether to map according to specific isotopes
73  GetParam("IsotopesUseSameModel", fIsotopesUseSameModel ) ;
74 
75  // load refined models for specific nuclei
76  for(int Z=1; Z<140; Z++) {
77  for(int A=Z; A<3*Z; A++) {
78  std::ostringstream key;
79  const int nucpdg = pdg::IonPdgCode(A,Z);
80  key << "IBDNucXSecModel@Pdg=" << nucpdg;
81  RgKey rgkey = key.str();
82  if ( GetConfig().Exists(rgkey) ) {
83  RgAlg rgmodel = GetConfig().GetAlg(rgkey);
84  LOG("IBD", pNOTICE)
85  << "Nucleus =" << nucpdg
86  << " -> refined nuclear model: " << rgmodel;
87  const XSecAlgorithmI* model =
88  dynamic_cast<const XSecAlgorithmI*>(this->SubAlg(rgkey));
89  assert(model);
90  const int mapkeyval = (fIsotopesUseSameModel) ? Z : nucpdg;
92  insert(map<int,const XSecAlgorithmI*>::value_type(mapkeyval,
93  model));
94  }
95  }
96  }
97 }
98 //____________________________________________________________________________
100 {
101  // search the map for the PDG code of the target
102  // if a refined model is found, return it
103  // otherwise return the default xsec model
104 
105  map<int,const XSecAlgorithmI*>::const_iterator it = fRefinedModels.find(t.Pdg());
106 
107  if(it != fRefinedModels.end()) return it->second;
108  else return fDefaultModel;
109 }
110 //____________________________________________________________________________
112 {
113  const XSecAlgorithmI* xs = this->SelectModel(i->InitState().Tgt());
114  if (xs!=0) {
115  return xs->XSec(i, k);
116  } else {
117  LOG("IBD", pERROR) << "No IBD XSec model found for target "
118  << i->InitState().TgtPdg();
119  return 0;
120  }
121 }
122 //____________________________________________________________________________
123 double IBDXSecMap::Integral(const Interaction * i) const
124 {
125  const XSecAlgorithmI* xs = this->SelectModel(i->InitState().Tgt());
126  if (xs!=0) {
127  return xs->Integral(i);
128  } else {
129  LOG("IBD", pERROR) << "No IBD XSec model found for target "
130  << i->InitState().TgtPdg();
131  return 0;
132  }
133 }
134 //____________________________________________________________________________
136 {
137  const XSecAlgorithmI* xs = this->SelectModel(i->InitState().Tgt());
138  if (xs!=0) {
139  return xs->ValidProcess(i);
140  } else {
141  LOG("IBD", pERROR) << "No IBD XSec model found for target "
142  << i->InitState().TgtPdg();
143  return 0;
144  }
145 }
146 //____________________________________________________________________________
148 {
149  const XSecAlgorithmI* xs = this->SelectModel(i->InitState().Tgt());
150  if (xs!=0) {
151  return xs->ValidKinematics(i);
152  } else {
153  LOG("IBD", pERROR) << "No IBD XSec model found for target "
154  << i->InitState().TgtPdg();
155  return 0;
156  }
157 }
Cross Section Calculation Interface.
#define pERROR
Definition: Messenger.h:59
void Configure(const Registry &config)
Definition: IBDXSecMap.cxx:45
int Pdg(void) const
Definition: Target.h:71
const XSecAlgorithmI * fDefaultModel
Definition: IBDXSecMap.h:50
double Integral(const Interaction *i) const
Definition: IBDXSecMap.cxx:123
enum genie::EKinePhaseSpace KinePhaseSpace_t
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
void LoadConfig(void)
Definition: IBDXSecMap.cxx:57
bool ValidKinematics(const Interaction *i) const
Is the input kinematical point a physically allowed one?
Definition: IBDXSecMap.cxx:147
Summary information for an interaction.
Definition: Interaction.h:56
virtual bool ValidKinematics(const Interaction *i) const
Is the input kinematical point a physically allowed one?
std::map< int, const XSecAlgorithmI * > fRefinedModels
Definition: IBDXSecMap.h:51
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
static constexpr double A
Definition: Units.h:74
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
Maps specific nuclei to appropriate cross section models.
Definition: IBDXSecMap.h:25
#define pINFO
Definition: Messenger.h:62
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
bool fIsotopesUseSameModel
Definition: IBDXSecMap.h:49
const XSecAlgorithmI * SelectModel(const Target &t) const
Definition: IBDXSecMap.cxx:99
virtual ~IBDXSecMap()
Definition: IBDXSecMap.cxx:39
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
ClassImp(CacheBranchFx)
int TgtPdg(void) const
int IonPdgCode(int A, int Z)
Definition: PDGUtils.cxx:71
double XSec(const Interaction *i, KinePhaseSpace_t k) const
Compute the cross section for the input interaction.
Definition: IBDXSecMap.cxx:111
const InitialState & InitState(void) const
Definition: Interaction.h:69
#define pNOTICE
Definition: Messenger.h:61
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
const Target & Tgt(void) const
Definition: InitialState.h:66
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
bool ValidProcess(const Interaction *i) const
Can this cross section algorithm handle the input process?
Definition: IBDXSecMap.cxx:135
virtual double Integral(const Interaction *i) const =0
RgAlg GetAlg(RgKey key) const
Definition: Registry.cxx:488
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345