1#ifndef AMPGEN_EVENTLIST_H
2#define AMPGEN_EVENTLIST_H
34 std::vector<Event> m_data = {};
36 std::map<std::string, unsigned int> m_extensions = {};
46 template <
class... ARGS>
EventList(
const std::vector<std::string> &fname,
const EventType &evtType,
const ARGS &...args) :
EventList(evtType) {
53 std::vector<Event>::reverse_iterator
rbegin() {
return m_data.rbegin(); }
54 std::vector<Event>::reverse_iterator
rend() {
return m_data.rend(); }
55 std::vector<Event>::iterator
begin() {
return m_data.begin(); }
56 std::vector<Event>::iterator
end() {
return m_data.end(); }
60 std::vector<Event>::const_iterator
begin()
const {
return m_data.cbegin(); }
61 std::vector<Event>::const_iterator
end()
const {
return m_data.cend(); }
64 const Event &
at(
const size_t &pos)
const {
return m_data[pos]; }
65 size_t size()
const {
return m_data.size(); }
67 size_t nBlocks()
const {
return m_data.size(); }
69 double *
block(
const unsigned pos) {
return m_data[pos].address(); }
70 real_t weight(
const size_t &pos)
const {
return m_data[pos].weight(); }
71 real_t genPDF(
const size_t &pos)
const {
return m_data[pos].genPdf(); }
72 unsigned key(
const std::string &
key)
const {
73 auto it = m_extensions.find(
key);
74 if(it == m_extensions.end())
return m_data[0].size() - 1;
86 void extend(
const std::string &
key,
unsigned pos) { m_extensions[
key] = pos; }
88 void setWeight(
const unsigned int &pos,
const double &w,
const double &g = +1) {
89 m_data[pos].setWeight(w);
90 m_data[pos].setGenPdf(g);
92 void setGenPDF(
const unsigned int &pos,
const double &g) { m_data[pos].setGenPdf(g); }
93 void erase(
const std::vector<Event>::iterator &
begin,
const std::vector<Event>::iterator &
end);
95 TTree *
tree(
const std::string &name,
const std::vector<std::string> &extraBranches = {})
const;
103 size_t nBins = argPack.getArg<PlotOptions::Bins>(100);
108 template <
typename... ARGS> std::vector<TH1D *>
makeProjections(
const std::vector<Projection> &projections,
const ARGS &...args) {
112 template <
typename... ARGS,
typename = std::enable_if_t<!std::is_same<
zeroType<ARGS...>,
ArgumentPack>::value>>
117 template <
typename... ARGS,
typename = std::enable_if_t<!std::is_same<
zeroType<ARGS...>,
ArgumentPack>::value>>
123 for(
auto &event : m_data)
fcn(event);
127 template <
typename functor>
void filter(functor &&
fcn) {
128 unsigned currentSize =
size();
129 m_data.erase(std::remove_if(m_data.begin(), m_data.end(),
fcn), m_data.end());
130 INFO(
"Filter retains " <<
size() <<
" / " << currentSize <<
" events");
133 template <
typename functor>
unsigned count(functor &&
fcn)
const {
return std::count_if(std::begin(*
this), std::end(*
this),
fcn); }
138 std::vector<std::string>);
#define DECLARE_ARGUMENT(X, Y)
Container for a set of arguments Contains a set of arguments packed from a variadic constructor,...
Base class for compiled expressions, i.e.
Encapsulates the final state particles of a single event.
double * block(const unsigned pos)
EventList(const EventType &type)
std::vector< Event >::iterator begin()
EventList & transform(functor &&fcn)
const Event & at(const size_t &pos) const
void setEventType(const EventType &type)
std::vector< TH1D * > makeDefaultProjections(const ARGS &...args)
real_t * getEvent(const size_t &index)
EventList(const std::vector< std::string > &fname, const EventType &evtType, const ARGS &...args)
TTree * tree(const std::string &name, const std::vector< std::string > &extraBranches={}) const
unsigned key(const std::string &key) const
TH1D * makeProjection(const Projection &projection, const ARGS &...args) const
std::vector< TH1D * > makeProjections(const std::vector< Projection > &projections, const ArgumentPack &args)
void setGenPDF(const unsigned int &pos, const double &g)
void reserve(const size_t &size)
real_t weight(const size_t &pos) const
TH2D * makeProjection(const Projection2D &projection, const ARGS &...args)
std::vector< Event >::reverse_iterator rbegin()
EventList(TTree *tree, const EventType &evtType, const ARGS &...args)
Event & operator[](const size_t &pos)
EventType eventType() const
TH1D * makeProjection(const Projection &projection, const ArgumentPack &args=ArgumentPack()) const
std::vector< Event >::const_iterator end() const
void loadFromFile(const std::string &fname, const ArgumentPack &args)
void emplace_back(const Event &evt)
void filter(functor &&fcn)
std::vector< Event >::const_iterator begin() const
size_t aligned_size() const
TH2D * makeProjection(const Projection2D &projection, const ArgumentPack &args=ArgumentPack()) const
void erase(const std::vector< Event >::iterator &begin, const std::vector< Event >::iterator &end)
std::vector< Event >::iterator end()
std::vector< Event >::reverse_iterator rend()
void loadFromTree(TTree *tree, const ArgumentPack &args)
EventList(const std::string &fname, const EventType &evtType, const ARGS &...args)
void add(const EventList &evts)
void extend(const std::string &key, unsigned pos)
EventList(const std::string &fname, const ARGS &...args)
unsigned count(functor &&fcn) const
void resize(const size_t &size)
std::vector< TH1D * > makeProjections(const std::vector< Projection > &projections, const ARGS &...args)
const EventList & store() const
void setWeight(const unsigned int &pos, const double &w, const double &g=+1)
const Event & operator[](const size_t &pos) const
void push_back(const Event &evt)
const real_t * getEvent(const size_t &index) const
real_t genPDF(const size_t &pos) const
Deals with final state configuration of events, specifically dealing with the ordering of particles i...
std::vector< Projection > defaultProjections(const unsigned &nBins=100, const std::string &var="mass2") const
#define INFO(X)
Used for printing information messages, and will always be printed.
typename detail::zeroType< args... >::type zeroType