40 virtual void serialize(std::ostream &stream)
const = 0;
41 virtual void visit(
const std::function<
void(
INode *)> &visit_function) = 0;
48 void serialize(std::ostream &stream)
const override;
49 unsigned int voxNumber()
const {
return m_voxNumber; }
50 unsigned int binNumber()
const {
return m_binNumber; }
52 void visit(
const std::function<
void(
INode *)> &visit_function)
override { visit_function(
this); }
56 unsigned int m_voxNumber;
57 unsigned int m_binNumber;
62 Decision(
const unsigned int &index,
const double &value, std::shared_ptr<INode> left =
nullptr, std::shared_ptr<INode> right =
nullptr);
64 void serialize(std::ostream &stream)
const override;
65 void setChildren(std::shared_ptr<INode> l, std::shared_ptr<INode> r);
66 void visit(
const std::function<
void(
INode *)> &visit_function)
override;
71 std::shared_ptr<INode> m_left;
72 std::shared_ptr<INode> m_right;
83 template <
class iterator_type,
class... ARGS>
91 std::shared_ptr<INode>
top() {
return m_top; }
95 unsigned int getBin(
const double *evt)
const;
100 void setQueueOrdering(
const std::vector<unsigned> &queueOrdering) { m_queueOrdering = queueOrdering; }
101 std::vector<std::shared_ptr<EndNode>> &
nodes() {
return m_endNodes; }
102 const std::vector<std::shared_ptr<EndNode>> &
const_nodes()
const {
return m_endNodes; }
103 std::vector<std::shared_ptr<EndNode>>::iterator
begin() {
return m_endNodes.begin(); }
104 std::vector<std::shared_ptr<EndNode>>::iterator
end() {
return m_endNodes.end(); }
107 void refreshQueue(
const std::vector<double *> &, std::queue<unsigned> &,
const unsigned &);
108 template <
class iterator_type> std::shared_ptr<INode>
makeNodes(
const iterator_type &
begin,
const iterator_type &
end) {
109 std::vector<double> data(m_dim * (
end -
begin));
110 std::vector<double *> addresses(
end -
begin);
112 for(
auto evt =
begin; evt !=
end; ++evt) {
113 auto val = m_functors(*evt);
114 for(
unsigned int i = 0; i < m_dim; ++i) data[m_dim * counter + i] = val[i];
115 addresses[counter] = &(data[m_dim * counter]);
120 std::shared_ptr<INode>
makeNodes(
const std::vector<double *> &, std::queue<unsigned>,
const unsigned &);
121 std::shared_ptr<INode>
makeNodes(
const std::vector<double *> &);
122 std::shared_ptr<INode>
makeNodes(
const std::vector<double *> &,
const std::vector<double *> &);
123 std::shared_ptr<INode>
makeNodes(std::vector<double *>, std::vector<double *>, std::queue<unsigned>,
const unsigned &);
124 void setFunctor(
const std::function<std::vector<double>(
const Event &)> &functors) { m_functors = functors; }
127 std::shared_ptr<INode> m_top = {
nullptr};
128 unsigned m_dim = {0};
129 unsigned m_minEvents = {0};
130 unsigned m_maxDepth = {0};
131 std::vector<unsigned> m_queueOrdering = {};
132 std::vector<std::shared_ptr<EndNode>> m_endNodes = {};
133 std::function<std::vector<double>(
const Event &)> m_functors = {};
134 double getBestPost(
const std::vector<double *> &source,
const std::vector<double *> &target,
int index,
bool verbose =
false);
#define DECLARE_ARGUMENT(X, Y)
Container for a set of arguments Contains a set of arguments packed from a variadic constructor,...
Decision(const unsigned int &index, const double &value, std::shared_ptr< INode > left=nullptr, std::shared_ptr< INode > right=nullptr)
void visit(const std::function< void(INode *)> &visit_function) override
const EndNode * operator()(const double *evt) const override
void serialize(std::ostream &stream) const override
void setChildren(std::shared_ptr< INode > l, std::shared_ptr< INode > r)
const EndNode * operator()(const double *evt) const override
void serialize(std::ostream &stream) const override
void visit(const std::function< void(INode *)> &visit_function) override
unsigned int binNumber() const
unsigned int voxNumber() const
EndNode(const unsigned int &no, const unsigned int &binNumber=999)
void setBinNumber(const unsigned int &binNumber)
virtual const EndNode * operator()(const double *evt) const =0
virtual void visit(const std::function< void(INode *)> &visit_function)=0
virtual void serialize(std::ostream &stream) const =0
void serialize(std::ofstream &output)
BinDT(const EventList &events, const ARGS &...args)
std::shared_ptr< INode > makeNodes(std::vector< double * >, std::vector< double * >, std::queue< unsigned >, const unsigned &)
BinDT(const std::vector< double * > &addr, const ARGS &...args)
std::shared_ptr< INode > makeNodes(const iterator_type &begin, const iterator_type &end)
void refreshQueue(const std::vector< double * > &, std::queue< unsigned > &, const unsigned &)
unsigned int getBin(const double *evt) const
unsigned int getBinNumber(const double *evt) const
unsigned int getBin(const Event &evt) const
const std::vector< std::shared_ptr< EndNode > > & const_nodes() const
std::vector< std::shared_ptr< EndNode > >::iterator begin()
BinDT(const iterator_type &begin, const iterator_type &end, const ARGS &...args)
void readFromStream(std::istream &stream)
std::shared_ptr< INode > makeNodes(const std::vector< double * > &, const std::vector< double * > &)
BinDT(const ARGS &...args)
void serialize(const std::string &filename)
std::vector< std::shared_ptr< EndNode > >::iterator end()
unsigned int getBinNumber(const Event &evt) const
void setQueueOrdering(const std::vector< unsigned > &queueOrdering)
BinDT(const EventList &events, const ArgumentPack &args)
std::shared_ptr< INode > top()
std::shared_ptr< INode > makeNodes(const std::vector< double * > &, std::queue< unsigned >, const unsigned &)
void setFunctor(const std::function< std::vector< double >(const Event &)> &functors)
std::function< std::vector< double >(const Event &)> makeDefaultFunctors()
unsigned int size() const
BinDT(const ArgumentPack &args)
std::shared_ptr< INode > makeNodes(const std::vector< double * > &)
std::vector< std::shared_ptr< EndNode > > & nodes()
Encapsulates the final state particles of a single event.
std::vector< Event >::iterator begin()
std::vector< Event >::iterator end()