GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NuclearModelMap.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 
7  Costas Andreopoulos <c.andreopoulos \at cern.ch>
8  University of Liverpool
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 //____________________________________________________________________________
93 double NuclearModelMap::FermiMomentum( const Target & t, int nucleon_pdg ) const {
94 
95  const NuclearModelI * nm = this->SelectModel(t);
96  return nm -> FermiMomentum( t, nucleon_pdg ) ;
97 
98 }
99 //____________________________________________________________________________
101  int nucleon_pdg, double radius ) const {
102 
103  const NuclearModelI * nm = this->SelectModel(t);
104  return nm -> LocalFermiMomentum( t, nucleon_pdg, radius ) ;
105 
106 }
107 //____________________________________________________________________________
109 {
110  Algorithm::Configure(config);
111  this->LoadConfig();
112 }
113 //____________________________________________________________________________
114 void NuclearModelMap::Configure(string config)
115 {
116  Algorithm::Configure(config);
117 
118  Registry * algos = AlgConfigPool::Instance() -> GlobalParameterList() ;
119  Registry r( "NuclearModelMap", false ) ;
120 
121  // copy in local pool relevant configurations
122  RgIMap entries = algos -> GetItemMap();
123  const std::string keyStart = "NuclearModel";
124  for( RgIMap::const_iterator it = entries.begin(); it != entries.end(); ++it ) {
125 
126  if( it -> first.compare(0, keyStart.size(), keyStart.c_str()) == 0 ) {
127  r.Set( it -> first, algos -> GetAlg(it->first ) ) ;
128  }
129 
130  }
131 
133 
134  this->LoadConfig();
135 }
136 //____________________________________________________________________________
138 {
139 
140  fDefGlobModel = 0;
141  // load default global model (should work for all nuclei)
142  RgAlg dgmodel ;
143  GetParam( "NuclearModel", dgmodel ) ;
144 
145  LOG("Nuclear", pINFO)
146  << "Default global nuclear model: " << dgmodel;
147  fDefGlobModel = dynamic_cast<const NuclearModelI *> ( this -> SubAlg( "NuclearModel" ) ) ;
148  assert(fDefGlobModel);
149 
150  // We're looking for keys that match this string
151  const std::string keyStart = "NuclearModel@Pdg=";
152  // Looking in both of these registries
153  RgIMap entries = GetConfig().GetItemMap();
154 
155  for(RgIMap::const_iterator it = entries.begin(); it != entries.end(); ++it){
156  const std::string& key = it->first;
157  // Does it start with the right string?
158  if(key.compare(0, keyStart.size(), keyStart.c_str()) == 0){
159  // The rest is the PDG code
160  const int pdg = atoi(key.c_str()+keyStart.size());
161  const int Z = pdg::IonPdgCodeToZ(pdg);
162  //const int A = pdg::IonPdgCodeToA(pdg);
163 
164  RgAlg rgmodel = GetConfig().GetAlg(key) ;
165  LOG("Nuclear", pNOTICE)
166  << "Nucleus =" << pdg
167  << " -> refined nuclear model: " << rgmodel;
168  const NuclearModelI * model =
169  dynamic_cast<const NuclearModelI *> (
170  this -> SubAlg(key) ) ;
171  assert(model);
172  fRefinedModels.insert(map<int,const NuclearModelI*>::value_type(Z,model));
173  }
174  }
175 
176 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
177  for (map<int,const NuclearModelI*>::iterator it = fRefinedModels.begin();
178  it != fRefinedModels.end(); ++it) {
179  LOG("Nuclear", pDEBUG)
180  << "Z = " << (*it).first << "; model = " << (*it).second;
181  }
182 #endif
183 }
184 
185 //____________________________________________________________________________
187 {
188  int Z = t.Z();
189 
190  map<int,const NuclearModelI*>::const_iterator it = fRefinedModels.find(Z);
191 
192  if(it != fRefinedModels.end()) return it->second;
193  else return fDefGlobModel;
194 }
195 //____________________________________________________________________________
virtual double Prob(double p, double w, const Target &t, double hitNucleonRadius) const
virtual double LocalFermiMomentum(const Target &t, int nucleon_pdg, double radius) const
double RemovalEnergy(void) const
Definition: NuclearModelI.h:65
Pure abstract base class. Defines the NuclearModelI interface to be implemented by any physics model ...
Definition: NuclearModelI.h:46
const NuclearModelI * fDefGlobModel
default basic model (should work for all nuclei)
const TVector3 & Momentum3(void) const
Definition: NuclearModelI.h:75
virtual NuclearModel_t ModelType(const Target &) const =0
FermiMoverInteractionType_t GetFermiMoverInteractionType(void) const
Definition: NuclearModelI.h:80
virtual const Registry & GetConfig(void) const
Definition: Algorithm.cxx:246
NuclearModel_t ModelType(const Target &t) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
FermiMoverInteractionType_t fFermiMoverInteractionType
const RgIMap & GetItemMap(void) const
Definition: Registry.h:161
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 Z(void) const
Definition: Target.h:68
virtual double Prob(double p, double w, const Target &) const =0
#define pINFO
Definition: Messenger.h:62
virtual bool GenerateNucleon(const Target &t, double hitNucleonRadius) const
map< int, const NuclearModelI * > fRefinedModels
refinements for specific elements
void Configure(const Registry &config)
enum genie::ENuclearModel NuclearModel_t
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
virtual double FermiMomentum(const Target &t, int nucleon_pdg) const
int IonPdgCodeToZ(int pdgc)
Definition: PDGUtils.cxx:55
const NuclearModelI * SelectModel(const Target &t) const
#define pNOTICE
Definition: Messenger.h:61
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
virtual bool GenerateNucleon(const Target &) const =0
void Set(RgIMapPair entry)
Definition: Registry.cxx:267
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:488
static AlgConfigPool * Instance()
#define pDEBUG
Definition: Messenger.h:63
map< RgKey, RegistryItemI * > RgIMap
Definition: Registry.h:45
const Algorithm * SubAlg(const RgKey &registry_key) const
Definition: Algorithm.cxx:345