Version: SMASH-1.7
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 581 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

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

Cannot be copied.

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

Move constructor.

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 616 of file scatteractionsfinder.cc.

620  : name_(name),
621  weight_(weight),
622  initial_particles_(std::move(initial_particles)),
623  final_particles_(std::move(final_particles)),
624  state_(std::move(state)),
625  children_(std::move(children)) {}
std::vector< Node > children_
Possible actions after this action.
ParticleTypePtrList initial_particles_
Initial-state particle types in this action.
std::string name_
Name for printing.
double weight_
Weight (cross section or branching ratio).
ParticleTypePtrList final_particles_
Final-state particle types in this action.
ParticleTypePtrList state_
Particle types corresponding to the global state after this action.

Member Function Documentation

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 638 of file scatteractionsfinder.cc.

640  {
641  // Copy parent state and update it.
642  ParticleTypePtrList state(state_);
643  for (const auto& p : initial_particles) {
644  state.erase(std::find(state.begin(), state.end(), p));
645  }
646  for (const auto& p : final_particles) {
647  state.push_back(p);
648  }
649  // Sort the state to normalize the output.
650  std::sort(state.begin(), state.end(),
651  [](ParticleTypePtr a, ParticleTypePtr b) {
652  return a->name() < b->name();
653  });
654  // Push new node to children.
655  Node new_node(name, weight, std::move(initial_particles),
656  std::move(final_particles), std::move(state), {});
657  children_.emplace_back(std::move(new_node));
658  return children_.back();
659  }
Node(const Node &)=delete
Cannot be copied.
std::vector< Node > children_
Possible actions after this action.
constexpr int p
Proton.
ParticleTypePtrList state_
Particle types corresponding to the global state after this action.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Print the decay tree starting with this node.

Definition at line 662 of file scatteractionsfinder.cc.

662 { print_helper(0); }
void print_helper(uint64_t depth) const
Internal helper function for print, to be called recursively to print all nodes.
std::vector<FinalStateCrossSection> smash::decaytree::Node::final_state_cross_sections ( ) const
inline
Returns
Final-state cross sections.

Definition at line 667 of file scatteractionsfinder.cc.

667  {
668  std::vector<FinalStateCrossSection> result;
669  final_state_cross_sections_helper(0, result, "", 1.);
670  return result;
671  }
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...
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 680 of file scatteractionsfinder.cc.

680  {
681  for (uint64_t i = 0; i < depth; i++) {
682  std::cout << " ";
683  }
684  std::cout << name_ << " " << weight_ << std::endl;
685  for (const auto& child : children_) {
686  child.print_helper(depth + 1);
687  }
688  }
std::vector< Node > children_
Possible actions after this action.
std::string name_
Name for printing.
double weight_
Weight (cross section or branching ratio).
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 701 of file scatteractionsfinder.cc.

704  {
705  // The first node corresponds to the total cross section and has to be
706  // ignored. The second node corresponds to the partial cross section. All
707  // further nodes correspond to branching ratios.
708  if (depth > 0) {
709  weight *= weight_;
710  }
711 
712  std::string new_name;
713  double mass = 0.;
714 
715  if (show_intermediate_states) {
716  new_name = name;
717  if (!new_name.empty()) {
718  new_name += "->";
719  }
720  new_name += name_;
721  new_name += "{";
722  } else {
723  new_name = "";
724  }
725  for (const auto& s : state_) {
726  new_name += s->name();
727  mass += s->mass();
728  }
729  if (show_intermediate_states) {
730  new_name += "}";
731  }
732 
733  if (children_.empty()) {
734  result.emplace_back(FinalStateCrossSection(new_name, weight, mass));
735  return;
736  }
737  for (const auto& child : children_) {
738  child.final_state_cross_sections_helper(depth + 1, result, new_name,
739  weight, show_intermediate_states);
740  }
741  }
std::vector< Node > children_
Possible actions after this action.
std::string name_
Name for printing.
double weight_
Weight (cross section or branching ratio).
ParticleTypePtrList state_
Particle types corresponding to the global state after this action.

Member Data Documentation

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

Name for printing.

Definition at line 584 of file scatteractionsfinder.cc.

double smash::decaytree::Node::weight_

Weight (cross section or branching ratio).

Definition at line 587 of file scatteractionsfinder.cc.

ParticleTypePtrList smash::decaytree::Node::initial_particles_

Initial-state particle types in this action.

Definition at line 590 of file scatteractionsfinder.cc.

ParticleTypePtrList smash::decaytree::Node::final_particles_

Final-state particle types in this action.

Definition at line 593 of file scatteractionsfinder.cc.

ParticleTypePtrList smash::decaytree::Node::state_

Particle types corresponding to the global state after this action.

Definition at line 596 of file scatteractionsfinder.cc.

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

Possible actions after this action.

Definition at line 599 of file scatteractionsfinder.cc.


The documentation for this struct was generated from the following file: