Belle II Software  release-05-01-25
DecayTree.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Thomas Keck *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <analysis/utility/DecayNode.h>
14 
15 #include <vector>
16 #include <string>
17 
18 namespace Belle2 {
28  class DecayTree {
29 
30  public:
34  explicit DecayTree(const std::string& decaystring, bool removeRadiativeGammaFlag = false);
35 
40  DecayTree(const DecayTree& tree);
41 
46  DecayTree& operator=(const DecayTree& tree);
47 
54  std::vector<DecayNode> build_tree(const std::string& decaystring, bool removeRadiativeGammaFlag);
55 
60  bool find_decay(const DecayTree& tree) const;
61 
65  std::string to_string() const;
66 
70  int getMatchSymbolPosition() const { return m_match_symbol_position; }
71 
75  bool isValid() const { return m_valid; }
76 
81  const DecayNode& getDecayNode(unsigned int n) const;
82 
87  DecayNode& getDecayNode(unsigned int n);
88 
92  size_t getNumberOfDecayNodes() const { return m_nodes_cache.size(); }
93 
94  private:
99  void build_cache(DecayNode& node);
100 
101  private:
102  bool m_valid;
103  size_t m_i;
104  unsigned int m_token_count;
107  std::vector<DecayNode*>
108  m_nodes_cache;
109  };
111 }
Belle2::DecayTree::getDecayNode
const DecayNode & getDecayNode(unsigned int n) const
Returns n-th node as const.
Definition: DecayTree.cc:144
Belle2::DecayTree::m_valid
bool m_valid
True if the tree is valid (invalid can happen if is constructed from a node with "No match")
Definition: DecayTree.h:110
Belle2::DecayTree::to_string
std::string to_string() const
Output string representation of DecayTree.
Definition: DecayTree.cc:150
Belle2::DecayTree::find_decay
bool find_decay(const DecayTree &tree) const
Check if the decay tree contains the given decay tree.
Definition: DecayTree.cc:134
Belle2::DecayTree::isValid
bool isValid() const
Returns if the decay tree is valid (constructed from a decay string which has a match)
Definition: DecayTree.h:83
Belle2::DecayTree::m_i
size_t m_i
Current position in the building of the DecayTree.
Definition: DecayTree.h:111
Belle2::DecayTree::getMatchSymbolPosition
int getMatchSymbolPosition() const
Returns position of match symbol.
Definition: DecayTree.h:78
Belle2::DecayTree::build_tree
std::vector< DecayNode > build_tree(const std::string &decaystring, bool removeRadiativeGammaFlag)
Recursively build a new tree.
Definition: DecayTree.cc:74
Belle2::DecayTree::m_match_symbol_position
int m_match_symbol_position
Position of the token with the match symbol ^.
Definition: DecayTree.h:113
Belle2::DecayTree::DecayTree
DecayTree()
Default constructor.
Definition: DecayTree.h:56
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DecayNode
DecayNode describes the decay of a particle identified by its pdg code, into list of daughters.
Definition: DecayNode.h:35
Belle2::DecayTree::getNumberOfDecayNodes
size_t getNumberOfDecayNodes() const
Return number of nodes in this tree.
Definition: DecayTree.h:100
Belle2::DecayTree::operator=
DecayTree & operator=(const DecayTree &tree)
Assign operator Required because we need to rebuild the node cache.
Definition: DecayTree.cc:50
Belle2::DecayTree::m_nodes_cache
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:116
Belle2::DecayTree::build_cache
void build_cache(DecayNode &node)
Build nodes_cache in order of appearance in the decay string for fast access.
Definition: DecayTree.cc:65
Belle2::DecayTree::m_token_count
unsigned int m_token_count
Count current tokens.
Definition: DecayTree.h:112
Belle2::DecayTree::m_root_node
DecayNode m_root_node
root DecayNode
Definition: DecayTree.h:114