Version: SMASH-3.4
processbranch.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2026
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 
21 /**
22  * <tt>ProcessType</tt>s are used to identify the type of the process.
23  * Corresponding integer numbers are given explicitly, because they appear in
24  * the output.
25  *
26  * @note Types (41-45) refers to soft string excitations. Here \b "soft" means
27  * that the process does not involve quark or gluon scattering. A string is
28  * formed by quark and antiquark, or quark and diquark, in its ends. Then this
29  * string decays. Depending on which quark and anti- (or di-)quarks are selected
30  * for string formation, the process has one of the following types.
31  *
32  * @attention Since the process type numbers appear in the output, it is
33  * important to have an explanation in the user guide. We therefore do not give
34  * here an explicit members description and we simply refer to the user guide.
35  * If you add a new process type here, document the new member as the other
36  * existing ones and include the corresponding description in the Doxygen page
37  * with anchor "doxypage_output_process_types".
38  */
39 enum class ProcessType {
40  /// \see_process_type{0}
41  None = 0,
42  /// \see_process_type{1}
43  Elastic = 1,
44  /// \see_process_type{2}
45  TwoToOne = 2,
46  /// \see_process_type{3}
47  TwoToTwo = 3,
48  /// \see_process_type{4}
49  TwoToThree = 4,
50  /// \see_process_type{15}
51  TwoToFour = 15,
52  /// \see_process_type{13}
53  TwoToFive = 13,
54  /// \see_process_type{5}
55  Decay = 5,
56  /// \see_process_type{6}
57  Wall = 6,
58  /// \see_process_type{7}
59  Thermalization = 7,
60  /// \see_process_type{8}
61  Fluidization = 8,
62  /// \see_process_type{21}
64  /// \see_process_type{9}
66  /// \see_process_type{16}
68  /// \see_process_type{10}
70  /// \see_process_type{11}
72  /// \see_process_type{14}
74  /// \see_process_type{12}
76  /// \see_process_type{41}
78  /// \see_process_type{42}
80  /// \see_process_type{43}
82  /// \see_process_type{44}
84  /// \see_process_type{45}
86  /// \see_process_type{46}
88  /// \see_process_type{47}
90  /// \see_process_type{48}
92  /// \see_process_type{49}
94  /// \see_process_type{50}
95  FailedString = 50,
96  /// \see_process_type{90}
97  Freeforall = 90
98 };
99 
100 inline bool is_valid_process_type(int v) {
101  // NOTE: There must NOT be a default case in the following switch, to let the
102  // compiler warn about missing cases.
103  switch (static_cast<ProcessType>(v)) {
104  case ProcessType::None:
111  case ProcessType::Decay:
112  case ProcessType::Wall:
133  return true;
134  }
135  return false;
136 }
137 /**
138  * Check if a given process type is a soft string excitation
139  * \param[in] p The process type
140  */
142 
143 /**
144  * Check if a given process type is a hard string excitation
145  * \param[in] p The process type
146  */
148 
149 /**
150  * Check if a given process type is a string excitation
151  * \param[in] p The process type
152  */
154 
155 /**
156  * \ingroup logging
157  * Writes the textual representation of the \p process_type
158  * to the output stream \p os.
159  */
160 std::ostream &operator<<(std::ostream &os, ProcessType process_type);
161 
162 /**
163  * \ingroup data
164  *
165  * ProcessBranch represents one possible final state
166  * of an interaction process.
167  *
168  * Each final state has two components;
169  * 1. The list of particle types present in this state.
170  * 2. The weight of this state, i.e. how probable this outcome is
171  * compared to other possible outcomes. Depending on context,
172  * this can be either a cross section or a branching ratio.
173  * 3. The process id that identifies a certain class of processes.
174  * If the outgoing particles are not known yet, e.g. for strings
175  * there will be only the weight and the process id.
176  *
177  * For example, create a list of decay modes for \f$\Delta^+\f$ resonance:
178  * \code
179  * std::vector<ProcessBranch> deltaplus_decay_modes;
180  * ProcessBranch branch;
181  * branch.set_weight(2);
182  * deltaplus_decay_modes.push_back(branch);
183  * // set_weight erases the previous weight
184  * branch.set_weight(1);
185  * deltaplus_decay_modes.push_back(branch);
186  * \endcode
187  */
189  public:
190  /// Create a ProcessBranch without final states and weight.
192 
193  /**
194  * Create a ProcessBranch with with weight but without final states.
195  * \param[in] w Weight of new branch.
196  */
197  explicit ProcessBranch(double w) : branch_weight_(w) {}
198 
199  /// Copying is disabled. Use std::move or create a new object.
200  ProcessBranch(const ProcessBranch &) = delete;
201 
202  /**
203  * Virtual Destructor.
204  * The declaration of the destructor is necessary to make it virtual.
205  */
206  virtual ~ProcessBranch() = default;
207 
208  /**
209  * Set the weight of the branch.
210  * In other words, how probable this branch is
211  * compared to other branches.
212  * \param[in] process_weight Weight of the process.
213  */
214  inline void set_weight(double process_weight);
215 
216  /// \return the process type
217  virtual ProcessType get_type() const = 0;
218 
219  /// \return the particle types associated with this branch.
220  virtual const ParticleTypePtrList &particle_types() const = 0;
221 
222  /**
223  * \return a list of ParticleData initialized with the stored ParticleType
224  * objects.
225  */
226  ParticleList particle_list() const;
227 
228  /// \return the branch weight.
229  inline double weight() const;
230 
231  /**
232  * \return the threshold for this branch, i.e. the minimum energy that is
233  * required to produce all final-state particles.
234  */
235  double threshold() const;
236 
237  /// \return the number of particles in the final state.
238  virtual unsigned int particle_number() const = 0;
239 
240  protected:
241  /// Weight of the branch, typically a cross section or a branching ratio
243  /// Threshold of the branch
244  mutable double threshold_ = -1.;
245 };
246 
247 inline void ProcessBranch::set_weight(double process_weight) {
248  branch_weight_ = process_weight;
249 }
250 
251 /// \return the branch weight
252 inline double ProcessBranch::weight() const { return branch_weight_; }
253 
254 /**
255  * \relates ProcessBranch
256  * \param[in] l The list of all the processes that would be summed.
257  * \return the total weight calculated by summing all weights of the
258  * ProcessBranch objects in the list \p l.
259  */
260 template <typename Branch>
261 inline double total_weight(const ProcessBranchList<Branch> &l) {
262  double sum = 0.;
263  for (const auto &p : l) {
264  sum += p->weight();
265  }
266  return sum;
267 }
268 
269 /**
270  * \ingroup data
271  *
272  * CollisionBranch is a derivative of ProcessBranch,
273  * which is used to represent particular final-state channels in a collision.
274  */
276  public:
277  /**
278  * Construct collision branch with empty final state.
279  * \param[in] w Weight of created branch.
280  * \param[in] p_type Process type of created branch.
281  */
282  CollisionBranch(double w, ProcessType p_type)
283  : ProcessBranch(w), process_type_(p_type) {}
284  /**
285  * Construct collision branch with 1 particle in final state.
286  * \param[in] type Particle type of final state particle.
287  * \param[in] w Weight of created branch.
288  * \param[in] p_type Process type of created branch.
289  */
290  CollisionBranch(const ParticleType &type, double w, ProcessType p_type)
291  : ProcessBranch(w), process_type_(p_type) {
292  particle_types_.reserve(1);
293  particle_types_.push_back(&type);
294  }
295  /**
296  * Construct collision branch with 2 particles in final state.
297  * \param[in] type_a Particle types of one final state particle.
298  * \param[in] type_b Particle types of other final state particle.
299  * \param[in] w Weight of created branch.
300  * \param[in] p_type Process type of created branch.
301  */
302  CollisionBranch(const ParticleType &type_a, const ParticleType &type_b,
303  double w, ProcessType p_type)
304  : ProcessBranch(w), process_type_(p_type) {
305  particle_types_.reserve(2);
306  particle_types_.push_back(&type_a);
307  particle_types_.push_back(&type_b);
308  }
309 
310  /**
311  * Construct collision branch with 3 particles in final state.
312  * \param[in] type_a Particle type of first final state particle.
313  * \param[in] type_b Particle type of second final state particle.
314  * \param[in] type_c Particle type of third final state particle.
315  * \param[in] w Weight of created branch.
316  * \param[in] p_type Process type of created branch.
317  */
318  CollisionBranch(const ParticleType &type_a, const ParticleType &type_b,
319  const ParticleType &type_c, double w, ProcessType p_type)
320  : ProcessBranch(w), process_type_(p_type) {
321  particle_types_.reserve(3);
322  particle_types_.push_back(&type_a);
323  particle_types_.push_back(&type_b);
324  particle_types_.push_back(&type_c);
325  }
326 
327  /**
328  * Construct collision branch with 4 particles in final state.
329  * \param[in] type_a Particle type of first final state particle.
330  * \param[in] type_b Particle type of second final state particle.
331  * \param[in] type_c Particle type of third final state particle.
332  * \param[in] type_d Particle type of fourth final state particle.
333  * \param[in] w Weight of created branch.
334  * \param[in] p_type Process type of created branch.
335  */
336  CollisionBranch(const ParticleType &type_a, const ParticleType &type_b,
337  const ParticleType &type_c, const ParticleType &type_d,
338  double w, ProcessType p_type)
339  : ProcessBranch(w), process_type_(p_type) {
340  particle_types_.reserve(4);
341  particle_types_.push_back(&type_a);
342  particle_types_.push_back(&type_b);
343  particle_types_.push_back(&type_c);
344  particle_types_.push_back(&type_d);
345  }
346 
347  /**
348  * Construct collision branch with 5 particles in final state.
349  * \param[in] type_a Particle type of first final state particle.
350  * \param[in] type_b Particle type of second final state particle.
351  * \param[in] type_c Particle type of third final state particle.
352  * \param[in] type_d Particle type of fourth final state particle.
353  * \param[in] type_e Particle type of fith final state particle.
354  * \param[in] w Weight of created branch.
355  * \param[in] p_type Process type of created branch.
356  */
357  CollisionBranch(const ParticleType &type_a, const ParticleType &type_b,
358  const ParticleType &type_c, const ParticleType &type_d,
359  const ParticleType &type_e, double w, ProcessType p_type)
360  : ProcessBranch(w), process_type_(p_type) {
361  particle_types_.reserve(5);
362  particle_types_.push_back(&type_a);
363  particle_types_.push_back(&type_b);
364  particle_types_.push_back(&type_c);
365  particle_types_.push_back(&type_d);
366  particle_types_.push_back(&type_e);
367  }
368 
369  /**
370  * Construct collision branch with a list of particles in final state.
371  * \param[in] new_types List of particle types of final state particles.
372  * \param[in] w Weight of created branch.
373  * \param[in] p_type Process type of created branch.
374  */
375  CollisionBranch(ParticleTypePtrList new_types, double w, ProcessType p_type)
376  : ProcessBranch(w),
377  particle_types_(std::move(new_types)),
378  process_type_(p_type) {}
379  /// The move constructor efficiently moves the particle-type list member.
382  particle_types_(std::move(rhs.particle_types_)),
384  const ParticleTypePtrList &particle_types() const override {
385  return particle_types_;
386  }
387  /**
388  * Set the process type
389  *
390  * \param[in] p_type The new value of the process type
391  */
392  inline void set_type(ProcessType p_type) { process_type_ = p_type; }
393  /// \return type of the process
394  inline ProcessType get_type() const override { return process_type_; }
395  /// \return number of particles involved in the process
396  unsigned int particle_number() const override {
397  return particle_types_.size();
398  }
399 
400  private:
401  /// List of particles appearing in this process outcome.
402  ParticleTypePtrList particle_types_;
403 
404  /**
405  * Process type are used to distinguish different types of processes,
406  * e.g. string formation, resonance formation, elastic scattering and so on.
407  */
409 };
410 
411 /**
412  * \ingroup logging
413  * Writes the textual representation of the Collision Branch \p cbranch
414  * to the output stream \p os.
415  */
416 std::ostream &operator<<(std::ostream &os, const CollisionBranch &cbranch);
417 
418 /**
419  * \ingroup data
420  *
421  * DecayBranch is a derivative of ProcessBranch,
422  * which is used to represent decay channels.
423  * It contains additional information like the angular momentum.
424  */
425 class DecayBranch : public ProcessBranch {
426  public:
427  /**
428  * Construct decay branch.
429  * \param[in] t DecayType of branch.
430  * \param[in] w Weight of created branch.
431  */
432  DecayBranch(const DecayType &t, double w) : ProcessBranch(w), type_(t) {}
433  /// The move constructor efficiently moves the particle-type list member.
435  : ProcessBranch(rhs.branch_weight_), type_(rhs.type_) {}
436  /// \return the quantized angular momentum of this branch.
437  inline int angular_momentum() const { return type_.angular_momentum(); }
438  const ParticleTypePtrList &particle_types() const override {
439  return type_.particle_types();
440  }
441  unsigned int particle_number() const override {
442  return type_.particle_number();
443  }
444  /// \return the DecayType of the branch.
445  inline const DecayType &type() const { return type_; }
446  /// \return "Decay" to the process type.
447  inline ProcessType get_type() const override { return ProcessType::Decay; }
448 
449  private:
450  /// Decay type (including final-state particles and angular momentum)
451  const DecayType &type_;
452 };
453 
454 } // namespace smash
455 
456 #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:100
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:546
constexpr int p
Proton.
Definition: action.h:24
bool is_valid_process_type(int v)
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.
@ StringHardSingleDiffractiveAX
See here for a short description.
@ MultiParticleThreeToTwo
See here for a short description.
@ BremsstrahlungPhoton
See here for a short description.
@ StringSoftDoubleDiffractive
See here for a short description.
@ Fluidization
See here for a short description.
@ BremsstrahlungDilepton
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.
@ StringHardNonDiffractive
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.
@ StringHardSingleDiffractiveXB
See here for a short description.
@ StringHardDoubleDiffractive
See here for a short description.
@ TwoToThree
See here for a short description.
@ MultiParticleFiveToTwo
See here for a short description.
bool is_string_hard_process(ProcessType p)
Check if a given process type is a hard string excitation.
bool is_string_soft_process(ProcessType p)
Check if a given process type is a soft string excitation.
bool is_string_process(ProcessType p)
Check if a given process type is a string excitation.