ComPWA
Common Partial-Wave-Analysis Framework
|
TreeNode is the basic building block of the FunctionTree. More...
#include <TreeNode.hpp>
Public Member Functions | |
TreeNode (std::shared_ptr< Strategy > strategy) | |
Constructor for tree using a strategy . More... | |
TreeNode (std::shared_ptr< Parameter > parameter, std::shared_ptr< Strategy > strategy=nullptr) | |
Constructor for tree using a parameter and a strategy . More... | |
virtual | ~TreeNode () |
void | removeExpiredParents () |
void | addNode (std::shared_ptr< TreeNode > node) |
void | addNodes (std::vector< std::shared_ptr< TreeNode >> nodes) |
void | addParent (std::weak_ptr< TreeNode > node) |
std::shared_ptr< Parameter > | parameter () |
Obtain parameter of node. More... | |
void | fillParameters (ParameterList &list) |
Fill ParameterList with parameters. More... | |
void | update () |
Flags the node as modified. Should only be called from its child nodes. More... | |
std::string | print (int level=-1, std::string prefix="") |
Print node and its child nodes to std::string. More... | |
Private Member Functions | |
std::shared_ptr< ComPWA::FunctionTree::Parameter > | recalculate () |
Obtain parameter of node. More... | |
Private Attributes | |
std::vector< std::weak_ptr< TreeNode > > | Parents |
List of parent nodes. More... | |
std::vector< std::shared_ptr< TreeNode > > | ChildNodes |
std::shared_ptr< ComPWA::FunctionTree::Parameter > | OutputParameter |
(cached) node value More... | |
bool | HasChanged |
Node has changed and needs to call recalculate() More... | |
std::shared_ptr< Strategy > | Strat |
Node strategy. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, std::shared_ptr< TreeNode > p) |
TreeNode is the basic building block of the FunctionTree.
A FunctionTree is merely a collection of TreeNodes that are connected to each other in a specific way via addNode(). The FunctionTree represents an arbitrary function. structure. Parts of the tree that were calculated before and have not been changed are cached. This reduces the amount of recalculation at evaluation time.
There are normal TreeNodes which perform a calculation. They have a Strategy to calculate its value. The other type of TreeNodes are leaves. They simply need an output parameter and acts as a data source. Leaves can be created via createLeaf().
Definition at line 35 of file TreeNode.hpp.
ComPWA::FunctionTree::TreeNode::TreeNode | ( | std::shared_ptr< Strategy > | strategy | ) |
Constructor for tree using a strategy
.
This will not cache the output value
Definition at line 15 of file TreeNode.cpp.
ComPWA::FunctionTree::TreeNode::TreeNode | ( | std::shared_ptr< Parameter > | parameter, |
std::shared_ptr< Strategy > | strategy = nullptr |
||
) |
Constructor for tree using a parameter
and a strategy
.
The output value will be cached.
Definition at line 21 of file TreeNode.cpp.
|
virtual |
Definition at line 33 of file TreeNode.cpp.
void ComPWA::FunctionTree::TreeNode::addNode | ( | std::shared_ptr< TreeNode > | node | ) |
Definition at line 48 of file TreeNode.cpp.
void ComPWA::FunctionTree::TreeNode::addNodes | ( | std::vector< std::shared_ptr< TreeNode >> | nodes | ) |
Definition at line 53 of file TreeNode.cpp.
void ComPWA::FunctionTree::TreeNode::addParent | ( | std::weak_ptr< TreeNode > | node | ) |
Definition at line 61 of file TreeNode.cpp.
void ComPWA::FunctionTree::TreeNode::fillParameters | ( | ParameterList & | list | ) |
Fill ParameterList with parameters.
The function is intended to be filled with fit parameters, so we add only FitParameters.
Definition at line 119 of file TreeNode.cpp.
std::shared_ptr< Parameter > ComPWA::FunctionTree::TreeNode::parameter | ( | ) |
Obtain parameter of node.
In case child nodes have changed, child nodes are recalculated and Parameter is updated
Definition at line 71 of file TreeNode.cpp.
std::string ComPWA::FunctionTree::TreeNode::print | ( | int | level = -1 , |
std::string | prefix = "" |
||
) |
Print node and its child nodes to std::string.
The recursion goes down until level
is reached. A prefix
can be added inorder to create a tree like output.
Definition at line 126 of file TreeNode.cpp.
|
private |
Obtain parameter of node.
In case child nodes have changed, child nodes are recalculated and Parameter is updated
Definition at line 90 of file TreeNode.cpp.
void ComPWA::FunctionTree::TreeNode::removeExpiredParents | ( | ) |
Definition at line 42 of file TreeNode.cpp.
|
virtual |
Flags the node as modified. Should only be called from its child nodes.
Implements ComPWA::FunctionTree::ParObserver.
Definition at line 65 of file TreeNode.cpp.
|
friend |
Definition at line 65 of file TreeNode.hpp.
|
private |
Definition at line 80 of file TreeNode.hpp.
|
private |
Node has changed and needs to call recalculate()
Definition at line 86 of file TreeNode.hpp.
|
private |
(cached) node value
Definition at line 83 of file TreeNode.hpp.
|
private |
List of parent nodes.
Definition at line 77 of file TreeNode.hpp.
|
private |
Node strategy.
Strategy defines how the node value calculated given its child nodes and child leafs.
Definition at line 90 of file TreeNode.hpp.