GooFit  v2.1.3
GaussianPdf.cu
Go to the documentation of this file.
1 #include <goofit/PDFs/basic/GaussianPdf.h>
2 
3 namespace GooFit {
4 
5 __device__ fptype device_Gaussian(fptype *evt, fptype *p, unsigned int *indices) {
6  fptype x = evt[RO_CACHE(indices[2 + RO_CACHE(indices[0])])];
7  fptype mean = RO_CACHE(p[RO_CACHE(indices[1])]);
8  fptype sigma = RO_CACHE(p[RO_CACHE(indices[2])]);
9 
10  fptype ret = exp(-0.5 * (x - mean) * (x - mean) / (sigma * sigma));
11 
12  return ret;
13 }
14 
15 __device__ device_function_ptr ptr_to_Gaussian = device_Gaussian;
16 
17 __host__ GaussianPdf::GaussianPdf(std::string n, Observable _x, Variable mean, Variable sigma)
18  : GooPdf(n, _x) {
19  std::vector<unsigned int> pindices;
20  pindices.push_back(registerParameter(mean));
21  pindices.push_back(registerParameter(sigma));
22  GET_FUNCTION_ADDR(ptr_to_Gaussian);
23  initialize(pindices);
24 }
25 
26 __host__ fptype GaussianPdf::integrate(fptype lo, fptype hi) const {
27  static const fptype rootPi = sqrt(atan2(0.0, -1.0));
28 
29  unsigned int *indices = host_indices + parameters;
30 
31  // Integral over all R.
32  fptype sigma = host_params[indices[2]];
33  sigma *= root2 * rootPi;
34  return sigma;
35 }
36 
37 } // namespace GooFit