GooFit  v2.1.3
TrigThresholdPdf.cu
Go to the documentation of this file.
1 #include <goofit/PDFs/basic/TrigThresholdPdf.h>
2 
3 namespace GooFit {
4 
5 __device__ fptype threshCalc(fptype distance, fptype linConst) {
6  fptype ret
7  = (distance > fptype(0.5) ? fptype(1) : (linConst + (1 - linConst) * sin(distance * fptype(3.14159265))));
8  return ret;
9 }
10 
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]];
16 
17  trigConst *= (thresh - x);
18  return threshCalc(trigConst, linConst);
19 }
20 
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]];
26 
27  trigConst *= (x - thresh);
28  return threshCalc(trigConst, linConst);
29 }
30 
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
33 
34  fptype x = evt[indices[2 + indices[0] + 0]];
35  fptype y = evt[indices[2 + indices[0] + 1]];
36 
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;
41 
42  trigConst *= (thresh - z);
43  return threshCalc(trigConst, linConst);
44 }
45 
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]];
49 
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;
54 
55  trigConst *= (z - thresh);
56  fptype ret = threshCalc(trigConst, linConst);
57 
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);
60 
61  return ret;
62 }
63 
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;
70 
71 __host__ TrigThresholdPdf::TrigThresholdPdf(
72  std::string n, Observable _x, Variable thresh, Variable trigConst, Variable linConst, bool upper)
73  : GooPdf(n, _x) {
74  std::vector<unsigned int> pindices;
75  pindices.push_back(registerParameter(thresh));
76  pindices.push_back(registerParameter(trigConst));
77  pindices.push_back(registerParameter(linConst));
78 
79  if(upper) {
80  GET_FUNCTION_ADDR(ptr_to_TrigThresholdUpper);
81  } else {
82  GET_FUNCTION_ADDR(ptr_to_TrigThresholdLower);
83  }
84 
85  initialize(pindices);
86 }
87 
88 __host__ TrigThresholdPdf::TrigThresholdPdf(std::string n,
89  Observable _x,
90  Observable _y,
91  Variable thresh,
92  Variable trigConst,
93  Variable linConst,
94  Variable massConstant,
95  bool upper)
96  : GooPdf(n, _x, _y) {
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));
102 
103  if(upper) {
104  GET_FUNCTION_ADDR(ptr_to_VerySpecialEpisodeTrigThresholdUpper);
105  } else {
106  GET_FUNCTION_ADDR(ptr_to_VerySpecialEpisodeTrigThresholdLower);
107  }
108 
109  initialize(pindices);
110 }
111 } // namespace GooFit