Version: SMASH-3.3
processbranch.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2025
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_PROCESSBRANCH_H_
8 #define SRC_INCLUDE_SMASH_PROCESSBRANCH_H_
9 
10 #include <iostream>
11 #include <memory>
12 #include <utility>
13 #include <vector>
14 
15 #include "decaytype.h"
16 #include "forwarddeclarations.h"
17 #include "particletype.h"
18 
19 namespace smash {
20 
39 enum class ProcessType {
41  None = 0,
43  Elastic = 1,
45  TwoToOne = 2,
47  TwoToTwo = 3,
49  TwoToThree = 4,
51  TwoToFour = 15,
53  TwoToFive = 13,
55  Decay = 5,
57  Wall = 6,
59  Thermalization = 7,
61  Fluidization = 8,
65  Bremsstrahlung = 9,
85  StringHard = 46,
87  FailedString = 47,
89  Freeforall = 90
90 };
91 
92 inline bool is_valid_process_type(int v) {
93  // NOTE: There must NOT be a default case in the following switch, to let the
94  // compiler warn about missing cases.
95  switch (static_cast<ProcessType>(v)) {
96  case ProcessType::None:
103  case ProcessType::Decay:
104  case ProcessType::Wall:
121  return true;
122  }
123  return false;
124 }
130 
136 std::ostream &operator<<(std::ostream &os, ProcessType process_type);
137 
165  public:
168 
173  explicit ProcessBranch(double w) : branch_weight_(w) {}
174 
176  ProcessBranch(const ProcessBranch &) = delete;
177 
182  virtual ~ProcessBranch() = default;
183 
190  inline void set_weight(double process_weight);
191 
193  virtual ProcessType get_type() const = 0;
194 
196  virtual const ParticleTypePtrList &particle_types() const = 0;
197 
202  ParticleList particle_list() const;
203 
205  inline double weight() const;
206 
211  double threshold() const;
212 
214  virtual unsigned int particle_number() const = 0;
215 
216  protected:
220  mutable double threshold_ = -1.;
221 };
222 
223 inline void ProcessBranch::set_weight(double process_weight) {
224  branch_weight_ = process_weight;
225 }
226 
228 inline double ProcessBranch::weight() const { return branch_weight_; }
229 
236 template <typename Branch>
237 inline double total_weight(const ProcessBranchList<Branch> &l) {
238  double sum = 0.;
239  for (const auto &p : l) {
240  sum += p->weight();
241  }
242  return sum;
243 }
244 
252  public:
258  CollisionBranch(double w, ProcessType p_type)
259  : ProcessBranch(w), process_type_(p_type) {}
266  CollisionBranch(const ParticleType &type, double w, ProcessType p_type)
267  : ProcessBranch(w), process_type_(p_type) {
268  particle_types_.reserve(1);
269  particle_types_.push_back(&type);
270  }
278  CollisionBranch(const ParticleType &type_a, const ParticleType &type_b,
279  double w, ProcessType p_type)
280  : ProcessBranch(w), process_type_(p_type) {
281  particle_types_.reserve(2);
282  particle_types_.push_back(&type_a);
283  particle_types_.push_back(&type_b);
284  }
285 
294  CollisionBranch(const ParticleType &type_a, const ParticleType &type_b,
295  const ParticleType &type_c, double w, ProcessType p_type)
296  : ProcessBranch(w), process_type_(p_type) {
297  particle_types_.reserve(3);
298  particle_types_.push_back(&type_a);
299  particle_types_.push_back(&type_b);
300  particle_types_.push_back(&type_c);
301  }
302 
312  CollisionBranch(const ParticleType &type_a, const ParticleType &type_b,
313  const ParticleType &type_c, const ParticleType &type_d,
314  double w, ProcessType p_type)
315  : ProcessBranch(w), process_type_(p_type) {
316  particle_types_.reserve(4);
317  particle_types_.push_back(&type_a);
318  particle_types_.push_back(&type_b);
319  particle_types_.push_back(&type_c);
320  particle_types_.push_back(&type_d);
321  }
322 
333  CollisionBranch(const ParticleType &type_a, const ParticleType &type_b,
334  const ParticleType &type_c, const ParticleType &type_d,
335  const ParticleType &type_e, double w, ProcessType p_type)
336  : ProcessBranch(w), process_type_(p_type) {
337  particle_types_.reserve(5);
338  particle_types_.push_back(&type_a);
339  particle_types_.push_back(&type_b);
340  particle_types_.push_back(&type_c);
341  particle_types_.push_back(&type_d);
342  particle_types_.push_back(&type_e);
343  }
344 
351  CollisionBranch(ParticleTypePtrList new_types, double w, ProcessType p_type)
352  : ProcessBranch(w),
353  particle_types_(std::move(new_types)),
354  process_type_(p_type) {}
358  particle_types_(std::move(rhs.particle_types_)),
360  const ParticleTypePtrList &particle_types() const override {
361  return particle_types_;
362  }
368  inline void set_type(ProcessType p_type) { process_type_ = p_type; }
370  inline ProcessType get_type() const override { return process_type_; }
372  unsigned int particle_number() const override {
373  return particle_types_.size();
374  }
375 
376  private:
378  ParticleTypePtrList particle_types_;
379 
385 };
386 
392 std::ostream &operator<<(std::ostream &os, const CollisionBranch &cbranch);
393 
401 class DecayBranch : public ProcessBranch {
402  public:
408  DecayBranch(const DecayType &t, double w) : ProcessBranch(w), type_(t) {}
411  : ProcessBranch(rhs.branch_weight_), type_(rhs.type_) {}
413  inline int angular_momentum() const { return type_.angular_momentum(); }
414  const ParticleTypePtrList &particle_types() const override {
415  return type_.particle_types();
416  }
417  unsigned int particle_number() const override {
418  return type_.particle_number();
419  }
421  inline const DecayType &type() const { return type_; }
423  inline ProcessType get_type() const override { return ProcessType::Decay; }
424 
425  private:
427  const DecayType &type_;
428 };
429 
430 } // namespace smash
431 
432 #endif // SRC_INCLUDE_SMASH_PROCESSBRANCH_H_
CollisionBranch is a derivative of ProcessBranch, which is used to represent particular final-state c...
ProcessType get_type() const override
CollisionBranch(CollisionBranch &&rhs)
The move constructor efficiently moves the particle-type list member.
ParticleTypePtrList particle_types_
List of particles appearing in this process outcome.
CollisionBranch(const ParticleType &type_a, const ParticleType &type_b, const ParticleType &type_c, const ParticleType &type_d, const ParticleType &type_e, double w, ProcessType p_type)
Construct collision branch with 5 particles in final state.
const ParticleTypePtrList & particle_types() const override
CollisionBranch(const ParticleType &type, double w, ProcessType p_type)
Construct collision branch with 1 particle in final state.
CollisionBranch(ParticleTypePtrList new_types, double w, ProcessType p_type)
Construct collision branch with a list of particles in final state.
ProcessType process_type_
Process type are used to distinguish different types of processes, e.g.
unsigned int particle_number() const override
CollisionBranch(const ParticleType &type_a, const ParticleType &type_b, const ParticleType &type_c, double w, ProcessType p_type)
Construct collision branch with 3 particles in final state.
CollisionBranch(const ParticleType &type_a, const ParticleType &type_b, const ParticleType &type_c, const ParticleType &type_d, double w, ProcessType p_type)
Construct collision branch with 4 particles in final state.
CollisionBranch(const ParticleType &type_a, const ParticleType &type_b, double w, ProcessType p_type)
Construct collision branch with 2 particles in final state.
CollisionBranch(double w, ProcessType p_type)
Construct collision branch with empty final state.
void set_type(ProcessType p_type)
Set the process type.
DecayBranch is a derivative of ProcessBranch, which is used to represent decay channels.
DecayBranch(DecayBranch &&rhs)
The move constructor efficiently moves the particle-type list member.
unsigned int particle_number() const override
ProcessType get_type() const override
const DecayType & type() const
DecayBranch(const DecayType &t, double w)
Construct decay branch.
const ParticleTypePtrList & particle_types() const override
int angular_momentum() const
const DecayType & type_
Decay type (including final-state particles and angular momentum)
DecayType is the abstract base class for all decay types.
Definition: decaytype.h:23
virtual unsigned int particle_number() const =0
const ParticleTypePtrList & particle_types() const
Definition: decaytype.h:58
int angular_momentum() const
Definition: decaytype.h:60
Particle type contains the static properties of a particle species.
Definition: particletype.h:98
ProcessBranch represents one possible final state of an interaction process.
ParticleList particle_list() const
virtual ~ProcessBranch()=default
Virtual Destructor.
virtual const ParticleTypePtrList & particle_types() const =0
double total_weight(const ProcessBranchList< Branch > &l)
ProcessBranch(const ProcessBranch &)=delete
Copying is disabled. Use std::move or create a new object.
virtual ProcessType get_type() const =0
ProcessBranch()
Create a ProcessBranch without final states and weight.
double threshold_
Threshold of the branch.
double branch_weight_
Weight of the branch, typically a cross section or a branching ratio.
ProcessBranch(double w)
Create a ProcessBranch with with weight but without final states.
void set_weight(double process_weight)
Set the weight of the branch.
virtual unsigned int particle_number() const =0
double threshold() const
double weight() const
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
Definition: action.h:555
constexpr int p
Proton.
Definition: action.h:24
bool is_valid_process_type(int v)
Definition: processbranch.h:92
ProcessType
ProcessTypes are used to identify the type of the process.
Definition: processbranch.h:39
@ FluidizationNoRemoval
See here for a short description.
@ FailedString
See here for a short description.
@ TwoToOne
See here for a short description.
@ MultiParticleThreeToTwo
See here for a short description.
@ StringSoftDoubleDiffractive
See here for a short description.
@ Fluidization
See here for a short description.
@ Bremsstrahlung
See here for a short description.
@ Thermalization
See here for a short description.
@ Freeforall
See here for a short description.
@ Decay
See here for a short description.
@ TwoToFive
See here for a short description.
@ None
See here for a short description.
@ StringSoftSingleDiffractiveXB
See here for a short description.
@ TwoToTwo
See here for a short description.
@ Wall
See here for a short description.
@ Elastic
See here for a short description.
@ TwoToFour
See here for a short description.
@ StringSoftAnnihilation
See here for a short description.
@ MultiParticleThreeMesonsToOne
See here for a short description.
@ StringSoftNonDiffractive
See here for a short description.
@ MultiParticleFourToTwo
See here for a short description.
@ StringSoftSingleDiffractiveAX
See here for a short description.
@ StringHard
See here for a short description.
@ TwoToThree
See here for a short description.
@ MultiParticleFiveToTwo
See here for a short description.
bool is_string_soft_process(ProcessType p)
Check if a given process type is a soft string excitation.