Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
|
#include <Evaluator.h>
Public Member Functions | |
Evaluator () | |
~Evaluator () | |
double | evaluate (const char *expression) |
int | status () const |
int | error_position () const |
void | print_error () const |
std::string | error_name () const |
void | setVariable (const char *name, double value) |
void | setVariable (const char *name, const char *expression) |
void | setFunction (const char *name, double(*fun)()) |
void | setFunction (const char *name, double(*fun)(double)) |
void | setFunction (const char *name, double(*fun)(double, double)) |
void | setFunction (const char *name, double(*fun)(double, double, double)) |
void | setFunction (const char *name, double(*fun)(double, double, double, double)) |
void | setFunction (const char *name, double(*fun)(double, double, double, double, double)) |
bool | findVariable (const char *name) const |
bool | findFunction (const char *name, int npar) const |
void | removeVariable (const char *name) |
void | removeFunction (const char *name, int npar) |
void | clear () |
void | setStdMath () |
void | setSystemOfUnits (double meter=1.0, double kilogram=1.0, double second=1.0, double ampere=1.0, double kelvin=1.0, double mole=1.0, double candela=1.0) |
Evaluator of arithmetic expressions with an extendable dictionary. Example:
Definition at line 25 of file Evaluator.h.
anonymous enum |
List of possible statuses. Status of the last operation can be obtained with status(). In case if status() is an ERROR the corresponding error message can be printed with print_error().
Definition at line 38 of file Evaluator.h.
HepTool::Evaluator::Evaluator | ( | ) |
Constructor.
Definition at line 601 of file Evaluator.cc.
HepTool::Evaluator::~Evaluator | ( | ) |
void HepTool::Evaluator::clear | ( | ) |
Clear all settings.
Definition at line 767 of file Evaluator.cc.
Referenced by G4GDMLEvaluator::Clear(), and G4GDMLEvaluator::G4GDMLEvaluator().
std::string HepTool::Evaluator::error_name | ( | ) | const |
get a string defining the error name
Definition at line 655 of file Evaluator.cc.
Referenced by print_error().
int HepTool::Evaluator::error_position | ( | ) | const |
Returns position in the input string where the problem occured.
Definition at line 641 of file Evaluator.cc.
double HepTool::Evaluator::evaluate | ( | const char * | expression | ) |
Evaluates the arithmetic expression given as character string. The expression may consist of numbers, variables and functions separated by arithmetic (+, - , /, *, ^, **) and logical operators (==, !=, >, >=, <, <=, &&, ||).
expression | input expression. |
Definition at line 616 of file Evaluator.cc.
Referenced by G4GDMLEvaluator::Evaluate(), and G4tgrUtils::GetDouble().
bool HepTool::Evaluator::findFunction | ( | const char * | name, |
int | npar ) const |
Finds the function in the dictionary.
name | name of the function to be unset. |
npar | number of parameters of the function. |
Definition at line 737 of file Evaluator.cc.
bool HepTool::Evaluator::findVariable | ( | const char * | name | ) | const |
Finds the variable in the dictionary.
name | name of the variable. |
Definition at line 726 of file Evaluator.cc.
Referenced by G4GDMLEvaluator::DefineConstant(), G4GDMLEvaluator::DefineVariable(), and G4GDMLEvaluator::GetConstant().
void HepTool::Evaluator::print_error | ( | ) | const |
Prints error message if status() is an ERROR.
Definition at line 646 of file Evaluator.cc.
Referenced by G4GDMLEvaluator::Evaluate(), and G4tgrEvaluator::print_error().
void HepTool::Evaluator::removeFunction | ( | const char * | name, |
int | npar ) |
Removes the function from the dictionary.
name | name of the function to be unset. |
npar | number of parameters of the function. |
Definition at line 757 of file Evaluator.cc.
void HepTool::Evaluator::removeVariable | ( | const char * | name | ) |
Removes the variable from the dictionary.
name | name of the variable. |
Definition at line 748 of file Evaluator.cc.
void HepTool::Evaluator::setFunction | ( | const char * | name, |
double(* | fun )() ) |
Adds to the dictionary a function without parameters. If such a function already exist in the dictionary, then status will be set to WARNING_EXISTING_FUNCTION.
name | function name. |
fun | pointer to the real function in the user code. |
Definition at line 701 of file Evaluator.cc.
Referenced by setStdMath().
void HepTool::Evaluator::setFunction | ( | const char * | name, |
double(* | fun )(double) ) |
Adds to the dictionary a function with one parameter. If such a function already exist in the dictionary, then status will be set to WARNING_EXISTING_FUNCTION.
name | function name. |
fun | pointer to the real function in the user code. |
Definition at line 705 of file Evaluator.cc.
void HepTool::Evaluator::setFunction | ( | const char * | name, |
double(* | fun )(double, double) ) |
Adds to the dictionary a function with two parameters. If such a function already exist in the dictionary, then status will be set to WARNING_EXISTING_FUNCTION.
name | function name. |
fun | pointer to the real function in the user code. |
Definition at line 709 of file Evaluator.cc.
void HepTool::Evaluator::setFunction | ( | const char * | name, |
double(* | fun )(double, double, double) ) |
Adds to the dictionary a function with three parameters. If such a function already exist in the dictionary, then status will be set to WARNING_EXISTING_FUNCTION.
name | function name. |
fun | pointer to the real function in the user code. |
Definition at line 713 of file Evaluator.cc.
void HepTool::Evaluator::setFunction | ( | const char * | name, |
double(* | fun )(double, double, double, double) ) |
Adds to the dictionary a function with four parameters. If such a function already exist in the dictionary, then status will be set to WARNING_EXISTING_FUNCTION.
name | function name. |
fun | pointer to the real function in the user code. |
Definition at line 717 of file Evaluator.cc.
void HepTool::Evaluator::setFunction | ( | const char * | name, |
double(* | fun )(double, double, double, double, double) ) |
Adds to the dictionary a function with five parameters. If such a function already exist in the dictionary, then status will be set to WARNING_EXISTING_FUNCTION.
name | function name. |
fun | pointer to the real function in the user code. |
Definition at line 721 of file Evaluator.cc.
void HepTool::Evaluator::setStdMath | ( | ) |
Sets standard mathematical functions and constants.
Definition at line 29 of file setStdMath.cc.
Referenced by G4GDMLEvaluator::Clear(), and G4GDMLEvaluator::G4GDMLEvaluator().
void HepTool::Evaluator::setSystemOfUnits | ( | double | meter = 1.0, |
double | kilogram = 1.0, | ||
double | second = 1.0, | ||
double | ampere = 1.0, | ||
double | kelvin = 1.0, | ||
double | mole = 1.0, | ||
double | candela = 1.0 ) |
Sets system of units. Default is the SI system of units. To set the CGS (Centimeter-Gram-Second) system of units one should call: setSystemOfUnits(100., 1000., 1.0, 1.0, 1.0, 1.0, 1.0);
To set system of units accepted in the GEANT4 simulation toolkit one should call:
The basic units in GEANT4 are:
Definition at line 8 of file setSystemOfUnits.cc.
Referenced by G4GDMLEvaluator::Clear(), and G4GDMLEvaluator::G4GDMLEvaluator().
void HepTool::Evaluator::setVariable | ( | const char * | name, |
const char * | expression ) |
Adds to the dictionary a variable with an arithmetic expression assigned to it. If a variable with such a name already exist in the dictionary, then status will be set to WARNING_EXISTING_VARIABLE.
name | name of the variable. |
expression | arithmetic expression. |
Definition at line 695 of file Evaluator.cc.
void HepTool::Evaluator::setVariable | ( | const char * | name, |
double | value ) |
Adds to the dictionary a variable with given value. If a variable with such a name already exist in the dictionary, then status will be set to WARNING_EXISTING_VARIABLE.
name | name of the variable. |
value | value assigned to the variable. |
Definition at line 692 of file Evaluator.cc.
Referenced by G4GDMLEvaluator::DefineConstant(), G4GDMLEvaluator::DefineVariable(), setStdMath(), setSystemOfUnits(), and G4GDMLEvaluator::SetVariable().
int HepTool::Evaluator::status | ( | ) | const |
Returns status of the last operation with the evaluator.
Definition at line 636 of file Evaluator.cc.
Referenced by G4GDMLEvaluator::Evaluate(), and G4tgrUtils::GetDouble().