GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::flux::GNuMIFluxXMLHelper Class Reference
Collaboration diagram for genie::flux::GNuMIFluxXMLHelper:
Collaboration graph
[legend]

Public Member Functions

 GNuMIFluxXMLHelper (GNuMIFlux *gnumi)
 
 ~GNuMIFluxXMLHelper ()
 
bool LoadConfig (std::string cfg)
 
std::vector< double > GetDoubleVector (std::string str)
 
std::vector< long int > GetIntVector (std::string str)
 

Private Member Functions

bool LoadParamSet (xmlDocPtr &, std::string cfg)
 
void ParseParamSet (xmlDocPtr &, xmlNodePtr &)
 
void ParseBeamDir (xmlDocPtr &, xmlNodePtr &)
 
void ParseBeamPos (std::string)
 
void ParseRotSeries (xmlDocPtr &, xmlNodePtr &)
 
void ParseWindowSeries (xmlDocPtr &, xmlNodePtr &)
 
void ParseEnuMax (std::string)
 
TVector3 AnglesToAxis (double theta, double phi, std::string units="deg")
 
TVector3 ParseTV3 (const std::string &)
 

Private Attributes

int fVerbose
 how noisy to be when parsing XML More...
 
GNuMIFluxfGNuMI
 
TVector3 fBeamPosXML
 
TRotation fBeamRotXML
 
TVector3 fFluxWindowPtXML [3]
 

Detailed Description

Definition at line 73 of file GNuMIFlux.cxx.

Constructor & Destructor Documentation

genie::flux::GNuMIFluxXMLHelper::GNuMIFluxXMLHelper ( GNuMIFlux gnumi)
inline

Definition at line 75 of file GNuMIFlux.cxx.

75 : fVerbose(0), fGNuMI(gnumi) { ; }
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
genie::flux::GNuMIFluxXMLHelper::~GNuMIFluxXMLHelper ( )
inline

Definition at line 76 of file GNuMIFlux.cxx.

76 { ; }

Member Function Documentation

TVector3 GNuMIFluxXMLHelper::AnglesToAxis ( double  theta,
double  phi,
std::string  units = "deg" 
)
private

Definition at line 2876 of file GNuMIFlux.cxx.

Referenced by ParseBeamDir().

2877 {
2878  double xyz[3];
2879  // assume radians unless given a hint that it's degrees
2880  double scale = ('d'==units[0]||'D'==units[0]) ? TMath::DegToRad() : 1.0 ;
2881 
2882  xyz[0] = TMath::Cos(scale*phi)*TMath::Sin(scale*theta);
2883  xyz[1] = TMath::Sin(scale*phi)*TMath::Sin(scale*theta);
2884  xyz[2] = TMath::Cos(scale*theta);
2885  // condition vector to eliminate most floating point errors
2886  for (int i=0; i<3; ++i) {
2887  const double eps = 1.0e-15;
2888  if (TMath::Abs(xyz[i]) < eps ) xyz[i] = 0;
2889  if (TMath::Abs(xyz[i]-1) < eps ) xyz[i] = 1;
2890  if (TMath::Abs(xyz[i]+1) < eps ) xyz[i] = -1;
2891  }
2892  return TVector3(xyz[0],xyz[1],xyz[2]);
2893 }
std::vector< double > GNuMIFluxXMLHelper::GetDoubleVector ( std::string  str)

Definition at line 2450 of file GNuMIFlux.cxx.

References fVerbose, genie::utils::str::Split(), and genie::utils::str::TrimSpaces().

Referenced by ParseBeamDir(), ParseBeamPos(), ParseEnuMax(), ParseParamSet(), ParseTV3(), and ParseWindowSeries().

2451 {
2452  // turn string into vector<double>
2453  // be liberal about separators, users might punctuate for clarity
2454  std::vector<std::string> strtokens = genie::utils::str::Split(str," ,;:()[]=");
2455  std::vector<double> vect;
2456  size_t ntok = strtokens.size();
2457 
2458  if ( fVerbose > 2 )
2459  std::cout << "GetDoubleVector \"" << str << "\"" << std::endl;
2460 
2461  for (size_t i=0; i < ntok; ++i) {
2462  std::string trimmed = utils::str::TrimSpaces(strtokens[i]);
2463  if ( " " == trimmed || "" == trimmed ) continue; // skip empty strings
2464  double val = strtod(trimmed.c_str(), (char**)NULL);
2465  if ( fVerbose > 2 )
2466  std::cout << "(" << vect.size() << ") = " << val << std::endl;
2467  vect.push_back(val);
2468  }
2469 
2470  return vect;
2471 }
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
std::vector< long int > GNuMIFluxXMLHelper::GetIntVector ( std::string  str)

Definition at line 2473 of file GNuMIFlux.cxx.

References fVerbose, genie::utils::str::Split(), and genie::utils::str::TrimSpaces().

Referenced by ParseParamSet().

2474 {
2475  // turn string into vector<long int>
2476  // be liberal about separators, users might punctuate for clarity
2477  std::vector<std::string> strtokens = genie::utils::str::Split(str," ,;:()[]=");
2478  std::vector<long int> vect;
2479  size_t ntok = strtokens.size();
2480 
2481  if ( fVerbose > 2 )
2482  std::cout << "GetIntVector \"" << str << "\"" << std::endl;
2483 
2484  for (size_t i=0; i < ntok; ++i) {
2485  std::string trimmed = utils::str::TrimSpaces(strtokens[i]);
2486  if ( " " == trimmed || "" == trimmed ) continue; // skip empty strings
2487  long int val = strtol(trimmed.c_str(),(char**)NULL,10);
2488  if ( fVerbose > 2 )
2489  std::cout << "(" << vect.size() << ") = " << val << std::endl;
2490  vect.push_back(val);
2491  }
2492 
2493  return vect;
2494 }
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:36
bool GNuMIFluxXMLHelper::LoadConfig ( std::string  cfg)

Definition at line 2496 of file GNuMIFlux.cxx.

References fGNuMI, genie::flux::GFluxFileConfigI::GetXMLFileBase(), genie::utils::xml::GetXMLFilePath(), LoadParamSet(), pERROR, pINFO, and SLOG.

Referenced by genie::flux::GNuMIFlux::LoadConfig().

2497 {
2499 
2500  bool is_accessible = ! (gSystem->AccessPathName(fname.c_str()));
2501  if (!is_accessible) {
2502  SLOG("GNuMIFlux", pERROR)
2503  << "The XML doc doesn't exist! (filename: " << fname << ")";
2504  return false;
2505  }
2506 
2507  xmlDocPtr xml_doc = xmlParseFile( fname.c_str() );
2508  if ( xml_doc == NULL) {
2509  SLOG("GNuMIFlux", pERROR)
2510  << "The XML doc can't be parsed! (filename: " << fname << ")";
2511  return false;
2512  }
2513 
2514  xmlNodePtr xml_root = xmlDocGetRootElement( xml_doc );
2515  if ( xml_root == NULL ) {
2516  SLOG("GNuMIFlux", pERROR)
2517  << "The XML doc is empty! (filename: " << fname << ")";
2518  return false;
2519  }
2520 
2521  string rootele = "gnumi_config";
2522  if ( xmlStrcmp(xml_root->name, (const xmlChar*)rootele.c_str() ) ) {
2523  SLOG("GNuMIFlux", pERROR)
2524  << "The XML doc has invalid root element! (filename: " << fname << ")"
2525  << " expected \"" << rootele << "\", saw \"" << xml_root->name << "\"";
2526  return false;
2527  }
2528 
2529  SLOG("GNuMIFlux", pINFO) << "Attempt to load config \"" << cfg
2530  << "\" from file: " << fname;
2531 
2532  bool found = this->LoadParamSet(xml_doc,cfg);
2533 
2534  xmlFree(xml_doc);
2535  return found;
2536 
2537 }
bool LoadParamSet(xmlDocPtr &, std::string cfg)
Definition: GNuMIFlux.cxx:2539
#define pERROR
Definition: Messenger.h:59
string GetXMLFilePath(string basename)
#define pINFO
Definition: Messenger.h:62
virtual std::string GetXMLFileBase() const
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
bool GNuMIFluxXMLHelper::LoadParamSet ( xmlDocPtr &  ,
std::string  cfg 
)
private

Definition at line 2539 of file GNuMIFlux.cxx.

References genie::utils::xml::GetAttribute(), ParseParamSet(), pINFO, SLOG, and genie::utils::str::TrimSpaces().

Referenced by LoadConfig(), and ParseParamSet().

2540 {
2541 
2542  xmlNodePtr xml_root = xmlDocGetRootElement( xml_doc );
2543 
2544  // loop over all xml tree nodes that are children of the root node
2545  // read the entries looking for "param_set" of the right name
2546 
2547  // loop looking for particular config
2548  bool found = false;
2549  xmlNodePtr xml_pset = xml_root->xmlChildrenNode;
2550  for ( ; xml_pset != NULL ; xml_pset = xml_pset->next ) {
2551  if ( ! xmlStrEqual(xml_pset->name, (const xmlChar*)"param_set") ) continue;
2552  // every time there is a 'param_set' tag
2553  string param_set_name =
2555 
2556  if ( param_set_name != cfg ) continue;
2557 
2558  SLOG("GNuMIFlux", pINFO) << "Found config \"" << cfg;
2559 
2560  this->ParseParamSet(xml_doc,xml_pset);
2561  found = true;
2562 
2563  } // loop over elements of root
2564  xmlFree(xml_pset);
2565 
2566  return found;
2567 }
void ParseParamSet(xmlDocPtr &, xmlNodePtr &)
Definition: GNuMIFlux.cxx:2569
#define pINFO
Definition: Messenger.h:62
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
void GNuMIFluxXMLHelper::ParseBeamDir ( xmlDocPtr &  xml_doc,
xmlNodePtr &  xml_beamdir 
)
private

Definition at line 2650 of file GNuMIFlux.cxx.

References AnglesToAxis(), fBeamRotXML, fVerbose, genie::utils::xml::GetAttribute(), GetDoubleVector(), ParseRotSeries(), pWARN, SLOG, genie::utils::str::TrimSpaces(), and genie::utils::xml::TrimSpaces().

Referenced by ParseParamSet().

2651 {
2652  fBeamRotXML.SetToIdentity(); // start fresh
2653 
2654  string dirtype =
2656  utils::xml::GetAttribute(xml_beamdir,"type"));
2657 
2658  string pval =
2660  xmlNodeListGetString(xml_doc, xml_beamdir->xmlChildrenNode, 1));
2661 
2662  if ( dirtype == "series" ) {
2663  // series of rotations around an axis
2664  ParseRotSeries(xml_doc,xml_beamdir);
2665 
2666  } else if ( dirtype == "thetaphi3") {
2667  // G3 style triplet of (theta,phi) pairs
2668  std::vector<double> thetaphi3 = GetDoubleVector(pval);
2669  string units =
2670  utils::str::TrimSpaces(utils::xml::GetAttribute(xml_beamdir,"units"));
2671  if ( thetaphi3.size() == 6 ) {
2672  TRotation fTempRot;
2673  TVector3 newX = AnglesToAxis(thetaphi3[0],thetaphi3[1],units);
2674  TVector3 newY = AnglesToAxis(thetaphi3[2],thetaphi3[3],units);
2675  TVector3 newZ = AnglesToAxis(thetaphi3[4],thetaphi3[5],units);
2676  fTempRot.RotateAxes(newX,newY,newZ);
2677  fBeamRotXML = fTempRot; //.Inverse();
2678  } else {
2679  SLOG("GNuMIFlux", pWARN)
2680  << " type=\"" << dirtype << "\" within <beamdir> needs 6 values";
2681  }
2682 
2683  } else if ( dirtype == "newxyz" ) {
2684  // G4 style new axis values
2685  std::vector<double> newdir = GetDoubleVector(pval);
2686  if ( newdir.size() == 9 ) {
2687  TRotation fTempRot;
2688  TVector3 newX = TVector3(newdir[0],newdir[1],newdir[2]).Unit();
2689  TVector3 newY = TVector3(newdir[3],newdir[4],newdir[5]).Unit();
2690  TVector3 newZ = TVector3(newdir[6],newdir[7],newdir[8]).Unit();
2691  fTempRot.RotateAxes(newX,newY,newZ);
2692  fBeamRotXML = fTempRot.Inverse(); // weirdly necessary: frame vs. obj rot
2693  } else {
2694  SLOG("GNuMIFlux", pWARN)
2695  << " type=\"" << dirtype << "\" within <beamdir> needs 9 values";
2696  }
2697 
2698  } else {
2699  // yet something else ... what? 3 choices weren't sufficient?
2700  SLOG("GNuMIFlux", pWARN)
2701  << " UNHANDLED type=\"" << dirtype << "\" within <beamdir>";
2702  }
2703 
2704  if ( fVerbose > 1 ) {
2705  int w=10, p=6;
2706  std::cout << " fBeamRotXML: " << std::setprecision(p) << std::endl;
2707  std::cout << " [ "
2708  << std::setw(w) << fBeamRotXML.XX() << " "
2709  << std::setw(w) << fBeamRotXML.XY() << " "
2710  << std::setw(w) << fBeamRotXML.XZ() << endl
2711  << " "
2712  << std::setw(w) << fBeamRotXML.YX() << " "
2713  << std::setw(w) << fBeamRotXML.YY() << " "
2714  << std::setw(w) << fBeamRotXML.YZ() << endl
2715  << " "
2716  << std::setw(w) << fBeamRotXML.ZX() << " "
2717  << std::setw(w) << fBeamRotXML.ZY() << " "
2718  << std::setw(w) << fBeamRotXML.ZZ() << " ] " << std::endl;
2719  std::cout << std::endl;
2720  }
2721 
2722 }
TVector3 AnglesToAxis(double theta, double phi, std::string units="deg")
Definition: GNuMIFlux.cxx:2876
string TrimSpaces(xmlChar *xmls)
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
void ParseRotSeries(xmlDocPtr &, xmlNodePtr &)
Definition: GNuMIFlux.cxx:2778
#define pWARN
Definition: Messenger.h:60
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2450
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
void GNuMIFluxXMLHelper::ParseBeamPos ( std::string  str)
private

Definition at line 2724 of file GNuMIFlux.cxx.

References fBeamPosXML, fBeamRotXML, fVerbose, GetDoubleVector(), pWARN, and SLOG.

Referenced by ParseParamSet().

2725 {
2726  std::vector<double> xyz = GetDoubleVector(str);
2727  if ( xyz.size() == 3 ) {
2728  fBeamPosXML = TVector3(xyz[0],xyz[1],xyz[2]);
2729  } else if ( xyz.size() == 6 ) {
2730  // should check for '=' between triplets but we won't be so pedantic
2731  // ( userx, usery, userz ) = ( beamx, beamy, beamz )
2732  TVector3 userpos(xyz[0],xyz[1],xyz[2]);
2733  TVector3 beampos(xyz[3],xyz[4],xyz[5]);
2734  fBeamPosXML = userpos - fBeamRotXML*beampos;
2735  } else {
2736  SLOG("GNuMIFlux", pWARN)
2737  << "Unable to parse " << xyz.size() << " values in <beampos>";
2738  return;
2739  }
2740  if ( fVerbose > 1 ) {
2741  int w=16, p=10;
2742  std::cout << " fBeamPosXML: [ " << std::setprecision(p)
2743  << std::setw(w) << fBeamPosXML.X() << " , "
2744  << std::setw(w) << fBeamPosXML.Y() << " , "
2745  << std::setw(w) << fBeamPosXML.Z() << " ] "
2746  << std::endl;
2747  }
2748 }
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
#define pWARN
Definition: Messenger.h:60
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2450
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
void GNuMIFluxXMLHelper::ParseEnuMax ( std::string  str)
private

Definition at line 2750 of file GNuMIFlux.cxx.

References fGNuMI, fVerbose, GetDoubleVector(), genie::flux::GNuMIFlux::SetMaxEFudge(), genie::flux::GNuMIFlux::SetMaxEnergy(), and genie::flux::GNuMIFlux::SetMaxWgtScan().

Referenced by ParseParamSet().

2751 {
2752  std::vector<double> v = GetDoubleVector(str);
2753  size_t n = v.size();
2754  if ( n > 0 ) {
2755  fGNuMI->SetMaxEnergy(v[0]);
2756  if ( fVerbose > 1 )
2757  std::cout << "ParseEnuMax SetMaxEnergy(" << v[0] << ") " << std::endl;
2758  }
2759  if ( n > 1 ) {
2760  fGNuMI->SetMaxEFudge(v[1]);
2761  if ( fVerbose > 1 )
2762  std::cout << "ParseEnuMax SetMaxEFudge(" << v[1] << ")" << std::endl;
2763  }
2764  if ( n > 2 ) {
2765  if ( n == 3 ) {
2766  fGNuMI->SetMaxWgtScan(v[2]);
2767  if ( fVerbose > 1 )
2768  std::cout << "ParseEnuMax SetMaxWgtScan(" << v[2] << ")" << std::endl;
2769  } else {
2770  long int nentries = (long int)v[3];
2771  fGNuMI->SetMaxWgtScan(v[2],nentries);
2772  if ( fVerbose > 1 )
2773  std::cout << "ParseEnuMax SetMaxWgtScan(" << v[2] << "," << nentries << ")" << std::endl;
2774  }
2775  }
2776 }
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
void SetMaxWgtScan(double fudge=1.05, long int nentries=2500000)
Definition: GNuMIFlux.h:298
void SetMaxEFudge(double fudge=1.05)
Definition: GNuMIFlux.h:300
void SetMaxEnergy(double Ev)
specify maximum flx neutrino energy
Definition: GNuMIFlux.cxx:760
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2450
void GNuMIFluxXMLHelper::ParseParamSet ( xmlDocPtr &  xml_doc,
xmlNodePtr &  xml_pset 
)
private

Definition at line 2569 of file GNuMIFlux.cxx.

References fBeamPosXML, fBeamRotXML, fFluxWindowPtXML, fGNuMI, fVerbose, GetDoubleVector(), GetIntVector(), LoadParamSet(), ParseBeamDir(), ParseBeamPos(), ParseEnuMax(), ParseWindowSeries(), pFATAL, pINFO, pWARN, genie::flux::GNuMIFlux::SetBeamCenter(), genie::flux::GNuMIFlux::SetBeamRotation(), genie::flux::GNuMIFlux::SetEntryReuse(), genie::flux::GNuMIFlux::SetFluxWindow(), genie::flux::GNuMIFlux::SetLengthUnits(), genie::flux::GFluxFileConfigI::SetUpstreamZ(), SLOG, genie::utils::xml::TrimSpaces(), and genie::utils::units::UnitFromString().

Referenced by LoadParamSet().

2570 {
2571  xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2572  for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2573  // handle basic gnumi_config/param_set
2574  // bad cast away const on next line, but function sig requires it
2575  string pname =
2576  utils::xml::TrimSpaces(const_cast<xmlChar*>(xml_child->name));
2577  if ( pname == "text" || pname == "comment" ) continue;
2578  string pval =
2580  xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2581 
2582  if ( fVerbose > 1 )
2583  SLOG("GNuMIFlux", pINFO)
2584  << " pname \"" << pname << "\", string value \"" << pval << "\"";
2585 
2586  if ( pname == "verbose" ) {
2587  fVerbose = atoi(pval.c_str());
2588 
2589  } else if ( pname == "using_param_set" ) {
2590  SLOG("GNuMIFlux", pWARN) << "start using_param_set: \"" << pval << "\"";
2591  bool found = this->LoadParamSet(xml_doc,pval); // recurse
2592  if ( ! found ) {
2593  SLOG("GNuMIFlux", pFATAL) << "using_param_set: \"" << pval << "\" NOT FOUND";
2594  assert(found);
2595  }
2596  SLOG("GNuMIFlux", pWARN) << "done using_param_set: \"" << pval << "\"";
2597  } else if ( pname == "units" ) {
2598  double scale = genie::utils::units::UnitFromString(pval);
2599  fGNuMI->SetLengthUnits(scale);
2600  SLOG("GNuMIFlux", pINFO) << "set user units to \"" << pval << "\"";
2601 
2602  } else if ( pname == "beamdir" ) {
2603  ParseBeamDir(xml_doc,xml_child);
2605 
2606  } else if ( pname == "beampos" ) {
2607  ParseBeamPos(pval);
2609 
2610  } else if ( pname == "window" ) {
2611  ParseWindowSeries(xml_doc,xml_child);
2612  // RWH !!!! MEMORY LEAK!!!!
2613  //std::cout << " flux window " << std::endl
2614  // << " [0] " << utils::print::X4AsString(new TLorentzVector(fFluxWindowPt[0],0)) << std::endl
2615  // << " [1] " << utils::print::X4AsString(new TLorentzVector(fFluxWindowPt[1],0)) << std::endl
2616  // << " [2] " << utils::print::X4AsString(new TLorentzVector(fFluxWindowPt[2],0)) << std::endl;
2617 
2619  fFluxWindowPtXML[1],
2620  fFluxWindowPtXML[2]);
2621 
2622  } else if ( pname == "enumax" ) {
2623  ParseEnuMax(pval);
2624 
2625  } else if ( pname == "upstreamz" ) {
2626  double z0usr = -3.4e38;
2627  std::vector<double> v = GetDoubleVector(pval);
2628  if ( v.size() > 0 ) z0usr = v[0];
2629  fGNuMI->SetUpstreamZ(z0usr);
2630  SLOG("GNuMIFlux", pINFO) << "set upstreamz = " << z0usr;
2631 
2632  } else if ( pname == "reuse" ) {
2633  long int nreuse = 1;
2634  std::vector<long int> v = GetIntVector(pval);
2635  if ( v.size() > 0 ) nreuse = v[0];
2636  fGNuMI->SetEntryReuse(nreuse);
2637  SLOG("GNuMIFlux", pINFO) << "set entry reuse = " << nreuse;
2638 
2639  } else {
2640  SLOG("GNuMIFlux", pWARN)
2641  << " NOT HANDLED: pname \"" << pname
2642  << "\", string value \"" << pval << "\"";
2643 
2644  }
2645 
2646  } // loop over param_set contents
2647  xmlFree(xml_child);
2648 }
bool LoadParamSet(xmlDocPtr &, std::string cfg)
Definition: GNuMIFlux.cxx:2539
std::vector< long int > GetIntVector(std::string str)
Definition: GNuMIFlux.cxx:2473
void SetEntryReuse(long int nuse=1)
of times to use entry before moving to next
Definition: GNuMIFlux.cxx:768
void SetLengthUnits(double user_units)
Set units assumed by user.
Definition: GNuMIFlux.cxx:1206
string TrimSpaces(xmlChar *xmls)
#define pFATAL
Definition: Messenger.h:56
void ParseBeamDir(xmlDocPtr &, xmlNodePtr &)
Definition: GNuMIFlux.cxx:2650
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
virtual void SetUpstreamZ(double z0)
void ParseBeamPos(std::string)
Definition: GNuMIFlux.cxx:2724
void SetBeamRotation(TRotation beamrot)
&lt; beam (0,0,0) relative to user frame, beam direction in user frame
Definition: GNuMIFlux.cxx:913
double UnitFromString(string u)
Definition: UnitUtils.cxx:18
void SetBeamCenter(TVector3 beam0)
Definition: GNuMIFlux.cxx:920
#define pINFO
Definition: Messenger.h:62
bool SetFluxWindow(StdFluxWindow_t stdwindow, double padding=0)
return false if unhandled
Definition: GNuMIFlux.cxx:801
#define pWARN
Definition: Messenger.h:60
void ParseWindowSeries(xmlDocPtr &, xmlNodePtr &)
Definition: GNuMIFlux.cxx:2825
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2450
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
void GNuMIFluxXMLHelper::ParseRotSeries ( xmlDocPtr &  xml_doc,
xmlNodePtr &  xml_pset 
)
private

Definition at line 2778 of file GNuMIFlux.cxx.

References fBeamRotXML, fVerbose, genie::utils::xml::GetAttribute(), pINFO, pWARN, SLOG, genie::utils::str::TrimSpaces(), and genie::utils::xml::TrimSpaces().

Referenced by ParseBeamDir().

2779 {
2780  TRotation fTempRot; // reset matrix
2781 
2782  xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2783  for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2784  // in a <beamdir> of type "series"
2785  // should be a sequence of <rotation> entries
2786  string name =
2787  utils::xml::TrimSpaces(const_cast<xmlChar*>(xml_child->name));
2788  if ( name == "text" || name == "comment" ) continue;
2789 
2790  if ( name == "rotation" ) {
2791  string val = utils::xml::TrimSpaces(
2792  xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2793  string axis =
2795 
2796  string units =
2798 
2799  double rot = atof(val.c_str());
2800  // assume radians unless given a hint that it's degrees
2801  if ( 'd' == units[0] || 'D' == units[0] ) rot *= TMath::DegToRad();
2802 
2803  if ( fVerbose > 0 )
2804  SLOG("GNuMIFlux", pINFO)
2805  << " rotate " << rot << " radians around " << axis << " axis";
2806 
2807  if ( axis[0] == 'x' || axis[0] == 'X' ) fTempRot.RotateX(rot);
2808  else if ( axis[0] == 'y' || axis[0] == 'Y' ) fTempRot.RotateY(rot);
2809  else if ( axis[0] == 'z' || axis[0] == 'Z' ) fTempRot.RotateZ(rot);
2810  else {
2811  SLOG("GNuMIFlux", pINFO)
2812  << " no " << axis << " to rotate around";
2813  }
2814 
2815  } else {
2816  SLOG("GNuMIFlux", pWARN)
2817  << " found <" << name << "> within <beamdir type=\"series\">";
2818  }
2819  }
2820  // TRotation rotates objects not frames, so we want the inverse
2821  fBeamRotXML = fTempRot.Inverse();
2822  xmlFree(xml_child);
2823 }
string TrimSpaces(xmlChar *xmls)
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
#define pINFO
Definition: Messenger.h:62
#define pWARN
Definition: Messenger.h:60
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
const char * name
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
TVector3 GNuMIFluxXMLHelper::ParseTV3 ( const std::string &  )
private

Definition at line 2895 of file GNuMIFlux.cxx.

References GetDoubleVector(), pWARN, and SLOG.

2896 {
2897  std::vector<double> xyz = GetDoubleVector(str);
2898  if ( xyz.size() != 3 ) {
2899  return TVector3();
2900  SLOG("GNuMIFlux", pWARN)
2901  << " ParseTV3 \"" << str << "\" had " << xyz.size() << " elements ";
2902  }
2903  return TVector3(xyz[0],xyz[1],xyz[2]);
2904 
2905 }
#define pWARN
Definition: Messenger.h:60
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2450
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
void GNuMIFluxXMLHelper::ParseWindowSeries ( xmlDocPtr &  xml_doc,
xmlNodePtr &  xml_pset 
)
private

Definition at line 2825 of file GNuMIFlux.cxx.

References fFluxWindowPtXML, fVerbose, genie::utils::xml::GetAttribute(), GetDoubleVector(), pWARN, SLOG, genie::utils::str::TrimSpaces(), and genie::utils::xml::TrimSpaces().

Referenced by ParseParamSet().

2826 {
2827  int ientry = -1;
2828 
2829  xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2830  for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2831  // in a <windowr> element
2832  // should be a sequence of <point> entries
2833  string name =
2834  utils::xml::TrimSpaces(const_cast<xmlChar*>(xml_child->name));
2835  if ( name == "text" || name == "comment" ) continue;
2836 
2837  if ( name == "point" ) {
2838  string val =
2840  xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2841  string coord =
2843 
2844  std::vector<double> xyz = GetDoubleVector(val);
2845  if ( xyz.size() != 3 || coord != "det" ) {
2846  SLOG("GNuMIFlux", pWARN)
2847  << "parsing <window> found <point> but size=" << xyz.size()
2848  << " (expect 3) and coord=\"" << coord << "\" (expect \"det\")"
2849  << " IGNORE problem";
2850  }
2851  ++ientry;
2852  if ( ientry < 3 && ientry >= 0 ) {
2853  TVector3 pt(xyz[0],xyz[1],xyz[2]);
2854  if ( fVerbose > 0 ) {
2855  int w=16, p=10;
2856  std::cout << " point[" << ientry <<"] = [ " << std::setprecision(p)
2857  << std::setw(w) << pt.X() << " , "
2858  << std::setw(w) << pt.Y() << " , "
2859  << std::setw(w) << pt.Z() << " ] "
2860  << std::endl;
2861  }
2862  fFluxWindowPtXML[ientry] = pt; // save the point
2863  } else {
2864  SLOG("GNuMIFlux", pWARN)
2865  << " <window><point> ientry " << ientry << " out of range (0-2)";
2866  }
2867 
2868  } else {
2869  SLOG("GNuMIFlux", pWARN)
2870  << " found <" << name << "> within <window>";
2871  }
2872  }
2873  xmlFree(xml_child);
2874 }
string TrimSpaces(xmlChar *xmls)
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:94
#define pWARN
Definition: Messenger.h:60
string TrimSpaces(string input)
Definition: StringUtils.cxx:18
const char * name
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2450
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:84
string GetAttribute(xmlNodePtr xml_cur, string attr_name)

Member Data Documentation

TVector3 genie::flux::GNuMIFluxXMLHelper::fBeamPosXML
private

Definition at line 99 of file GNuMIFlux.cxx.

Referenced by ParseBeamPos(), and ParseParamSet().

TRotation genie::flux::GNuMIFluxXMLHelper::fBeamRotXML
private

Definition at line 100 of file GNuMIFlux.cxx.

Referenced by ParseBeamDir(), ParseBeamPos(), ParseParamSet(), and ParseRotSeries().

TVector3 genie::flux::GNuMIFluxXMLHelper::fFluxWindowPtXML[3]
private

Definition at line 101 of file GNuMIFlux.cxx.

Referenced by ParseParamSet(), and ParseWindowSeries().

GNuMIFlux* genie::flux::GNuMIFluxXMLHelper::fGNuMI
private

Definition at line 96 of file GNuMIFlux.cxx.

Referenced by LoadConfig(), ParseEnuMax(), and ParseParamSet().

int genie::flux::GNuMIFluxXMLHelper::fVerbose
private

how noisy to be when parsing XML

Definition at line 94 of file GNuMIFlux.cxx.

Referenced by GetDoubleVector(), GetIntVector(), ParseBeamDir(), ParseBeamPos(), ParseEnuMax(), ParseParamSet(), ParseRotSeries(), and ParseWindowSeries().


The documentation for this class was generated from the following file: