GooFit  v2.1.3
JohnsonSUPdf.cu
Go to the documentation of this file.
1 #include <goofit/PDFs/basic/JohnsonSUPdf.h>
2 
3 namespace GooFit {
4 
5 const fptype SQRT2PI = 2.506628;
6 
7 __device__ fptype device_JohnsonSU(fptype *evt, fptype *p, unsigned int *indices) {
8  fptype _Jm = p[indices[1]];
9  fptype _Js = p[indices[2]];
10  fptype _Jg = p[indices[3]];
11  fptype _Jd = p[indices[4]];
12  fptype x = evt[indices[2 + indices[0]]];
13 
14  fptype px = (x - _Jm) / _Js;
15  fptype px2 = px * px;
16  fptype sqrt_arg = sqrt(1 + px2);
17  fptype inv_sinh = log(px + sqrt_arg);
18  fptype gaus_arg = _Jg + _Jd * inv_sinh;
19  // if ((gpuDebug & 1) && (0 == BLOCKIDX) && (0 == THREADIDX))
20  // if (gpuDebug & 1)
21  // printf("Johnson SU: %f %f %f %f | %f %f %i\n", _Jm, _Js, _Jg, _Jd, x, _Jd / (_Js * SQRT2PI * sqrt_arg) * exp(-0.5
22  // * gaus_arg * gaus_arg), indices[2 + indices[0]]);
23  // printf("Johnson SU: %f %f %f %f | %f %f %f %f\n", _Jm, _Js, _Jg, _Jd, x, _Jd / (_Js * SQRT2PI * sqrt_arg) *
24  // exp(-0.5 * gaus_arg * gaus_arg), cudaArray[indices[1]], cudaArray[indices[2]]);
25  return _Jd / (_Js * SQRT2PI * sqrt_arg) * exp(-0.5 * gaus_arg * gaus_arg);
26 }
27 
28 __device__ device_function_ptr ptr_to_JohnsonSU = device_JohnsonSU;
29 
30 __host__
31 JohnsonSUPdf::JohnsonSUPdf(std::string n, Observable _x, Variable mean, Variable sigma, Variable gamma, Variable delta)
32  : GooPdf(n, _x) {
33  std::vector<unsigned int> pindices;
34  pindices.push_back(registerParameter(mean));
35  pindices.push_back(registerParameter(sigma));
36  pindices.push_back(registerParameter(gamma));
37  pindices.push_back(registerParameter(delta));
38  GET_FUNCTION_ADDR(ptr_to_JohnsonSU);
39  initialize(pindices);
40 }
41 
42 __host__ fptype JohnsonSUPdf::integrate(fptype lo, fptype hi) const {
43  return 1.0; // Analytic integral included in device function! (Correct for minus to plus inf.)
44 }
45 } // namespace GooFit