AmpGen 2.1
Loading...
Searching...
No Matches
CoherentSum.h
Go to the documentation of this file.
1#ifndef AMPGEN_COHERENTSUM_H
2#define AMPGEN_COHERENTSUM_H
3
4#include <memory.h>
5#include <stddef.h>
6#include <complex>
7#include <map>
8#include <memory>
9#include <string>
10#include <utility>
11#include <vector>
12
16#include "AmpGen/EventList.h"
18#include "AmpGen/EventType.h"
19#include "AmpGen/Integrator.h"
20#include "AmpGen/Types.h"
21#include "AmpGen/Event.h"
22#include "AmpGen/Projection.h"
24#include "AmpGen/Store.h"
26#include "AmpGen/Property.h"
27
28namespace AmpGen {
31 class FitFraction;
32 class Particle;
33
45 class CoherentSum : public Configurable<CoherentSum> {
46 public:
47#if ENABLE_AVX
49#else
51#endif
53 CoherentSum(const EventType &type, const AmpGen::MinuitParameterSet &mps, const std::string &prefix = "");
54 virtual ~CoherentSum();
55
56 std::string prefix() const { return m_prefix; }
57
58 auto &operator[](const size_t &index) { return m_matrixElements[index]; }
59 auto &operator[](const size_t &index) const { return m_matrixElements[index]; }
60 size_t size() const { return m_matrixElements.size(); }
61 real_t getWeight() const { return m_weight; }
62 real_t norm(const Bilinears &norms) const;
63 real_t norm() const;
64 real_t getNorm(const Bilinears &normalisations);
65
66 complex_t norm(const size_t &x, const size_t &y) const;
67 complex_t getVal(const Event &evt) const;
68 complex_t getValNoCache(const Event &evt) const;
69
71 void prepare();
72 void printVal(const Event &evt);
74 void setWeight(MinuitProxy param) { m_weight = param; }
76 void reset(bool resetEvents = false);
77 void setEvents(const EventList_type &list);
78 void setMC(const EventList_type &sim);
79#if ENABLE_AVX
80 void setEvents(const EventList &list) {
81 WARNING("Setting events from a AoS container, will need to make a copy");
82 m_ownEvents = true;
83 setEvents(*(new EventListSIMD(list)));
84 }
85 void setMC(const EventList &list) {
86 WARNING("Setting integration events from a AoS container, will need to make a copy");
87 setMC(*(new EventListSIMD(list)));
88 }
89 // double operator()(const double*, const unsigned) const;
90#endif
91
92 real_v operator()(const real_v *, const unsigned) const;
93 real_t operator()(const Event &evt) const { return m_weight * std::norm(getVal(evt)) / m_norm; }
94
95 void debug(const Event &, const std::string & = "");
96 void generateSourceCode(const std::string &, const double & = 1, bool = false);
97
98 std::vector<FitFraction> fitFractions(const LinearErrorPropagator &, bool = false);
99 auto matrixElements() const { return m_matrixElements; }
100
101 std::map<std::string, std::vector<unsigned int>> getGroupedAmplitudes();
102 Bilinears norms() const { return m_normalisations; }
103
104 std::function<real_t(const Event &)> evaluator(const EventList_type * = nullptr) const;
105 std::function<complex_t(const Event &)> amplitudeEvaluator(const EventList_type * = nullptr) const;
106 KeyedFunctors<double(Event)> componentEvaluator(const EventList_type * = nullptr) const;
107 EventType eventType() const { return m_eventType; }
108 const auto &cache() const { return m_cache; }
109
110 protected:
111 // Property<int> m_verbose{this, "CoherentSum::Verbose", 0, "Flag for verbose printing"};
112
113 std::vector<MatrixElement> m_matrixElements;
116 const EventList_type *m_events = {nullptr};
118
119 bool m_ownEvents = {false};
121 size_t m_prepareCalls = {0};
122 size_t m_lastPrint = {0};
123 MinuitProxy m_weight = {nullptr, 1};
124 double m_norm = {1};
125 bool m_isConstant = {false};
126 bool m_verbosity = {false};
127 std::string m_prefix = {""};
128 const MinuitParameterSet *m_mps = {nullptr};
129 void addMatrixElement(std::pair<Particle, TotalCoupling> &particleWithCoupling, const MinuitParameterSet &mps);
130 };
131} // namespace AmpGen
132
133#endif
real_t norm(const Bilinears &norms) const
std::string prefix() const
Definition CoherentSum.h:56
size_t size() const
Definition CoherentSum.h:60
real_t norm() const
auto matrixElements() const
Definition CoherentSum.h:99
Bilinears norms() const
void printVal(const Event &evt)
CoherentSum(const EventType &type, const AmpGen::MinuitParameterSet &mps, const std::string &prefix="")
bool m_ownEvents
Flag as to whether events are owned by this PDF or not.
std::vector< FitFraction > fitFractions(const LinearErrorPropagator &, bool=false)
Integrator m_integrator
Tool to calculate integrals.
std::string m_prefix
Prefix for matrix elements.
complex_t getValNoCache(const Event &evt) const
void setMC(const EventList_type &sim)
std::function< real_t(const Event &)> evaluator(const EventList_type *=nullptr) const
void setWeight(MinuitProxy param)
Definition CoherentSum.h:74
MinuitProxy m_weight
Weight (i.e. the normalised yield).
void generateSourceCode(const std::string &, const double &=1, bool=false)
void setEvents(const EventList_type &list)
void addMatrixElement(std::pair< Particle, TotalCoupling > &particleWithCoupling, const MinuitParameterSet &mps)
auto & operator[](const size_t &index) const
Definition CoherentSum.h:59
EventList EventList_type
Definition CoherentSum.h:50
bool m_verbosity
Flag for verbose printing.
Bilinears m_normalisations
Normalisation integrals.
void debug(const Event &, const std::string &="")
complex_t getVal(const Event &evt) const
const auto & cache() const
EventType eventType() const
EventType m_eventType
Final state for this amplitude.
real_t getNorm(const Bilinears &normalisations)
const EventList_type * m_events
Data events to evaluate PDF on.
size_t m_lastPrint
Last time verbose PDF info was printed.
real_t operator()(const Event &evt) const
Definition CoherentSum.h:93
const MinuitParameterSet * m_mps
virtual ~CoherentSum()
std::vector< MatrixElement > m_matrixElements
Vector of matrix elements.
real_t getWeight() const
Definition CoherentSum.h:61
void reset(bool resetEvents=false)
FunctionCache< EventList_type, complex_v, Alignment::AoS > m_cache
Store of intermediate values for the PDF calculation.
real_v operator()(const real_v *, const unsigned) const
std::map< std::string, std::vector< unsigned int > > getGroupedAmplitudes()
KeyedFunctors< double(Event)> componentEvaluator(const EventList_type *=nullptr) const
double m_norm
Normalisation integral.
bool m_isConstant
Flag for a constant PDF.
auto & operator[](const size_t &index)
Definition CoherentSum.h:58
complex_t norm(const size_t &x, const size_t &y) const
std::function< complex_t(const Event &)> amplitudeEvaluator(const EventList_type *=nullptr) const
size_t m_prepareCalls
Number of times prepare has been called.
Encapsulates the final state particles of a single event.
Definition Event.h:19
Deals with final state configuration of events, specifically dealing with the ordering of particles i...
Definition EventType.h:22
Propagates uncertainties on functors using either a MinuitParameterSet (thus assuming a diagonal cova...
Describes a particle, its decay process and subsequent decay products, which are also Particles.
Definition Particle.h:103
#define WARNING(X)
Used for printing warning messages, can be switched off using WARNINGLEVEL.
Definition MsgService.h:103
double real_t
Definition Types.h:6
std::complex< real_t > complex_t
Definition Types.h:7
AVX::real_v real_v
Definition utils.h:47