93 LOG(
"GSimFiles",
pNOTICE) <<
"Loading: " << xmlfile;
101 xmlTextReaderPtr reader = xmlNewTextReaderFilename(xmlfile.c_str());
106 const int kNodeTypeStartElement = 1;
107 const int kNodeTypeEndElement = 15;
110 bool is_xsec_file =
false;
111 bool is_evt_file =
false;
112 bool is_ghep_evt_file =
false;
113 bool is_gst_evt_file =
false;
114 bool have_ghep_files =
false;
115 bool have_gst_files =
false;
117 if (reader != NULL) {
118 int ret = xmlTextReaderRead(reader);
120 xmlChar *
name = xmlTextReaderName (reader);
121 xmlChar * value = xmlTextReaderValue (reader);
122 int type = xmlTextReaderNodeType (reader);
123 int depth = xmlTextReaderDepth (reader);
125 bool start_element = (type==kNodeTypeStartElement);
126 bool end_element = (type==kNodeTypeEndElement);
128 if(depth==0 && start_element) {
130 if(xmlStrcmp(name, (
const xmlChar *)
"genie_simulation_outputs")) {
132 <<
"\nXML doc. has invalid root element! [filename: "
138 if( (!xmlStrcmp(name, (
const xmlChar *)
"model")) && start_element) {
139 xmlChar * xname = xmlTextReaderGetAttribute(reader,(
const xmlChar*)
"name");
141 model_tag[imodel] = sname;
143 <<
"Adding files for model ID: "
144 << imodel <<
" (" << model_tag[imodel] <<
")";
147 if( (!xmlStrcmp(name, (
const xmlChar *)
"model")) && end_element) {
149 <<
"Done adding files for model ID: " << imodel;
152 if( (!xmlStrcmp(name, (
const xmlChar *)
"xsec_file")) && start_element) {
155 if( (!xmlStrcmp(name, (
const xmlChar *)
"xsec_file")) && end_element) {
156 is_xsec_file =
false;
158 if( (!xmlStrcmp(name, (
const xmlChar *)
"evt_file")) && start_element) {
160 is_ghep_evt_file =
false;
161 is_gst_evt_file =
false;
162 xmlChar * xfmt = xmlTextReaderGetAttribute(reader,(
const xmlChar*)
"format");
164 if (sfmt.find(
"gst") != string::npos)
166 is_gst_evt_file =
true;
167 if(!have_gst_files) { have_gst_files =
true; }
170 if (sfmt.find(
"ghep") != string::npos)
172 is_ghep_evt_file =
true;
173 if(!have_ghep_files) { have_ghep_files =
true; }
175 if(have_gst_files && have_ghep_files) {
177 <<
"Oops! You shouldn't mix GHEP and GST event files in GSimFiles";
179 <<
"Please correct XML file: " << xmlfile;
185 if( (!xmlStrcmp(name, (
const xmlChar *)
"evt_file")) && end_element) {
188 if( (!xmlStrcmp(name, (
const xmlChar *)
"#text")) && depth==3) {
192 <<
" * Adding event file: " << filename;
195 if(!evt_chain[imodel] && is_gst_evt_file) {
196 evt_chain[imodel] =
new TChain(
"gst");
198 if(!evt_chain[imodel] && is_ghep_evt_file) {
199 evt_chain[imodel] =
new TChain(
"gtree");
201 if(evt_chain[imodel]) {
202 evt_chain[imodel]->Add(filename.c_str());
205 evt_filenames[imodel].push_back(filename);
209 <<
" * Adding cross section file: " << filename;
210 xsec_file [imodel] =
new TFile(filename.c_str(),
"read");
211 xsec_filename[imodel] = filename;
212 if(!xsec_file[imodel]) {
221 ret = xmlTextReaderRead(reader);
225 xmlFreeTextReader(reader);
vector< TFile * > * fXSecFile
vector< TChain * > * fEvtChain
vector< string > * fModelTag
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
vector< vector< string > > * fEvtFileNames
string TrimSpaces(string input)
vector< string > * fXSecFileName