ComPWA
Common Partial-Wave-Analysis Framework
ComPWA::FunctionTree::TreeNode Class Reference

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< Parameterparameter ()
 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::Parameterrecalculate ()
 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::ParameterOutputParameter
 (cached) node value More...
 
bool HasChanged
 Node has changed and needs to call recalculate() More...
 
std::shared_ptr< StrategyStrat
 Node strategy. More...
 

Friends

std::ostream & operator<< (std::ostream &os, std::shared_ptr< TreeNode > p)
 

Detailed Description

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.

+ Inheritance diagram for ComPWA::FunctionTree::TreeNode:
+ Collaboration diagram for ComPWA::FunctionTree::TreeNode:

Constructor & Destructor Documentation

◆ TreeNode() [1/2]

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.

◆ TreeNode() [2/2]

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.

◆ ~TreeNode()

ComPWA::FunctionTree::TreeNode::~TreeNode ( )
virtual

Definition at line 33 of file TreeNode.cpp.

Member Function Documentation

◆ addNode()

void ComPWA::FunctionTree::TreeNode::addNode ( std::shared_ptr< TreeNode node)

Definition at line 48 of file TreeNode.cpp.

◆ addNodes()

void ComPWA::FunctionTree::TreeNode::addNodes ( std::vector< std::shared_ptr< TreeNode >>  nodes)

Definition at line 53 of file TreeNode.cpp.

◆ addParent()

void ComPWA::FunctionTree::TreeNode::addParent ( std::weak_ptr< TreeNode node)

Definition at line 61 of file TreeNode.cpp.

◆ fillParameters()

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.

◆ parameter()

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.

◆ print()

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.

◆ recalculate()

std::shared_ptr< Parameter > ComPWA::FunctionTree::TreeNode::recalculate ( )
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.

◆ removeExpiredParents()

void ComPWA::FunctionTree::TreeNode::removeExpiredParents ( )

Definition at line 42 of file TreeNode.cpp.

◆ update()

void ComPWA::FunctionTree::TreeNode::update ( )
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.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
std::shared_ptr< TreeNode p 
)
friend

Definition at line 65 of file TreeNode.hpp.

Member Data Documentation

◆ ChildNodes

std::vector<std::shared_ptr<TreeNode> > ComPWA::FunctionTree::TreeNode::ChildNodes
private

Definition at line 80 of file TreeNode.hpp.

◆ HasChanged

bool ComPWA::FunctionTree::TreeNode::HasChanged
private

Node has changed and needs to call recalculate()

Definition at line 86 of file TreeNode.hpp.

◆ OutputParameter

std::shared_ptr<ComPWA::FunctionTree::Parameter> ComPWA::FunctionTree::TreeNode::OutputParameter
private

(cached) node value

Definition at line 83 of file TreeNode.hpp.

◆ Parents

std::vector<std::weak_ptr<TreeNode> > ComPWA::FunctionTree::TreeNode::Parents
private

List of parent nodes.

Definition at line 77 of file TreeNode.hpp.

◆ Strat

std::shared_ptr<Strategy> ComPWA::FunctionTree::TreeNode::Strat
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.


The documentation for this class was generated from the following files: