Version: SMASH-1.8
smash::decaytree::Node Struct Reference

Node of a decay tree, representing a possible action (2-to-2 or 1-to-2).

This data structure can be used to build a tree going from the initial state (a collision of two particles) to all possible final states by recursively performing all possible decays. The tree can be used to calculate the final state cross sections.

The initial actions are 2-to-2 or 2-to-1 scatterings, all other actions are 1-to-2 decays.

Definition at line 596 of file scatteractionsfinder.cc.

Collaboration diagram for smash::decaytree::Node:
[legend]

Public Member Functions

 Node (const Node &)=delete
 Cannot be copied. More...
 
 Node (Node &&)=default
 Move constructor. More...
 
 Node (const std::string &name, double weight, ParticleTypePtrList &&initial_particles, ParticleTypePtrList &&final_particles, ParticleTypePtrList &&state, std::vector< Node > &&children)
 
Nodeadd_action (const std::string &name, double weight, ParticleTypePtrList &&initial_particles, ParticleTypePtrList &&final_particles)
 Add an action to the children of this node. More...
 
void print () const
 Print the decay tree starting with this node. More...
 
std::vector< FinalStateCrossSectionfinal_state_cross_sections () const
 

Public Attributes

std::string name_
 Name for printing. More...
 
double weight_
 Weight (cross section or branching ratio). More...
 
ParticleTypePtrList initial_particles_
 Initial-state particle types in this action. More...
 
ParticleTypePtrList final_particles_
 Final-state particle types in this action. More...
 
ParticleTypePtrList state_
 Particle types corresponding to the global state after this action. More...
 
std::vector< Nodechildren_
 Possible actions after this action. More...
 

Private Member Functions

void print_helper (uint64_t depth) const
 Internal helper function for print, to be called recursively to print all nodes. More...
 
void final_state_cross_sections_helper (uint64_t depth, std::vector< FinalStateCrossSection > &result, const std::string &name, double weight, bool show_intermediate_states=false) const
 Internal helper function for final_state_cross_sections, to be called recursively to calculate all final-state cross sections. More...
 

Constructor & Destructor Documentation

◆ Node() [1/3]

smash::decaytree::Node::Node ( const Node )
delete

Cannot be copied.

◆ Node() [2/3]

smash::decaytree::Node::Node ( Node &&  )
default

Move constructor.

◆ Node() [3/3]

smash::decaytree::Node::Node ( const std::string &  name,
double  weight,
ParticleTypePtrList &&  initial_particles,
ParticleTypePtrList &&  final_particles,
ParticleTypePtrList &&  state,
std::vector< Node > &&  children 
)
inline
Returns
A new decay tree node.
Parameters
nameName for printing.
weightCross section or branching ratio.
initial_particlesInitial-state particle types in this node.
final_particlesFinal-state particle types in this node.
stateCurent particle types of the system.
childrenPossible actions after this action.

Definition at line 631 of file scatteractionsfinder.cc.

635  : name_(name),
636  weight_(weight),
637  initial_particles_(std::move(initial_particles)),
638  final_particles_(std::move(final_particles)),
639  state_(std::move(state)),
640  children_(std::move(children)) {}

Member Function Documentation

◆ add_action()

Node& smash::decaytree::Node::add_action ( const std::string &  name,
double  weight,
ParticleTypePtrList &&  initial_particles,
ParticleTypePtrList &&  final_particles 
)
inline

Add an action to the children of this node.

The current particle state of the new action is automatically calculated.

Parameters
nameName of the action used for output.
weightCross section/branching ratio of the action.
initial_particlesInitial-state particle types of the action.
final_particlesFinal-state particle types of the action.
Returns
Newly added node by reference.

Definition at line 653 of file scatteractionsfinder.cc.

655  {
656  // Copy parent state and update it.
657  ParticleTypePtrList state(state_);
658  for (const auto& p : initial_particles) {
659  state.erase(std::find(state.begin(), state.end(), p));
660  }
661  for (const auto& p : final_particles) {
662  state.push_back(p);
663  }
664  // Sort the state to normalize the output.
665  std::sort(state.begin(), state.end(),
666  [](ParticleTypePtr a, ParticleTypePtr b) {
667  return a->name() < b->name();
668  });
669  // Push new node to children.
670  Node new_node(name, weight, std::move(initial_particles),
671  std::move(final_particles), std::move(state), {});
672  children_.emplace_back(std::move(new_node));
673  return children_.back();
674  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

void smash::decaytree::Node::print ( ) const
inline

Print the decay tree starting with this node.

Definition at line 677 of file scatteractionsfinder.cc.

677 { print_helper(0); }
Here is the call graph for this function:

◆ final_state_cross_sections()

std::vector<FinalStateCrossSection> smash::decaytree::Node::final_state_cross_sections ( ) const
inline
Returns
Final-state cross sections.

Definition at line 682 of file scatteractionsfinder.cc.

682  {
683  std::vector<FinalStateCrossSection> result;
684  final_state_cross_sections_helper(0, result, "", 1.);
685  return result;
686  }
Here is the call graph for this function:

◆ print_helper()

void smash::decaytree::Node::print_helper ( uint64_t  depth) const
inlineprivate

Internal helper function for print, to be called recursively to print all nodes.

Parameters
depthRecursive call depth.

Definition at line 695 of file scatteractionsfinder.cc.

695  {
696  for (uint64_t i = 0; i < depth; i++) {
697  std::cout << " ";
698  }
699  std::cout << name_ << " " << weight_ << std::endl;
700  for (const auto& child : children_) {
701  child.print_helper(depth + 1);
702  }
703  }
Here is the caller graph for this function:

◆ final_state_cross_sections_helper()

void smash::decaytree::Node::final_state_cross_sections_helper ( uint64_t  depth,
std::vector< FinalStateCrossSection > &  result,
const std::string &  name,
double  weight,
bool  show_intermediate_states = false 
) const
inlineprivate

Internal helper function for final_state_cross_sections, to be called recursively to calculate all final-state cross sections.

Parameters
depthRecursive call depth.
resultPairs of process names and exclusive cross sections.
nameCurrent name.
weightcurrent Weight/cross section.
show_intermediate_statesWhether intermediate states should be shown.

Definition at line 716 of file scatteractionsfinder.cc.

719  {
720  // The first node corresponds to the total cross section and has to be
721  // ignored. The second node corresponds to the partial cross section. All
722  // further nodes correspond to branching ratios.
723  if (depth > 0) {
724  weight *= weight_;
725  }
726 
727  std::string new_name;
728  double mass = 0.;
729 
730  if (show_intermediate_states) {
731  new_name = name;
732  if (!new_name.empty()) {
733  new_name += "->";
734  }
735  new_name += name_;
736  new_name += "{";
737  } else {
738  new_name = "";
739  }
740  for (const auto& s : state_) {
741  new_name += s->name();
742  mass += s->mass();
743  }
744  if (show_intermediate_states) {
745  new_name += "}";
746  }
747 
748  if (children_.empty()) {
749  result.emplace_back(FinalStateCrossSection(new_name, weight, mass));
750  return;
751  }
752  for (const auto& child : children_) {
753  child.final_state_cross_sections_helper(depth + 1, result, new_name,
754  weight, show_intermediate_states);
755  }
756  }
Here is the caller graph for this function:

Member Data Documentation

◆ name_

std::string smash::decaytree::Node::name_

Name for printing.

Definition at line 599 of file scatteractionsfinder.cc.

◆ weight_

double smash::decaytree::Node::weight_

Weight (cross section or branching ratio).

Definition at line 602 of file scatteractionsfinder.cc.

◆ initial_particles_

ParticleTypePtrList smash::decaytree::Node::initial_particles_

Initial-state particle types in this action.

Definition at line 605 of file scatteractionsfinder.cc.

◆ final_particles_

ParticleTypePtrList smash::decaytree::Node::final_particles_

Final-state particle types in this action.

Definition at line 608 of file scatteractionsfinder.cc.

◆ state_

ParticleTypePtrList smash::decaytree::Node::state_

Particle types corresponding to the global state after this action.

Definition at line 611 of file scatteractionsfinder.cc.

◆ children_

std::vector<Node> smash::decaytree::Node::children_

Possible actions after this action.

Definition at line 614 of file scatteractionsfinder.cc.


The documentation for this struct was generated from the following file:
smash::decaytree::Node::print_helper
void print_helper(uint64_t depth) const
Internal helper function for print, to be called recursively to print all nodes.
Definition: scatteractionsfinder.cc:695
smash::decaytree::Node::final_particles_
ParticleTypePtrList final_particles_
Final-state particle types in this action.
Definition: scatteractionsfinder.cc:608
smash::decaytree::Node::final_state_cross_sections_helper
void final_state_cross_sections_helper(uint64_t depth, std::vector< FinalStateCrossSection > &result, const std::string &name, double weight, bool show_intermediate_states=false) const
Internal helper function for final_state_cross_sections, to be called recursively to calculate all fi...
Definition: scatteractionsfinder.cc:716
smash::decaytree::Node::Node
Node(const Node &)=delete
Cannot be copied.
smash::decaytree::Node::children_
std::vector< Node > children_
Possible actions after this action.
Definition: scatteractionsfinder.cc:614
smash::decaytree::Node::weight_
double weight_
Weight (cross section or branching ratio).
Definition: scatteractionsfinder.cc:602
smash::decaytree::Node::initial_particles_
ParticleTypePtrList initial_particles_
Initial-state particle types in this action.
Definition: scatteractionsfinder.cc:605
smash::decaytree::Node::name_
std::string name_
Name for printing.
Definition: scatteractionsfinder.cc:599
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28
smash::decaytree::Node::state_
ParticleTypePtrList state_
Particle types corresponding to the global state after this action.
Definition: scatteractionsfinder.cc:611