GooFit  v2.1.3
CorrGaussianPdf.cu
Go to the documentation of this file.
1 #include <goofit/PDFs/basic/CorrGaussianPdf.h>
2 
3 namespace GooFit {
4 
5 __device__ fptype device_CorrGaussian(fptype *evt, fptype *p, unsigned int *indices) {
6  fptype x = evt[indices[2 + indices[0]]];
7  fptype y = evt[indices[3 + indices[0]]];
8  fptype mean1 = p[indices[1]];
9  fptype sigma1 = p[indices[2]];
10  fptype mean2 = p[indices[3]];
11  fptype sigma2 = p[indices[4]];
12  fptype corr = p[indices[5]];
13 
14  fptype x_dist = (x - mean1) / sigma1;
15  sigma2 *= (1 + corr * x_dist * x_dist);
16  fptype y_dist = (y - mean2) * (sigma2 == 0 ? 0 : (1.0 / sigma2));
17  fptype ret = exp(-0.5 * (x_dist * x_dist + y_dist * y_dist));
18 
19  // if ((gpuDebug & 1) && (THREADIDX == 60)) printf("CorrGauss: %f %f %f %f %f %f %f %f %f %.12f\n", x, y, mean1,
20  // sigma1, mean2, sigma2, corr, x_dist, y_dist, ret);
21  // if ((gpuDebug & 1) && (THREADIDX == 60)) printf("[%i, %i] [%i, %i] CorrGauss: %f %f %f\n", BLOCKIDX, THREADIDX,
22  // gridDim.x, BLOCKDIM, x, y, ret);
23  // printf("CorrGauss: %i %i %i %f %f %f %f\n", indices[2 + indices[0]], indices[3 + indices[0]], indices[0], x, y,
24  // mean1, mean2);
25 
26  return ret;
27 }
28 
29 __device__ device_function_ptr ptr_to_CorrGaussian = device_CorrGaussian;
30 
31 __host__ CorrGaussianPdf::CorrGaussianPdf(std::string n,
32  Observable _x,
33  Observable _y,
34  Variable mean1,
35  Variable sigma1,
36  Variable mean2,
37  Variable sigma2,
38  Variable correlation)
39  : GooPdf(n, _x, _y) {
40  // registerObservable(_x);
41  // registerObservable(_y);
42 
43  std::vector<unsigned int> pindices;
44  pindices.push_back(registerParameter(mean1));
45  pindices.push_back(registerParameter(sigma1));
46  pindices.push_back(registerParameter(mean2));
47  pindices.push_back(registerParameter(sigma2));
48  pindices.push_back(registerParameter(correlation));
49 
50  GET_FUNCTION_ADDR(ptr_to_CorrGaussian);
51  initialize(pindices);
52 }
53 
54 } // namespace GooFit