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
funct::ConvolutionStruct::max_
double max_
Definition: Convolution.h:33
funct::conv
funct::Convolution< A, B, Integrator >::type conv(const A &a, const B &b, double min, double max, const Integrator &i)
Definition: Convolution.h:46
funct::ConvolutionStruct::function::x_
double x_
Definition: Convolution.h:30
mps_fire.i
i
Definition: mps_fire.py:355
funct::ConvolutionStruct::min_
double min_
Definition: Convolution.h:33
funct::ConvolutionStruct::delta_
double delta_
Definition: Convolution.h:33
funct::B
TEMPL(T2) struct Divides B
Definition: Factorize.h:29
min
T min(T a, T b)
Definition: MathUtil.h:58
EDMException.h
funct::ConvolutionStruct::integrator_
Integrator integrator_
Definition: Convolution.h:34
funct::ConvolutionStruct::function
Definition: Convolution.h:22
funct::ConvolutionStruct
Definition: Convolution.h:8
b
double b
Definition: hdecay.h:118
funct::ConvolutionStruct::function::_2
B _2
Definition: Convolution.h:29
funct::ConvolutionStruct::function::_1
A _1
Definition: Convolution.h:28
a
double a
Definition: hdecay.h:119
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
funct::ConvolutionStruct::f_
function f_
Definition: Convolution.h:32
A
funct::ConvolutionStruct::function::operator()
double operator()(double y) const
Definition: Convolution.h:25
funct::ConvolutionStruct::ConvolutionStruct
ConvolutionStruct(const A &a, const B &b, double min, double max, const Integrator &integrator)
Definition: Convolution.h:11
Exception
Definition: hltDiff.cc:246
funct::Convolution::compose
static type compose(const A &a, const B &b, double min, double max, const Integrator &i)
Definition: Convolution.h:40
NumericalIntegration.h
funct::ConvolutionStruct::function::setX
void setX(double x) const
Definition: Convolution.h:24
funct::Convolution
Definition: Convolution.h:38
funct::Convolution::type
ConvolutionStruct< A, B, Integrator > type
Definition: Convolution.h:39
edm::errors::Configuration
Definition: EDMException.h:36
funct
Definition: Abs.h:5
funct::ConvolutionStruct::operator()
double operator()(double x) const
Definition: Convolution.h:16