Public Member Functions | Private Member Functions | Private Attributes | List of all members
genie::flux::GNuMIFluxXMLHelper Class Reference

Public Member Functions

 GNuMIFluxXMLHelper (GNuMIFlux *gnumi)
 
 ~GNuMIFluxXMLHelper ()
 
bool LoadConfig (std::string cfg)
 
std::vector< double > GetDoubleVector (std::string str)
 
std::vector< long intGetIntVector (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 229 of file GNuMIFlux.cxx.

Constructor & Destructor Documentation

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

Definition at line 231 of file GNuMIFlux.cxx.

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

Definition at line 232 of file GNuMIFlux.cxx.

References submit_syst::str, string, and chisquared::theta.

232 { ; }

Member Function Documentation

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

Definition at line 3032 of file GNuMIFlux.cxx.

References MECModelEnuComparisons::i, and scale.

3033 {
3034  double xyz[3];
3035  // assume radians unless given a hint that it's degrees
3036  double scale = ('d'==units[0]||'D'==units[0]) ? TMath::DegToRad() : 1.0 ;
3037 
3038  xyz[0] = TMath::Cos(scale*phi)*TMath::Sin(scale*theta);
3039  xyz[1] = TMath::Sin(scale*phi)*TMath::Sin(scale*theta);
3040  xyz[2] = TMath::Cos(scale*theta);
3041  // condition vector to eliminate most floating point errors
3042  for (int i=0; i<3; ++i) {
3043  const double eps = 1.0e-15;
3044  if (TMath::Abs(xyz[i]) < eps ) xyz[i] = 0;
3045  if (TMath::Abs(xyz[i]-1) < eps ) xyz[i] = 1;
3046  if (TMath::Abs(xyz[i]+1) < eps ) xyz[i] = -1;
3047  }
3048  return TVector3(xyz[0],xyz[1],xyz[2]);
3049 }
Double_t scale
Definition: plot.C:25
std::vector< double > GNuMIFluxXMLHelper::GetDoubleVector ( std::string  str)

Definition at line 2606 of file GNuMIFlux.cxx.

References om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, genie::utils::str::Split(), string, genie::utils::str::TrimSpaces(), and febshutoff_auto::val.

2607 {
2608  // turn string into vector<double>
2609  // be liberal about separators, users might punctuate for clarity
2610  std::vector<std::string> strtokens = genie::utils::str::Split(str," ,;:()[]=");
2611  std::vector<double> vect;
2612  size_t ntok = strtokens.size();
2613 
2614  if ( fVerbose > 2 )
2615  std::cout << "GetDoubleVector \"" << str << "\"" << std::endl;
2616 
2617  for (size_t i=0; i < ntok; ++i) {
2618  std::string trimmed = utils::str::TrimSpaces(strtokens[i]);
2619  if ( " " == trimmed || "" == trimmed ) continue; // skip empty strings
2620  double val = strtod(trimmed.c_str(), (char**)NULL);
2621  if ( fVerbose > 2 )
2622  std::cout << "(" << vect.size() << ") = " << val << std::endl;
2623  vect.push_back(val);
2624  }
2625 
2626  return vect;
2627 }
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:250
OStream cout
Definition: OStream.cxx:6
string TrimSpaces(string input)
Definition: StringUtils.cxx:24
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:42
enum BeamMode string
std::vector< long int > GNuMIFluxXMLHelper::GetIntVector ( std::string  str)

Definition at line 2629 of file GNuMIFlux.cxx.

References om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, genie::utils::str::Split(), string, genie::utils::str::TrimSpaces(), and febshutoff_auto::val.

2630 {
2631  // turn string into vector<long int>
2632  // be liberal about separators, users might punctuate for clarity
2633  std::vector<std::string> strtokens = genie::utils::str::Split(str," ,;:()[]=");
2634  std::vector<long int> vect;
2635  size_t ntok = strtokens.size();
2636 
2637  if ( fVerbose > 2 )
2638  std::cout << "GetIntVector \"" << str << "\"" << std::endl;
2639 
2640  for (size_t i=0; i < ntok; ++i) {
2641  std::string trimmed = utils::str::TrimSpaces(strtokens[i]);
2642  if ( " " == trimmed || "" == trimmed ) continue; // skip empty strings
2643  long int val = strtol(trimmed.c_str(),(char**)NULL,10);
2644  if ( fVerbose > 2 )
2645  std::cout << "(" << vect.size() << ") = " << val << std::endl;
2646  vect.push_back(val);
2647  }
2648 
2649  return vect;
2650 }
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:250
OStream cout
Definition: OStream.cxx:6
string TrimSpaces(string input)
Definition: StringUtils.cxx:24
vector< string > Split(string input, string delim)
Definition: StringUtils.cxx:42
enum BeamMode string
bool GNuMIFluxXMLHelper::LoadConfig ( std::string  cfg)

Definition at line 2652 of file GNuMIFlux.cxx.

References plot_validation_datamc::fname, modifyFHiCL::found, genie::utils::xml::GetXMLFilePath(), pERROR, pINFO, and SLOG.

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

2653 {
2655 
2656  bool is_accessible = ! (gSystem->AccessPathName(fname.c_str()));
2657  if (!is_accessible) {
2658  SLOG("GNuMIFlux", pERROR)
2659  << "The XML doc doesn't exist! (filename: " << fname << ")";
2660  return false;
2661  }
2662 
2663  xmlDocPtr xml_doc = xmlParseFile( fname.c_str() );
2664  if ( xml_doc == NULL) {
2665  SLOG("GNuMIFlux", pERROR)
2666  << "The XML doc can't be parsed! (filename: " << fname << ")";
2667  return false;
2668  }
2669 
2670  xmlNodePtr xml_root = xmlDocGetRootElement( xml_doc );
2671  if ( xml_root == NULL ) {
2672  SLOG("GNuMIFlux", pERROR)
2673  << "The XML doc is empty! (filename: " << fname << ")";
2674  return false;
2675  }
2676 
2677  string rootele = "gnumi_config";
2678  if ( xmlStrcmp(xml_root->name, (const xmlChar*)rootele.c_str() ) ) {
2679  SLOG("GNuMIFlux", pERROR)
2680  << "The XML doc has invalid root element! (filename: " << fname << ")"
2681  << " expected \"" << rootele << "\", saw \"" << xml_root->name << "\"";
2682  return false;
2683  }
2684 
2685  SLOG("GNuMIFlux", pINFO) << "Attempt to load config \"" << cfg
2686  << "\" from file: " << fname;
2687 
2688  bool found = this->LoadParamSet(xml_doc,cfg);
2689 
2690  xmlFree(xml_doc);
2691  return found;
2692 
2693 }
bool LoadParamSet(xmlDocPtr &, std::string cfg)
Definition: GNuMIFlux.cxx:2695
#define pERROR
Definition: Messenger.h:60
string GetXMLFilePath(string basename)
#define pINFO
Definition: Messenger.h:63
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:85
bool GNuMIFluxXMLHelper::LoadParamSet ( xmlDocPtr &  ,
std::string  cfg 
)
private

Definition at line 2695 of file GNuMIFlux.cxx.

References plotROC::cfg, modifyFHiCL::found, genie::utils::xml::GetAttribute(), pINFO, SLOG, and genie::utils::str::TrimSpaces().

2696 {
2697 
2698  xmlNodePtr xml_root = xmlDocGetRootElement( xml_doc );
2699 
2700  // loop over all xml tree nodes that are children of the root node
2701  // read the entries looking for "param_set" of the right name
2702 
2703  // loop looking for particular config
2704  bool found = false;
2705  xmlNodePtr xml_pset = xml_root->xmlChildrenNode;
2706  for ( ; xml_pset != NULL ; xml_pset = xml_pset->next ) {
2707  if ( ! xmlStrEqual(xml_pset->name, (const xmlChar*)"param_set") ) continue;
2708  // every time there is a 'param_set' tag
2709  string param_set_name =
2711 
2712  if ( param_set_name != cfg ) continue;
2713 
2714  SLOG("GNuMIFlux", pINFO) << "Found config \"" << cfg;
2715 
2716  this->ParseParamSet(xml_doc,xml_pset);
2717  found = true;
2718 
2719  } // loop over elements of root
2720  xmlFree(xml_pset);
2721 
2722  return found;
2723 }
void ParseParamSet(xmlDocPtr &, xmlNodePtr &)
Definition: GNuMIFlux.cxx:2725
#define pINFO
Definition: Messenger.h:63
string TrimSpaces(string input)
Definition: StringUtils.cxx:24
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
void GNuMIFluxXMLHelper::ParseBeamDir ( xmlDocPtr &  xml_doc,
xmlNodePtr &  xml_beamdir 
)
private

Definition at line 2806 of file GNuMIFlux.cxx.

References om::cout, allTimeWatchdog::endl, genie::utils::xml::GetAttribute(), pWARN, SLOG, genie::utils::str::TrimSpaces(), genie::utils::xml::TrimSpaces(), genie::flux::GNuMIFluxPassThroughInfo::units, and w.

2807 {
2808  fBeamRotXML.SetToIdentity(); // start fresh
2809 
2810  string dirtype =
2812  utils::xml::GetAttribute(xml_beamdir,"type"));
2813 
2814  string pval =
2816  xmlNodeListGetString(xml_doc, xml_beamdir->xmlChildrenNode, 1));
2817 
2818  if ( dirtype == "series" ) {
2819  // series of rotations around an axis
2820  ParseRotSeries(xml_doc,xml_beamdir);
2821 
2822  } else if ( dirtype == "thetaphi3") {
2823  // G3 style triplet of (theta,phi) pairs
2824  std::vector<double> thetaphi3 = GetDoubleVector(pval);
2825  string units =
2826  utils::str::TrimSpaces(utils::xml::GetAttribute(xml_beamdir,"units"));
2827  if ( thetaphi3.size() == 6 ) {
2828  TRotation fTempRot;
2829  TVector3 newX = AnglesToAxis(thetaphi3[0],thetaphi3[1],units);
2830  TVector3 newY = AnglesToAxis(thetaphi3[2],thetaphi3[3],units);
2831  TVector3 newZ = AnglesToAxis(thetaphi3[4],thetaphi3[5],units);
2832  fTempRot.RotateAxes(newX,newY,newZ);
2833  fBeamRotXML = fTempRot; //.Inverse();
2834  } else {
2835  SLOG("GNuMIFlux", pWARN)
2836  << " type=\"" << dirtype << "\" within <beamdir> needs 6 values";
2837  }
2838 
2839  } else if ( dirtype == "newxyz" ) {
2840  // G4 style new axis values
2841  std::vector<double> newdir = GetDoubleVector(pval);
2842  if ( newdir.size() == 9 ) {
2843  TRotation fTempRot;
2844  TVector3 newX = TVector3(newdir[0],newdir[1],newdir[2]).Unit();
2845  TVector3 newY = TVector3(newdir[3],newdir[4],newdir[5]).Unit();
2846  TVector3 newZ = TVector3(newdir[6],newdir[7],newdir[8]).Unit();
2847  fTempRot.RotateAxes(newX,newY,newZ);
2848  fBeamRotXML = fTempRot.Inverse(); // weirdly necessary: frame vs. obj rot
2849  } else {
2850  SLOG("GNuMIFlux", pWARN)
2851  << " type=\"" << dirtype << "\" within <beamdir> needs 9 values";
2852  }
2853 
2854  } else {
2855  // yet something else ... what? 3 choices weren't sufficient?
2856  SLOG("GNuMIFlux", pWARN)
2857  << " UNHANDLED type=\"" << dirtype << "\" within <beamdir>";
2858  }
2859 
2860  if ( fVerbose > 1 ) {
2861  int w=10, p=6;
2862  std::cout << " fBeamRotXML: " << std::setprecision(p) << std::endl;
2863  std::cout << " [ "
2864  << std::setw(w) << fBeamRotXML.XX() << " "
2865  << std::setw(w) << fBeamRotXML.XY() << " "
2866  << std::setw(w) << fBeamRotXML.XZ() << endl
2867  << " "
2868  << std::setw(w) << fBeamRotXML.YX() << " "
2869  << std::setw(w) << fBeamRotXML.YY() << " "
2870  << std::setw(w) << fBeamRotXML.YZ() << endl
2871  << " "
2872  << std::setw(w) << fBeamRotXML.ZX() << " "
2873  << std::setw(w) << fBeamRotXML.ZY() << " "
2874  << std::setw(w) << fBeamRotXML.ZZ() << " ] " << std::endl;
2875  std::cout << std::endl;
2876  }
2877 
2878 }
TVector3 AnglesToAxis(double theta, double phi, std::string units="deg")
Definition: GNuMIFlux.cxx:3032
string TrimSpaces(xmlChar *xmls)
const char * p
Definition: xmltok.h:285
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:250
void ParseRotSeries(xmlDocPtr &, xmlNodePtr &)
Definition: GNuMIFlux.cxx:2934
#define pWARN
Definition: Messenger.h:61
OStream cout
Definition: OStream.cxx:6
string TrimSpaces(string input)
Definition: StringUtils.cxx:24
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2606
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
Float_t w
Definition: plot.C:20
void GNuMIFluxXMLHelper::ParseBeamPos ( std::string  str)
private

Definition at line 2880 of file GNuMIFlux.cxx.

References om::cout, allTimeWatchdog::endl, pWARN, SLOG, and w.

2881 {
2882  std::vector<double> xyz = GetDoubleVector(str);
2883  if ( xyz.size() == 3 ) {
2884  fBeamPosXML = TVector3(xyz[0],xyz[1],xyz[2]);
2885  } else if ( xyz.size() == 6 ) {
2886  // should check for '=' between triplets but we won't be so pedantic
2887  // ( userx, usery, userz ) = ( beamx, beamy, beamz )
2888  TVector3 userpos(xyz[0],xyz[1],xyz[2]);
2889  TVector3 beampos(xyz[3],xyz[4],xyz[5]);
2890  fBeamPosXML = userpos - fBeamRotXML*beampos;
2891  } else {
2892  SLOG("GNuMIFlux", pWARN)
2893  << "Unable to parse " << xyz.size() << " values in <beampos>";
2894  return;
2895  }
2896  if ( fVerbose > 1 ) {
2897  int w=16, p=10;
2898  std::cout << " fBeamPosXML: [ " << std::setprecision(p)
2899  << std::setw(w) << fBeamPosXML.X() << " , "
2900  << std::setw(w) << fBeamPosXML.Y() << " , "
2901  << std::setw(w) << fBeamPosXML.Z() << " ] "
2902  << std::endl;
2903  }
2904 }
const char * p
Definition: xmltok.h:285
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:250
#define pWARN
Definition: Messenger.h:61
OStream cout
Definition: OStream.cxx:6
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2606
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
Float_t w
Definition: plot.C:20
void GNuMIFluxXMLHelper::ParseEnuMax ( std::string  str)
private

Definition at line 2906 of file GNuMIFlux.cxx.

References om::cout, allTimeWatchdog::endl, makeTrainCVSamples::int, getGoodRuns4SAM::n, nentries, and registry_explorer::v.

2907 {
2908  std::vector<double> v = GetDoubleVector(str);
2909  size_t n = v.size();
2910  if ( n > 0 ) {
2911  fGNuMI->SetMaxEnergy(v[0]);
2912  if ( fVerbose > 1 )
2913  std::cout << "ParseEnuMax SetMaxEnergy(" << v[0] << ") " << std::endl;
2914  }
2915  if ( n > 1 ) {
2916  fGNuMI->SetMaxEFudge(v[1]);
2917  if ( fVerbose > 1 )
2918  std::cout << "ParseEnuMax SetMaxEFudge(" << v[1] << ")" << std::endl;
2919  }
2920  if ( n > 2 ) {
2921  if ( n == 3 ) {
2922  fGNuMI->SetMaxWgtScan(v[2]);
2923  if ( fVerbose > 1 )
2924  std::cout << "ParseEnuMax SetMaxWgtScan(" << v[2] << ")" << std::endl;
2925  } else {
2926  long int nentries = (long int)v[3];
2927  fGNuMI->SetMaxWgtScan(v[2],nentries);
2928  if ( fVerbose > 1 )
2929  std::cout << "ParseEnuMax SetMaxWgtScan(" << v[2] << "," << nentries << ")" << std::endl;
2930  }
2931  }
2932 }
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:250
Long64_t nentries
void SetMaxWgtScan(double fudge=1.05, long int nentries=2500000)
Definition: GNuMIFlux.h:298
OStream cout
Definition: OStream.cxx:6
void SetMaxEFudge(double fudge=1.05)
Definition: GNuMIFlux.h:300
void SetMaxEnergy(double Ev)
specify maximum flx neutrino energy
Definition: GNuMIFlux.cxx:916
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2606
void GNuMIFluxXMLHelper::ParseParamSet ( xmlDocPtr &  xml_doc,
xmlNodePtr &  xml_pset 
)
private

Definition at line 2725 of file GNuMIFlux.cxx.

References ana::assert(), modifyFHiCL::found, pFATAL, pINFO, eplot::pname, pWARN, scale, SLOG, genie::utils::xml::TrimSpaces(), genie::utils::units::UnitFromString(), and registry_explorer::v.

2726 {
2727  xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2728  for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2729  // handle basic gnumi_config/param_set
2730  // bad cast away const on next line, but function sig requires it
2731  string pname =
2732  utils::xml::TrimSpaces(const_cast<xmlChar*>(xml_child->name));
2733  if ( pname == "text" || pname == "comment" ) continue;
2734  string pval =
2736  xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2737 
2738  if ( fVerbose > 1 )
2739  SLOG("GNuMIFlux", pINFO)
2740  << " pname \"" << pname << "\", string value \"" << pval << "\"";
2741 
2742  if ( pname == "verbose" ) {
2743  fVerbose = atoi(pval.c_str());
2744 
2745  } else if ( pname == "using_param_set" ) {
2746  SLOG("GNuMIFlux", pWARN) << "start using_param_set: \"" << pval << "\"";
2747  bool found = this->LoadParamSet(xml_doc,pval); // recurse
2748  if ( ! found ) {
2749  SLOG("GNuMIFlux", pFATAL) << "using_param_set: \"" << pval << "\" NOT FOUND";
2750  assert(found);
2751  }
2752  SLOG("GNuMIFlux", pWARN) << "done using_param_set: \"" << pval << "\"";
2753  } else if ( pname == "units" ) {
2755  fGNuMI->SetLengthUnits(scale);
2756  SLOG("GNuMIFlux", pINFO) << "set user units to \"" << pval << "\"";
2757 
2758  } else if ( pname == "beamdir" ) {
2759  ParseBeamDir(xml_doc,xml_child);
2761 
2762  } else if ( pname == "beampos" ) {
2763  ParseBeamPos(pval);
2765 
2766  } else if ( pname == "window" ) {
2767  ParseWindowSeries(xml_doc,xml_child);
2768  // RWH !!!! MEMORY LEAK!!!!
2769  //std::cout << " flux window " << std::endl
2770  // << " [0] " << utils::print::X4AsString(new TLorentzVector(fFluxWindowPt[0],0)) << std::endl
2771  // << " [1] " << utils::print::X4AsString(new TLorentzVector(fFluxWindowPt[1],0)) << std::endl
2772  // << " [2] " << utils::print::X4AsString(new TLorentzVector(fFluxWindowPt[2],0)) << std::endl;
2773 
2775  fFluxWindowPtXML[1],
2776  fFluxWindowPtXML[2]);
2777 
2778  } else if ( pname == "enumax" ) {
2779  ParseEnuMax(pval);
2780 
2781  } else if ( pname == "upstreamz" ) {
2782  double z0usr = -3.4e38;
2783  std::vector<double> v = GetDoubleVector(pval);
2784  if ( v.size() > 0 ) z0usr = v[0];
2785  fGNuMI->SetUpstreamZ(z0usr);
2786  SLOG("GNuMIFlux", pINFO) << "set upstreamz = " << z0usr;
2787 
2788  } else if ( pname == "reuse" ) {
2789  long int nreuse = 1;
2790  std::vector<long int> v = GetIntVector(pval);
2791  if ( v.size() > 0 ) nreuse = v[0];
2792  fGNuMI->SetEntryReuse(nreuse);
2793  SLOG("GNuMIFlux", pINFO) << "set entry reuse = " << nreuse;
2794 
2795  } else {
2796  SLOG("GNuMIFlux", pWARN)
2797  << " NOT HANDLED: pname \"" << pname
2798  << "\", string value \"" << pval << "\"";
2799 
2800  }
2801 
2802  } // loop over param_set contents
2803  xmlFree(xml_child);
2804 }
bool LoadParamSet(xmlDocPtr &, std::string cfg)
Definition: GNuMIFlux.cxx:2695
std::vector< long int > GetIntVector(std::string str)
Definition: GNuMIFlux.cxx:2629
void SetEntryReuse(long int nuse=1)
of times to use entry before moving to next
Definition: GNuMIFlux.cxx:924
void SetLengthUnits(double user_units)
Set units assumed by user.
Definition: GNuMIFlux.cxx:1362
string TrimSpaces(xmlChar *xmls)
#define pFATAL
Definition: Messenger.h:57
void ParseBeamDir(xmlDocPtr &, xmlNodePtr &)
Definition: GNuMIFlux.cxx:2806
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:250
virtual void SetUpstreamZ(double z0)
Double_t scale
Definition: plot.C:25
void ParseBeamPos(std::string)
Definition: GNuMIFlux.cxx:2880
void SetBeamRotation(TRotation beamrot)
< beam (0,0,0) relative to user frame, beam direction in user frame
Definition: GNuMIFlux.cxx:1069
double UnitFromString(string u)
Definition: UnitUtils.cxx:26
void SetBeamCenter(TVector3 beam0)
Definition: GNuMIFlux.cxx:1076
#define pINFO
Definition: Messenger.h:63
bool SetFluxWindow(StdFluxWindow_t stdwindow, double padding=0)
return false if unhandled
Definition: GNuMIFlux.cxx:957
string pname
Definition: eplot.py:33
#define pWARN
Definition: Messenger.h:61
void ParseWindowSeries(xmlDocPtr &, xmlNodePtr &)
Definition: GNuMIFlux.cxx:2981
assert(nhit_max >=nhit_nbins)
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2606
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
void GNuMIFluxXMLHelper::ParseRotSeries ( xmlDocPtr &  xml_doc,
xmlNodePtr &  xml_pset 
)
private

Definition at line 2934 of file GNuMIFlux.cxx.

References allInOneTrainingPlots::axis, genie::utils::xml::GetAttribute(), pINFO, pWARN, SLOG, genie::utils::str::TrimSpaces(), genie::utils::xml::TrimSpaces(), genie::flux::GNuMIFluxPassThroughInfo::units, and febshutoff_auto::val.

2935 {
2936  TRotation fTempRot; // reset matrix
2937 
2938  xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2939  for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2940  // in a <beamdir> of type "series"
2941  // should be a sequence of <rotation> entries
2942  string name =
2943  utils::xml::TrimSpaces(const_cast<xmlChar*>(xml_child->name));
2944  if ( name == "text" || name == "comment" ) continue;
2945 
2946  if ( name == "rotation" ) {
2947  string val = utils::xml::TrimSpaces(
2948  xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2949  string axis =
2951 
2952  string units =
2954 
2955  double rot = atof(val.c_str());
2956  // assume radians unless given a hint that it's degrees
2957  if ( 'd' == units[0] || 'D' == units[0] ) rot *= TMath::DegToRad();
2958 
2959  if ( fVerbose > 0 )
2960  SLOG("GNuMIFlux", pINFO)
2961  << " rotate " << rot << " radians around " << axis << " axis";
2962 
2963  if ( axis[0] == 'x' || axis[0] == 'X' ) fTempRot.RotateX(rot);
2964  else if ( axis[0] == 'y' || axis[0] == 'Y' ) fTempRot.RotateY(rot);
2965  else if ( axis[0] == 'z' || axis[0] == 'Z' ) fTempRot.RotateZ(rot);
2966  else {
2967  SLOG("GNuMIFlux", pINFO)
2968  << " no " << axis << " to rotate around";
2969  }
2970 
2971  } else {
2972  SLOG("GNuMIFlux", pWARN)
2973  << " found <" << name << "> within <beamdir type=\"series\">";
2974  }
2975  }
2976  // TRotation rotates objects not frames, so we want the inverse
2977  fBeamRotXML = fTempRot.Inverse();
2978  xmlFree(xml_child);
2979 }
const XML_Char * name
Definition: expat.h:151
string TrimSpaces(xmlChar *xmls)
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:250
#define pINFO
Definition: Messenger.h:63
#define pWARN
Definition: Messenger.h:61
string TrimSpaces(string input)
Definition: StringUtils.cxx:24
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
TVector3 GNuMIFluxXMLHelper::ParseTV3 ( const std::string )
private

Definition at line 3051 of file GNuMIFlux.cxx.

References pWARN, and SLOG.

3052 {
3053  std::vector<double> xyz = GetDoubleVector(str);
3054  if ( xyz.size() != 3 ) {
3055  return TVector3();
3056  SLOG("GNuMIFlux", pWARN)
3057  << " ParseTV3 \"" << str << "\" had " << xyz.size() << " elements ";
3058  }
3059  return TVector3(xyz[0],xyz[1],xyz[2]);
3060 
3061 }
#define pWARN
Definition: Messenger.h:61
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2606
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
void GNuMIFluxXMLHelper::ParseWindowSeries ( xmlDocPtr &  xml_doc,
xmlNodePtr &  xml_pset 
)
private

Definition at line 2981 of file GNuMIFlux.cxx.

References om::cout, allTimeWatchdog::endl, genie::utils::xml::GetAttribute(), gen_flatrecord::pt, pWARN, SLOG, genie::utils::str::TrimSpaces(), genie::utils::xml::TrimSpaces(), febshutoff_auto::val, and w.

2982 {
2983  int ientry = -1;
2984 
2985  xmlNodePtr xml_child = xml_pset->xmlChildrenNode;
2986  for ( ; xml_child != NULL ; xml_child = xml_child->next ) {
2987  // in a <windowr> element
2988  // should be a sequence of <point> entries
2989  string name =
2990  utils::xml::TrimSpaces(const_cast<xmlChar*>(xml_child->name));
2991  if ( name == "text" || name == "comment" ) continue;
2992 
2993  if ( name == "point" ) {
2994  string val =
2996  xmlNodeListGetString(xml_doc, xml_child->xmlChildrenNode, 1));
2997  string coord =
2999 
3000  std::vector<double> xyz = GetDoubleVector(val);
3001  if ( xyz.size() != 3 || coord != "det" ) {
3002  SLOG("GNuMIFlux", pWARN)
3003  << "parsing <window> found <point> but size=" << xyz.size()
3004  << " (expect 3) and coord=\"" << coord << "\" (expect \"det\")"
3005  << " IGNORE problem";
3006  }
3007  ++ientry;
3008  if ( ientry < 3 && ientry >= 0 ) {
3009  TVector3 pt(xyz[0],xyz[1],xyz[2]);
3010  if ( fVerbose > 0 ) {
3011  int w=16, p=10;
3012  std::cout << " point[" << ientry <<"] = [ " << std::setprecision(p)
3013  << std::setw(w) << pt.X() << " , "
3014  << std::setw(w) << pt.Y() << " , "
3015  << std::setw(w) << pt.Z() << " ] "
3016  << std::endl;
3017  }
3018  fFluxWindowPtXML[ientry] = pt; // save the point
3019  } else {
3020  SLOG("GNuMIFlux", pWARN)
3021  << " <window><point> ientry " << ientry << " out of range (0-2)";
3022  }
3023 
3024  } else {
3025  SLOG("GNuMIFlux", pWARN)
3026  << " found <" << name << "> within <window>";
3027  }
3028  }
3029  xmlFree(xml_child);
3030 }
const XML_Char * name
Definition: expat.h:151
string TrimSpaces(xmlChar *xmls)
const char * p
Definition: xmltok.h:285
int fVerbose
how noisy to be when parsing XML
Definition: GNuMIFlux.cxx:250
#define pWARN
Definition: Messenger.h:61
OStream cout
Definition: OStream.cxx:6
string TrimSpaces(string input)
Definition: StringUtils.cxx:24
std::vector< double > GetDoubleVector(std::string str)
Definition: GNuMIFlux.cxx:2606
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition: Messenger.h:85
string GetAttribute(xmlNodePtr xml_cur, string attr_name)
Float_t w
Definition: plot.C:20

Member Data Documentation

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

Definition at line 255 of file GNuMIFlux.cxx.

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

Definition at line 256 of file GNuMIFlux.cxx.

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

Definition at line 257 of file GNuMIFlux.cxx.

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

Definition at line 252 of file GNuMIFlux.cxx.

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

how noisy to be when parsing XML

Definition at line 250 of file GNuMIFlux.cxx.


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