Belle II Software development
DecayTree.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <analysis/utility/DecayNode.h>
12
13#include <vector>
14#include <string>
15
16namespace Belle2 {
26 class DecayTree {
27
28 public:
32 explicit DecayTree(const std::string& decaystring, bool removeRadiativeGammaFlag = false);
33
38 DecayTree(const DecayTree& tree);
39
44 DecayTree& operator=(const DecayTree& tree);
45
52 std::vector<DecayNode> build_tree(const std::string& decaystring, bool removeRadiativeGammaFlag);
53
58 bool find_decay(const DecayTree& tree) const;
59
63 std::string to_string() const;
64
69
73 bool isValid() const { return m_valid; }
74
79 const DecayNode& getDecayNode(unsigned int n) const;
80
85 DecayNode& getDecayNode(unsigned int n);
86
90 size_t getNumberOfDecayNodes() const { return m_nodes_cache.size(); }
91
92 private:
97 void build_cache(DecayNode& node);
98
99 private:
100 bool m_valid;
101 size_t m_i;
102 unsigned int m_token_count;
105 std::vector<DecayNode*>
107 };
109}
DecayNode describes the decay of a particle identified by its pdg code, into list of daughters.
Definition: DecayNode.h:23
DecayTree & operator=(const DecayTree &tree)
Assign operator Required because we need to rebuild the node cache.
Definition: DecayTree.cc:45
unsigned int m_token_count
Count current tokens.
Definition: DecayTree.h:102
bool isValid() const
Returns if the decay tree is valid (constructed from a decay string which has a match)
Definition: DecayTree.h:73
std::vector< DecayNode * > m_nodes_cache
Vector of decay nodes of the particles in the order of their appearance in the decay string for fast ...
Definition: DecayTree.h:106
DecayNode m_root_node
root DecayNode
Definition: DecayTree.h:104
bool m_valid
True if the tree is valid (invalid can happen if is constructed from a node with "No match")
Definition: DecayTree.h:100
size_t getNumberOfDecayNodes() const
Return number of nodes in this tree.
Definition: DecayTree.h:90
const DecayNode & getDecayNode(unsigned int n) const
Returns n-th node as const.
Definition: DecayTree.cc:139
std::vector< DecayNode > build_tree(const std::string &decaystring, bool removeRadiativeGammaFlag)
Recursively build a new tree.
Definition: DecayTree.cc:69
int getMatchSymbolPosition() const
Returns position of match symbol.
Definition: DecayTree.h:68
std::string to_string() const
Output string representation of DecayTree.
Definition: DecayTree.cc:145
int m_match_symbol_position
Position of the token with the match symbol ^.
Definition: DecayTree.h:103
bool find_decay(const DecayTree &tree) const
Check if the decay tree contains the given decay tree.
Definition: DecayTree.cc:129
size_t m_i
Current position in the building of the DecayTree.
Definition: DecayTree.h:101
void build_cache(DecayNode &node)
Build nodes_cache in order of appearance in the decay string for fast access.
Definition: DecayTree.cc:60
DecayTree()
Default constructor.
Definition: DecayTree.h:43
Abstract base class for different kinds of events.