GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FermiMomentumTable.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 */
15 //____________________________________________________________________________
16 
17 #include <TMath.h>
18 
22 
23 using namespace genie;
24 
25 //____________________________________________________________________________
27 {
28 }
29 //____________________________________________________________________________
31 {
32 
33 }
34 //____________________________________________________________________________
36 {
37 
38 }
39 //____________________________________________________________________________
41 {
42  fKFSets.insert(map<int, KF_t>::value_type(tgt_pdgc, kf));
43 }
44 //____________________________________________________________________________
45 double FermiMomentumTable::FindClosestKF(int tgt_pdgc, int nucleon_pdgc) const
46 {
47  LOG("FermiP", pINFO)
48  << "Finding Fermi momenta table entry for (tgt = "
49  << tgt_pdgc << ", nucl = " << nucleon_pdgc << ")";
50 
51  if(fKFSets.size()==0) {
52  LOG("FermiP", pWARN)
53  << "The Fermi momenta table is empty! Returning kf(tgt = "
54  << tgt_pdgc << ", nucl = " << nucleon_pdgc << ") = 0";
55  return 0;
56  }
57 
58  double kf=0;
59  bool isp = pdg::IsProton(nucleon_pdgc);
60 
61  if(fKFSets.count(tgt_pdgc) == 1) {
62  LOG("FermiP", pDEBUG) << "Got exact match in Fermi momenta table";
63  map<int, KF_t>::const_iterator table_iter = fKFSets.find(tgt_pdgc);
64  if(isp) kf = table_iter->second.p;
65  else kf = table_iter->second.n;
66  LOG("FermiP", pINFO) << "kF = " << kf;
67  return kf;
68  }
69  LOG("FermiP", pINFO) << "Couldn't find exact match in Fermi momenta table";
70 
71  int Z = pdg::IonPdgCodeToZ(tgt_pdgc);
72  int Ac=9999, Zc=9999, dZmin=9999;
73  map<int, KF_t>::const_iterator kfiter;
74  for(kfiter=fKFSets.begin(); kfiter!=fKFSets.end(); ++kfiter) {
75  int pdgc = kfiter->first;
76  int Zt = pdg::IonPdgCodeToZ(pdgc);
77  int dZ = TMath::Abs(Zt-Z);
78  if(dZ<dZmin) {
79  dZmin = dZ;
80  Zc = Zt;
81  Ac = pdg::IonPdgCodeToA(pdgc);
82  KF_t kft = kfiter->second;
83  if(isp) kf=kft.p;
84  else kf=kft.n;
85  }
86  }
87  LOG("FermiP", pINFO)
88  << "The closest nucleus in table is pdgc = " << pdg::IonPdgCode(Ac,Zc);
89  LOG("FermiP", pINFO) << "kF = " << kf;
90  return kf;
91 }
92 //____________________________________________________________________________
int IonPdgCodeToA(int pdgc)
Definition: PDGUtils.cxx:63
A table of Fermi momentum constants.
bool IsProton(int pdgc)
Definition: PDGUtils.cxx:336
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
#define pINFO
Definition: Messenger.h:62
void AddTableEntry(int target_pdgc, KF_t kf)
#define pWARN
Definition: Messenger.h:60
int IonPdgCode(int A, int Z)
Definition: PDGUtils.cxx:71
int IonPdgCodeToZ(int pdgc)
Definition: PDGUtils.cxx:55
double FindClosestKF(int target_pdgc, int nucleon_pdgc) const
#define pDEBUG
Definition: Messenger.h:63