NuclearModelMap.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: Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
8  University of Liverpool & STFC Rutherford Appleton Lab
9 
10  For the class documentation see the corresponding header file.
11 
12  Important revisions after version 2.0.0 :
13 
14  @ Mar 18, 2016- Joe Johnston (SD)
15  Update GenerateNucleon() and Prob() to accept a radius as the argument,
16  and call the corresponding methods in the nuclear model with a radius.
17 
18 */
19 //____________________________________________________________________________
20 
21 #include <sstream>
22 
23 #include <TSystem.h>
24 #include <TNtupleD.h>
25 #include <TGraph2D.h>
26 
36 
37 using std::ostringstream;
38 using namespace genie;
39 using namespace genie::constants;
40 using namespace genie::controls;
41 
42 //____________________________________________________________________________
44 NuclearModelI("genie::NuclearModelMap")
45 {
46 
47 }
48 //____________________________________________________________________________
50 NuclearModelI("genie::NuclearModelMap", config)
51 {
52 
53 }
54 //____________________________________________________________________________
56 {
57 
58 }
59 //____________________________________________________________________________
61  double hitNucleonRadius) const
62 {
63  const NuclearModelI * nm = this->SelectModel(target);
64  if(!nm) return false;
65 
66  bool ok = nm->GenerateNucleon(target,hitNucleonRadius);
67 
69  const TVector3& p = nm->Momentum3();
70  fCurrMomentum.SetXYZ(p.Px(), p.Py(), p.Pz());
72 
73  return ok;
74 }
75 //____________________________________________________________________________
76 double NuclearModelMap::Prob(double p, double w, const Target & target,
77  double hitNucRadius) const
78 {
79  const NuclearModelI * nm = this->SelectModel(target);
80  if(!nm) return 0;
81 
82  return nm->Prob(p,w,target,hitNucRadius);
83 }
84 //____________________________________________________________________________
86 {
87  const NuclearModelI * nm = this->SelectModel(target);
88  if(!nm) return kNucmUndefined;
89 
90  return nm->ModelType(target);
91 }
92 //____________________________________________________________________________
94 {
95  Algorithm::Configure(config);
96  this->LoadConfig();
97 }
98 //____________________________________________________________________________
100 {
101  Algorithm::Configure(config);
102 
103  Registry * algos = AlgConfigPool::Instance() -> GlobalParameterList() ;
104  Registry r( "NuclearModelMap", false ) ;
105 
106  // copy in local pool relevant configurations
107  RgIMap entries = algos -> GetItemMap();
108  const std::string keyStart = "NuclearModel";
109  for( RgIMap::const_iterator it = entries.begin(); it != entries.end(); ++it ) {
110 
111  if( it -> first.compare(0, keyStart.size(), keyStart.c_str()) == 0 ) {
112  r.Set( it -> first, algos -> GetAlg(it->first ) ) ;
113  }
114 
115  }
116 
118 
119  this->LoadConfig();
120 }
121 //____________________________________________________________________________
123 {
124 
125  fDefGlobModel = 0;
126  // load default global model (should work for all nuclei)
127  RgAlg dgmodel ;
128  GetParam( "NuclearModel", dgmodel ) ;
129 
130  LOG("Nuclear", pINFO)
131  << "Default global nuclear model: " << dgmodel;
132  fDefGlobModel = dynamic_cast<const NuclearModelI *> ( this -> SubAlg( "NuclearModel" ) ) ;
134 
135  // We're looking for keys that match this string
136  const std::string keyStart = "NuclearModel@Pdg=";
137  // Looking in both of these registries
138  RgIMap entries = GetConfig().GetItemMap();
139 
140  for(RgIMap::const_iterator it = entries.begin(); it != entries.end(); ++it){
141  const std::string& key = it->first;
142  // Does it start with the right string?
143  if(key.compare(0, keyStart.size(), keyStart.c_str()) == 0){
144  // The rest is the PDG code
145  const int pdg = atoi(key.c_str()+keyStart.size());
146  const int Z = pdg::IonPdgCodeToZ(pdg);
147  //const int A = pdg::IonPdgCodeToA(pdg);
148 
149  RgAlg rgmodel = GetConfig().GetAlg(key) ;
150  LOG("Nuclear", pNOTICE)
151  << "Nucleus =" << pdg
152  << " -> refined nuclear model: " << rgmodel;
153  const NuclearModelI * model =
154  dynamic_cast<const NuclearModelI *> (
155  this -> SubAlg(key) ) ;
156  assert(model);
157  fRefinedModels.insert(map<int,const NuclearModelI*>::value_type(Z,model));
158  }
159  }
160 
161 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
162  for (map<int,const NuclearModelI*>::iterator it = fRefinedModels.begin();
163  it != fRefinedModels.end(); ++it) {
164  LOG("Nuclear", pDEBUG)
165  << "Z = " << (*it).first << "; model = " << (*it).second;
166  }
167 #endif
168 }
169 
170 //____________________________________________________________________________
172 {
173  int Z = t.Z();
174 
175  map<int,const NuclearModelI*>::const_iterator it = fRefinedModels.find(Z);
176 
177  if(it != fRefinedModels.end()) return it->second;
178  else return fDefGlobModel;
179 }
180 //____________________________________________________________________________
virtual double Prob(double p, double w, const Target &t, double hitNucleonRadius) const
Basic constants.
const XML_Char * target
Definition: expat.h:268
double RemovalEnergy(void) const
Definition: NuclearModelI.h:57
set< int >::iterator it
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
const char * p
Definition: xmltok.h:285
static constexpr Double_t nm
Definition: Munits.h:133
Pure abstract base class. Defines the NuclearModelI interface to be implemented by any physics model ...
Definition: NuclearModelI.h:42
Definition: config.py:1
const NuclearModelI * fDefGlobModel
default basic model (should work for all nuclei)
const TVector3 & Momentum3(void) const
Definition: NuclearModelI.h:67
FermiMoverInteractionType_t GetFermiMoverInteractionType(void) const
Definition: NuclearModelI.h:72
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:254
virtual NuclearModel_t ModelType(const Target &) const =0
NuclearModel_t ModelType(const Target &t) const
Float_t Z
Definition: plot.C:38
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:97
FermiMoverInteractionType_t fFermiMoverInteractionType
const RgIMap & GetItemMap(void) const
Definition: Registry.h:162
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
int Z(void) const
Definition: Target.h:69
#define pINFO
Definition: Messenger.h:63
virtual bool GenerateNucleon(const Target &t, double hitNucleonRadius) const
map< int, const NuclearModelI * > fRefinedModels
refinements for specific elements
Misc GENIE control constants.
void Configure(const Registry &config)
enum genie::ENuclearModel NuclearModel_t
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:66
assert(nhit_max >=nhit_nbins)
TRandom3 r(0)
virtual bool GenerateNucleon(const Target &) const =0
int IonPdgCodeToZ(int pdgc)
Definition: PDGUtils.cxx:53
const NuclearModelI * SelectModel(const Target &t) const
#define pNOTICE
Definition: Messenger.h:62
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
virtual double Prob(double p, double w, const Target &) const =0
Float_t w
Definition: plot.C:20
const XML_Char XML_Content * model
Definition: expat.h:151
void Set(RgIMapPair entry)
Definition: Registry.cxx:282
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
RgAlg GetAlg(RgKey key) const
Definition: Registry.cxx:503
static AlgConfigPool * Instance()
#define pDEBUG
Definition: Messenger.h:64
map< RgKey, RegistryItemI * > RgIMap
Definition: Registry.h:46
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:353