 |
Belle II Software
release-05-01-25
|
11 #include <analysis/utility/DecayTree.h>
17 DecayTree::DecayTree(
const std::string& decaystring,
bool removeRadiativeGammaFlag) : m_i(0), m_token_count(0),
18 m_match_symbol_position(-1)
21 m_valid = decaystring.find(
"No match") == std::string::npos;
23 const auto& root_nodes = this->
build_tree(decaystring, removeRadiativeGammaFlag);
24 if (root_nodes.size() == 1)
38 m_root_node(tree.m_root_node)
77 const unsigned int N = decaystring.size();
78 std::vector<DecayNode> nodes;
83 if (decaystring[
m_i] ==
' ' or decaystring[
m_i] ==
'>' or (
m_i + 1 < N and decaystring[
m_i] ==
'-'
84 and decaystring[
m_i + 1] ==
'>')) {
89 if (decaystring[
m_i] ==
'^') {
95 if (decaystring[
m_i] ==
'(') {
97 nodes.back().daughters = this->
build_tree(decaystring, removeRadiativeGammaFlag);
102 if (decaystring[
m_i] ==
')') {
107 unsigned int j =
m_i + 1;
109 if (decaystring[j] ==
' ' or decaystring[j] ==
')' or decaystring[j] ==
'(')
115 const int pdg = std::stoi(decaystring.substr(
m_i, j -
m_i));
116 if (removeRadiativeGammaFlag) {
117 if (nodes.size() < 2 or pdg != 22) {
118 nodes.emplace_back(pdg);
122 nodes.emplace_back(pdg);
126 }
catch (
const std::invalid_argument&) {
const DecayNode & getDecayNode(unsigned int n) const
Returns n-th node as const.
bool m_valid
True if the tree is valid (invalid can happen if is constructed from a node with "No match")
std::string print_node(unsigned int indent=0) const
Output a single node.
std::string to_string() const
Output string representation of DecayTree.
This is a helper class for the MCDecayFinderModule.
bool find_decay(const DecayTree &tree) const
Check if the decay tree contains the given decay tree.
size_t m_i
Current position in the building of the DecayTree.
std::vector< DecayNode > build_tree(const std::string &decaystring, bool removeRadiativeGammaFlag)
Recursively build a new tree.
int m_match_symbol_position
Position of the token with the match symbol ^.
DecayTree()
Default constructor.
Abstract base class for different kinds of events.
bool find_decay(const DecayNode &to_find) const
Check if the decay node contains the given decay tree.
DecayNode describes the decay of a particle identified by its pdg code, into list of daughters.
DecayTree & operator=(const DecayTree &tree)
Assign operator Required because we need to rebuild the node cache.
std::vector< DecayNode > daughters
daughter decay nodes
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 ...
void build_cache(DecayNode &node)
Build nodes_cache in order of appearance in the decay string for fast access.
unsigned int m_token_count
Count current tokens.
DecayNode m_root_node
root DecayNode