BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
eemmg-lib/src/kinem.h
Go to the documentation of this file.
1/*
2 * kinem.h - kinematics classes
3 *
4 * this file is part of PJFry library
5 * Copyright 2011 Valery Yundin
6 */
7
8#ifndef QUL_KINEM_H
9#define QUL_KINEM_H
10
11#include "common.h"
12#include <cstdlib>
13// #include <cfloat>
14
15template <int R>
16class Kinem
17{
18 public:
19 bool operator == (const Kinem& kinem) const;
20
21 inline
22 double mass(int i) const
23 {
24 return kdata[(i-1)*(i+2)/2];
25 }
26
27 protected:
28 Kinem() {}
29
30 void zero(); // initialize to zero
31
32 typedef union { double d64; int64_t i64; } DI64;
33// static const double mdelta=1e-14;
34// static const int64_t idelta=1+mdelta/DBL_EPSILON; // needs cfloat
35 /*
36 Comparison tolerance for double
37 idelta fdelta(%)
38 5 - 1.11e-15
39 46 - 1.02e-14
40 451 - 1.00e-13
41 4504 - 1.00e-12
42 45036 - 1.00e-11
43 */
44 static const uint64_t idelta=5; // unsigned !!!
45
46 inline
47 bool eq(const double& a, const double &b) const
48 {
49 const DI64 ia={a};
50 const DI64 ib={b};
51 const int64_t diff=ia.i64-ib.i64;
52 return diff == 0LL || static_cast<uint64_t>(llabs(diff)) <= idelta;
53 }
54 inline
55 bool neq(const double& a, const double &b) const
56 {
57 const DI64 ia={a};
58 const DI64 ib={b};
59 const int64_t diff=ia.i64-ib.i64;
60 return diff != 0LL && static_cast<uint64_t>(llabs(diff)) > idelta;
61 }
62
63 static const int KLEN=R*(R+1)/2;
64 enum Invar {im1=0,
65 ip1, im2,
66 ip2, ip3, im3,
67 ip4, is12, is23, im4,
68 ip5, is34, is45, is15, im5,
69 ip6, /* 6-point inv */ im6};
70
71 double kdata[KLEN];
72};
73
74template <int R>
75bool Kinem<R>::operator == (const Kinem<R>& kinem) const
76{
77 for (int i=0; i<KLEN; i++) {
78 if (not eq(kdata[i], kinem.kdata[i])) return false;
79 }
80 return true;
81}
82
83template <int R>
84void Kinem<R>::zero()
85{
86 for (int i=0; i<KLEN; i++) {
87 kdata[i]=0;
88 }
89}
90
91// 1-point kinematics
92class Kinem1 : public Kinem<1>
93{
94 public:
95 Kinem1() { zero(); }
96 Kinem1(double xm1) {
97 kdata[im1]=xm1;
98 }
99
100 inline double m1() const { return kdata[im1]; }
101};
102
103// 2-point kinematics
104class Kinem2 : public Kinem<2>
105{
106 public:
107 Kinem2() { zero(); }
108 Kinem2(double xp1,
109 double xm1, double xm2)
110 {
111 kdata[ip1]=xp1;
112 kdata[im1]=xm1;
113 kdata[im2]=xm2;
114 }
115
116 inline double p1() const { return kdata[ip1]; }
117 inline double m1() const { return kdata[im1]; }
118 inline double m2() const { return kdata[im2]; }
119};
120
121// 3-point kinematics
122class Kinem3 : public Kinem<3>
123{
124 public:
125 Kinem3() { zero(); }
126 Kinem3(double xp1, double xp2, double xp3,
127 double xm1, double xm2, double xm3)
128 {
129 kdata[ip1]=xp1;
130 kdata[ip2]=xp2;
131 kdata[ip3]=xp3;
132 kdata[im1]=xm1;
133 kdata[im2]=xm2;
134 kdata[im3]=xm3;
135 }
136
137 inline double p1() const { return kdata[ip1]; }
138 inline double p2() const { return kdata[ip2]; }
139 inline double p3() const { return kdata[ip3]; }
140 inline double m1() const { return kdata[im1]; }
141 inline double m2() const { return kdata[im2]; }
142 inline double m3() const { return kdata[im3]; }
143};
144
145// 4-point kinematics
146class Kinem4 : public Kinem<4>
147{
148 public:
149 Kinem4() { zero(); }
150 Kinem4(double xp1, double xp2, double xp3, double xp4,
151 double xs12, double xs23,
152 double xm1, double xm2, double xm3, double xm4)
153 {
154 kdata[ip1]=xp1;
155 kdata[ip2]=xp2;
156 kdata[ip3]=xp3;
157 kdata[ip4]=xp4;
158 kdata[is12]=xs12;
159 kdata[is23]=xs23;
160 kdata[im1]=xm1;
161 kdata[im2]=xm2;
162 kdata[im3]=xm3;
163 kdata[im4]=xm4;
164 }
165
166 inline double p1() const { return kdata[ip1]; }
167 inline double p2() const { return kdata[ip2]; }
168 inline double p3() const { return kdata[ip3]; }
169 inline double p4() const { return kdata[ip4]; }
170 inline double m1() const { return kdata[im1]; }
171 inline double m2() const { return kdata[im2]; }
172 inline double m3() const { return kdata[im3]; }
173 inline double m4() const { return kdata[im4]; }
174 inline double s12() const { return kdata[is12]; }
175 inline double s23() const { return kdata[is23]; }
176};
177
178// 5-point kinematics
179class Kinem5 : public Kinem<5>
180{
181 public:
182 Kinem5() { zero(); }
183 Kinem5(double xp1, double xp2, double xp3, double xp4, double xp5,
184 double xs12, double xs23, double xs34, double xs45, double xs15,
185 double xm1, double xm2, double xm3, double xm4, double xm5)
186 {
187 kdata[ip1]=xp1;
188 kdata[ip2]=xp2;
189 kdata[ip3]=xp3;
190 kdata[ip4]=xp4;
191 kdata[ip5]=xp5;
192 kdata[is12]=xs12;
193 kdata[is23]=xs23;
194 kdata[is34]=xs34;
195 kdata[is45]=xs45;
196 kdata[is15]=xs15;
197 kdata[im1]=xm1;
198 kdata[im2]=xm2;
199 kdata[im3]=xm3;
200 kdata[im4]=xm4;
201 kdata[im5]=xm5;
202 }
203
204 inline double p1() const { return kdata[ip1]; }
205 inline double p2() const { return kdata[ip2]; }
206 inline double p3() const { return kdata[ip3]; }
207 inline double p4() const { return kdata[ip4]; }
208 inline double p5() const { return kdata[ip5]; }
209 inline double m1() const { return kdata[im1]; }
210 inline double m2() const { return kdata[im2]; }
211 inline double m3() const { return kdata[im3]; }
212 inline double m4() const { return kdata[im4]; }
213 inline double m5() const { return kdata[im5]; }
214 inline double s12() const { return kdata[is12]; }
215 inline double s23() const { return kdata[is23]; }
216 inline double s34() const { return kdata[is34]; }
217 inline double s45() const { return kdata[is45]; }
218 inline double s15() const { return kdata[is15]; }
219};
220
221#endif /* QUL_KINEM_H */
Kinem1(double xm1)
double m1() const
Kinem2(double xp1, double xm1, double xm2)
double m2() const
double m1() const
double p1() const
double m1() const
double p1() const
double p3() const
Kinem3(double xp1, double xp2, double xp3, double xm1, double xm2, double xm3)
double p2() const
double m2() const
double m3() const
double m1() const
double m3() const
double s12() const
double p1() const
Kinem4(double xp1, double xp2, double xp3, double xp4, double xs12, double xs23, double xm1, double xm2, double xm3, double xm4)
double s23() const
double m2() const
double p3() const
double p2() const
double p4() const
double m4() const
double p4() const
Kinem5(double xp1, double xp2, double xp3, double xp4, double xp5, double xs12, double xs23, double xs34, double xs45, double xs15, double xm1, double xm2, double xm3, double xm4, double xm5)
double p3() const
double m1() const
double p1() const
double s15() const
double s45() const
double p2() const
double p5() const
double m4() const
double s34() const
double m5() const
double m2() const
double s12() const
double s23() const
double m3() const
static const uint64_t idelta
bool eq(const double &a, const double &b) const
static const int KLEN
double kdata[KLEN]
void zero()
double mass(int i) const
bool neq(const double &a, const double &b) const
bool operator==(const Kinem &kinem) const
const double b
Definition: slope.cxx:9