CMS 3D CMS Logo

ExpressionFunctionSetter.cc
Go to the documentation of this file.
5 #include <cmath>
6 #include <Math/ProbFuncMathCore.h>
9 
10 namespace reco {
11  namespace parser {
12  struct abs_f {
13  double operator()(double x) const { return fabs(x); }
14  };
15  struct acos_f {
16  double operator()(double x) const { return acos(x); }
17  };
18  struct asin_f {
19  double operator()(double x) const { return asin(x); }
20  };
21  struct atan_f {
22  double operator()(double x) const { return atan(x); }
23  };
24  struct atan2_f {
25  double operator()(double x, double y) const { return atan2(x, y); }
26  };
27  struct chi2prob_f {
28  double operator()(double x, double y) const { return ROOT::Math::chisquared_cdf_c(x, y); }
29  };
30  struct cos_f {
31  double operator()(double x) const { return cos(x); }
32  };
33  struct cosh_f {
34  double operator()(double x) const { return cosh(x); }
35  };
36  struct deltaR_f {
37  double operator()(double e1, double p1, double e2, double p2) const { return reco::deltaR(e1, p1, e2, p2); }
38  };
39  struct deltaPhi_f {
40  double operator()(double p1, double p2) const { return reco::deltaPhi(p1, p2); }
41  };
42  struct exp_f {
43  double operator()(double x) const { return exp(x); }
44  };
45  struct hypot_f {
46  double operator()(double x, double y) const { return hypot(x, y); }
47  };
48  struct log_f {
49  double operator()(double x) const { return log(x); }
50  };
51  struct log10_f {
52  double operator()(double x) const { return log10(x); }
53  };
54  struct max_f {
55  double operator()(double x, double y) const { return std::max(x, y); }
56  };
57  struct min_f {
58  double operator()(double x, double y) const { return std::min(x, y); }
59  };
60  struct pow_f {
61  double operator()(double x, double y) const { return pow(x, y); }
62  };
63  struct sin_f {
64  double operator()(double x) const { return sin(x); }
65  };
66  struct sinh_f {
67  double operator()(double x) const { return sinh(x); }
68  };
69  struct sqrt_f {
70  double operator()(double x) const { return sqrt(x); }
71  };
72  struct tan_f {
73  double operator()(double x) const { return tan(x); }
74  };
75  struct tanh_f {
76  double operator()(double x) const { return tanh(x); }
77  };
78  struct test_bit_f {
79  double operator()(double mask, double iBit) const { return (int(mask) >> int(iBit)) & 1; }
80  };
81  } // namespace parser
82 } // namespace reco
83 
84 using namespace reco::parser;
85 
86 void ExpressionFunctionSetter::operator()(const char *, const char *) const {
87  Function fun = funStack_.back();
88  funStack_.pop_back();
89  ExpressionPtr funExp;
90  switch (fun) {
91  case (kAbs):
92  funExp.reset(new ExpressionUnaryOperator<abs_f>(expStack_));
93  break;
94  case (kAcos):
95  funExp.reset(new ExpressionUnaryOperator<acos_f>(expStack_));
96  break;
97  case (kAsin):
98  funExp.reset(new ExpressionUnaryOperator<asin_f>(expStack_));
99  break;
100  case (kAtan):
101  funExp.reset(new ExpressionUnaryOperator<atan_f>(expStack_));
102  break;
103  case (kAtan2):
104  funExp.reset(new ExpressionBinaryOperator<atan2_f>(expStack_));
105  break;
106  case (kChi2Prob):
108  break;
109  case (kCos):
110  funExp.reset(new ExpressionUnaryOperator<cos_f>(expStack_));
111  break;
112  case (kCosh):
113  funExp.reset(new ExpressionUnaryOperator<cosh_f>(expStack_));
114  break;
115  case (kDeltaR):
117  break;
118  case (kDeltaPhi):
120  break;
121  case (kExp):
122  funExp.reset(new ExpressionUnaryOperator<exp_f>(expStack_));
123  break;
124  case (kHypot):
125  funExp.reset(new ExpressionBinaryOperator<hypot_f>(expStack_));
126  break;
127  case (kLog):
128  funExp.reset(new ExpressionUnaryOperator<log_f>(expStack_));
129  break;
130  case (kLog10):
131  funExp.reset(new ExpressionUnaryOperator<log10_f>(expStack_));
132  break;
133  case (kMax):
134  funExp.reset(new ExpressionBinaryOperator<max_f>(expStack_));
135  break;
136  case (kMin):
137  funExp.reset(new ExpressionBinaryOperator<min_f>(expStack_));
138  break;
139  case (kPow):
140  funExp.reset(new ExpressionBinaryOperator<pow_f>(expStack_));
141  break;
142  case (kSin):
143  funExp.reset(new ExpressionUnaryOperator<sin_f>(expStack_));
144  break;
145  case (kSinh):
146  funExp.reset(new ExpressionUnaryOperator<sinh_f>(expStack_));
147  break;
148  case (kSqrt):
149  funExp.reset(new ExpressionUnaryOperator<sqrt_f>(expStack_));
150  break;
151  case (kTan):
152  funExp.reset(new ExpressionUnaryOperator<tan_f>(expStack_));
153  break;
154  case (kTanh):
155  funExp.reset(new ExpressionUnaryOperator<tanh_f>(expStack_));
156  break;
157  case (kTestBit):
159  break;
160  };
161  expStack_.push_back(funExp);
162 }
reco::parser::kLog
Definition: Function.h:29
reco::parser::abs_f
Definition: ExpressionFunctionSetter.cc:12
reco::parser::tanh_f
Definition: ExpressionFunctionSetter.cc:75
reco::parser::kSin
Definition: Function.h:34
reco::parser::kCosh
Definition: Function.h:26
reco::parser::chi2prob_f::operator()
double operator()(double x, double y) const
Definition: ExpressionFunctionSetter.cc:28
reco::parser::kTanh
Definition: Function.h:38
reco::parser::kAcos
Definition: Function.h:20
reco::parser::atan2_f
Definition: ExpressionFunctionSetter.cc:24
min
T min(T a, T b)
Definition: MathUtil.h:58
reco::deltaPhi
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
deltaPhi.h
reco::parser::test_bit_f::operator()
double operator()(double mask, double iBit) const
Definition: ExpressionFunctionSetter.cc:79
reco::parser::acos_f
Definition: ExpressionFunctionSetter.cc:15
reco::parser::sinh_f
Definition: ExpressionFunctionSetter.cc:66
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
reco::parser::test_bit_f
Definition: ExpressionFunctionSetter.cc:78
reco::parser::kHypot
Definition: Function.h:28
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
reco::parser::ExpressionFunctionSetter::funStack_
FunctionStack & funStack_
Definition: ExpressionFunctionSetter.h:24
reco::parser::asin_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:19
reco::parser::acos_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:16
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
reco::parser::log_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:49
reco::parser::sin_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:64
reco::parser::min_f
Definition: ExpressionFunctionSetter.cc:57
reco::parser::ExpressionQuaterOperator
Definition: ExpressionQuaterOperator.h:19
reco::parser::kMax
Definition: Function.h:31
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
reco::parser::kCos
Definition: Function.h:25
reco::parser::kAsin
Definition: Function.h:21
reco::parser::exp_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:43
reco::parser::kDeltaR
Definition: Function.h:39
ExpressionQuaterOperator.h
reco::parser::tan_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:73
reco::parser::log10_f
Definition: ExpressionFunctionSetter.cc:51
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::parser::kDeltaPhi
Definition: Function.h:40
reco::parser::atan_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:22
p2
double p2[4]
Definition: TauolaWrapper.h:90
reco::parser::log10_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:52
reco::parser::min_f::operator()
double operator()(double x, double y) const
Definition: ExpressionFunctionSetter.cc:58
reco::parser::deltaR_f::operator()
double operator()(double e1, double p1, double e2, double p2) const
Definition: ExpressionFunctionSetter.cc:37
reco::parser::chi2prob_f
Definition: ExpressionFunctionSetter.cc:27
reco::parser::max_f
Definition: ExpressionFunctionSetter.cc:54
reco::parser::log_f
Definition: ExpressionFunctionSetter.cc:48
reco::parser::cosh_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:34
reco::parser::deltaR_f
Definition: ExpressionFunctionSetter.cc:36
reco::parser::tan_f
Definition: ExpressionFunctionSetter.cc:72
reco::parser::sqrt_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:70
reco::parser::kAtan
Definition: Function.h:22
reco::parser::ExpressionBinaryOperator
Definition: ExpressionBinaryOperator.h:19
deltaR.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
reco::parser::kSqrt
Definition: Function.h:36
reco::parser::hypot_f
Definition: ExpressionFunctionSetter.cc:45
StorageManager_cfg.e1
e1
Definition: StorageManager_cfg.py:16
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
reco::parser::sinh_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:67
reco::parser::abs_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:13
p1
double p1[4]
Definition: TauolaWrapper.h:89
reco::parser::atan_f
Definition: ExpressionFunctionSetter.cc:21
reco::parser::ExpressionPtr
std::shared_ptr< ExpressionBase > ExpressionPtr
Definition: ExpressionBase.h:25
ExpressionFunctionSetter.h
ExpressionUnaryOperator.h
reco::parser::kChi2Prob
Definition: Function.h:24
reco::parser::sin_f
Definition: ExpressionFunctionSetter.cc:63
reco::parser::kAbs
Definition: Function.h:19
reco::parser::asin_f
Definition: ExpressionFunctionSetter.cc:18
reco::parser::exp_f
Definition: ExpressionFunctionSetter.cc:42
reco::parser
Definition: cutParser.h:9
reco::parser::ExpressionFunctionSetter::operator()
void operator()(const char *, const char *) const
Definition: ExpressionFunctionSetter.cc:86
reco::parser::kTan
Definition: Function.h:37
reco::parser::sqrt_f
Definition: ExpressionFunctionSetter.cc:69
reco::parser::cosh_f
Definition: ExpressionFunctionSetter.cc:33
reco::parser::kAtan2
Definition: Function.h:23
reco::parser::kMin
Definition: Function.h:32
reco::parser::deltaPhi_f
Definition: ExpressionFunctionSetter.cc:39
reco::parser::ExpressionFunctionSetter::expStack_
ExpressionStack & expStack_
Definition: ExpressionFunctionSetter.h:23
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
reco::parser::ExpressionUnaryOperator
Definition: ExpressionUnaryOperator.h:19
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
ExpressionBinaryOperator.h
reco::parser::cos_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:31
reco::parser::tanh_f::operator()
double operator()(double x) const
Definition: ExpressionFunctionSetter.cc:76
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
reco::parser::hypot_f::operator()
double operator()(double x, double y) const
Definition: ExpressionFunctionSetter.cc:46
reco::parser::kExp
Definition: Function.h:27
reco::parser::pow_f::operator()
double operator()(double x, double y) const
Definition: ExpressionFunctionSetter.cc:61
reco::parser::pow_f
Definition: ExpressionFunctionSetter.cc:60
reco::parser::kTestBit
Definition: Function.h:41
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
reco::parser::Function
Function
Definition: Function.h:18
reco::parser::kLog10
Definition: Function.h:30
reco::parser::kPow
Definition: Function.h:33
reco::parser::kSinh
Definition: Function.h:35
reco::parser::atan2_f::operator()
double operator()(double x, double y) const
Definition: ExpressionFunctionSetter.cc:25
reco::parser::deltaPhi_f::operator()
double operator()(double p1, double p2) const
Definition: ExpressionFunctionSetter.cc:40
reco::parser::max_f::operator()
double operator()(double x, double y) const
Definition: ExpressionFunctionSetter.cc:55
reco::parser::cos_f
Definition: ExpressionFunctionSetter.cc:30