24#include "libxml/xmlmemory.h"
27using std::ostringstream;
40 string str = string( (
const char *) xmls );
53 xmlChar * xmls = xmlGetProp(xml_cur, (
const xmlChar *) attr_name.c_str());
70 if ( p0.size() ) { pathlist += std::string(p0) +
":" ; }
71 const char* p1 = std::getenv(
"GXMLPATH" );
72 if ( p1 ) { pathlist += std::string(p1) +
":" ; }
73 const char* p2 = std::getenv(
"GXMLPATHS" );
74 if ( p2 ) { pathlist += std::string(p2) +
":" ; }
77 const char* p3 = std::getenv(
"GALGCONF" );
78 if ( p3 ) { pathlist += std::string(p3) +
":" ; }
85 LOG(
"XmlParser",
pFATAL) <<
"Tune not validated" ;
98 auto GENIE_REWEIGHT = std::getenv(
"GENIE_REWEIGHT");
100 pathlist +=
":" + (std::string(GENIE_REWEIGHT) +
"/config");
101 pathlist +=
":$GENIE/src/Tools/Flux/GNuMINtuple";
115 if ( basename ==
"" )
return basename;
120 size_t np = paths.size();
121 for (
size_t i=0; i< np; ++i ) {
122 const char* tmppath = paths[i].c_str();
123 auto expanded_path = gSystem->ExpandPathName(tmppath);
124 std::string onepath (expanded_path);
125 delete[] expanded_path;
128 bool noAccess = gSystem->AccessPathName(onepath.c_str());
142 xmlNodePtr root_node = xmlDocGetRootElement(xml_doc);
143 if(root_node==NULL) {
144 LOG(
"XML",
pERROR) <<
"Null root XML node";
150 unsigned int ndepth = node_path_vec.size();
151 unsigned int idepth = 0;
153 xmlNodePtr curr_node = root_node;
155 while (curr_node != NULL) {
157 curr_node->name, (
const xmlChar *) node_path_vec[idepth].c_str())) )
160 if(idepth == ndepth) {
163 curr_node = curr_node->xmlChildrenNode;
166 curr_node = curr_node->next;
180 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
182 if(content ==
"true" ||
189 content ==
"I")
return true;
191 if(content ==
"false" ||
192 content ==
"FALSE" ||
193 content ==
"False" ||
198 content ==
"O")
return false;
201 <<
"Could not interpret content (" << content
202 <<
") found at node_path: " << node_path <<
" as a boolean!";
213 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
214 int value = atoi(content.c_str());
228 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
231 vector<string>::const_iterator str_tokens_iter = str_tokens.begin();
232 for( ; str_tokens_iter != str_tokens.end(); ++str_tokens_iter) {
234 if (not token.size() )
continue;
235 array.push_back( atoi(token.c_str()) );
247 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
248 double value = atof(content.c_str());
255 vector<double> array;
263 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
266 vector<string>::const_iterator str_tokens_iter = str_tokens.begin();
267 for( ; str_tokens_iter != str_tokens.end(); ++str_tokens_iter) {
269 if (not token.size() )
continue;
270 array.push_back( atof(token.c_str()) );
282 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
302 xmlDocPtr xml_doc,
string node_path,
string base_dir)
304 LOG(
"XML",
pINFO) <<
"Reading info at XML node node_path: " << node_path;
308 string used_base_dir = base_dir;
309 if(base_dir.find(
"<env>") != string::npos) {
310 used_base_dir = gSystem->Getenv(
"GENIE");
313 const char * full_filename =
314 Form(
"%s/%s", used_base_dir.c_str(), filename.c_str());
315 TFile * file =
new TFile(full_filename,
"read");
317 LOG(
"XML",
pERROR) <<
"No file: " << full_filename <<
" found";
320 if(file->IsZombie()) {
321 LOG(
"XML",
pERROR) <<
"File is a zombie: " << full_filename;
329 xmlDocPtr xml_doc,
string node_path,
string base_dir)
335 TH1F *
h = (TH1F*)file->Get(objname.c_str());
343 TH1F * hcopy =
new TH1F(*
h);
344 hcopy->SetDirectory(0);
352 xmlDocPtr xml_doc,
string node_path,
string base_dir)
358 TH1D *
h = (TH1D*)file->Get(objname.c_str());
366 TH1D * hcopy =
new TH1D(*
h);
367 hcopy->SetDirectory(0);
375 xmlDocPtr xml_doc,
string node_path,
string base_dir)
381 TH2D *
h = (TH2D*)file->Get(objname.c_str());
389 TH2D * hcopy =
new TH2D(*
h);
390 hcopy->SetDirectory(0);
398 xmlDocPtr xml_doc,
string node_path,
string base_dir)
404 TVectorD * vec = (TVectorD*)file->Get(objname.c_str());
412 TVectorD * veccopy =
new TVectorD(*vec);
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
Is a concrete implementation of the QELFormFactorsModelI: Form Factors for Quasi Elastic CC vN Delta ...
static RunOpt * Instance(void)
Utilities for string manipulation.
string TrimSpaces(string input)
vector< string > Split(string input, string delim)
TVectorD * GetTVectorD(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")
TH2D * GetTH2D(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")
vector< double > GetDoubleArray(xmlDocPtr xml_doc, string node_path)
string GetXMLPathList(bool add_tune=true)
double GetDouble(xmlDocPtr xml_doc, string node_path)
string TrimSpaces(xmlChar *xmls)
string GetString(xmlDocPtr xml_doc, string node_path)
bool GetBool(xmlDocPtr xml_doc, string node_path)
xmlNodePtr FindNode(xmlDocPtr xml_doc, string node_path)
string GetROOTObjName(xmlDocPtr xml_doc, string node_path)
int GetInt(xmlDocPtr xml_doc, string node_path)
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
string TrimSpacesClean(xmlChar *xmls)
vector< int > GetIntArray(xmlDocPtr xml_doc, string node_path)
string GetROOTFileName(xmlDocPtr xml_doc, string node_path)
string GetROOTObjType(xmlDocPtr xml_doc, string node_path)
string GetXMLDefaultPath()
string GetXMLFilePath(string basename)
TH1F * GetTH1F(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")
TH1D * GetTH1D(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")
TFile * GetTFile(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")