Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
genie::SpectralFunc1d Class Reference

Simpler approach to using spectral functions. A beta version. Implements the NuclearModelI interface. More...

#include <SpectralFunc1d.h>

Inheritance diagram for genie::SpectralFunc1d:
genie::NuclearModelI genie::Algorithm

Public Member Functions

 SpectralFunc1d ()
 
 SpectralFunc1d (string config)
 
virtual ~SpectralFunc1d ()
 
bool GenerateNucleon (const Target &t) const
 
double Prob (double p, double w, const Target &t) const
 
NuclearModel_t ModelType (const Target &) const
 
void Configure (const Registry &config)
 
void Configure (string param_set)
 
- Public Member Functions inherited from genie::NuclearModelI
virtual ~NuclearModelI ()
 
virtual bool GenerateNucleon (const Target &tgt, double hitNucleonRadius) const
 
virtual double Prob (double p, double w, const Target &tgt, double hitNucleonRadius) const
 
virtual double FermiMomentum (const Target &, int nucleon_pdg) const
 
virtual double LocalFermiMomentum (const Target &, int nucleon_pdg, double radius) const
 
double RemovalEnergy (void) const
 
double Momentum (void) const
 
const TVector3 & Momentum3 (void) const
 
FermiMoverInteractionType_t GetFermiMoverInteractionType (void) const
 
void SetMomentum3 (const TVector3 &mom) const
 
void SetRemovalEnergy (double E) const
 
- Public Member Functions inherited from genie::Algorithm
virtual ~Algorithm ()
 
virtual void FindConfig (void)
 
virtual const RegistryGetConfig (void) const
 
RegistryGetOwnedConfig (void)
 
virtual const AlgIdId (void) const
 Get algorithm ID. More...
 
virtual AlgStatus_t GetStatus (void) const
 Get algorithm status. More...
 
virtual bool AllowReconfig (void) const
 
virtual AlgCmp_t Compare (const Algorithm *alg) const
 Compare with input algorithm. More...
 
virtual void SetId (const AlgId &id)
 Set algorithm ID. More...
 
virtual void SetId (string name, string config)
 
const AlgorithmSubAlg (const RgKey &registry_key) const
 
void AdoptConfig (void)
 
void AdoptSubstructure (void)
 
virtual void Print (ostream &stream) const
 Print algorithm info. More...
 

Protected Member Functions

void LoadConfig (void)
 
- Protected Member Functions inherited from genie::NuclearModelI
 NuclearModelI ()
 
 NuclearModelI (std::string name)
 
 NuclearModelI (std::string name, std::string config)
 
const stringFermiMomentumTableName () const
 
const genie::FermiMomentumTableFermiMomentumTable () const
 
- Protected Member Functions inherited from genie::Algorithm
 Algorithm ()
 
 Algorithm (string name)
 
 Algorithm (string name, string config)
 
void Initialize (void)
 
void DeleteConfig (void)
 
void DeleteSubstructure (void)
 
RegistryExtractLocalConfig (const Registry &in) const
 
RegistryExtractLowerConfig (const Registry &in, const string &alg_key) const
 Split an incoming configuration Registry into a block valid for the sub-algo identified by alg_key. More...
 
template<class T >
bool GetParam (const RgKey &name, T &p, bool is_top_call=true) const
 
template<class T >
bool GetParamDef (const RgKey &name, T &p, const T &def) const
 
template<class T >
int GetParamVect (const std::string &comm_name, std::vector< T > &v, bool is_top_call=true) const
 Handle to load vectors of parameters. More...
 
int GetParamVectKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
 
int AddTopRegistry (Registry *rp, bool owns=true)
 add registry with top priority, also update ownership More...
 
int AddLowRegistry (Registry *rp, bool owns=true)
 add registry with lowest priority, also update ownership More...
 
int MergeTopRegistry (const Registry &r)
 
int AddTopRegisties (const vector< Registry * > &rs, bool owns=false)
 Add registries with top priority, also udated Ownerships. More...
 

Private Member Functions

void CleanUp (void)
 

Private Attributes

bool fUseRFGRemovalE
 
bool fUseRFGMomentumCutoff
 
double fPCutOff
 
map< int, Spline * > fSFk
 All available spectral funcs integrated over removal energy. More...
 
map< int, Spline * > fSFw
 Average nucleon removal as a function of pF - computed from the spectral function. More...
 
map< int, double > fNucRmvE
 Removal energies as used in FG model. More...
 
map< int, double > fMaxProb
 Max SF(k) probability used in rejection method. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from genie::Algorithm
static string BuildParamVectKey (const std::string &comm_name, unsigned int i)
 
static string BuildParamVectSizeKey (const std::string &comm_name)
 
- Protected Attributes inherited from genie::NuclearModelI
double fCurrRemovalEnergy
 
TVector3 fCurrMomentum
 
FermiMoverInteractionType_t fFermiMoverInteractionType
 
- Protected Attributes inherited from genie::Algorithm
bool fAllowReconfig
 
bool fOwnsSubstruc
 true if it owns its substructure (sub-algs,...) More...
 
AlgId fID
 algorithm name and configuration set More...
 
vector< Registry * > fConfVect
 
vector< boolfOwnerships
 ownership for every registry in fConfVect More...
 
AlgStatus_t fStatus
 algorithm execution status More...
 
AlgMapfOwnedSubAlgMp
 local pool for owned sub-algs (taken out of the factory pool) More...
 

Detailed Description

Simpler approach to using spectral functions. A beta version. Implements the NuclearModelI interface.

Author
Costas Andreopoulos <constantinos.andreopoulos cern.ch> University of Liverpool & STFC Rutherford Appleton Laboratory

October 09, 2004

Copyright (c) 2003-2020, The GENIE Collaboration For the full text of the license visit http://copyright.genie-mc.org

Definition at line 35 of file SpectralFunc1d.h.

Constructor & Destructor Documentation

SpectralFunc1d::SpectralFunc1d ( )

Definition at line 40 of file SpectralFunc1d.cxx.

40  :
41 NuclearModelI("genie::SpectralFunc1d")
42 {
43 
44 }
SpectralFunc1d::SpectralFunc1d ( string  config)

Definition at line 46 of file SpectralFunc1d.cxx.

46  :
47 NuclearModelI("genie::SpectralFunc1d", config)
48 {
49 
50 }
static Config * config
Definition: config.cpp:1054
SpectralFunc1d::~SpectralFunc1d ( )
virtual

Definition at line 52 of file SpectralFunc1d.cxx.

53 {
54  this->CleanUp();
55 }

Member Function Documentation

void SpectralFunc1d::CleanUp ( void  )
private

Definition at line 238 of file SpectralFunc1d.cxx.

239 {
241 
242  for(spliter = fSFk.begin(); spliter != fSFk.end(); ++spliter) {
243  Spline * spl = spliter->second;
244  if(spl) delete spl;
245  }
246  for(spliter = fSFw.begin(); spliter != fSFw.end(); ++spliter) {
247  Spline * spl = spliter->second;
248  if(spl) delete spl;
249  }
250  fSFk.clear();
251  fSFw.clear();
252  fNucRmvE.clear();
253  fMaxProb.clear();
254 }
intermediate_table::iterator iterator
A numeric analysis tool class for interpolating 1-D functions.
Definition: Spline.h:46
map< int, double > fNucRmvE
Removal energies as used in FG model.
map< int, Spline * > fSFk
All available spectral funcs integrated over removal energy.
map< int, double > fMaxProb
Max SF(k) probability used in rejection method.
map< int, Spline * > fSFw
Average nucleon removal as a function of pF - computed from the spectral function.
void SpectralFunc1d::Configure ( const Registry config)
virtual

Configure the algorithm with an external registry The registry is merged with the top level registry if it is owned, Otherwise a copy of it is added with the highest priority

Reimplemented from genie::Algorithm.

Definition at line 145 of file SpectralFunc1d.cxx.

146 {
147  Algorithm::Configure(config);
148  this->LoadConfig();
149 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void SpectralFunc1d::Configure ( string  config)
virtual

Configure the algorithm from the AlgoConfigPool based on param_set string given in input An algorithm contains a vector of registries coming from different xml configuration files, which are loaded according a very precise prioriy This methods will load a number registries in order of priority: 1) "Tunable" parameter set from CommonParametes. This is loaded with the highest prioriry and it is designed to be used for tuning procedure Usage not expected from the user. 2) For every string defined in "CommonParame" the corresponding parameter set will be loaded from CommonParameter.xml 3) parameter set specified by the config string and defined in the xml file of the algorithm 4) if config is not "Default" also the Default parameter set from the same xml file will be loaded Effectively this avoids the repetion of a parameter when it is not changed in the requested configuration

Reimplemented from genie::Algorithm.

Definition at line 151 of file SpectralFunc1d.cxx.

152 {
153  Algorithm::Configure(param_set);
154  this->LoadConfig();
155 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
bool SpectralFunc1d::GenerateNucleon ( const Target t) const
virtual

Implements genie::NuclearModelI.

Definition at line 57 of file SpectralFunc1d.cxx.

58 {
60  int Z = target.Z();
61 
64 
65  // Select fermi momentum from the integrated (over removal energies) s/f.
66  //
67  spl_it = fSFk.find(Z);
68  dbl_it = fMaxProb.find(Z);
69  if(spl_it == fSFk.end() || dbl_it == fMaxProb.end()) {
70  fCurrRemovalEnergy = 0.;
71  fCurrMomentum.SetXYZ(0.,0.,0.);
72  return false;
73  }
74 
75  double prob_max = dbl_it->second;
76  LOG("SpectralFunc1", pDEBUG) << "Max probability = " << prob_max;
77 
78  double p = 0;
79  unsigned int niter = 0;
80  while(1) {
81  if(niter > kRjMaxIterations) {
82  LOG("SpectralFunc1", pWARN)
83  << "Couldn't generate a hit nucleon after " << niter << " iterations";
84  return false;
85  }
86  niter++;
87 
88  if(fUseRFGMomentumCutoff) p = fPCutOff * rnd->RndGen().Rndm();
89  else p = rnd->RndGen().Rndm();
90 
91  double prob = spl_it->second->Evaluate(p);
92  double probg = prob_max * rnd->RndGen().Rndm();
93  LOG("SpectralFunc1", pDEBUG) << "Trying p = " << p << " / prob = " << prob;
94 
95  bool accept = (probg<prob);
96  if(accept) break;
97  }
98 
99  LOG("SpectralFunc1", pINFO) << "|p,nucleon| = " << p;
100 
101  double costheta = -1. + 2. * rnd->RndGen().Rndm();
102  double sintheta = TMath::Sqrt(1.-costheta*costheta);
103  double fi = 2 * kPi * rnd->RndGen().Rndm();
104  double cosfi = TMath::Cos(fi);
105  double sinfi = TMath::Sin(fi);
106 
107  double px = p*sintheta*cosfi;
108  double py = p*sintheta*sinfi;
109  double pz = p*costheta;
110 
111  fCurrMomentum.SetXYZ(px,py,pz);
112 
113  // Set removal energy
114  // Do it either in the same way as in the FG model or by using the average
115  // removal energy for the seleced pF as calculated from the s/f itself
116  //
117  if(fUseRFGRemovalE) {
118  dbl_it = fNucRmvE.find(Z);
119  if(dbl_it != fNucRmvE.end()) fCurrRemovalEnergy = dbl_it->second;
121  } else {
122  spl_it = fSFw.find(Z);
123  if(spl_it==fSFw.end()) {
124  fCurrRemovalEnergy = 0.;
125  fCurrMomentum.SetXYZ(0.,0.,0.);
126  return false;
127  } else fCurrRemovalEnergy = spl_it->second->Evaluate(p);
128  }
129 
130  return true;
131 }
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
map< int, double > fNucRmvE
Removal energies as used in FG model.
map< int, Spline * > fSFk
All available spectral funcs integrated over removal energy.
intermediate_table::const_iterator const_iterator
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
double BindEnergyPerNucleon(const Target &target)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
p
Definition: test.py:223
#define pINFO
Definition: Messenger.h:62
#define pWARN
Definition: Messenger.h:60
map< int, double > fMaxProb
Max SF(k) probability used in rejection method.
TRandom3 & RndGen(void) const
rnd number generator for generic usage
Definition: RandomGen.h:80
static const unsigned int kRjMaxIterations
Definition: Controls.h:26
static const double kPi
Definition: Constants.h:37
map< int, Spline * > fSFw
Average nucleon removal as a function of pF - computed from the spectral function.
#define pDEBUG
Definition: Messenger.h:63
void SpectralFunc1d::LoadConfig ( void  )
protectedvirtual

Reimplemented from genie::NuclearModelI.

Definition at line 157 of file SpectralFunc1d.cxx.

158 {
159 
161 
162  LOG("SpectralFunc1", pDEBUG) << "Loading coonfiguration for SpectralFunc1d";
163 
164  this->CleanUp();
165 
166  // Load spectral function data.
167  // Hopefully analytical expressions will be available soon.
168  // Currently I have spectral functions for C12 and Fe56 only.
169  //
170  string data_dir =
171  string(gSystem->Getenv("GENIE")) + string("/data/evgen/nucl/spectral_functions/");
172 
173  string c12_sf1dk_file = data_dir + "benhar-sf1dk-12c.data";
174  string fe56_sf1dk_file = data_dir + "benhar-sf1dk-56fe.data";
175  string c12_sf1dw_file = data_dir + "benhar-sf1dw-12c.data";
176  string fe56_sf1dw_file = data_dir + "benhar-sf1dw-56fe.data";
177 
178  Spline * spl = 0;
179 
180  spl = new Spline(c12_sf1dk_file);
181  fSFk.insert(map<int, Spline*>::value_type(6,spl));
182  spl = new Spline(fe56_sf1dk_file);
183  fSFk.insert(map<int, Spline*>::value_type(26,spl));
184 
185  spl = new Spline(c12_sf1dw_file);
186  fSFw.insert(map<int, Spline*>::value_type(6,spl));
187  spl = new Spline(fe56_sf1dw_file);
188  fSFw.insert(map<int, Spline*>::value_type(26,spl));
189 
190  // scan for max.
192  int n = 100;
193  double pmin = 0.000;
194  double dp = 0.010;
195  for(spliter = fSFk.begin(); spliter != fSFk.end(); ++spliter) {
196  double prob_max = 0;
197  int Z = spliter->first;
198  spl = spliter->second;
199  for(int i=0; i<n; i++) {
200  double p = pmin + i*dp;
201  prob_max = TMath::Max(prob_max, spl->Evaluate(p));
202  }
203  fMaxProb.insert(map<int,double>::value_type(Z,prob_max));
204  }
205 
206  // Check whether to use the same removal energies as in the FG model or
207  // to use the average removal energy for the selected fermi momentum
208  // (computed from the spectral function itself)
209  GetParam( "UseRFGRemovalE", fUseRFGRemovalE ) ;
210 
211  // Check whether to use the same momentum cutoff as in the FG model
212  GetParam("UseRFGMomentumCutoff", fUseRFGMomentumCutoff ) ;
213 
214  //Get the momentum cutoff
215  GetParam( "RFG-MomentumCutOff", fPCutOff ) ;
216 
217  // Removal energies as used in the FG model
218  // Load removal energy for specific nuclei from either the algorithm's
219  // configuration file or the UserPhysicsOptions file.
220  // If none is used use Wapstra's semi-empirical formula.
221  for(int Z=1; Z<140; Z++) {
222  for(int A=Z; A<3*Z; A++) {
223  ostringstream key;
224  int pdgc = pdg::IonPdgCode(A,Z);
225  key << "RFG-NucRemovalE@Pdg=" << pdgc;
226  RgKey rgkey = key.str();
227  double eb ;
228  if ( GetParam( rgkey, eb, false ) ) {
229  eb = TMath::Max(eb, 0.);
230  LOG("BodekRitchie", pNOTICE)
231  << "Nucleus: " << pdgc << " -> using Eb = " << eb << " GeV";
232  fNucRmvE.insert(map<int,double>::value_type(Z,eb));
233  }
234  }
235  }
236 }
std::string string
Definition: nybbler.cc:12
A numeric analysis tool class for interpolating 1-D functions.
Definition: Spline.h:46
map< int, double > fNucRmvE
Removal energies as used in FG model.
map< int, Spline * > fSFk
All available spectral funcs integrated over removal energy.
intermediate_table::const_iterator const_iterator
double Evaluate(double x) const
Definition: Spline.cxx:361
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
def key(type, name=None)
Definition: graph.py:13
std::void_t< T > n
p
Definition: test.py:223
virtual void LoadConfig()
string RgKey
map< int, double > fMaxProb
Max SF(k) probability used in rejection method.
int IonPdgCode(int A, int Z)
Definition: PDGUtils.cxx:68
#define A
Definition: memgrp.cpp:38
#define pNOTICE
Definition: Messenger.h:61
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
map< int, Spline * > fSFw
Average nucleon removal as a function of pF - computed from the spectral function.
#define pDEBUG
Definition: Messenger.h:63
NuclearModel_t genie::SpectralFunc1d::ModelType ( const Target ) const
inlinevirtual

is not really a spectral func model, just a FG model with different momentum distribution

Implements genie::NuclearModelI.

Definition at line 48 of file SpectralFunc1d.h.

49  {
50  return kNucmFermiGas; /// is not really a spectral func model, just a FG model with different momentum distribution
51  }
double SpectralFunc1d::Prob ( double  p,
double  w,
const Target t 
) const
virtual

Implements genie::NuclearModelI.

Definition at line 133 of file SpectralFunc1d.cxx.

135 {
136  if(fUseRFGMomentumCutoff) { if(p > fPCutOff) return 0; }
137 
138  int Z = target.Z();
139  map<int, Spline*>::const_iterator spl_it = fSFk.find(Z);
140 
141  if(spl_it == fSFk.end()) return 0;
142  else return TMath::Max(0.,spl_it->second->Evaluate(p));
143 }
map< int, Spline * > fSFk
All available spectral funcs integrated over removal energy.
intermediate_table::const_iterator const_iterator
p
Definition: test.py:223

Member Data Documentation

map<int, double> genie::SpectralFunc1d::fMaxProb
private

Max SF(k) probability used in rejection method.

Definition at line 74 of file SpectralFunc1d.h.

map<int, double> genie::SpectralFunc1d::fNucRmvE
private

Removal energies as used in FG model.

Definition at line 73 of file SpectralFunc1d.h.

double genie::SpectralFunc1d::fPCutOff
private

Definition at line 70 of file SpectralFunc1d.h.

map<int, Spline *> genie::SpectralFunc1d::fSFk
private

All available spectral funcs integrated over removal energy.

Definition at line 71 of file SpectralFunc1d.h.

map<int, Spline *> genie::SpectralFunc1d::fSFw
private

Average nucleon removal as a function of pF - computed from the spectral function.

Definition at line 72 of file SpectralFunc1d.h.

bool genie::SpectralFunc1d::fUseRFGMomentumCutoff
private

Definition at line 69 of file SpectralFunc1d.h.

bool genie::SpectralFunc1d::fUseRFGRemovalE
private

Definition at line 68 of file SpectralFunc1d.h.


The documentation for this class was generated from the following files: