9 #include <analysis/utility/DecayTree.h> 
   10 #include <framework/gearbox/Const.h> 
   16 DecayTree::DecayTree(
const std::string& decaystring, 
bool removeRadiativeGammaFlag) : m_i(0), m_token_count(0),
 
   17   m_match_symbol_position(-1)
 
   20   m_valid = decaystring.find(
"No match") == std::string::npos;
 
   22     const auto& root_nodes = this->
build_tree(decaystring, removeRadiativeGammaFlag);
 
   23     if (root_nodes.size() == 1) {
 
   33   m_root_node(tree.m_root_node)
 
   72   const unsigned int N = decaystring.size();
 
   73   std::vector<DecayNode> nodes;
 
   78     if (decaystring[
m_i] == 
' ' or decaystring[
m_i] == 
'>' or (
m_i + 1 < N and decaystring[
m_i] == 
'-' 
   79                                                                and decaystring[
m_i + 1] == 
'>')) {
 
   84     if (decaystring[
m_i] == 
'^') {
 
   90     if (decaystring[
m_i] == 
'(') {
 
   92       nodes.back().daughters = this->
build_tree(decaystring, removeRadiativeGammaFlag);
 
   97     if (decaystring[
m_i] == 
')') {
 
  102     unsigned int j = 
m_i + 1;
 
  104       if (decaystring[j] == 
' ' or decaystring[j] == 
')' or decaystring[j] == 
'(')
 
  110       const int pdg = std::stoi(decaystring.substr(
m_i, j - 
m_i));
 
  111       if (removeRadiativeGammaFlag) {
 
  113           nodes.emplace_back(pdg);
 
  117         nodes.emplace_back(pdg);
 
  121     } 
catch (
const std::invalid_argument&) {
 
int getPDGCode() const
PDG code.
static const ParticleType photon
photon particle
DecayNode describes the decay of a particle identified by its pdg code, into list of daughters.
std::vector< DecayNode > daughters
daughter decay nodes
This is a helper class for the MCDecayFinderModule.
DecayTree & operator=(const DecayTree &tree)
Assign operator Required because we need to rebuild the node cache.
unsigned int m_token_count
Count current tokens.
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 ...
DecayNode m_root_node
root DecayNode
bool m_valid
True if the tree is valid (invalid can happen if is constructed from a node with "No match")
const DecayNode & getDecayNode(unsigned int n) const
Returns n-th node as const.
std::vector< DecayNode > build_tree(const std::string &decaystring, bool removeRadiativeGammaFlag)
Recursively build a new tree.
std::string to_string() const
Output string representation of DecayTree.
int m_match_symbol_position
Position of the token with the match symbol ^.
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.
void build_cache(DecayNode &node)
Build nodes_cache in order of appearance in the decay string for fast access.
DecayTree()
Default constructor.
std::string print_node(unsigned int indent=0) const
Output a single node.
bool find_decay(const DecayNode &to_find) const
Check if the decay node contains the given decay tree.
Abstract base class for different kinds of events.