BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
cache.h
Go to the documentation of this file.
1/*
2 * cache.h - cache classes header
3 *
4 * this file is part of PJFry library
5 * Copyright 2011 Valery Yundin
6 */
7
8#ifndef QUL_CACHE_H
9#define QUL_CACHE_H
10
11#include "common.h"
12#include "kinem.h"
13#include "minor.h"
14#ifdef USE_GOLEM_MODE
15 #include "golem.h"
16#endif
17
18template <typename TK, typename TV>
19class MEntry
20{
21 public:
22 MEntry() : key(), val() {}
23 MEntry(const TK& k, TV& v) : key(k), val(v) {}
24
25 MEntry& operator= (const MEntry& entry)
26 {
27 key=entry.key;
28 val=entry.val;
29 return *this;
30 }
31
32 TK key;
33 mutable TV val; // TODO: remove auto_ptr in the future
34
35 MEntry(const MEntry& entry);
36};
37
38class Cache
39{
40 protected:
41 static const int size6=2;
42
43 static const int size5=size6*6;
44 static const int size4=size6*15;
45 static const int size3=size6*20;
46 static const int size2=size6*15;
47 static const int size1=size6*6;
48
49};
50
51class ICache : public Cache
52{
53#ifdef USE_GOLEM_MODE
54 friend class Golem;
55#endif
56 public:
57 typedef struct { ncomplex val[3]; } Ival;
58
79 };
80
81 enum Dcoefs {dd0=1,dd1,dd2,dd3,
90 };
91
92 enum Ccoefs {cc0=1,cc1,cc2,
96 };
97
98 enum Bcoefs {bb0=1,bb1,
102 };
103
104 // Scalars
105 static ncomplex getI4(int ep, const Kinem4 &k);
106 static ncomplex getI3(int ep, const Kinem3 &k);
107 static ncomplex getI2(int ep, const Kinem2 &k);
108 static ncomplex getI1(int ep, const Kinem1 &k);
109
110 // Tensor PENTAGON
111 static ncomplex getE(int ep, const Kinem5 &kin);
112 static ncomplex getE(int ep, int i, const Kinem5 &kin);
113 static ncomplex getE(int ep, int i, int j, const Kinem5 &kin);
114 static ncomplex getE(int ep, int i, int j, int k, const Kinem5 &kin);
115 static ncomplex getE(int ep, int i, int j, int k, int l, const Kinem5 &kin);
116 static ncomplex getE(int ep, int i, int j, int k, int l, int m, const Kinem5 &kin);
117
118 // Tensor BOX
119 static ncomplex getD(int ep, const Kinem4 &kin) { return getI4(ep, kin); }
120 static ncomplex getD(int ep, int i, const Kinem4 &kin);
121 static ncomplex getD(int ep, int i, int j, const Kinem4 &kin);
122 static ncomplex getD(int ep, int i, int j, int k, const Kinem4 &kin);
123 static ncomplex getD(int ep, int i, int j, int k, int l, const Kinem4 &kin);
124
125 // Tensor TRIANGLE
126 static ncomplex getC(int ep, const Kinem3 &kin) { return getI3(ep, kin); }
127 static ncomplex getC(int ep, int i, const Kinem3 &kin);
128 static ncomplex getC(int ep, int i, int j, const Kinem3 &kin);
129 static ncomplex getC(int ep, int i, int j, int k, const Kinem3 &kin);
130
131 // Tensor BUBBLE
132 static ncomplex getB(int ep, const Kinem2 &kin) { return getI2(ep, kin); }
133 static ncomplex getB(int ep, int i, const Kinem2 &kin);
134 static ncomplex getB(int ep, int i, int j, const Kinem2 &kin);
135
136 // Tadpole
137 static ncomplex getA(int ep, const Kinem1 &kin) { return getI1(ep, kin); }
138
139 static void Clear();
140 static void ClearCC();
141 static void ClearIC();
142
143 static double getMu2();
144 static double setMu2(const double newmu2);
145
146 private:
147 static double mu2;
148 typedef union { int64_t i64; double d64; } ID64;
149 typedef union { double d64; int64_t i64; } DI64;
150 static const ID64 sNAN;
151 friend bool operator==(const double &x, const ICache::ID64 &y);
152
153 // ------------------------------
154 // Tensor integral coefficients
155 // ------------------------------
156 // TODO: rethink and optimize layout later
157 typedef CArray< ncomplex, eeLAST > Save5;
158 typedef MEntry< Kinem5, Save5::Ptr > Entry5;
159 typedef DArray< Entry5, size5 > Array5;
160 static Array5 ic5[3];
161 static Save5* getS5(int ep, const Kinem5 &kin, int coefn);
162
163 typedef CArray< ncomplex, ddLAST > Save4;
164 typedef MEntry< Kinem4, Save4::Ptr > Entry4;
165 typedef DArray< Entry4, size4 > Array4;
166 static Array4 ic4[3];
167 static Save4* getS4(int ep, const Kinem4 &kin, int coefn);
168
169 typedef CArray< ncomplex, ccLAST > Save3;
170 typedef MEntry< Kinem3, Save3::Ptr > Entry3;
171 typedef DArray< Entry3, size3 > Array3;
172 static Array3 ic3[3];
173 static Save3* getS3(int ep, const Kinem3 &kin, int coefn);
174
175 typedef CArray< ncomplex, bbLAST > Save2;
176 typedef MEntry< Kinem2, Save2::Ptr > Entry2;
177 typedef DArray< Entry2, size2 > Array2;
178 static Array2 ic2[3];
179 static Save2* getS2(int ep, const Kinem2 &kin, int coefn);
180
181 // ------------------------------
182 // Scalar integrals
183 // ------------------------------
184 typedef MEntry< Kinem4, Ival > EntryS4;
185 typedef DArray< EntryS4, size4 > ArrayS4;
186 static ArrayS4 ics4;
187
188 typedef MEntry< Kinem3, Ival > EntryS3;
189 typedef DArray< EntryS3, size3 > ArrayS3;
190 static ArrayS3 ics3;
191
192 typedef MEntry< Kinem2, Ival > EntryS2;
193 typedef DArray< EntryS2, size2 > ArrayS2;
194 static ArrayS2 ics2;
195
196 typedef MEntry< Kinem1, Ival > EntryS1;
197 typedef DArray< EntryS1, size1 > ArrayS1;
198 static ArrayS1 ics1;
199};
200
201inline
202bool operator==(const double &x, const ICache::ID64 &y)
203{
204 const ICache::DI64 ix={x};
205 return ix.i64 == y.i64;
206}
207
208
209class MCache : public Cache
210{
211#ifdef USE_GOLEM_MODE
212 friend class Golem;
213#endif
214 public:
215 // TODO: may be return by reference here?
216 static Minor5::Ptr getMinor5(const Kinem5 &k);
217 static Minor4::Ptr getMinor4(const Kinem4 &k);
218 static Minor3::Ptr getMinor3(const Kinem3 &k);
219 static Minor2::Ptr getMinor2(const Kinem2 &k);
220
221 static void insertMinor5(const Kinem5 &k, Minor5::Ptr &m);
222 static void insertMinor4(const Kinem4 &k, Minor4::Ptr &m);
223 static void insertMinor3(const Kinem3 &k, Minor3::Ptr &m);
224 static void insertMinor2(const Kinem2 &k, Minor2::Ptr &m);
225
226#ifdef USE_SMART_INSERT
227# define INSERTMINOR3 smartinsertMinor3
228# define INSERTMINOR2 smartinsertMinor2
229 static void smartinsertMinor3(const Kinem3 &k, Minor3::Ptr &m);
230 static void smartinsertMinor2(const Kinem2 &k, Minor2::Ptr &m);
231#else
232# define INSERTMINOR3 insertMinor3
233# define INSERTMINOR2 insertMinor2
234#endif
235
236 static void Clear();
237
238 private:
239
240 typedef MEntry< Kinem5, Minor5::Ptr > Entry5;
241 typedef DArray< Entry5, size5 > Array5;
242 static Array5 cm5;
243
244 typedef MEntry< Kinem4, Minor4::Ptr > Entry4;
245 typedef DArray< Entry4, size4 > Array4;
246 static Array4 cm4;
247
248 typedef MEntry< Kinem3, Minor3::Ptr > Entry3;
249 typedef DArray< Entry3, size3 > Array3;
250 static Array3 cm3;
251
252 typedef MEntry< Kinem2, Minor2::Ptr > Entry2;
253 typedef DArray< Entry2, size2 > Array2;
254 static Array2 cm2;
255
256};
257
258/* =============================================
259 *
260 * inline functions
261 *
262 * =============================================
263 */
264
265#define insertMinorN(n) \
266inline \
267void MCache::insertMinor##n(const Kinem##n &k, Minor##n::Ptr &m) \
268{ \
269 cm##n.insert(Entry##n(k,m)); \
270}
271
276
277#undef insertMinorN
278
279#endif /* _QUL_CACHE_H */
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
#define insertMinorN(n)
Definition: cache.h:265
bool operator==(const double &x, const ICache::ID64 &y)
Definition: cache.h:202
Definition: cache.h:39
static const int size4
Definition: cache.h:44
static const int size2
Definition: cache.h:46
static const int size1
Definition: cache.h:47
static const int size6
Definition: cache.h:41
static const int size5
Definition: cache.h:43
static const int size3
Definition: cache.h:45
Definition: pointer.h:80
Definition: cache.h:52
static void ClearIC()
Definition: cache.cpp:60
static double setMu2(const double newmu2)
Definition: cache.cpp:25
static ncomplex getI2(int ep, const Kinem2 &k)
Dcoefs
Definition: cache.h:81
@ dd33
Definition: cache.h:82
@ dd222
Definition: cache.h:84
@ dd1112
Definition: cache.h:86
@ dd1233
Definition: cache.h:87
@ dd2
Definition: cache.h:81
@ dd1
Definition: cache.h:81
@ dd2223
Definition: cache.h:88
@ dd0022
Definition: cache.h:85
@ dd3333
Definition: cache.h:89
@ dd00
Definition: cache.h:82
@ dd1223
Definition: cache.h:87
@ dd333
Definition: cache.h:84
@ dd0000
Definition: cache.h:85
@ dd1122
Definition: cache.h:86
@ dd003
Definition: cache.h:83
@ dd133
Definition: cache.h:84
@ dd2222
Definition: cache.h:88
@ dd123
Definition: cache.h:84
@ dd0012
Definition: cache.h:85
@ dd122
Definition: cache.h:84
@ dd3
Definition: cache.h:81
@ dd1333
Definition: cache.h:87
@ dd0013
Definition: cache.h:85
@ dd0023
Definition: cache.h:85
@ dd22
Definition: cache.h:82
@ dd111
Definition: cache.h:84
@ dd1111
Definition: cache.h:86
@ dd0033
Definition: cache.h:85
@ dd1123
Definition: cache.h:86
@ dd233
Definition: cache.h:84
@ ddLAST
Definition: cache.h:89
@ dd001
Definition: cache.h:83
@ dd23
Definition: cache.h:82
@ dd002
Definition: cache.h:83
@ dd1113
Definition: cache.h:86
@ dd0
Definition: cache.h:81
@ dd2333
Definition: cache.h:88
@ dd2233
Definition: cache.h:88
@ dd112
Definition: cache.h:84
@ dd113
Definition: cache.h:84
@ dd223
Definition: cache.h:84
@ dd12
Definition: cache.h:82
@ dd1222
Definition: cache.h:87
@ dd13
Definition: cache.h:82
@ dd11
Definition: cache.h:82
@ dd0011
Definition: cache.h:85
@ dd1133
Definition: cache.h:86
static double getMu2()
Definition: cache.cpp:20
static ncomplex getI4(int ep, const Kinem4 &k)
static ncomplex getD(int ep, const Kinem4 &kin)
Definition: cache.h:119
static void Clear()
Definition: cache.cpp:40
static ncomplex getI3(int ep, const Kinem3 &k)
static ncomplex getA(int ep, const Kinem1 &kin)
Definition: cache.h:137
Ecoefs
Definition: cache.h:59
@ ee4
Definition: cache.h:59
@ ee33334
Definition: cache.h:77
@ ee003
Definition: cache.h:61
@ ee22244
Definition: cache.h:76
@ ee11114
Definition: cache.h:72
@ ee2334
Definition: cache.h:67
@ ee224
Definition: cache.h:63
@ ee00004
Definition: cache.h:69
@ ee1122
Definition: cache.h:65
@ ee4444
Definition: cache.h:68
@ ee12233
Definition: cache.h:74
@ ee11123
Definition: cache.h:72
@ ee22224
Definition: cache.h:76
@ ee44
Definition: cache.h:60
@ ee24
Definition: cache.h:60
@ ee144
Definition: cache.h:62
@ ee33
Definition: cache.h:60
@ ee1134
Definition: cache.h:65
@ ee2
Definition: cache.h:59
@ ee13444
Definition: cache.h:75
@ ee3344
Definition: cache.h:68
@ ee11234
Definition: cache.h:73
@ ee11224
Definition: cache.h:73
@ ee223
Definition: cache.h:63
@ ee2223
Definition: cache.h:67
@ ee22444
Definition: cache.h:76
@ ee14
Definition: cache.h:60
@ ee0023
Definition: cache.h:64
@ ee1233
Definition: cache.h:66
@ ee34
Definition: cache.h:60
@ ee002
Definition: cache.h:61
@ ee0014
Definition: cache.h:64
@ ee11
Definition: cache.h:60
@ eeLAST
Definition: cache.h:78
@ ee00224
Definition: cache.h:70
@ ee2344
Definition: cache.h:67
@ ee00113
Definition: cache.h:69
@ ee1123
Definition: cache.h:65
@ ee1224
Definition: cache.h:66
@ ee22233
Definition: cache.h:76
@ ee0024
Definition: cache.h:64
@ ee1112
Definition: cache.h:65
@ ee1234
Definition: cache.h:66
@ ee33344
Definition: cache.h:77
@ ee12224
Definition: cache.h:74
@ ee11122
Definition: cache.h:72
@ ee1124
Definition: cache.h:65
@ ee13333
Definition: cache.h:75
@ ee222
Definition: cache.h:63
@ ee11344
Definition: cache.h:73
@ ee24444
Definition: cache.h:77
@ ee00112
Definition: cache.h:69
@ ee11144
Definition: cache.h:72
@ ee1444
Definition: cache.h:66
@ ee22222
Definition: cache.h:76
@ ee2233
Definition: cache.h:67
@ ee23334
Definition: cache.h:77
@ ee12223
Definition: cache.h:74
@ ee00223
Definition: cache.h:70
@ ee1114
Definition: cache.h:65
@ ee344
Definition: cache.h:63
@ ee00001
Definition: cache.h:69
@ ee334
Definition: cache.h:63
@ ee11333
Definition: cache.h:73
@ ee22333
Definition: cache.h:76
@ ee2444
Definition: cache.h:67
@ ee3333
Definition: cache.h:68
@ ee11134
Definition: cache.h:72
@ ee00222
Definition: cache.h:70
@ ee22344
Definition: cache.h:76
@ ee11124
Definition: cache.h:72
@ ee1144
Definition: cache.h:65
@ ee00123
Definition: cache.h:70
@ ee12222
Definition: cache.h:74
@ ee13344
Definition: cache.h:75
@ ee0
Definition: cache.h:59
@ ee2224
Definition: cache.h:67
@ ee00134
Definition: cache.h:70
@ ee0044
Definition: cache.h:64
@ ee12234
Definition: cache.h:74
@ ee11113
Definition: cache.h:72
@ ee0022
Definition: cache.h:64
@ ee001
Definition: cache.h:61
@ ee1113
Definition: cache.h:65
@ ee11444
Definition: cache.h:73
@ ee13
Definition: cache.h:60
@ ee1222
Definition: cache.h:66
@ ee244
Definition: cache.h:63
@ ee113
Definition: cache.h:62
@ ee00002
Definition: cache.h:69
@ ee12244
Definition: cache.h:74
@ ee11233
Definition: cache.h:73
@ ee112
Definition: cache.h:62
@ ee22223
Definition: cache.h:76
@ ee3
Definition: cache.h:59
@ ee23
Definition: cache.h:60
@ ee111
Definition: cache.h:62
@ ee12444
Definition: cache.h:74
@ ee00122
Definition: cache.h:70
@ ee12344
Definition: cache.h:74
@ ee2234
Definition: cache.h:67
@ ee2244
Definition: cache.h:67
@ ee22
Definition: cache.h:60
@ ee44444
Definition: cache.h:78
@ ee1244
Definition: cache.h:66
@ ee122
Definition: cache.h:62
@ ee22234
Definition: cache.h:76
@ ee004
Definition: cache.h:61
@ ee124
Definition: cache.h:62
@ ee3444
Definition: cache.h:68
@ ee33333
Definition: cache.h:77
@ ee1
Definition: cache.h:59
@ ee11222
Definition: cache.h:73
@ ee00114
Definition: cache.h:69
@ ee00344
Definition: cache.h:71
@ ee12
Definition: cache.h:60
@ ee133
Definition: cache.h:62
@ ee0011
Definition: cache.h:64
@ ee13334
Definition: cache.h:75
@ ee1334
Definition: cache.h:66
@ ee123
Definition: cache.h:62
@ ee00444
Definition: cache.h:71
@ ee444
Definition: cache.h:63
@ ee1133
Definition: cache.h:65
@ ee1344
Definition: cache.h:66
@ ee1111
Definition: cache.h:65
@ ee34444
Definition: cache.h:77
@ ee0000
Definition: cache.h:64
@ ee22334
Definition: cache.h:76
@ ee0034
Definition: cache.h:64
@ ee00133
Definition: cache.h:70
@ ee3334
Definition: cache.h:68
@ ee23333
Definition: cache.h:77
@ ee11223
Definition: cache.h:73
@ ee1333
Definition: cache.h:66
@ ee00124
Definition: cache.h:70
@ ee00111
Definition: cache.h:69
@ ee23344
Definition: cache.h:77
@ ee23444
Definition: cache.h:77
@ ee12333
Definition: cache.h:74
@ ee0012
Definition: cache.h:64
@ ee00333
Definition: cache.h:71
@ ee00003
Definition: cache.h:69
@ ee11112
Definition: cache.h:72
@ ee11334
Definition: cache.h:73
@ ee2222
Definition: cache.h:67
@ ee14444
Definition: cache.h:75
@ ee134
Definition: cache.h:62
@ ee00233
Definition: cache.h:71
@ ee333
Definition: cache.h:63
@ ee233
Definition: cache.h:63
@ ee00144
Definition: cache.h:70
@ ee11111
Definition: cache.h:72
@ ee33444
Definition: cache.h:77
@ ee12334
Definition: cache.h:74
@ ee1223
Definition: cache.h:66
@ ee00244
Definition: cache.h:71
@ ee0013
Definition: cache.h:64
@ ee00
Definition: cache.h:60
@ ee00234
Definition: cache.h:71
@ ee234
Definition: cache.h:63
@ ee11133
Definition: cache.h:72
@ ee11244
Definition: cache.h:73
@ ee114
Definition: cache.h:62
@ ee0033
Definition: cache.h:64
@ ee2333
Definition: cache.h:67
@ ee00334
Definition: cache.h:71
static ncomplex getB(int ep, const Kinem2 &kin)
Definition: cache.h:132
friend bool operator==(const double &x, const ICache::ID64 &y)
Definition: cache.h:202
Ccoefs
Definition: cache.h:92
@ cc00
Definition: cache.h:93
@ cc112
Definition: cache.h:95
@ cc111
Definition: cache.h:95
@ cc002
Definition: cache.h:94
@ cc12
Definition: cache.h:93
@ cc1
Definition: cache.h:92
@ cc2
Definition: cache.h:92
@ cc0
Definition: cache.h:92
@ ccLAST
Definition: cache.h:95
@ cc11
Definition: cache.h:93
@ cc222
Definition: cache.h:95
@ cc001
Definition: cache.h:94
@ cc22
Definition: cache.h:93
@ cc122
Definition: cache.h:95
static ncomplex getC(int ep, const Kinem3 &kin)
Definition: cache.h:126
Bcoefs
Definition: cache.h:98
@ bb0
Definition: cache.h:98
@ bb001
Definition: cache.h:100
@ bb111
Definition: cache.h:101
@ bb1
Definition: cache.h:98
@ bb00
Definition: cache.h:99
@ bbLAST
Definition: cache.h:101
@ bb11
Definition: cache.h:99
static ncomplex getE(int ep, const Kinem5 &kin)
Definition: cache.cpp:233
static ncomplex getI1(int ep, const Kinem1 &k)
static void ClearCC()
Definition: cache.cpp:47
Definition: kinem.h:93
Definition: kinem.h:105
Definition: kinem.h:123
Definition: kinem.h:147
Definition: kinem.h:180
Definition: cache.h:210
static void Clear()
Definition: cache.cpp:69
static void insertMinor5(const Kinem5 &k, Minor5::Ptr &m)
static void insertMinor4(const Kinem4 &k, Minor4::Ptr &m)
static Minor5::Ptr getMinor5(const Kinem5 &k)
static Minor2::Ptr getMinor2(const Kinem2 &k)
static Minor3::Ptr getMinor3(const Kinem3 &k)
static void smartinsertMinor2(const Kinem2 &k, Minor2::Ptr &m)
Definition: cache.cpp:690
static void insertMinor2(const Kinem2 &k, Minor2::Ptr &m)
static void insertMinor3(const Kinem3 &k, Minor3::Ptr &m)
static Minor4::Ptr getMinor4(const Kinem4 &k)
Definition: cache.cpp:658
static void smartinsertMinor3(const Kinem3 &k, Minor3::Ptr &m)
Definition: cache.cpp:679
Definition: cache.h:20
MEntry(const MEntry &entry)
TK key
Definition: cache.h:32
MEntry(const TK &k, TV &v)
Definition: cache.h:23
MEntry & operator=(const MEntry &entry)
Definition: cache.h:25
TV val
Definition: cache.h:33
MEntry()
Definition: cache.h:22
Definition: pointer.h:25
std::complex< double > ncomplex
Definition: common.h:25
double y[1000]
double x[1000]
#define ix(i)
Definition: minoreval.cpp:387