GooFit  v2.1.3
BifurGaussPdf.cu
Go to the documentation of this file.
1 #include <goofit/PDFs/basic/BifurGaussPdf.h>
2 
3 namespace GooFit {
4 
5 __device__ fptype device_BifurGauss(fptype *evt, fptype *p, unsigned int *indices) {
6  fptype x = evt[indices[2 + indices[0]]]; // why does indices recall itself?
7  fptype mean = p[indices[1]];
8  fptype sigmaLeft = p[indices[2]];
9  fptype sigmaRight = p[indices[3]];
10 
11  // how to calculate the value of a bifurcated gaussian?
12  fptype sigma = sigmaLeft;
13 
14  if(x > mean)
15  sigma = sigmaRight;
16 
17  fptype ret = exp(-0.5 * (x - mean) * (x - mean) / (sigma * sigma));
18  return ret;
19 }
20 
21 __device__ device_function_ptr ptr_to_BifurGauss = device_BifurGauss;
22 
23 __host__ BifurGaussPdf::BifurGaussPdf(std::string n, Observable _x, Variable mean, Variable sigmaL, Variable sigmaR)
24  : GooPdf(n, _x) {
25  std::vector<unsigned int> pindices;
26  pindices.push_back(registerParameter(mean));
27  pindices.push_back(registerParameter(sigmaL));
28  pindices.push_back(registerParameter(sigmaR));
29  GET_FUNCTION_ADDR(ptr_to_BifurGauss);
30  initialize(pindices);
31 }
32 
33 // q: how shall the normalization of a bifurcated gaussian be calculated?
34 // a: a "sum" of two half-gaussians?
35 __host__ fptype BifurGaussPdf::integrate(fptype lo, fptype hi) const {
36  unsigned int *indices
37  = host_indices + parameters; // look at the global indexes vector starting at the parameters of this function
38 
39  fptype sL = host_params[indices[2]];
40  fptype sR = host_params[indices[3]];
41 
42  fptype normL = 1. / (sqrt(2 * M_PI) * sL);
43  fptype normR = 1. / (sqrt(2 * M_PI) * sR);
44 
45  return .5 * normL + .5 * normR;
46 }
47 } // namespace GooFit