AmpGen
2.1
Toggle main menu visibility
Loading...
Searching...
No Matches
Integrator.h
Go to the documentation of this file.
1
#ifndef AMPGEN_INTEGRATOR_H
2
#define AMPGEN_INTEGRATOR_H
3
4
#include "
AmpGen/Types.h
"
5
#include "
AmpGen/EventList.h
"
6
#include <array>
7
#include <complex>
8
#include "
AmpGen/simd/utils.h
"
9
#include "
AmpGen/Store.h
"
10
#include "
AmpGen/EventListSIMD.h
"
11
#include "
AmpGen/EventList.h
"
12
13
namespace
AmpGen
{
14
class
Integrator
{
15
#if ENABLE_AVX
16
using
EventList_t =
EventListSIMD
;
17
#else
18
using
EventList_t =
EventList
;
19
#endif
20
struct
QueuedIntegral {
21
QueuedIntegral() =
default
;
22
QueuedIntegral(
complex_t
*result,
const
unsigned
&i,
const
unsigned
&j) : result(result), i(i), j(j) {}
23
complex_t
*result = {
nullptr
};
24
unsigned
i = {0};
25
unsigned
j = {0};
26
};
27
28
public
:
29
Integrator
() =
default
;
30
31
template
<
typename
EventList_type,
typename
T>
Integrator
(
const
EventList_type *
events
,
const
std::vector<T> &expressions = {}) : m_events(
events
) {
32
if
(
events
==
nullptr
) {
33
WARNING
(
"No events specified, returning"
);
34
return
;
35
}
36
m_cache.allocate(
events
, expressions);
37
m_weight.resize(
events
->nBlocks());
38
real_v
norm_acc = 0.;
39
for
(
size_t
i = 0; i < events->nBlocks(); ++i) {
40
m_weight[i] =
events
->weight(i) /
events
->genPDF(i);
41
norm_acc += m_weight[i];
42
}
43
m_norm =
utils::sum_elements
(norm_acc);
44
}
45
46
bool
isReady
()
const
;
47
void
queueIntegral
(
complex_t
*result,
const
unsigned
&i,
const
unsigned
&j);
48
void
flush
();
49
50
template
<
class
return_type> return_type
get
(
const
unsigned
&index,
const
unsigned
&evt)
const
;
51
template
<
class
T>
unsigned
getCacheIndex
(
const
T &t)
const
{
return
m_cache.find(t.name())[0]; }
52
double
norm
()
const
{
return
m_norm; }
53
54
template
<
class
T>
void
updateCache
(
const
T &expression) {
55
if
(
isReady
()) m_cache.update(expression);
56
}
57
template
<
class
T>
const
T *
events
()
const
{
return
static_cast<
const
T *
>
(m_events); }
58
59
const
auto
&
cache
()
const
{
return
m_cache; }
60
61
private
:
62
static
constexpr
size_t
N = {8};
63
size_t
m_counter = {0};
64
std::array<QueuedIntegral, N> m_integrals;
65
const
void
*m_events = {
nullptr
};
66
std::vector<real_v> m_weight;
67
FunctionCache<EventList_t, complex_v, Alignment::SoA> m_cache;
68
double
m_norm = {0};
69
void
integrateBlock();
70
};
71
72
class
Bilinears
{
73
private
:
74
size_t
rows;
75
size_t
cols;
76
std::vector<complex_t> norms;
77
std::vector<bool> markAsZero;
78
std::vector<bool> calculate;
79
80
public
:
81
Bilinears
(
const
size_t
&r = 0,
const
size_t
&c = 0);
82
complex_t
get
(
const
size_t
&x,
const
size_t
&y)
const
;
83
complex_t
get
(
const
size_t
&x,
const
size_t
&y,
Integrator
*integ =
nullptr
,
const
size_t
&kx = 0,
const
size_t
&ky = 0) {
84
if
(integ !=
nullptr
) integ->queueIntegral(&norms[x * cols + y], kx, ky);
86
return
norms[x * cols + y];
87
}
88
void
set
(
const
size_t
&x,
const
size_t
&y,
const
complex_t
&f);
89
void
setZero
(
const
size_t
&x,
const
size_t
&y);
90
void
resetCalculateFlags
();
91
complex_t
&
operator()
(
const
size_t
&x,
const
size_t
&y);
92
bool
isZero
(
const
size_t
&x,
const
size_t
&y);
93
bool
workToDo
(
const
size_t
&x,
const
size_t
&y)
const
;
94
void
resize
(
const
size_t
&r,
const
size_t
&c = 1);
95
};
96
97
}
// namespace AmpGen
98
#endif
EventList.h
EventListSIMD.h
Store.h
Types.h
AmpGen::Bilinears::Bilinears
Bilinears(const size_t &r=0, const size_t &c=0)
AmpGen::Bilinears::workToDo
bool workToDo(const size_t &x, const size_t &y) const
AmpGen::Bilinears::resetCalculateFlags
void resetCalculateFlags()
AmpGen::Bilinears::get
complex_t get(const size_t &x, const size_t &y) const
AmpGen::Bilinears::operator()
complex_t & operator()(const size_t &x, const size_t &y)
AmpGen::Bilinears::resize
void resize(const size_t &r, const size_t &c=1)
AmpGen::Bilinears::set
void set(const size_t &x, const size_t &y, const complex_t &f)
AmpGen::Bilinears::setZero
void setZero(const size_t &x, const size_t &y)
AmpGen::Bilinears::get
complex_t get(const size_t &x, const size_t &y, Integrator *integ=nullptr, const size_t &kx=0, const size_t &ky=0)
Definition
Integrator.h:83
AmpGen::Bilinears::isZero
bool isZero(const size_t &x, const size_t &y)
AmpGen::EventList
Definition
EventList.h:32
AmpGen::EventListSIMD
Definition
EventListSIMD.h:32
AmpGen::Integrator
Definition
Integrator.h:14
AmpGen::Integrator::events
const T * events() const
Definition
Integrator.h:57
AmpGen::Integrator::Integrator
Integrator()=default
AmpGen::Integrator::getCacheIndex
unsigned getCacheIndex(const T &t) const
Definition
Integrator.h:51
AmpGen::Integrator::get
return_type get(const unsigned &index, const unsigned &evt) const
AmpGen::Integrator::norm
double norm() const
Definition
Integrator.h:52
AmpGen::Integrator::updateCache
void updateCache(const T &expression)
Definition
Integrator.h:54
AmpGen::Integrator::Integrator
Integrator(const EventList_type *events, const std::vector< T > &expressions={})
Definition
Integrator.h:31
AmpGen::Integrator::isReady
bool isReady() const
AmpGen::Integrator::flush
void flush()
AmpGen::Integrator::cache
const auto & cache() const
Definition
Integrator.h:59
AmpGen::Integrator::queueIntegral
void queueIntegral(complex_t *result, const unsigned &i, const unsigned &j)
WARNING
#define WARNING(X)
Used for printing warning messages, can be switched off using WARNINGLEVEL.
Definition
MsgService.h:103
AmpGen::utils::sum_elements
auto sum_elements(const simd_type &obj)
Definition
utils.h:87
AmpGen
Definition
AddCPConjugate.h:2
AmpGen::complex_t
std::complex< real_t > complex_t
Definition
Types.h:7
AmpGen::real_v
AVX::real_v real_v
Definition
utils.h:47
utils.h
AmpGen
Integrator.h
Generated on
for AmpGen by
1.17.0