24 #include "libxml/parser.h"
25 #include "libxml/xmlmemory.h"
37 using namespace genie;
45 LOG(
"FermiP",
pERROR) <<
"FermiMomentumTablePool initialization failed!";
52 map<string, FermiMomentumTable *>::iterator titer;
66 LOG(
"FermiP",
pINFO) <<
"FermiMomentumTablePool late initialization";
78 string defopt =
"Default";
80 map<string, FermiMomentumTable *>::const_iterator table_iter;
84 table_iter =
fKFSets.find(name);
85 table = table_iter->second;
86 if(table)
return table;
88 if(
fKFSets.count(defopt) == 1) {
90 <<
"Fermi momentum table: [" << name <<
"] was not found! "
91 <<
"Switching to table: [" << defopt <<
"]";
92 table_iter =
fKFSets.find(defopt);
93 table = table_iter->second;
94 if(table)
return table;
97 <<
"Not even the default Fermi momentum table was not found!";
108 LOG(
"FermiP",
pINFO) <<
"Loading Fermi momenta from file: " << filename;
110 bool is_accessible = ! (gSystem->AccessPathName( filename.c_str() ));
117 <<
" - Couldn't read file: " << filename;
121 LOG(
"FermiP",
pWARN) <<
"Not accessible file: " << filename;
129 LOG(
"FermiP",
pDEBUG) <<
"Reading XML file: " << filename;
131 xmlDocPtr xml_doc = xmlParseFile(filename.c_str());
134 xmlNodePtr xml_root = xmlDocGetRootElement(xml_doc);
141 const xmlChar * xml_root_name = (
const xmlChar *)
"fermi_momentum_const";
142 if( xmlStrcmp(xml_root->name, xml_root_name) )
148 xmlNodePtr xml_kft = xml_root->xmlChildrenNode;
151 while (xml_kft != NULL) {
152 if( (!xmlStrcmp(xml_kft->name, (
const xmlChar *)
"kf_table")) ) {
157 LOG(
"FermiP",
pDEBUG) <<
"Reading Fermi momenta table: " << name;
162 xmlNodePtr xml_kf = xml_kft->xmlChildrenNode;
163 while (xml_kf != NULL) {
164 if( (!xmlStrcmp(xml_kf->name, (
const xmlChar *)
"kf")) ) {
168 int pdgc = atoi (spdgc.c_str());
170 xmlNodePtr xml_cur = xml_kf->xmlChildrenNode;
171 const xmlChar * ntag = (
const xmlChar *)
"n";
172 const xmlChar * ptag = (
const xmlChar *)
"p";
173 double kfp=0, kfn=0, kf=0;
175 while (xml_cur != NULL) {
176 bool isp = !xmlStrcmp(xml_cur->name, ptag);
177 bool isn = !xmlStrcmp(xml_cur->name, ntag);
180 xmlNodeListGetString(xml_doc, xml_cur->xmlChildrenNode, 1));
181 kf = atof(skf.c_str());
185 xml_cur = xml_cur->next;
187 xmlFreeNode(xml_cur);
194 <<
"Add KF table entry: PDGC = " << pdgc
195 <<
" --> " <<
"kf(p) = " << kft.
p <<
", kf(n) = " << kft.
n;
198 xml_kf = xml_kf->next;
203 map<string, FermiMomentumTable *>::value_type(name,kftable));
206 xml_kft = xml_kft->next;
208 xmlFreeNode(xml_kft);
string TrimSpaces(xmlChar *xmls)
static FermiMomentumTablePool * Instance(void)
static FermiMomentumTablePool * fInstance
A table of Fermi momentum constants.
map< string, FermiMomentumTable * > fKFSets
Singleton class to load & serve tables of Fermi momentum constants.
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
const FermiMomentumTable * GetTable(string name)
string GetXMLFilePath(string basename)
void AddTableEntry(int target_pdgc, KF_t kf)
string TrimSpaces(string input)
virtual ~FermiMomentumTablePool()
void DummyMethodAndSilentCompiler()
static const char * AsString(XmlParserStatus_t status)
XmlParserStatus_t ParseXMLTables(string filename)
enum genie::EXmlParseStatus XmlParserStatus_t
string GetAttribute(xmlNodePtr xml_cur, string attr_name)