IBDXSecMap.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2019, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5  or see $GENIE/LICENSE
6 
7  Author: Corey Reed <cjreed \at nikhef.nl>
8  Nikhef - February 4, 2010
9 
10  For the class documentation see the corresponding header file.
11 */
12 //____________________________________________________________________________
13 
14 #include "IBDXSecMap.h"
15 
20 
21 #include <sstream>
22 
23 using namespace genie;
24 
26 
27 //____________________________________________________________________________
30  fDefaultModel(0)
31 {
32 
33 }
34 //____________________________________________________________________________
36  XSecAlgorithmI("genie::IBDXSecMap", config),
37  fDefaultModel(0)
38 {
39 
40 }
41 //____________________________________________________________________________
43 {
44 
45 }
46 
47 //____________________________________________________________________________
49 {
50  Algorithm::Configure(config);
51  this->LoadConfig();
52 }
53 //____________________________________________________________________________
55 {
56  Algorithm::Configure(config);
57  this->LoadConfig();
58 }
59 //____________________________________________________________________________
61 {
62  // build the default xsec model according to the options contained
63  // in IBDXSecMap.xml and/or UserPhysicsOptions.xml
64 
65  // load default global model (should work for all nuclei)
66  RgAlg dgmodel ;
67  GetParam( "IBDNucXSecModel", dgmodel ) ;
68  LOG("IBD", pINFO)
69  << "Default IBD cross section model: " << dgmodel;
70 
72  dynamic_cast<const XSecAlgorithmI*>( this -> SubAlg("IBDNucXSecModel") );
74 
75  // check whether to map according to specific isotopes
76  GetParam("IsotopesUseSameModel", fIsotopesUseSameModel ) ;
77 
78  // load refined models for specific nuclei
79  for(int Z=1; Z<140; Z++) {
80  for(int A=Z; A<3*Z; A++) {
81  std::ostringstream key;
82  const int nucpdg = pdg::IonPdgCode(A,Z);
83  key << "IBDNucXSecModel@Pdg=" << nucpdg;
84  RgKey rgkey = key.str();
85  if ( GetConfig().Exists(rgkey) ) {
86  RgAlg rgmodel = GetConfig().GetAlg(rgkey);
87  LOG("IBD", pNOTICE)
88  << "Nucleus =" << nucpdg
89  << " -> refined nuclear model: " << rgmodel;
90  const XSecAlgorithmI* model =
91  dynamic_cast<const XSecAlgorithmI*>(this->SubAlg(rgkey));
92  assert(model);
93  const int mapkeyval = (fIsotopesUseSameModel) ? Z : nucpdg;
95  insert(map<int,const XSecAlgorithmI*>::value_type(mapkeyval,
96  model));
97  }
98  }
99  }
100 }
101 //____________________________________________________________________________
103 {
104  // search the map for the PDG code of the target
105  // if a refined model is found, return it
106  // otherwise return the default xsec model
107 
108  map<int,const XSecAlgorithmI*>::const_iterator it = fRefinedModels.find(t.Pdg());
109 
110  if(it != fRefinedModels.end()) return it->second;
111  else return fDefaultModel;
112 }
113 //____________________________________________________________________________
115 {
116  const XSecAlgorithmI* xs = this->SelectModel(i->InitState().Tgt());
117  if (xs!=0) {
118  return xs->XSec(i, k);
119  } else {
120  LOG("IBD", pERROR) << "No IBD XSec model found for target "
121  << i->InitState().TgtPdg();
122  return 0;
123  }
124 }
125 //____________________________________________________________________________
126 double IBDXSecMap::Integral(const Interaction * i) const
127 {
128  const XSecAlgorithmI* xs = this->SelectModel(i->InitState().Tgt());
129  if (xs!=0) {
130  return xs->Integral(i);
131  } else {
132  LOG("IBD", pERROR) << "No IBD XSec model found for target "
133  << i->InitState().TgtPdg();
134  return 0;
135  }
136 }
137 //____________________________________________________________________________
139 {
140  const XSecAlgorithmI* xs = this->SelectModel(i->InitState().Tgt());
141  if (xs!=0) {
142  return xs->ValidProcess(i);
143  } else {
144  LOG("IBD", pERROR) << "No IBD XSec model found for target "
145  << i->InitState().TgtPdg();
146  return 0;
147  }
148 }
149 //____________________________________________________________________________
151 {
152  const XSecAlgorithmI* xs = this->SelectModel(i->InitState().Tgt());
153  if (xs!=0) {
154  return xs->ValidKinematics(i);
155  } else {
156  LOG("IBD", pERROR) << "No IBD XSec model found for target "
157  << i->InitState().TgtPdg();
158  return 0;
159  }
160 }
161 
Cross Section Calculation Interface.
set< int >::iterator it
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
#define pERROR
Definition: Messenger.h:60
void Configure(const Registry &config)
Definition: IBDXSecMap.cxx:48
virtual double XSec(const Interaction *i, KinePhaseSpace_t k=kPSfE) const =0
Compute the cross section for the input interaction.
int Pdg(void) const
Definition: Target.h:72
const XSecAlgorithmI * fDefaultModel
Definition: IBDXSecMap.h:51
double Integral(const Interaction *i) const
Definition: IBDXSecMap.cxx:126
Definition: config.py:1
enum genie::EKinePhaseSpace KinePhaseSpace_t
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:254
void LoadConfig(void)
Definition: IBDXSecMap.cxx:60
Float_t Z
Definition: plot.C:38
bool ValidKinematics(const Interaction *i) const
Is the input kinematical point a physically allowed one?
Definition: IBDXSecMap.cxx:150
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:52
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
virtual double Integral(const Interaction *i) const =0
A Neutrino Interaction Target. Is a transparent encapsulation of quite different physical systems suc...
Definition: Target.h:41
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:70
Maps specific nuclei to appropriate cross section models.
Definition: IBDXSecMap.h:26
#define pINFO
Definition: Messenger.h:63
bool fIsotopesUseSameModel
Definition: IBDXSecMap.h:50
static const double A
Definition: Units.h:82
const XSecAlgorithmI * SelectModel(const Target &t) const
Definition: IBDXSecMap.cxx:102
virtual ~IBDXSecMap()
Definition: IBDXSecMap.cxx:42
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:66
int TgtPdg(void) const
int IonPdgCode(int A, int Z)
Definition: PDGUtils.cxx:69
double XSec(const Interaction *i, KinePhaseSpace_t k) const
Compute the cross section for the input interaction.
Definition: IBDXSecMap.cxx:114
virtual bool ValidProcess(const Interaction *i) const =0
Can this cross section algorithm handle the input process?
assert(nhit_max >=nhit_nbins)
ClassImp(IBDXSecMap) IBDXSecMap
Definition: IBDXSecMap.cxx:25
const InitialState & InitState(void) const
Definition: Interaction.h:69
#define pNOTICE
Definition: Messenger.h:62
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
const Target & Tgt(void) const
Definition: InitialState.h:67
const XML_Char XML_Content * model
Definition: expat.h:151
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:138
RgAlg GetAlg(RgKey key) const
Definition: Registry.cxx:503
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:353