CMS 3D CMS Logo

Convolution.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Convolution_h
2 #define PhysicsTools_Utilities_Convolution_h
5 
6 namespace funct {
7  template <typename A, typename B, typename Integrator>
9  public:
10  // min and max are defined in the domain of b
11  ConvolutionStruct(const A& a, const B& b, double min, double max, const Integrator& integrator)
12  : f_(a, b), min_(min), max_(max), integrator_(integrator) {
13  if (max < min)
14  throw edm::Exception(edm::errors::Configuration) << "Convolution: min must be smaller than max\n";
15  }
16  double operator()(double x) const {
17  f_.setX(x);
18  return integrator_(f_, x - max_, x - min_);
19  }
20 
21  private:
22  struct function {
23  function(const A& a, const B& b) : _1(a), _2(b) {}
24  void setX(double x) const { x_ = x; }
25  double operator()(double y) const { return _1(y) * _2(x_ - y); }
26 
27  private:
28  A _1;
29  B _2;
30  mutable double x_;
31  };
32  function f_;
33  double min_, max_, delta_;
34  Integrator integrator_;
35  };
36 
37  template <typename A, typename B, typename Integrator>
38  struct Convolution {
40  static type compose(const A& a, const B& b, double min, double max, const Integrator& i) {
41  return type(a, b, min, max, i);
42  }
43  };
44 
45  template <typename A, typename B, typename Integrator>
47  const A& a, const B& b, double min, double max, const Integrator& i) {
49  }
50 
51 } // namespace funct
52 
53 #endif
Definition: Abs.h:5
ConvolutionStruct< A, B, Integrator > type
Definition: Convolution.h:39
funct::Convolution< A, B, Integrator >::type conv(const A &a, const B &b, double min, double max, const Integrator &i)
Definition: Convolution.h:46
TEMPL(T2) struct Divides B
Definition: Factorize.h:24
double operator()(double x) const
Definition: Convolution.h:16
ConvolutionStruct(const A &a, const B &b, double min, double max, const Integrator &integrator)
Definition: Convolution.h:11
static type compose(const A &a, const B &b, double min, double max, const Integrator &i)
Definition: Convolution.h:40
double operator()(double y) const
Definition: Convolution.h:25
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
float x