CMS 3D CMS Logo

Ratio.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Ratio_h
2 #define PhysicsTools_Utilities_Ratio_h
3 
4 namespace funct {
5  template <typename A, typename B>
6  struct RatioStruct {
7  RatioStruct(const A& a, const B& b) : _1(a), _2(b) {}
8  double operator()() const { return _1() / _2(); }
9  operator double() const { return _1() / _2(); }
10  double operator()(double x) const { return _1(x) / _2(x); }
11  double operator()(double x, double y) const { return _1(x, y) / _2(x, y); }
12  A _1;
13  B _2;
14  };
15 
16  template <typename A, typename B>
17  struct Ratio {
19  static type combine(const A& a, const B& b) { return type(a, b); }
20  };
21 
22  template <typename A, typename B>
23  inline typename Ratio<A, B>::type operator/(const A& a, const B& b) {
24  return Ratio<A, B>::combine(a, b);
25  }
26 
27 } // namespace funct
28 
29 #endif
RatioStruct(const A &a, const B &b)
Definition: Ratio.h:7
Definition: Abs.h:5
Ratio< A, B >::type operator/(const A &a, const B &b)
Definition: Ratio.h:23
TEMPL(T2) struct Divides B
Definition: Factorize.h:24
double operator()(double x, double y) const
Definition: Ratio.h:11
double operator()() const
Definition: Ratio.h:8
RatioStruct< A, B > type
Definition: Ratio.h:18
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
float x
static type combine(const A &a, const B &b)
Definition: Ratio.h:19
double operator()(double x) const
Definition: Ratio.h:10