1 #include <goofit/PDFs/basic/TrigThresholdPdf.h>
5 __device__ fptype threshCalc(fptype distance, fptype linConst) {
7 = (distance > fptype(0.5) ? fptype(1) : (linConst + (1 - linConst) * sin(distance * fptype(3.14159265))));
11 __device__ fptype device_TrigThresholdUpper(fptype *evt, fptype *p, unsigned int *indices) {
12 fptype x = evt[indices[2 + indices[0]]];
13 fptype thresh = p[indices[1]];
14 fptype trigConst = p[indices[2]];
15 fptype linConst = p[indices[3]];
17 trigConst *= (thresh - x);
18 return threshCalc(trigConst, linConst);
21 __device__ fptype device_TrigThresholdLower(fptype *evt, fptype *p, unsigned int *indices) {
22 fptype x = evt[indices[2 + indices[0]]];
23 fptype thresh = p[indices[1]];
24 fptype trigConst = p[indices[2]];
25 fptype linConst = p[indices[3]];
27 trigConst *= (x - thresh);
28 return threshCalc(trigConst, linConst);
31 __device__ fptype device_VerySpecialEpisodeTrigThresholdUpper(fptype *evt, fptype *p, unsigned int *indices) {
32 // Annoying special case for use with Mikhail's efficiency function across the Dalitz plot
34 fptype x = evt[indices[2 + indices[0] + 0]];
35 fptype y = evt[indices[2 + indices[0] + 1]];
37 fptype thresh = p[indices[1]];
38 fptype trigConst = p[indices[2]];
39 fptype linConst = p[indices[3]];
40 fptype z = p[indices[4]] - x - y;
42 trigConst *= (thresh - z);
43 return threshCalc(trigConst, linConst);
46 __device__ fptype device_VerySpecialEpisodeTrigThresholdLower(fptype *evt, fptype *p, unsigned int *indices) {
47 fptype x = evt[indices[2 + indices[0] + 0]];
48 fptype y = evt[indices[2 + indices[0] + 1]];
50 fptype thresh = p[indices[1]];
51 fptype trigConst = p[indices[2]];
52 fptype linConst = p[indices[3]];
53 fptype z = p[indices[4]] - x - y;
55 trigConst *= (z - thresh);
56 fptype ret = threshCalc(trigConst, linConst);
58 // if ((1 > (int) floor(0.5 + evt[8])) && (gpuDebug & 1) && (paramIndices + debugParamIndex == indices))
59 // printf("TrigThreshold: (%f - %f = %f) -> %f %f\n", z, thresh, trigConst, linConst, ret);
64 __device__ device_function_ptr ptr_to_TrigThresholdUpper = device_TrigThresholdUpper;
65 __device__ device_function_ptr ptr_to_TrigThresholdLower = device_TrigThresholdLower;
66 __device__ device_function_ptr ptr_to_VerySpecialEpisodeTrigThresholdUpper
67 = device_VerySpecialEpisodeTrigThresholdUpper;
68 __device__ device_function_ptr ptr_to_VerySpecialEpisodeTrigThresholdLower
69 = device_VerySpecialEpisodeTrigThresholdLower;
71 __host__ TrigThresholdPdf::TrigThresholdPdf(
72 std::string n, Observable _x, Variable thresh, Variable trigConst, Variable linConst, bool upper)
74 std::vector<unsigned int> pindices;
75 pindices.push_back(registerParameter(thresh));
76 pindices.push_back(registerParameter(trigConst));
77 pindices.push_back(registerParameter(linConst));
80 GET_FUNCTION_ADDR(ptr_to_TrigThresholdUpper);
82 GET_FUNCTION_ADDR(ptr_to_TrigThresholdLower);
88 __host__ TrigThresholdPdf::TrigThresholdPdf(std::string n,
94 Variable massConstant,
97 std::vector<unsigned int> pindices;
98 pindices.push_back(registerParameter(thresh));
99 pindices.push_back(registerParameter(trigConst));
100 pindices.push_back(registerParameter(linConst));
101 pindices.push_back(registerParameter(massConstant));
104 GET_FUNCTION_ADDR(ptr_to_VerySpecialEpisodeTrigThresholdUpper);
106 GET_FUNCTION_ADDR(ptr_to_VerySpecialEpisodeTrigThresholdLower);
109 initialize(pindices);
111 } // namespace GooFit