22 #include "Exception.hh"
24 #include "GeometryHandler.hh"
49 { os << global.
_val;
return os; }
52 bool AsBool()
const {
return (
bool)strtol(&
_val[0], NULL, 10); }
55 int AsInt()
const {
return (
int)strtol(&
_val[0], NULL, 10); }
61 long int AsBase(
int base)
const {
return strtol(&
_val[0], NULL, base); }
82 operator bool()
const {
return AsBool(); }
85 operator int()
const {
return AsInt(); }
91 operator size_t()
const {
return (
size_t)
AsLongInt(); }
94 operator float()
const {
return AsFloat(); }
100 operator std::string()
const {
return _val; }
162 void LoadFile(std::string filename);
void SetDefaultStyle()
Sets the default style of the ROOT plots.
Definition: Globals.cc:199
const Global & operator[](const std::string &var) const
Returns the requested global variable.
Definition: Globals.cc:42
std::vector< std::string > _data_files
List of runs (remaining arguments)
Definition: Globals.hh:179
bool operator!() const
Overload the unary ! operator.
Definition: Globals.hh:79
double AsDouble() const
Returns the variable as a double.
Definition: Globals.hh:67
Global()
Default constructor, initializes everything to 0.
Definition: Globals.hh:32
std::string _des
Description of the global variable.
Definition: Globals.hh:105
const std::string & AsString() const
Returns the variable as an std::string.
Definition: Globals.hh:76
Globals & operator=(const Globals &globals)
Equality operator, not implemented for singleton.
Global(const std::string &val)
Proper constructor.
Definition: Globals.hh:35
int AsInt() const
Returns the variable as an int.
Definition: Globals.hh:55
Imports, stores and manages the global variables.
Definition: Globals.hh:116
friend std::ostream & operator<<(std::ostream &os, const Global &global)
Overloads the ostream operator.
Definition: Globals.hh:48
Stores the positions of all the requested MICE detectors.
Definition: GeometryHandler.hh:109
const GeometryHandler & GetGeometryHandler() const
Returns the geometry handelr.
Definition: Globals.hh:131
const Global & operator()(const std::string &var) const
Returns the requested global variable.
Definition: Globals.cc:31
bool AsBool() const
Returns the variable as a bool.
Definition: Globals.hh:52
Global & operator=(const Global &global)
Equality operator.
Definition: Globals.hh:41
std::string _val
Global variable stored as an std::string.
Definition: Globals.hh:104
GeometryHandler _geoh
Geometry handler.
Definition: Globals.hh:180
long int AsBase(int base) const
Returns the variable as an int in the requested base.
Definition: Globals.hh:61
const std::vector< std::string > & GetDataFiles() const
Returns the list of data files.
Definition: Globals.hh:128
void LoadGeometry()
Loads the geometry handler.
Definition: Globals.cc:180
static Globals & GetInstance(int argc=0, char **argv=NULL)
Returns the single instance of the class, initialize if not yet done.
Definition: Globals.cc:3
Global(const Global &global)
Copy constructor.
Definition: Globals.hh:38
void LoadCommandLine(int argc, char **argv)
Load the extra arguments from the command line arguments.
Definition: Globals.cc:102
std::map< std::string, Global > _globals
Dictionary of global variables.
Definition: Globals.hh:178
Globals(int argc, char **argv)
Command line construct, takes extra arguments from the command line.
Definition: Globals.cc:10
float AsFloat() const
Returns the variable as a float.
Definition: Globals.hh:64
void SetDescription(const std::string &des)
Sets the decription of the varibale.
Definition: Globals.hh:70
long int AsLongInt() const
Returns the variable as a long int.
Definition: Globals.hh:58
~Globals()
Destructor.
Definition: Globals.cc:29
void Print(Pitch::errorLevel level=Pitch::info) const
Print the list of datacards and their value.
Definition: Globals.cc:53
Represents a single global variable and defines the methods to read it.
Definition: Globals.hh:28
errorLevel
Error level that determines where the output goes.
Definition: Pitch.hh:43
void LoadFile(std::string filename)
Loads the global constants from a datacards file.
Definition: Globals.cc:67
~Global()
Destructor.
Definition: Globals.hh:45
const std::string & Description() const
Returns the decription of the varibale.
Definition: Globals.hh:73