GENIEGenerator
Loading...
Searching...
No Matches
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:
[legend]
Collaboration diagram for genie::SpectralFunc:
[legend]

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)
virtual bool GenerateNucleon (const Target &tgt, double hitNucleonRadius) const
virtual double Prob (double p, double w, const Target &tgt, double hitNucleonRadius) const
Public Member Functions inherited from genie::NuclearModelI
virtual ~NuclearModelI ()
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.
virtual AlgStatus_t GetStatus (void) const
 Get algorithm status.
virtual bool AllowReconfig (void) const
virtual AlgCmp_t Compare (const Algorithm *alg) const
 Compare with input algorithm.
virtual void SetId (const AlgId &id)
 Set algorithm ID.
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.

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 string & FermiMomentumTableName () 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.
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.
int GetParamVectKeys (const std::string &comm_name, std::vector< RgKey > &k, bool is_top_call=true) const
template<class T>
int GetParamMat (const std::string &comm_name, TMatrixT< T > &mat, bool is_top_call=true) const
 Handle to load matrix of parameters.
template<class T>
int GetParamMatSym (const std::string &comm_name, TMatrixTSym< T > &mat, bool is_top_call=true) const
int GetParamMatKeys (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
int AddLowRegistry (Registry *rp, bool owns=true)
 add registry with lowest priority, also update ownership
int MergeTopRegistry (const Registry &r)
int AddTopRegisties (const vector< Registry * > &rs, bool owns=false)
 Add registries with top priority, also udated Ownerships.

Private Member Functions

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

Private Attributes

TGraph2D * fSfFe56
 Benhar's Fe56 SF.
TGraph2D * fSfC12
 Benhar's C12 SF.

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)
static string BuildParamMatKey (const std::string &comm_name, unsigned int i, unsigned int j)
static string BuildParamMatRowSizeKey (const std::string &comm_name)
static string BuildParamMatColSizeKey (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,...)
AlgId fID
 algorithm name and configuration set
vector< Registry * > fConfVect
vector< bool > fOwnerships
 ownership for every registry in fConfVect
AlgStatus_t fStatus
 algorithm execution status
AlgMapfOwnedSubAlgMp
 local pool for owned sub-algs (taken out of the factory pool)

Detailed Description

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

Author
Costas Andreopoulos <c.andreopoulos \at cern.ch> University of Liverpool
Created:\n May 07, 2004
License:\n Copyright (c) 2003-2025, 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() [1/2]

SpectralFunc::SpectralFunc ( )

Definition at line 35 of file SpectralFunc.cxx.

35 :
36NuclearModelI("genie::SpectralFunc")
37{
38 fSfFe56 = 0;
39 fSfC12 = 0;
40}
TGraph2D * fSfFe56
Benhar's Fe56 SF.
TGraph2D * fSfC12
Benhar's C12 SF.

References fSfC12, fSfFe56, and genie::NuclearModelI::NuclearModelI().

◆ SpectralFunc() [2/2]

SpectralFunc::SpectralFunc ( string config)

Definition at line 42 of file SpectralFunc.cxx.

42 :
43NuclearModelI("genie::SpectralFunc", config)
44{
45 fSfFe56 = 0;
46 fSfC12 = 0;
47}

References fSfC12, fSfFe56, and genie::NuclearModelI::NuclearModelI().

◆ ~SpectralFunc()

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

◆ Configure() [1/2]

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

References genie::Algorithm::Configure(), and LoadConfig().

◆ Configure() [2/2]

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}

References genie::Algorithm::Configure(), and LoadConfig().

◆ Convert2Graph()

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}
const double e
static constexpr double MeV
Definition Units.h:129
static constexpr double GeV
Definition Units.h:28

References e, genie::units::GeV, and genie::units::MeV.

Referenced by LoadConfig().

◆ GenerateNucleon() [1/2]

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) {
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
78 RandomGen * rnd = RandomGen::Instance();
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
116 fCurrMomentum.SetXYZ(kx,ky,kz);
117
118 return true;
119 }
120 return false;
121}
#define pINFO
Definition Messenger.h:62
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Definition Messenger.h:96
#define pWARN
Definition Messenger.h:60
static RandomGen * Instance()
Access instance.
Definition RandomGen.cxx:74
TRandom3 & RndGen(void) const
rnd number generator for generic usage
Definition RandomGen.h:80
TGraph2D * SelectSpectralFunction(const Target &target) const
double Prob(double p, double w, const Target &t) const
static const unsigned int kRjMaxIterations
Definition Controls.h:26

References genie::NuclearModelI::fCurrMomentum, genie::NuclearModelI::fCurrRemovalEnergy, genie::RandomGen::Instance(), genie::constants::kPi, genie::controls::kRjMaxIterations, LOG, pINFO, Prob(), pWARN, genie::RandomGen::RndGen(), and SelectSpectralFunction().

◆ GenerateNucleon() [2/2]

bool NuclearModelI::GenerateNucleon ( const Target & tgt,
double hitNucleonRadius ) const
virtual

Reimplemented from genie::NuclearModelI.

Definition at line 52 of file NuclearModelI.cxx.

42 {
43 return GenerateNucleon(tgt);
44 }
bool GenerateNucleon(const Target &t) const

◆ LoadConfig()

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}
#define pDEBUG
Definition Messenger.h:63
virtual void LoadConfig()
TGraph2D * Convert2Graph(TNtupleD &data) const

References Convert2Graph(), fSfC12, fSfFe56, genie::NuclearModelI::LoadConfig(), LOG, and pDEBUG.

Referenced by Configure(), and Configure().

◆ ModelType()

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 }
@ kNucmSpectralFunc

References genie::kNucmSpectralFunc.

◆ Prob() [1/2]

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}

References SelectSpectralFunction().

Referenced by GenerateNucleon().

◆ Prob() [2/2]

double NuclearModelI::Prob ( double p,
double w,
const Target & tgt,
double hitNucleonRadius ) const
virtual

Reimplemented from genie::NuclearModelI.

Definition at line 56 of file NuclearModelI.cxx.

48 {
49 return Prob(p,w,tgt);
50 }

◆ SelectSpectralFunction()

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}
#define pERROR
Definition Messenger.h:59
const int kPdgTgtFe56
Definition PDGCodes.h:205
const int kPdgTgtC12
Definition PDGCodes.h:202

References fSfC12, fSfFe56, genie::kPdgTgtC12, genie::kPdgTgtFe56, LOG, genie::Target::Pdg(), and pERROR.

Referenced by GenerateNucleon(), and Prob().

Member Data Documentation

◆ fSfC12

TGraph2D* genie::SpectralFunc::fSfC12
private

Benhar's C12 SF.

Definition at line 63 of file SpectralFunc.h.

Referenced by LoadConfig(), SelectSpectralFunction(), SpectralFunc(), and SpectralFunc().

◆ fSfFe56

TGraph2D* genie::SpectralFunc::fSfFe56
private

Benhar's Fe56 SF.

Definition at line 62 of file SpectralFunc.h.

Referenced by LoadConfig(), SelectSpectralFunction(), SpectralFunc(), and SpectralFunc().


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