RunOpt.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::RunOpt
5 
6 \brief Some common run-time GENIE options.
7 
8 \author Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
9  University of Liverpool & STFC Rutherford Appleton Lab
10 
11 \created January 29, 2013
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 _RUN_OPT_H_
20 #define _RUN_OPT_H_
21 
22 #include <iostream>
23 #include <string>
24 
25 #include "Framework/Utils/TuneId.h"
26 
27 class TBits;
28 
29 using std::ostream;
30 
31 namespace genie {
32 
33 class RunOpt;
34 ostream & operator << (ostream & stream, const RunOpt & opt);
35 
36 class RunOpt
37 {
38 public:
39  static RunOpt * Instance(void);
40 
41  // Read options from the command line. Call from all GENIE command-line apps.
42  void ReadFromCommandLine(int argc, char ** argv);
43 
44  // Get options set.
45  TuneId * Tune (void) const { return fTune; }
46  string EventGeneratorList (void) const { return fEventGeneratorList; }
47  string CacheFile (void) const { return fCacheFile; }
48  string MesgThresholdFiles (void) const { return fMesgThresholds; }
49  TBits* UnphysEventMask (void) const { return fUnphysEventMask; }
50  int EventRecordPrintLevel (void) const { return fEventRecordPrintLevel; }
51  int MCJobStatusRefreshRate (void) const { return fMCJobStatusRefreshRate; }
52  bool BareXSecPreCalc (void) const { return fEnableBareXSecPreCalc; }
53  string XMLPath (void) const { return fXMLPath; }
54 
55  // If a user accesses the GENIE objects directly, then most of the options above
56  // can be set directly to the relevant objects (Messenger, Cache, etc).
57  //
58  void SetTuneName(string tuneName="Default");
59  void BuildTune(); ///< build tune and inform XSecSplineList
60  void SetEventGeneratorList(string evgenlist) { fEventGeneratorList = evgenlist; }
61  void EnableBareXSecPreCalc(bool flag) { fEnableBareXSecPreCalc = flag; }
62 
63  // Print
64  void Print (ostream & stream) const;
65  friend ostream & operator << (ostream & stream, const RunOpt & opt);
66 
67 private:
68 
69  void Init (void);
70 
71  // options
72  TuneId * fTune; ///< GENIE comprehensive neutrino interaction model tune.
73  string fEventGeneratorList; ///< Name of event generator list to be loaded by the event generation drivers.
74  string fCacheFile; ///< Name of cache file, is cache is to be re-used.
75  string fMesgThresholds; ///< List of files (delimited with : if more than one) with custom mesg stream thresholds.
76  TBits* fUnphysEventMask; ///< Unphysical event mask.
77  int fEventRecordPrintLevel; ///< GHEP event r ecord print level.
78  int fMCJobStatusRefreshRate; ///< MC job status file refresh rate.
79  bool fEnableBareXSecPreCalc; ///< Cache calcs relevant to free-nucleon xsecs before any nuclear xsec computation?
80  ///< The option switches on/off cacheing calculations which interfere with event reweighting.
81  string fXMLPath; ///< An path to look for XML in. Higher priority than GXMLPATH
82 
83  // Self
84  static RunOpt * fInstance;
85 
86  // Singleton class: constructors are private
87  RunOpt();
88  RunOpt(const RunOpt & opt);
89  virtual ~RunOpt();
90 
91  // Clean-up
92  struct Cleaner {
95  if (RunOpt::fInstance !=0) {
96  delete RunOpt::fInstance;
98  }
99  }
100  };
101  friend struct Cleaner;
102 };
103 
104 } // genie namespace
105 #endif // _RUN_OPT_H_
string EventGeneratorList(void) const
Definition: RunOpt.h:46
TuneId * Tune(void) const
Definition: RunOpt.h:45
static RunOpt * fInstance
Definition: RunOpt.h:84
string CacheFile(void) const
Definition: RunOpt.h:47
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
string fMesgThresholds
List of files (delimited with : if more than one) with custom mesg stream thresholds.
Definition: RunOpt.h:75
void ReadFromCommandLine(int argc, char **argv)
Definition: RunOpt.cxx:107
string fCacheFile
Name of cache file, is cache is to be re-used.
Definition: RunOpt.h:74
TBits * UnphysEventMask(void) const
Definition: RunOpt.h:49
int fEventRecordPrintLevel
GHEP event r ecord print level.
Definition: RunOpt.h:77
string MesgThresholdFiles(void) const
Definition: RunOpt.h:48
void SetEventGeneratorList(string evgenlist)
Definition: RunOpt.h:60
void Init(void)
Definition: RunOpt.cxx:72
Some common run-time GENIE options.
Definition: RunOpt.h:36
TBits * fUnphysEventMask
Unphysical event mask.
Definition: RunOpt.h:76
bool BareXSecPreCalc(void) const
Definition: RunOpt.h:52
friend ostream & operator<<(ostream &stream, const RunOpt &opt)
Definition: RunOpt.cxx:40
int fMCJobStatusRefreshRate
MC job status file refresh rate.
Definition: RunOpt.h:78
TuneId * fTune
GENIE comprehensive neutrino interaction model tune.
Definition: RunOpt.h:72
string XMLPath(void) const
Definition: RunOpt.h:53
void BuildTune()
build tune and inform XSecSplineList
Definition: RunOpt.cxx:100
bool fEnableBareXSecPreCalc
Definition: RunOpt.h:79
string fEventGeneratorList
Name of event generator list to be loaded by the event generation drivers.
Definition: RunOpt.h:73
virtual ~RunOpt()
Definition: RunOpt.cxx:55
static RunOpt * Instance(void)
Definition: RunOpt.cxx:62
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
GENIE tune ID.
Definition: TuneId.h:38
int EventRecordPrintLevel(void) const
Definition: RunOpt.h:50
void DummyMethodAndSilentCompiler()
Definition: RunOpt.h:93
void EnableBareXSecPreCalc(bool flag)
Definition: RunOpt.h:61
void Print(ostream &stream) const
Definition: RunOpt.cxx:165
void SetTuneName(string tuneName="Default")
Definition: RunOpt.cxx:89
int MCJobStatusRefreshRate(void) const
Definition: RunOpt.h:51
string fXMLPath
An path to look for XML in. Higher priority than GXMLPATH.
Definition: RunOpt.h:81