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