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,
12  double min, double max, const Integrator & integrator) :
13  f_(a, b), min_(min), max_(max), integrator_(integrator) {
14  if(max < min)
16  << "Convolution: min must be smaller than max\n";
17  }
18  double operator()(double x) const {
19  f_.setX(x);
20  return integrator_(f_, x - max_, x - min_);
21  }
22  private:
23  struct function {
24  function(const A& a, const B& b) : _1(a), _2(b) { }
25  void setX(double x) const { x_ = x; }
26  double operator()(double y) const {
27  return _1(y) * _2(x_ - y);
28  }
29  private:
30  A _1;
31  B _2;
32  mutable double x_;
33  };
34  function f_;
35  double min_, max_, delta_;
36  Integrator integrator_;
37  };
38 
39  template<typename A, typename B, typename Integrator>
40  struct Convolution {
42  static type compose(const A& a, const B& b, double min, double max, const Integrator& i) {
43  return type(a, b, min, max, i);
44  }
45  };
46 
47  template<typename A, typename B, typename Integrator>
48  inline typename funct::Convolution<A, B, Integrator>::type conv(const A& a, const B& b, double min, double max, const Integrator& i) {
49  return funct::Convolution<A, B, Integrator>::compose(a, b, min, max, i);
50  }
51 
52 }
53 
54 
55 
56 #endif
int i
Definition: DBlmapReader.cc:9
Definition: Abs.h:5
ConvolutionStruct< A, B, Integrator > type
Definition: Convolution.h:41
funct::Convolution< A, B, Integrator >::type conv(const A &a, const B &b, double min, double max, const Integrator &i)
Definition: Convolution.h:48
ConvolutionStruct(const A &a, const B &b, double min, double max, const Integrator &integrator)
Definition: Convolution.h:11
double operator()(double y) const
Definition: Convolution.h:26
T min(T a, T b)
Definition: MathUtil.h:58
static type compose(const A &a, const B &b, double min, double max, const Integrator &i)
Definition: Convolution.h:42
double b
Definition: hdecay.h:120
arg type
Definition: Factorize.h:37
double operator()(double x) const
Definition: Convolution.h:18
double a
Definition: hdecay.h:121
void setX(double x) const
Definition: Convolution.h:25