BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
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,
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>
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 */
Definition: kinem.h:93
Kinem1()
Definition: kinem.h:95
Kinem1(double xm1)
Definition: kinem.h:96
double m1() const
Definition: kinem.h:100
Definition: kinem.h:105
Kinem2(double xp1, double xm1, double xm2)
Definition: kinem.h:108
double m2() const
Definition: kinem.h:118
Kinem2()
Definition: kinem.h:107
double m1() const
Definition: kinem.h:117
double p1() const
Definition: kinem.h:116
Definition: kinem.h:123
double m1() const
Definition: kinem.h:140
double p1() const
Definition: kinem.h:137
double p3() const
Definition: kinem.h:139
Kinem3(double xp1, double xp2, double xp3, double xm1, double xm2, double xm3)
Definition: kinem.h:126
double p2() const
Definition: kinem.h:138
double m2() const
Definition: kinem.h:141
double m3() const
Definition: kinem.h:142
Kinem3()
Definition: kinem.h:125
Definition: kinem.h:147
double m1() const
Definition: kinem.h:170
double m3() const
Definition: kinem.h:172
double s12() const
Definition: kinem.h:174
double p1() const
Definition: kinem.h:166
Kinem4(double xp1, double xp2, double xp3, double xp4, double xs12, double xs23, double xm1, double xm2, double xm3, double xm4)
Definition: kinem.h:150
double s23() const
Definition: kinem.h:175
double m2() const
Definition: kinem.h:171
Kinem4()
Definition: kinem.h:149
double p3() const
Definition: kinem.h:168
double p2() const
Definition: kinem.h:167
double p4() const
Definition: kinem.h:169
double m4() const
Definition: kinem.h:173
Definition: kinem.h:180
double p4() const
Definition: kinem.h:207
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)
Definition: kinem.h:183
double p3() const
Definition: kinem.h:206
double m1() const
Definition: kinem.h:209
Kinem5()
Definition: kinem.h:182
double p1() const
Definition: kinem.h:204
double s15() const
Definition: kinem.h:218
double s45() const
Definition: kinem.h:217
double p2() const
Definition: kinem.h:205
double p5() const
Definition: kinem.h:208
double m4() const
Definition: kinem.h:212
double s34() const
Definition: kinem.h:216
double m5() const
Definition: kinem.h:213
double m2() const
Definition: kinem.h:210
double s12() const
Definition: kinem.h:214
double s23() const
Definition: kinem.h:215
double m3() const
Definition: kinem.h:211
Definition: kinem.h:17
bool eq(const double &a, const double &b) const
Definition: kinem.h:47
static const uint64_t idelta
Definition: kinem.h:44
static const int KLEN
Definition: kinem.h:63
Kinem()
Definition: kinem.h:28
Invar
Definition: kinem.h:64
@ is34
Definition: kinem.h:68
@ im1
Definition: kinem.h:64
@ im4
Definition: kinem.h:67
@ im2
Definition: kinem.h:65
@ is45
Definition: kinem.h:68
@ ip5
Definition: kinem.h:68
@ im6
Definition: kinem.h:69
@ ip3
Definition: kinem.h:66
@ ip2
Definition: kinem.h:66
@ im3
Definition: kinem.h:66
@ ip6
Definition: kinem.h:69
@ im5
Definition: kinem.h:68
@ ip1
Definition: kinem.h:65
@ is15
Definition: kinem.h:68
@ is12
Definition: kinem.h:67
@ is23
Definition: kinem.h:67
@ ip4
Definition: kinem.h:67
double kdata[KLEN]
Definition: kinem.h:71
void zero()
Definition: kinem.h:84
double mass(int i) const
Definition: kinem.h:22
bool neq(const double &a, const double &b) const
Definition: kinem.h:55
bool operator==(const Kinem &kinem) const
Definition: kinem.h:75
const double b
Definition: slope.cxx:9
double d64
Definition: kinem.h:32
int64_t i64
Definition: kinem.h:32