XSecSplineList.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::XSecSplineList
5 
6 \brief List of cross section vs energy splines
7 
8 \author Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
9  University of Liverpool & STFC Rutherford Appleton Laboratory
10 
11 \created May 12, 2005
12 
13 \cpright Copyright (c) 2003-2020, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15 */
16 //____________________________________________________________________________
17 
18 #ifndef _XSEC_SPLINE_LIST_H_
19 #define _XSEC_SPLINE_LIST_H_
20 
21 #include <ostream>
22 #include <map>
23 #include <set>
24 #include <vector>
25 #include <string>
26 
28 
29 using std::map;
30 using std::set;
31 using std::pair;
32 using std::vector;
33 using std::string;
34 using std::ostream;
35 
36 namespace genie {
37 
38 class XSecAlgorithmI;
39 class Interaction;
40 class Spline;
41 
42 class XSecSplineList;
43 ostream & operator << (ostream & stream, const XSecSplineList & xsl);
44 
46 
47 public:
48 
49  static XSecSplineList * Instance();
50 
51  // Save/load to/from XML file
52  void SaveAsXml (const string & filename, bool save_init = true) const;
53  XmlParserStatus_t LoadFromXml (const string & filename, bool keep = false);
54 
55  // Print available splines
56  void Print (ostream & stream) const;
57  friend ostream & operator << (ostream & stream, const XSecSplineList & xsl);
58 
59  // Set and query current tune.
60  // An XSecSplineList can keep splines for numerous tunes and pick the appropriate
61  // one for each process, as instructed.
62  void SetCurrentTune (const string & tune) { fCurrentTune = tune; }
63  string CurrentTune (void) const { return fCurrentTune; }
64  bool HasSplineFromTune( const string & tune ) const { return fSplineMap.count(tune) > 0 ; }
65 
66  // Query the existence, access or create a spline
67  // The results of the following methods depend on the current tune setting
68  bool SplineExists (const XSecAlgorithmI * alg, const Interaction * i) const;
69  bool SplineExists (string spline_key) const;
70  const Spline * GetSpline (const XSecAlgorithmI * alg, const Interaction * i) const;
71  const Spline * GetSpline (string spline_key) const;
72  void CreateSpline (const XSecAlgorithmI * alg, const Interaction * i,
73  int nknots = -1, double e_min = -1, double e_max = -1);
74  int NSplines (void) const;
75  bool IsEmpty (void) const;
76 
77  // Methods for building / getting keys
78  // The results of the following methods depend on the current tune setting
79  string BuildSplineKey(const XSecAlgorithmI * alg, const Interaction * i) const;
80  const vector<string> * GetSplineKeys(void) const;
81 
82 
83  // XSecSplineList options
84  void SetLogE (bool on); ///< set opt to build splines as f(E) or as f(logE)
85  void SetNKnots (int nk); ///< set default number of knots for building the spline
86  void SetMinE (double Ev); ///< set default minimum energy for xsec splines
87  void SetMaxE (double Ev); ///< set default maximum energy for xsec splines
88  bool UseLogE (void) const { return fUseLogE; }
89  int NKnots (void) const { return fNKnots; }
90  double Emin (void) const { return fEmin; }
91  double Emax (void) const { return fEmax; }
92 
93 private:
94 
96  XSecSplineList(const XSecSplineList & spline_list);
97  virtual ~XSecSplineList();
98 
100 
101  bool fUseLogE;
102  int fNKnots;
103  double fEmin;
104  double fEmax;
105 
106  string fCurrentTune; ///< The `active' tune, out the many that can co-exist
107 
108  map<string, map<string, Spline *> > fSplineMap; ///< tune -> { xsec_alg/xsec_config/interaction -> Spline }
109  map<string, set<string> > fLoadedSplineSet; ///< tune -> { set of initialy loaded splines }
110 
111  struct Cleaner {
114  if (XSecSplineList::fInstance !=0) {
117  }
118  }
119  };
120  friend struct Cleaner;
121 };
122 
123 } // genie namespace
124 
125 #endif // _XSEC_SPLINE_LIST_H_
Cross Section Calculation Interface.
string BuildSplineKey(const XSecAlgorithmI *alg, const Interaction *i) const
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
bool UseLogE(void) const
void CreateSpline(const XSecAlgorithmI *alg, const Interaction *i, int nknots=-1, double e_min=-1, double e_max=-1)
const vector< string > * GetSplineKeys(void) const
std::string string
Definition: nybbler.cc:12
bool SplineExists(const XSecAlgorithmI *alg, const Interaction *i) const
A numeric analysis tool class for interpolating 1-D functions.
Definition: Spline.h:46
struct vector vector
void SetMinE(double Ev)
set default minimum energy for xsec splines
map< string, set< string > > fLoadedSplineSet
tune -> { set of initialy loaded splines }
int NSplines(void) const
static XSecSplineList * Instance()
string filename
Definition: train.py:213
void SetCurrentTune(const string &tune)
Summary information for an interaction.
Definition: Interaction.h:56
void Print(ostream &stream) const
bool IsEmpty(void) const
double Emin(void) const
void SetNKnots(int nk)
set default number of knots for building the spline
map< string, map< string, Spline * > > fSplineMap
tune -> { xsec_alg/xsec_config/interaction -> Spline }
int NKnots(void) const
string fCurrentTune
The `active&#39; tune, out the many that can co-exist.
void SaveAsXml(const string &filename, bool save_init=true) const
friend ostream & operator<<(ostream &stream, const XSecSplineList &xsl)
double Emax(void) const
bool HasSplineFromTune(const string &tune) const
static XSecSplineList * fInstance
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
void SetLogE(bool on)
set opt to build splines as f(E) or as f(logE)
string CurrentTune(void) const
void SetMaxE(double Ev)
set default maximum energy for xsec splines
enum genie::EXmlParseStatus XmlParserStatus_t
const Spline * GetSpline(const XSecAlgorithmI *alg, const Interaction *i) const
List of cross section vs energy splines.
XmlParserStatus_t LoadFromXml(const string &filename, bool keep=false)