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 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
void operator()(const char *, const char *) const
double operator()(double x) const
double operator()(double x) const
std::shared_ptr< ExpressionBase > ExpressionPtr
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double operator()(double x, double y) const
double operator()(double x) const
double operator()(double x, double y) const
constexpr uint32_t mask
Definition: gpuClustering.h:24
double operator()(double x) const
double operator()(double x) const
double operator()(double x) const
double operator()(double x, double y) const
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double operator()(double x) const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double operator()(double x) const
double operator()(double x) const
double operator()(double mask, double iBit) const
double operator()(double x) const
double operator()(double x, double y) const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
double operator()(double p1, double p2) const
double operator()(double x) const
double operator()(double x, double y) const
fixed size matrix
float x
double operator()(double x) const
double operator()(double x) const
double operator()(double e1, double p1, double e2, double p2) const
double operator()(double x) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
double operator()(double x, double y) const