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 { double operator()( double x ) const { return fabs( x ); } };
13  struct acos_f { double operator()( double x ) const { return acos( x ); } };
14  struct asin_f { double operator()( double x ) const { return asin( x ); } };
15  struct atan_f { double operator()( double x ) const { return atan( x ); } };
16  struct atan2_f { double operator()( double x, double y ) const { return atan2( x, y ); } };
17  struct chi2prob_f { double operator()( double x, double y ) const { return ROOT::Math::chisquared_cdf_c( x, y ); } };
18  struct cos_f { double operator()( double x ) const { return cos( x ); } };
19  struct cosh_f { double operator()( double x ) const { return cosh( x ); } };
20  struct deltaR_f { double operator()( double e1, double p1, double e2, double p2 ) const { return reco::deltaR(e1,p1,e2,p2); } };
21  struct deltaPhi_f { double operator()( double p1, double p2 ) const { return reco::deltaPhi(p1,p2); } };
22  struct exp_f { double operator()( double x ) const { return exp( x ); } };
23  struct hypot_f { double operator()( double x, double y ) const { return hypot( x, y ); } };
24  struct log_f { double operator()( double x ) const { return log( x ); } };
25  struct log10_f { double operator()( double x ) const { return log10( x ); } };
26  struct max_f { double operator()( double x, double y ) const { return std::max( x, y ); } };
27  struct min_f { double operator()( double x, double y ) const { return std::min( x, y ); } };
28  struct pow_f { double operator()( double x, double y ) const { return pow( x, y ); } };
29  struct sin_f { double operator()( double x ) const { return sin( x ); } };
30  struct sinh_f { double operator()( double x ) const { return sinh( x ); } };
31  struct sqrt_f { double operator()( double x ) const { return sqrt( x ); } };
32  struct tan_f { double operator()( double x ) const { return tan( x ); } };
33  struct tanh_f { double operator()( double x ) const { return tanh( x ); } };
34  struct test_bit_f { double operator()( double mask, double iBit ) const { return (int(mask) >> int(iBit)) & 1; } };
35  }
36 }
37 
38 using namespace reco::parser;
39 
40 void ExpressionFunctionSetter::operator()( const char *, const char * ) const {
41  Function fun = funStack_.back(); funStack_.pop_back();
42  ExpressionPtr funExp;
43  switch( fun ) {
44  case( kAbs ) : funExp.reset( new ExpressionUnaryOperator <abs_f > ( expStack_ ) ); break;
45  case( kAcos ) : funExp.reset( new ExpressionUnaryOperator <acos_f > ( expStack_ ) ); break;
46  case( kAsin ) : funExp.reset( new ExpressionUnaryOperator <asin_f > ( expStack_ ) ); break;
47  case( kAtan ) : funExp.reset( new ExpressionUnaryOperator <atan_f > ( expStack_ ) ); break;
48  case( kAtan2 ) : funExp.reset( new ExpressionBinaryOperator<atan2_f> ( expStack_ ) ); break;
49  case( kChi2Prob ) : funExp.reset( new ExpressionBinaryOperator<chi2prob_f>( expStack_ ) ); break;
50  case( kCos ) : funExp.reset( new ExpressionUnaryOperator <cos_f > ( expStack_ ) ); break;
51  case( kCosh ) : funExp.reset( new ExpressionUnaryOperator <cosh_f > ( expStack_ ) ); break;
52  case( kDeltaR ) : funExp.reset( new ExpressionQuaterOperator<deltaR_f> ( expStack_ ) ); break;
53  case( kDeltaPhi ) : funExp.reset( new ExpressionBinaryOperator<deltaPhi_f>( expStack_ ) ); break;
54  case( kExp ) : funExp.reset( new ExpressionUnaryOperator <exp_f > ( expStack_ ) ); break;
55  case( kHypot ) : funExp.reset( new ExpressionBinaryOperator<hypot_f> ( expStack_ ) ); break;
56  case( kLog ) : funExp.reset( new ExpressionUnaryOperator <log_f > ( expStack_ ) ); break;
57  case( kLog10 ) : funExp.reset( new ExpressionUnaryOperator <log10_f> ( expStack_ ) ); break;
58  case( kMax ) : funExp.reset( new ExpressionBinaryOperator<max_f> ( expStack_ ) ); break;
59  case( kMin ) : funExp.reset( new ExpressionBinaryOperator<min_f> ( expStack_ ) ); break;
60  case( kPow ) : funExp.reset( new ExpressionBinaryOperator<pow_f > ( expStack_ ) ); break;
61  case( kSin ) : funExp.reset( new ExpressionUnaryOperator <sin_f > ( expStack_ ) ); break;
62  case( kSinh ) : funExp.reset( new ExpressionUnaryOperator <sinh_f > ( expStack_ ) ); break;
63  case( kSqrt ) : funExp.reset( new ExpressionUnaryOperator <sqrt_f > ( expStack_ ) ); break;
64  case( kTan ) : funExp.reset( new ExpressionUnaryOperator <tan_f > ( expStack_ ) ); break;
65  case( kTanh ) : funExp.reset( new ExpressionUnaryOperator <tanh_f > ( expStack_ ) ); break;
66  case( kTestBit ) : funExp.reset( new ExpressionBinaryOperator<test_bit_f>( expStack_ ) ); break;
67  };
68  expStack_.push_back( funExp );
69 }
double operator()(double x, double y) const
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
double operator()(double x) const
double operator()(double x) const
double operator()(double x) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double operator()(double x) const
double operator()(double x, double y) const
boost::shared_ptr< ExpressionBase > ExpressionPtr
double operator()(double mask, double iBit) const
double operator()(double x) const
double operator()(double p1, double p2) const
double operator()(double x, double y) const
double operator()(double x) const
T sqrt(T t)
Definition: SSEVec.h:18
double operator()(double x) const
double operator()(double x) const
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
T min(T a, T b)
Definition: MathUtil.h:58
double operator()(double x) const
double p2[4]
Definition: TauolaWrapper.h:90
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
double operator()(double x) const
double operator()(double e1, double p1, double e2, double p2) const
double operator()(double x, double y) const
fixed size matrix
double operator()(double x) const
double p1[4]
Definition: TauolaWrapper.h:89
double operator()(double x, double y) const
void operator()(const char *, const char *) const
double operator()(double x) const
double operator()(double x) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double operator()(double x, double y) const