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

A realistic spectral function - based nuclear model. Is a concrete implementation of the NuclearModelI interface. More...

#include <SpectralFunc.h>

Inheritance diagram for genie::SpectralFunc:
genie::NuclearModelI genie::Algorithm

Public Member Functions

 SpectralFunc ()
 
 SpectralFunc (string config)
 
virtual ~SpectralFunc ()
 
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 config)
 
- 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

TGraph2D * Convert2Graph (TNtupleD &data) const
 
TGraph2D * SelectSpectralFunction (const Target &target) const
 

Private Attributes

TGraph2D * fSfFe56
 Benhar's Fe56 SF. More...
 
TGraph2D * fSfC12
 Benhar's C12 SF. 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

A realistic spectral function - based nuclear model. Is a concrete implementation of the NuclearModelI interface.

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

May 07, 2004

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

Definition at line 31 of file SpectralFunc.h.

Constructor & Destructor Documentation

SpectralFunc::SpectralFunc ( )

Definition at line 35 of file SpectralFunc.cxx.

35  :
36 NuclearModelI("genie::SpectralFunc")
37 {
38  fSfFe56 = 0;
39  fSfC12 = 0;
40 }
TGraph2D * fSfFe56
Benhar&#39;s Fe56 SF.
Definition: SpectralFunc.h:62
TGraph2D * fSfC12
Benhar&#39;s C12 SF.
Definition: SpectralFunc.h:63
SpectralFunc::SpectralFunc ( string  config)

Definition at line 42 of file SpectralFunc.cxx.

42  :
43 NuclearModelI("genie::SpectralFunc", config)
44 {
45  fSfFe56 = 0;
46  fSfC12 = 0;
47 }
TGraph2D * fSfFe56
Benhar&#39;s Fe56 SF.
Definition: SpectralFunc.h:62
static Config * config
Definition: config.cpp:1054
TGraph2D * fSfC12
Benhar&#39;s C12 SF.
Definition: SpectralFunc.h:63
SpectralFunc::~SpectralFunc ( )
virtual

Definition at line 49 of file SpectralFunc.cxx.

50 {
51 //if (fSfFe56) delete fSfFe56;
52 //if (fSfC12 ) delete fSfC12;
53 }

Member Function Documentation

void SpectralFunc::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 132 of file SpectralFunc.cxx.

133 {
134  Algorithm::Configure(config);
135  this->LoadConfig();
136 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
void SpectralFunc::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 138 of file SpectralFunc.cxx.

139 {
140  Algorithm::Configure(param_set);
141  this->LoadConfig();
142 }
virtual void Configure(const Registry &config)
Definition: Algorithm.cxx:62
TGraph2D * SpectralFunc::Convert2Graph ( TNtupleD &  data) const
private

Definition at line 176 of file SpectralFunc.cxx.

177 {
178  int np = sfdata.GetEntries();
179  TGraph2D * sfgraph = new TGraph2D(np);
180 
181  sfdata.Draw("k:e:prob","","GOFF");
182  assert(np==sfdata.GetSelectedRows());
183  double * k = sfdata.GetV1();
184  double * e = sfdata.GetV2();
185  double * p = sfdata.GetV3();
186 
187  for(int i=0; i<np; i++) {
188  double ki = k[i] * (units::MeV/units::GeV); // momentum
189  double ei = e[i] * (units::MeV/units::GeV); // removal energy
190  double pi = p[i] * TMath::Power(ki,2); // probabillity
191  sfgraph->SetPoint(i, ki,ei,pi);
192  }
193  return sfgraph;
194 }
static constexpr double MeV
Definition: Units.h:129
const double e
static constexpr double GeV
Definition: Units.h:28
p
Definition: test.py:223
float pi
Definition: units.py:11
bool SpectralFunc::GenerateNucleon ( const Target t) const
virtual

Implements genie::NuclearModelI.

Definition at line 55 of file SpectralFunc.cxx.

56 {
57  TGraph2D * sf = this->SelectSpectralFunction(target);
58 
59  if(!sf) {
60  fCurrRemovalEnergy = 0.;
61  fCurrMomentum.SetXYZ(0.,0.,0.);
62  return false;
63  }
64 
65  double kmin = sf->GetXmin(); // momentum range
66  double kmax = sf->GetXmax();
67  double wmin = sf->GetYmin(); // removal energy range
68  double wmax = sf->GetYmax();
69  double probmax = sf->GetZmax(); // maximum probability
70  probmax *= 1.1;
71 
72  double dk = kmax - kmin;
73  double dw = wmax - wmin;
74 
75  LOG("SpectralFunc", pINFO) << "Momentum range = [" << kmin << ", " << kmax << "]";
76  LOG("SpectralFunc", pINFO) << "Rmv energy range = [" << wmin << ", " << wmax << "]";
77 
79 
80  unsigned int niter = 0;
81  while(1) {
82  if(niter > kRjMaxIterations) {
83  LOG("SpectralFunc", pWARN)
84  << "Couldn't generate a hit nucleon after " << niter << " iterations";
85  return false;
86  }
87  niter++;
88 
89  // random pair
90  double kc = kmin + dk * rnd->RndGen().Rndm();
91  double wc = wmin + dw * rnd->RndGen().Rndm();
92  LOG("SpectralFunc", pINFO) << "Trying p = " << kc << ", w = " << wc;
93 
94  // accept/reject
95  double prob = this->Prob(kc,wc, target);
96  double probg = probmax * rnd->RndGen().Rndm();
97  bool accept = (probg < prob);
98  if(!accept) continue;
99 
100  LOG("SpectralFunc", pINFO) << "|p,nucleon| = " << kc;
101  LOG("SpectralFunc", pINFO) << "|w,nucleon| = " << wc;
102 
103  // generate momentum components
104  double costheta = -1. + 2. * rnd->RndGen().Rndm();
105  double sintheta = TMath::Sqrt(1.-costheta*costheta);
106  double fi = 2 * kPi * rnd->RndGen().Rndm();
107  double cosfi = TMath::Cos(fi);
108  double sinfi = TMath::Sin(fi);
109 
110  double kx = kc*sintheta*cosfi;
111  double ky = kc*sintheta*sinfi;
112  double kz = kc*costheta;
113 
114  // set generated values
115  fCurrRemovalEnergy = wc;
116  fCurrMomentum.SetXYZ(kx,ky,kz);
117 
118  return true;
119  }
120  return false;
121 }
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
double Prob(double p, double w, const Target &t) const
A singleton holding random number generator classes. All random number generation in GENIE should tak...
Definition: RandomGen.h:29
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
constexpr double kc
Speed of light in vacuum in LArSoft units [cm/ns].
#define pINFO
Definition: Messenger.h:62
#define pWARN
Definition: Messenger.h:60
TRandom3 & RndGen(void) const
rnd number generator for generic usage
Definition: RandomGen.h:80
TGraph2D * SelectSpectralFunction(const Target &target) const
static const unsigned int kRjMaxIterations
Definition: Controls.h:26
static const double kPi
Definition: Constants.h:37
void SpectralFunc::LoadConfig ( void  )
protectedvirtual

Reimplemented from genie::NuclearModelI.

Definition at line 144 of file SpectralFunc.cxx.

145 {
146 
148 
149  LOG("SpectralFunc", pDEBUG) << "Loading Benhar et al. spectral functions";
150 
151  string data_dir =
152  string(gSystem->Getenv("GENIE")) +
153  string("/data/evgen/nucl/spectral_functions/");
154  string c12file = data_dir + "benhar-sf-12c.data";
155  string fe56file = data_dir + "benhar-sf-56fe.data";
156 
157  TNtupleD sfdata_fe56("sfdata_fe56","","k:e:prob");
158  TNtupleD sfdata_c12 ("sfdata_c12", "","k:e:prob");
159 
160  sfdata_fe56.ReadFile ( fe56file.c_str() );
161  sfdata_c12. ReadFile ( c12file.c_str () );
162 
163  LOG("SpectralFunc", pDEBUG) << "Loaded " << sfdata_fe56.GetEntries() << " Fe56 points";
164  LOG("SpectralFunc", pDEBUG) << "Loaded " << sfdata_c12.GetEntries() << " C12 points";
165 
166  if (fSfFe56) delete fSfFe56;
167  if (fSfC12 ) delete fSfC12;
168 
169  fSfFe56 = this->Convert2Graph(sfdata_fe56);
170  fSfC12 = this->Convert2Graph(sfdata_c12);
171 
172  fSfFe56->SetName("sf_fe56");
173  fSfC12 ->SetName("sf_c12");
174 }
TGraph2D * fSfFe56
Benhar&#39;s Fe56 SF.
Definition: SpectralFunc.h:62
std::string string
Definition: nybbler.cc:12
TGraph2D * Convert2Graph(TNtupleD &data) const
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
virtual void LoadConfig()
TGraph2D * fSfC12
Benhar&#39;s C12 SF.
Definition: SpectralFunc.h:63
#define pDEBUG
Definition: Messenger.h:63
NuclearModel_t genie::SpectralFunc::ModelType ( const Target ) const
inlinevirtual

Implements genie::NuclearModelI.

Definition at line 44 of file SpectralFunc.h.

45  {
46  return kNucmSpectralFunc;
47  }
double SpectralFunc::Prob ( double  p,
double  w,
const Target t 
) const
virtual

Implements genie::NuclearModelI.

Definition at line 123 of file SpectralFunc.cxx.

125 {
126  TGraph2D * sf = this->SelectSpectralFunction(target);
127  if(!sf) return 0;
128 
129  return sf->Interpolate(p,w);
130 }
p
Definition: test.py:223
TGraph2D * SelectSpectralFunction(const Target &target) const
TGraph2D * SpectralFunc::SelectSpectralFunction ( const Target target) const
private

Definition at line 196 of file SpectralFunc.cxx.

197 {
198  TGraph2D * sf = 0;
199  int pdgc = t.Pdg();
200 
201  if (pdgc == kPdgTgtC12) sf = fSfC12;
202  else if (pdgc == kPdgTgtFe56) sf = fSfFe56;
203  else {
204  LOG("SpectralFunc", pERROR)
205  << "** The spectral function for target " << pdgc << " isn't available";
206  }
207  if(!sf) {
208  LOG("SpectralFunc", pERROR) << "** Null spectral function";
209  }
210  return sf;
211 }
TGraph2D * fSfFe56
Benhar&#39;s Fe56 SF.
Definition: SpectralFunc.h:62
#define pERROR
Definition: Messenger.h:59
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
TGraph2D * fSfC12
Benhar&#39;s C12 SF.
Definition: SpectralFunc.h:63
const int kPdgTgtC12
Definition: PDGCodes.h:202
const int kPdgTgtFe56
Definition: PDGCodes.h:205

Member Data Documentation

TGraph2D* genie::SpectralFunc::fSfC12
private

Benhar's C12 SF.

Definition at line 63 of file SpectralFunc.h.

TGraph2D* genie::SpectralFunc::fSfFe56
private

Benhar's Fe56 SF.

Definition at line 62 of file SpectralFunc.h.


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