389 <<
"Loading splines from: " <<
filename;
391 <<
"Option to keep pre-existing splines is switched " 392 << ( (keep) ?
"ON" :
"OFF" );
396 const int kNodeTypeStartElement = 1;
397 const int kNodeTypeEndElement = 15;
398 const int kKnotX = 0;
399 const int kKnotY = 1;
401 xmlTextReaderPtr reader;
403 int ret = 0, val_type = -1, iknot = 0, nknots = 0;
404 double *
E = 0, * xsec = 0;
405 string spline_name =
"";
408 reader = xmlNewTextReaderFilename(
filename.c_str());
409 if (reader != NULL) {
410 ret = xmlTextReaderRead(reader);
412 xmlChar *
name = xmlTextReaderName (reader);
413 xmlChar *
value = xmlTextReaderValue (reader);
414 int type = xmlTextReaderNodeType (reader);
415 int depth = xmlTextReaderDepth (reader);
417 if(depth==0 && type==kNodeTypeStartElement) {
419 if(xmlStrcmp(name, (
const xmlChar *)
"genie_xsec_spline_list")) {
421 <<
"\nXML doc. has invalid root element! [filename: " <<
filename <<
"]";
425 xmlChar * xvrs = xmlTextReaderGetAttribute(reader,(
const xmlChar*)
"version");
426 xmlChar * xinlog = xmlTextReaderGetAttribute(reader,(
const xmlChar*)
"uselog");
431 <<
"Input x-section spline XML file format version: " << svrs;
433 if (atoi(sinlog.c_str()) == 1) this->
SetLogE(
true);
440 if( (!xmlStrcmp(name, (
const xmlChar *)
"genie_tune")) && type==kNodeTypeStartElement) {
441 xmlChar * xtune = xmlTextReaderGetAttribute(reader,(
const xmlChar*)
"name");
443 SLOG(
"XSecSplLst",
pNOTICE) <<
"Loading x-section splines for GENIE tune: " << temp_tune;
447 if( (!xmlStrcmp(name, (
const xmlChar *)
"spline")) && type==kNodeTypeStartElement) {
448 xmlChar * xname = xmlTextReaderGetAttribute(reader,(
const xmlChar*)
"name");
449 xmlChar * xnkn = xmlTextReaderGetAttribute(reader,(
const xmlChar*)
"nknots");
454 SLOG(
"XSecSplLst",
pNOTICE) <<
"Loading spline: " << spline_name;
456 nknots = atoi( snkn.c_str() );
458 E =
new double[nknots];
459 xsec =
new double[nknots];
465 if( (!xmlStrcmp(name, (
const xmlChar *)
"E")) && type==kNodeTypeStartElement) { val_type = kKnotX; }
466 if( (!xmlStrcmp(name, (
const xmlChar *)
"xsec")) && type==kNodeTypeStartElement) { val_type = kKnotY; }
468 if( (!xmlStrcmp(name, (
const xmlChar *)
"#text")) && depth==5) {
469 if (val_type==kKnotX) E [iknot] = atof((
const char *)value);
470 else if (val_type==kKnotY) xsec[iknot] = atof((
const char *)value);
472 if( (!xmlStrcmp(name, (
const xmlChar *)
"knot")) && type==kNodeTypeEndElement) {
475 if( (!xmlStrcmp(name, (
const xmlChar *)
"spline")) && type==kNodeTypeEndElement) {
476 #ifdef __GENIE_LOW_LEVEL_MESG_ENABLED__ 477 LOG(
"XSecSplLst",
pINFO) <<
"Done with current spline";
478 for(
int i=0; i<nknots; i++) {
479 LOG(
"XSecSplLst",
pINFO) <<
"xsec[E = " << E[i] <<
"] = " << xsec[i];
483 Spline *
spline =
new Spline(nknots, E, xsec);
491 map<string, Spline *> spl_map_curr_tune;
492 fSplineMap.insert( map<
string, map<string, Spline *> >::value_type(
493 temp_tune, spl_map_curr_tune) );
496 map<string, Spline *> & spl_map_curr_tune = mm_iter->second;
497 spl_map_curr_tune.insert(
498 map<string, Spline *>::value_type(spline_name, spline) );
503 ret = xmlTextReaderRead(reader);
505 xmlFreeTextReader(reader);
508 <<
"\nXML file could not be parsed! [filename: " <<
filename <<
"]";
513 <<
"\nXML file could not be found! [filename: " <<
filename <<
"]";
map< string, set< string > > fLoadedSplineSet
tune -> { set of initialy loaded splines }
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
map< string, map< string, Spline * > > fSplineMap
tune -> { xsec_alg/xsec_config/interaction -> Spline }
string TrimSpaces(string input)
void SetLogE(bool on)
set opt to build splines as f(E) or as f(logE)
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...