GooFit  v2.1.3
TruthResolution_Aux.cu
Go to the documentation of this file.
1 #include <goofit/PDFs/physics/TruthResolution_Aux.h>
2 
3 namespace GooFit {
4 
5 __device__ fptype device_truth_resolution(fptype coshterm,
6  fptype costerm,
7  fptype sinhterm,
8  fptype sinterm,
9  fptype tau,
10  fptype dtime,
11  fptype xmixing,
12  fptype ymixing,
13  fptype /*sigma*/,
14  fptype * /*p*/,
15  unsigned int * /*indices*/) {
16  fptype ret = 0;
17  dtime /= tau;
18  ret += coshterm * cosh(ymixing * dtime);
19  ret += costerm * cos(xmixing * dtime);
20  ret -= 2 * sinhterm * sinh(ymixing * dtime);
21  ret -= 2 * sinterm
22  * sin(xmixing * dtime); // Notice sign difference wrt to Mikhail's code, because I have AB* and he has A*B.
23  ret *= exp(-dtime);
24 
25  // printf("device_truth_resolution %f %f %f %f %f\n", coshterm, costerm, sinhterm, sinterm, dtime);
26  return ret;
27 }
28 
29 __device__ fptype device_truth_resolution_average_tau(
30  fptype A2, fptype B2, fptype ABr, fptype ABi, fptype xmixing, fptype ymixing, fptype tau) {
31  fptype a = A2 - B2;
32  fptype b = 2 * ABi;
33  fptype c = A2 + B2;
34  fptype d = 2 * ABr;
35  fptype averagetau = ((xmixing * xmixing + 1) * (ymixing * ymixing - 1)
36  * (((a * tau * (xmixing * xmixing - 1.) + 2. * b * tau * xmixing))
37  / ((xmixing * xmixing + 1.) * (xmixing * xmixing + 1.))
38  + (c * (-(tau * ymixing * ymixing) - tau) + d * (2. * tau) * ymixing)
39  / ((ymixing * ymixing - 1.) * (ymixing * ymixing - 1.))))
40  / ((ymixing * ymixing - 1) * (b * xmixing - a) + (xmixing * xmixing + 1) * (c - d * ymixing));
41  // printf("device avg tau: %.5g with A2: %.5g, B2: %.5g, ABr:%.5g, ABi:%.5g, x:%.5g, y:%.5g, tau:%.5g \n",
42  // averagetau, A2, B2, ABr, ABi, xmixing, ymixing, tau);
43  return averagetau;
44 }
45 
46 __device__ device_resfunction_ptr ptr_to_truth = device_truth_resolution;
47 __device__ device_calc_tau_fcn_ptr ptr_to_calc_tau = device_truth_resolution_average_tau;
48 
49 TruthResolution::TruthResolution()
50  : MixingTimeResolution() {
51  GET_FUNCTION_ADDR(ptr_to_truth);
52  initIndex();
53  GET_FUNCTION_ADDR(ptr_to_calc_tau);
54  setCalcTauIdx(GooPdf::findFunctionIdx(host_fcn_ptr));
55 }
56 TruthResolution::~TruthResolution() = default;
57 
58 fptype TruthResolution::normalisation(
59  fptype di1, fptype di2, fptype di3, fptype di4, fptype tau, fptype xmixing, fptype ymixing) const {
60  fptype timeIntegralOne = tau / (1 - ymixing * ymixing);
61  fptype timeIntegralTwo = tau / (1 + xmixing * xmixing);
62  fptype timeIntegralThr = ymixing * timeIntegralOne;
63  fptype timeIntegralFou = xmixing * timeIntegralTwo;
64 
65  fptype ret = timeIntegralOne * (di1 + di2);
66  ret += timeIntegralTwo * (di1 - di2);
67  ret -= 2 * timeIntegralThr * di3;
68  ret -= 2 * timeIntegralFou * di4;
69 
70  return ret;
71 }
72 
73 } // namespace GooFit