GooFit  v2.1.3
EvalVar.h
Go to the documentation of this file.
1 /*
2 04/18/2016 Christoph Hasse
3 
4 This file includes a converter from 16 values (4 4-momenta) to (the common set of) 5 parameters.
5 See UserUtils for a handy way to convert for tests.
6 
7 */
8 
9 #pragma once
10 
12 #include <mcbooster/GContainers.h>
13 #include <mcbooster/GFunctional.h>
14 #include <mcbooster/GTypes.h>
15 #include <mcbooster/Vector4R.h>
16 
17 namespace GooFit {
18 
19 struct Dim5 : public mcbooster::IFunctionArray {
20  Dim5() { dim = 4; }
21 
22  __host__ __device__ mcbooster::GReal_t
23  cosHELANG(const mcbooster::Vector4R p, const mcbooster::Vector4R q, const mcbooster::Vector4R d) {
24  mcbooster::GReal_t pd = p * d;
25  mcbooster::GReal_t pq = p * q;
26  mcbooster::GReal_t qd = q * d;
27  mcbooster::GReal_t mp2 = p.mass2();
28  mcbooster::GReal_t mq2 = q.mass2();
29  mcbooster::GReal_t md2 = d.mass2();
30 
31  return (pd * mq2 - pq * qd) / sqrt((pq * pq - mq2 * mp2) * (qd * qd - mq2 * md2));
32  }
33 
34  __host__ __device__ mcbooster::GReal_t phi(const mcbooster::Vector4R &p4_p,
35  const mcbooster::Vector4R &p4_d1,
36  const mcbooster::Vector4R &p4_d2,
37  const mcbooster::Vector4R &p4_h1,
38  const mcbooster::Vector4R &p4_h2) {
39  mcbooster::Vector4R p4_d1p, p4_h1p, p4_h2p, p4_d2p;
40 
41  mcbooster::Vector4R d1_perp, d1_prime, h1_perp;
42  mcbooster::Vector4R D;
43 
44  D = p4_d1 + p4_d2;
45  mcbooster::Vector4R D2 = p4_h1 + p4_h2;
46 
47  d1_perp = p4_d1 - (D.dot(p4_d1) / D.dot(D)) * D;
48  h1_perp = p4_h1 - (D2.dot(p4_h1) / D2.dot(D2)) * D2;
49 
50  // orthogonal to both D and d1_perp
51 
52  d1_prime = D.cross(d1_perp);
53 
54  d1_perp = d1_perp / d1_perp.d3mag();
55  d1_prime = d1_prime / d1_prime.d3mag();
56 
57  mcbooster::GReal_t x, y;
58 
59  x = d1_perp.dot(h1_perp);
60  y = d1_prime.dot(h1_perp);
61  mcbooster::GReal_t phi = atan2(y, x);
62  // printf("x:%.5g, y%.5g phi %.5g\n", x, y, phi );
63 
64  if(phi < 0.0)
65  phi += 2.0 * M_PI;
66 
67  mcbooster::Vector4R d1n = p4_d1 / p4_d1.d3mag();
68  mcbooster::Vector4R d2n = p4_d2 / p4_d2.d3mag();
69  mcbooster::Vector4R h1n = p4_h1 / p4_h1.d3mag();
70  mcbooster::Vector4R h2n = p4_h2 / p4_h2.d3mag();
71  mcbooster::Vector4R h12n = (p4_h1 + p4_h2);
72  h12n *= 1.0 / h12n.d3mag();
73 
74  mcbooster::Vector4R n1 = d1n.cross(d2n);
75  mcbooster::Vector4R n2 = h1n.cross(h2n);
76  n1 *= 1.0 / n1.d3mag();
77  n2 *= 1.0 / n2.d3mag();
78  mcbooster::Vector4R n3 = n1.cross(n2);
79 
80  mcbooster::GReal_t cp = (n1.dot(n2));
81  mcbooster::GReal_t sp = (n3.dot(h12n));
82 
83  mcbooster::GReal_t phi2 = acos(cp);
84 
85  if(sp < 0)
86  phi2 *= -1;
87 
88  // printf("cp %.5g, sp %.5g, phi2 %.5g\n",cp, sp, phi2 );
89 
90  return phi2;
91  }
92 
93  __host__ __device__ void
94  operator()(const mcbooster::GInt_t n, mcbooster::Vector4R **particles, mcbooster::GReal_t *variables) override {
95  mcbooster::Vector4R ppip = *particles[0];
96  mcbooster::Vector4R ppim = *particles[1];
97  mcbooster::Vector4R pK = *particles[2];
98  mcbooster::Vector4R ppip2 = *particles[3];
99 
100  mcbooster::Vector4R pM = ppip + ppim + pK + ppip2;
101  mcbooster::Vector4R ppipi = ppip + ppim;
102  mcbooster::Vector4R pKpi = pK + ppip2;
103 
104  variables[0] = ppipi.mass();
105  variables[1] = pKpi.mass();
106  variables[2] = cosHELANG(pM, ppipi, ppip);
107  variables[3] = cosHELANG(pM, pKpi, pK);
108  variables[4] = phi(pM, ppip, ppim, pK, ppip2);
109  }
110 };
111 
112 } // namespace GooFit
__host__ __device__ void operator()(const mcbooster::GInt_t n, mcbooster::Vector4R **particles, mcbooster::GReal_t *variables) override
Definition: EvalVar.h:94
__host__ __device__ mcbooster::GReal_t phi(const mcbooster::Vector4R &p4_p, const mcbooster::Vector4R &p4_d1, const mcbooster::Vector4R &p4_d2, const mcbooster::Vector4R &p4_h1, const mcbooster::Vector4R &p4_h2)
Definition: EvalVar.h:34
__host__ __device__ mcbooster::GReal_t cosHELANG(const mcbooster::Vector4R p, const mcbooster::Vector4R q, const mcbooster::Vector4R d)
Definition: EvalVar.h:23
constexpr rang::style const dim
Definition: Color.h:18