26 using std::ostringstream;
39 string str =
string( (
const char *) xmls );
45 xmlChar * xmls = xmlGetProp(xml_cur, (
const xmlChar *) attr_name.c_str());
62 if ( p0.size() ) { pathlist +=
std::string(p0) +
":" ; }
72 if ( add_tune && RunOpt::Instance() -> Tune() ) {
74 if ( RunOpt::Instance() -> Tune() -> IsConfigured() ) {
76 if ( ! RunOpt::Instance() -> Tune() -> IsValidated() ) {
77 LOG(
"XmlParser",
pFATAL) <<
"Tune not validated" ;
81 if ( ! RunOpt::Instance() -> Tune() -> OnlyConfiguration() )
82 pathlist += RunOpt::Instance() -> Tune() -> TuneDirectory() +
":" ;
84 pathlist += RunOpt::Instance() -> Tune() -> CMCDirectory() +
':' ;
90 pathlist +=
":$GENIE/src/Tools/Flux/GNuMINtuple";
105 if ( basename ==
"" )
return basename;
110 size_t np = paths.size();
111 for (
size_t i=0; i< np; ++i ) {
112 const char* tmppath = paths[i].c_str();
113 std::string onepath = gSystem->ExpandPathName(tmppath);
116 bool noAccess = gSystem->AccessPathName(onepath.c_str());
130 xmlNodePtr root_node = xmlDocGetRootElement(xml_doc);
131 if(root_node==NULL) {
132 LOG(
"XML",
pERROR) <<
"Null root XML node";
138 unsigned int ndepth = node_path_vec.size();
139 unsigned int idepth = 0;
141 xmlNodePtr curr_node = root_node;
143 while (curr_node != NULL) {
145 curr_node->name, (
const xmlChar *) node_path_vec[idepth].c_str())) )
148 if(idepth == ndepth) {
151 curr_node = curr_node->xmlChildrenNode;
154 curr_node = curr_node->next;
168 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
170 if(content ==
"true" ||
177 content ==
"I")
return true;
179 if(content ==
"false" ||
180 content ==
"FALSE" ||
181 content ==
"False" ||
186 content ==
"O")
return false;
189 <<
"Could not interpret content (" << content
190 <<
") found at node_path: " << node_path <<
" as a boolean!";
201 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
202 int value = atoi(content.c_str());
216 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
220 for( ; str_tokens_iter != str_tokens.end(); ++str_tokens_iter) {
222 if (not token.size() )
continue;
223 array.push_back( atoi(token.c_str()) );
235 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
236 double value = atof(content.c_str());
251 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
255 for( ; str_tokens_iter != str_tokens.end(); ++str_tokens_iter) {
257 if (not token.size() )
continue;
258 array.push_back( atof(token.c_str()) );
270 xmlNodeListGetString(xml_doc, node->xmlChildrenNode, 1) );
290 xmlDocPtr xml_doc,
string node_path,
string base_dir)
292 LOG(
"XML",
pINFO) <<
"Reading info at XML node node_path: " << node_path;
296 string used_base_dir = base_dir;
297 if(base_dir.find(
"<env>") != string::npos) {
298 used_base_dir = gSystem->Getenv(
"GENIE");
301 const char * full_filename =
302 Form(
"%s/%s", used_base_dir.c_str(), filename.c_str());
303 TFile *
file =
new TFile(full_filename,
"read");
305 LOG(
"XML",
pERROR) <<
"No file: " << full_filename <<
" found";
308 if(file->IsZombie()) {
309 LOG(
"XML",
pERROR) <<
"File is a zombie: " << full_filename;
317 xmlDocPtr xml_doc,
string node_path,
string base_dir)
323 TH1F *
h = (TH1F*)file->Get(objname.c_str());
331 TH1F * hcopy =
new TH1F(*h);
332 hcopy->SetDirectory(0);
340 xmlDocPtr xml_doc,
string node_path,
string base_dir)
346 TH1D *
h = (TH1D*)file->Get(objname.c_str());
354 TH1D * hcopy =
new TH1D(*h);
355 hcopy->SetDirectory(0);
363 xmlDocPtr xml_doc,
string node_path,
string base_dir)
369 TH2D *
h = (TH2D*)file->Get(objname.c_str());
377 TH2D * hcopy =
new TH2D(*h);
378 hcopy->SetDirectory(0);
386 xmlDocPtr xml_doc,
string node_path,
string base_dir)
392 TVectorD * vec = (TVectorD*)file->Get(objname.c_str());
400 TVectorD * veccopy =
new TVectorD(*vec);
string GetXMLPathList(bool add_tune=true)
string GetROOTObjName(xmlDocPtr xml_doc, string node_path)
string TrimSpaces(xmlChar *xmls)
xmlNodePtr FindNode(xmlDocPtr xml_doc, string node_path)
TH1D * GetTH1D(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")
string GetROOTFileName(xmlDocPtr xml_doc, string node_path)
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
std::string getenv(std::string const &name)
TH1F * GetTH1F(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")
string GetXMLFilePath(string basename)
string GetROOTObjType(xmlDocPtr xml_doc, string node_path)
TFile * GetTFile(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")
vector< double > GetDoubleArray(xmlDocPtr xml_doc, string node_path)
string TrimSpaces(string input)
auto array(Array const &a)
Returns a manipulator which will print the specified array.
vector< string > Split(string input, string delim)
string GetString(xmlDocPtr xml_doc, string node_path)
int GetInt(xmlDocPtr xml_doc, string node_path)
vector< int > GetIntArray(xmlDocPtr xml_doc, string node_path)
string GetXMLDefaultPath()
bool GetBool(xmlDocPtr xml_doc, string node_path)
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
double GetDouble(xmlDocPtr xml_doc, string node_path)
TH2D * GetTH2D(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")
TVectorD * GetTVectorD(xmlDocPtr xml_doc, string node_path, string base_dir="<env>")