LocalFGM.cxx
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*
3  Copyright (c) 2003-2020, The GENIE Collaboration
4  For the full text of the license visit http://copyright.genie-mc.org
5 
6 
7  Author: Joe Johnston, University of Pittsburgh (Advisor Steven Dytman)
8 
9  For the class documentation see the corresponding header file.
10 
11 */
12 //____________________________________________________________________________
13 
14 #include <sstream>
15 #include <cstdlib>
16 #include <TMath.h>
17 
19 #include "Framework/Conventions/GBuild.h"
28 
29 using std::ostringstream;
30 using namespace genie;
31 using namespace genie::constants;
32 using namespace genie::utils;
33 
34 //____________________________________________________________________________
36 NuclearModelI("genie::LocalFGM")
37 {
38 
39 }
40 //____________________________________________________________________________
42 NuclearModelI("genie::LocalFGM", config)
43 {
44 
45 }
46 //____________________________________________________________________________
48 {
49 
50 }
51 //____________________________________________________________________________
53  double hitNucleonRadius) const
54 {
55  assert(target.HitNucIsSet());
56 
58  fCurrMomentum.SetXYZ(0,0,0);
59 
60  //-- set fermi momentum vector
61  //
62  TH1D * prob = this->ProbDistro(target,hitNucleonRadius);
63  if(!prob) {
64  LOG("LocalFGM", pNOTICE)
65  << "Null nucleon momentum probability distribution";
66  exit(1);
67  }
68  double p = prob->GetRandom();
69  delete prob;
70  LOG("LocalFGM", pINFO) << "|p,nucleon| = " << p;
71 
73 
74  double costheta = -1. + 2. * rnd->RndGen().Rndm();
75  double sintheta = TMath::Sqrt(1.-costheta*costheta);
76  double fi = 2 * kPi * rnd->RndGen().Rndm();
77  double cosfi = TMath::Cos(fi);
78  double sinfi = TMath::Sin(fi);
79 
80  double px = p*sintheta*cosfi;
81  double py = p*sintheta*sinfi;
82  double pz = p*costheta;
83 
84  fCurrMomentum.SetXYZ(px,py,pz);
85 
86  //-- set removal energy
87  //
88  int Z = target.Z();
90  if(it != fNucRmvE.end()) fCurrRemovalEnergy = it->second;
91  else fCurrRemovalEnergy = nuclear::BindEnergyPerNucleon(target);
92 
93  return true;
94 }
95 //____________________________________________________________________________
96 double LocalFGM::Prob(double p, double w, const Target & target,
97  double hitNucleonRadius) const
98 {
99  if(w<0) {
100  TH1D * prob = this->ProbDistro(target, hitNucleonRadius);
101  int bin = prob->FindBin(p);
102  double y = prob->GetBinContent(bin);
103  double dx = prob->GetBinWidth(bin);
104  double pr = y*dx;
105  delete prob;
106  return pr;
107  }
108  return 1;
109 }
110 //____________________________________________________________________________
111 // *** The TH1D object must be deleted after it is used ***
112 TH1D * LocalFGM::ProbDistro(const Target & target, double r) const
113 {
114  LOG("LocalFGM", pNOTICE)
115  << "Computing P = f(p_nucleon) for: " << target.AsString()
116  << ", Nucleon Radius = " << r;
117  LOG("LocalFGM", pNOTICE)
118  << ", P(max) = " << fPMax;
119 
120  assert(target.HitNucIsSet());
121 
122  //-- get information for the nuclear target
123  int nucleon_pdgc = target.HitNucPdg();
124  assert(pdg::IsProton(nucleon_pdgc) || pdg::IsNeutron(nucleon_pdgc));
125 
126  // bool is_p = pdg::IsProton(nucleon_pdgc);
127  // double numNuc = (is_p) ? (double)target.Z():(double)target.N();
128 
129  // Calculate Fermi Momentum using Local FG equations
130  double KF = LocalFermiMomentum( target, nucleon_pdgc, r ) ;
131 
132  LOG("LocalFGM",pNOTICE) << "KF = " << KF;
133 
134  double a = 2.0;
135  double C = 4. * kPi * TMath::Power(KF,3) / 3.;
136 
137  // Do not include nucleon correlation tail
138  //double R = 1. / (1.- KF/4.);
139 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
140  LOG("LocalFGM", pDEBUG) << "a = " << a;
141  LOG("LocalFGM", pDEBUG) << "C = " << C;
142  //LOG("LocalFGM", pDEBUG) << "R = " << R;
143 #endif
144 
145  //-- create the probability distribution
146 
147  int npbins = (int) (1000*fPMax);
148  TH1D * prob = new TH1D("", "", npbins, 0, fPMax);
149  prob->SetDirectory(0);
150 
151  double dp = fPMax / (npbins-1);
152 // double iC = (C>0) ? 1./C : 0.; // unused variables
153 // double kfa_pi_2 = TMath::Power(KF*a/kPi,2); // unused variables
154 
155  for(int i = 0; i < npbins; i++) {
156  double p = i * dp;
157  double p2 = TMath::Power(p,2);
158 
159  // use expression with fSRC_Fraction to allow the possibility of
160  // using the Correlated Fermi Gas Model with a high momentum tail
161 
162  // calculate |phi(p)|^2
163  double phi2 = 0;
164  if (p <= KF){
165  phi2 = (1./(4*kPi)) * (3/TMath::Power(KF,3.)) * ( 1 - fSRC_Fraction );
166  }else if( p > KF && p < fPCutOff ){
167  phi2 = (1./(4*kPi)) * ( fSRC_Fraction / (1./KF - 1./fPCutOff) ) / TMath::Power(p,4.);
168  }
169 
170  // calculate probability density : dProbability/dp
171  double dP_dp = 4*kPi * p2 * phi2;
172 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__
173  LOG("LocalFGM", pDEBUG) << "p = " << p << ", dP/dp = " << dP_dp;
174 #endif
175  prob->Fill(p, dP_dp);
176  }
177 
178  //-- normalize the probability distribution
179  prob->Scale( 1.0 / prob->Integral("width") );
180 
181  return prob;
182 }
183 //____________________________________________________________________________
184 double LocalFGM::LocalFermiMomentum( const Target & t, int nucleon_pdg, double radius ) const {
185 
186  assert(pdg::IsProton(nucleon_pdg) || pdg::IsNeutron(nucleon_pdg)) ;
187 
188  bool is_p = pdg::IsProton(nucleon_pdg);
189  double numNuc = (double) ( (is_p) ? t.Z() : t.N() );
190 
191  // double hbarc = kLightSpeed*kPlankConstant/genie::units::fermi;
192 
193  double kF = TMath::Power( 3*kPi2*numNuc*genie::utils::nuclear::Density( radius, t.A() ),
194  1.0/3.0 )
196 
197  return kF ;
198 }
199 //____________________________________________________________________________
201 {
202  Algorithm::Configure(config);
203  this->LoadConfig();
204 }
205 //____________________________________________________________________________
206 void LocalFGM::Configure(string param_set)
207 {
208  Algorithm::Configure(param_set);
209  this->LoadConfig();
210 }
211 //____________________________________________________________________________
213 {
214 
216 
217  this->GetParamDef("LFG-MomentumMax", fPMax, 1.0);
218  assert(fPMax > 0);
219 
220  this->GetParamDef("SRC-Fraction", fSRC_Fraction, 0.0);
221  this->GetParam("LFG-MomentumCutOff", fPCutOff);
222 
223  if (fPCutOff > fPMax) {
224  LOG("LocalFGM", pFATAL) << "Momentum CutOff greater than Momentum Max";
225  exit(78);
226  }
227 
228 
229  // Load removal energy for specific nuclei from either the algorithm's
230  // configuration file or the UserPhysicsOptions file.
231  // If none is used use Wapstra's semi-empirical formula.
232  //
233 
234  for(int Z=1; Z<140; Z++) {
235  for(int A=Z; A<3*Z; A++) {
236  ostringstream key ;
237  int pdgc = pdg::IonPdgCode(A,Z);
238  key << "RFG-NucRemovalE@Pdg=" << pdgc;
239  RgKey rgkey = key.str();
240  double eb ;
241  if ( GetParam( rgkey, eb, false ) ) {
242  eb = TMath::Max(eb, 0.);
243  LOG("LocalFGM", pINFO) << "Nucleus: " << pdgc << " -> using Eb = " << eb << " GeV";
244  fNucRmvE.insert(map<int,double>::value_type(Z,eb));
245  }
246  }
247  }
248 }
249 //____________________________________________________________________________
Basic constants.
string AsString(void) const
Definition: Target.cxx:383
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
static RandomGen * Instance()
Access instance.
Definition: RandomGen.cxx:71
int HitNucPdg(void) const
Definition: Target.cxx:304
double Density(double r, int A, double ring=0.)
int A(void) const
Definition: Target.h:70
#define pFATAL
Definition: Messenger.h:56
double Prob(double p, double w, const Target &t, double hitNucleonRadius) const
Definition: LocalFGM.cxx:96
Pure abstract base class. Defines the NuclearModelI interface to be implemented by any physics model ...
Definition: NuclearModelI.h:46
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
bool IsNeutron(int pdgc)
Definition: PDGUtils.cxx:338
double BindEnergyPerNucleon(const Target &target)
bool IsProton(int pdgc)
Definition: PDGUtils.cxx:333
map< int, double > fNucRmvE
Definition: LocalFGM.h:75
#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
static Config * config
Definition: config.cpp:1054
void LoadConfig(void)
Definition: LocalFGM.cxx:212
const double a
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
double fSRC_Fraction
Definition: LocalFGM.h:80
double fPCutOff
Definition: LocalFGM.h:81
bool GenerateNucleon(const Target &t, double hitNucleonRadius) const
Definition: LocalFGM.cxx:52
p
Definition: test.py:223
int Z(void) const
Definition: Target.h:68
#define pINFO
Definition: Messenger.h:62
double fPMax
Definition: LocalFGM.h:77
virtual void LoadConfig()
TH1D * ProbDistro(const Target &t, double r) const
Definition: LocalFGM.cxx:112
int N(void) const
Definition: Target.h:69
bool HitNucIsSet(void) const
Definition: Target.cxx:283
string RgKey
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
virtual ~LocalFGM()
Definition: LocalFGM.cxx:47
TRandom3 & RndGen(void) const
rnd number generator for generic usage
Definition: RandomGen.h:80
int IonPdgCode(int A, int Z)
Definition: PDGUtils.cxx:68
QTextStream & bin(QTextStream &s)
#define A
Definition: memgrp.cpp:38
virtual double LocalFermiMomentum(const Target &t, int nucleon_pdg, double radius) const
Definition: LocalFGM.cxx:184
static constexpr double fermi
Definition: Units.h:55
void Configure(const Registry &config)
Definition: LocalFGM.cxx:200
#define pNOTICE
Definition: Messenger.h:61
bool GetParamDef(const RgKey &name, T &p, const T &def) const
bool GetParam(const RgKey &name, T &p, bool is_top_call=true) const
static const double kPi
Definition: Constants.h:37
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
static const double kPi2
Definition: Constants.h:38
Root of GENIE utility namespaces.
#define pDEBUG
Definition: Messenger.h:63