ATLAS Offline Software
ExpressionEvaluator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef EXPRESSION_EVALUATOR_H
6 #define EXPRESSION_EVALUATOR_H
7 
8 #include "CLHEP/Evaluator/Evaluator.h"
9 
10 #include <string>
11 #include <vector>
12 #include <map>
13 
14 namespace AGDD {
15 
16 typedef std::map< std::string, double> ConstantsTable;
17 typedef std::map< std::string, double> PhysicalConstantsTable;
18 typedef std::map< std::string, std::string> ExpressionsTable;
19 
21 {
22 public:
25 
26  bool RegisterConstant( std::string& c, double v );
27  bool RegisterPhysConstant( std::string&, const std::string&, const std::string& );
28  bool RegisterExpression( std::string& c, const std::string& v );
29  bool RegisterArray( std::string& c, const std::vector<double>& v );
30  bool RegisterVariable( const std::string& var_name, double value);
31 
32  double EvaluateString(const std::string& str);
33  bool is_delimiter(char c);
34  bool is_real_variable(const std::string& var_name);
35  double Eval( const std::string& expr );
36  double Eval( const char* expr );
37 
38  static std::string trim(const std::string&);
39  static std::vector<std::string> tokenize(const std::string&,const std::string&);
40 
41  void setFileCurrentlyParsed(const std::string& set)
42  {
44  }
45 
46 private:
47  HepTool::Evaluator m_calc;
50  std::string m_fileCurrentlyParsed;
51  std::vector<std::string> m_real_vars;
52 };
53 
54 } // namespace AGDD
55 
56 #endif // EXPRESSION_EVALUATOR_H
57 
AGDD::ExpressionEvaluator::trim
static std::string trim(const std::string &)
Definition: ExpressionEvaluator.cxx:276
CheckAppliedSFs.var_name
var_name
Definition: CheckAppliedSFs.py:241
AGDD::ExpressionEvaluator::ExpressionEvaluator
ExpressionEvaluator()
Definition: ExpressionEvaluator.cxx:17
AGDD::ConstantsTable
std::map< std::string, double > ConstantsTable
Definition: ExpressionEvaluator.h:16
athena.value
value
Definition: athena.py:122
AGDD::ExpressionEvaluator::is_real_variable
bool is_real_variable(const std::string &var_name)
Definition: ExpressionEvaluator.cxx:70
AGDD
Definition: ExpressionEvaluator.h:14
AGDD::ExpressionEvaluator::m_calc
HepTool::Evaluator m_calc
Definition: ExpressionEvaluator.h:47
AGDD::ExpressionEvaluator::RegisterConstant
bool RegisterConstant(std::string &c, double v)
Definition: ExpressionEvaluator.cxx:33
AGDD::ExpressionEvaluator::RegisterArray
bool RegisterArray(std::string &c, const std::vector< double > &v)
Definition: ExpressionEvaluator.cxx:48
AGDD::ExpressionEvaluator::m_PCTable
PhysicalConstantsTable m_PCTable
Definition: ExpressionEvaluator.h:49
AGDD::ExpressionsTable
std::map< std::string, std::string > ExpressionsTable
Definition: ExpressionEvaluator.h:18
AGDD::ExpressionEvaluator::m_real_vars
std::vector< std::string > m_real_vars
Definition: ExpressionEvaluator.h:51
AGDD::ExpressionEvaluator::setFileCurrentlyParsed
void setFileCurrentlyParsed(const std::string &set)
Definition: ExpressionEvaluator.h:41
AGDD::ExpressionEvaluator::~ExpressionEvaluator
~ExpressionEvaluator()
Definition: ExpressionEvaluator.cxx:26
AGDD::ExpressionEvaluator::RegisterVariable
bool RegisterVariable(const std::string &var_name, double value)
Definition: ExpressionEvaluator.cxx:63
AGDD::ExpressionEvaluator::m_fileCurrentlyParsed
std::string m_fileCurrentlyParsed
Definition: ExpressionEvaluator.h:50
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
AGDD::ExpressionEvaluator::m_CTable
ConstantsTable m_CTable
Definition: ExpressionEvaluator.h:48
AGDD::ExpressionEvaluator::tokenize
static std::vector< std::string > tokenize(const std::string &, const std::string &)
Definition: ExpressionEvaluator.cxx:297
AGDD::ExpressionEvaluator::RegisterExpression
bool RegisterExpression(std::string &c, const std::string &v)
Definition: ExpressionEvaluator.cxx:172
python.PyAthena.v
v
Definition: PyAthena.py:157
AGDD::ExpressionEvaluator::is_delimiter
bool is_delimiter(char c)
Definition: ExpressionEvaluator.cxx:89
AGDD::ExpressionEvaluator::EvaluateString
double EvaluateString(const std::string &str)
Definition: ExpressionEvaluator.cxx:95
AGDD::ExpressionEvaluator::Eval
double Eval(const std::string &expr)
Definition: ExpressionEvaluator.cxx:191
AGDD::ExpressionEvaluator::RegisterPhysConstant
bool RegisterPhysConstant(std::string &, const std::string &, const std::string &)
Definition: ExpressionEvaluator.cxx:150
AGDD::PhysicalConstantsTable
std::map< std::string, double > PhysicalConstantsTable
Definition: ExpressionEvaluator.h:17
str
Definition: BTagTrackIpAccessor.cxx:11
AGDD::ExpressionEvaluator
Definition: ExpressionEvaluator.h:21
python.compressB64.c
def c
Definition: compressB64.py:93