Version: SMASH-3.1
particledata.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2020,2022-2024
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_SMASH_PARTICLEDATA_H_
8 #define SRC_INCLUDE_SMASH_PARTICLEDATA_H_
9 
10 #include <limits>
11 
12 #include "forwarddeclarations.h"
13 #include "fourvector.h"
14 #include "particletype.h"
15 #include "pdgcode.h"
16 #include "processbranch.h"
17 
18 namespace smash {
19 
20 enum class BelongsTo : uint8_t {
21  Nothing = 0,
22  Projectile = 1,
23  Target = 2,
24 };
25 
30 struct HistoryData {
34  int32_t id_process = 0;
43  double time_last_collision = 0.0;
45  PdgCode p1 = 0x0;
47  PdgCode p2 = 0x0;
48 };
49 
58 class ParticleData {
59  public:
69  explicit ParticleData(const ParticleType &particle_type, int unique_id = -1)
70  : id_(unique_id), type_(&particle_type) {}
71 
76  int32_t id() const { return id_; }
81  void set_id(int i) { id_ = i; }
82 
87  PdgCode pdgcode() const { return type_->pdgcode(); }
88 
89  // Convenience accessors to PdgCode:
91  bool is_hadron() const { return type_->is_hadron(); }
92 
94  bool is_baryon() const { return pdgcode().is_baryon(); }
95 
97  bool is_nucleus() const { return pdgcode().is_nucleus(); }
98 
100  bool is_rho() const { return type_->is_rho(); }
101 
103  bool is_proton() const { return pdgcode().is_proton(); }
104 
106  bool is_neutron() const { return pdgcode().is_neutron(); }
107 
109  bool is_pion() const { return pdgcode().is_pion(); }
110 
115  double pole_mass() const { return type_->mass(); }
123  double effective_mass() const;
128  const ParticleType &type() const { return *type_; }
129 
134  uint32_t id_process() const { return history_.id_process; }
139  HistoryData get_history() const { return history_; }
151  void set_history(int ncoll, uint32_t pid, ProcessType pt, double time_of_or,
152  const ParticleList &plist);
153 
158  const FourVector &momentum() const { return momentum_; }
159 
164  void set_4momentum(const FourVector &momentum_vector) {
165  momentum_ = momentum_vector;
166  }
167 
174  void set_4momentum(double mass, const ThreeVector &mom) {
175  momentum_ = FourVector(std::sqrt(mass * mass + mom * mom), mom);
176  }
177 
186  void set_4momentum(double mass, double px, double py, double pz) {
187  momentum_ = FourVector(std::sqrt(mass * mass + px * px + py * py + pz * pz),
188  px, py, pz);
189  }
196  void set_3momentum(const ThreeVector &mom) {
197  momentum_ = FourVector(momentum_.x0(), mom);
198  }
199 
204  const FourVector &position() const { return position_; }
209  void set_4position(const FourVector &pos) { position_ = pos; }
216  void set_3position(const ThreeVector &pos) {
217  position_ = FourVector(position_.x0(), pos);
218  }
219 
224  ParticleData translated(const ThreeVector &delta) const {
225  ParticleData p = *this;
226  p.position_[1] += delta[0];
227  p.position_[2] += delta[1];
228  p.position_[3] += delta[2];
229  return p;
230  }
231 
236  double formation_time() const { return formation_time_; }
242  double begin_formation_time() const { return begin_formation_time_; }
243 
251  void set_formation_time(const double &form_time) {
252  formation_time_ = form_time;
253  // cross section scaling factor will be a step function in time
254  begin_formation_time_ = form_time;
255  }
265  void set_slow_formation_times(double begin_form_time, double form_time) {
266  begin_formation_time_ = begin_form_time;
267  formation_time_ = form_time;
268  }
269 
278  const double &initial_xsec_scaling_factor() const {
280  }
293  void set_cross_section_scaling_factor(const double &xsec_scal) {
294  initial_xsec_scaling_factor_ = xsec_scal;
295  }
296 
301  ThreeVector velocity() const { return momentum_.velocity(); }
302 
315  double inverse_gamma() const {
316  return std::sqrt(1. - momentum_.sqr3() / (momentum_.x0() * momentum_.x0()));
317  }
318 
323  void boost(const ThreeVector &v) {
326  }
327 
332  void boost_momentum(const ThreeVector &v) {
334  }
335 
337  void set_belongs_to(BelongsTo label) { belongs_to_ = label; }
339  BelongsTo belongs_to() const { return belongs_to_; }
340 
346  bool operator==(const ParticleData &a) const { return this->id_ == a.id_; }
352  bool operator<(const ParticleData &a) const { return this->id_ < a.id_; }
353 
359  bool operator==(int id_a) const { return this->id_ == id_a; }
364  bool operator<(int id_a) const { return this->id_ < id_a; }
365 
376  ParticleData(const ParticleType &ptype, int uid, int index)
377  : id_(uid), index_(index), type_(&ptype) {}
378 
386  double xsec_scaling_factor(double delta_time = 0.) const;
387 
389  static double formation_power_;
390 
391  private:
392  friend class Particles;
394  ParticleData() = default;
395 
402  void copy_to(ParticleData &dst) const {
403  dst.history_ = history_;
404  dst.momentum_ = momentum_;
405  dst.position_ = position_;
409  dst.belongs_to_ = belongs_to_;
410  }
411 
420  int32_t id_ = -1;
421 
430  unsigned index_ = std::numeric_limits<unsigned>::max();
431 
437 
438  // this leaves us two Bytes padding to use for "free"
439  static_assert(sizeof(ParticleTypePtr) == 2, "");
440  // make sure we don't exceed that space
441  static_assert(sizeof(bool) <= 2, "");
450  bool hole_ = false;
451 
459  double formation_time_ = 0.0;
461  double begin_formation_time_ = 0.0;
471 };
472 
477 std::ostream &operator<<(std::ostream &s, const ParticleData &p);
478 
484 std::ostream &operator<<(std::ostream &out, const ParticleList &particle_list);
485 
493  const ParticleList &list;
494 };
500 inline PrintParticleListDetailed detailed(const ParticleList &list) {
501  return {list};
502 }
503 
510 std::ostream &operator<<(std::ostream &out,
511  const PrintParticleListDetailed &particle_list);
512 
543  PdgCode pdgcode, double mass, const FourVector &four_position,
544  const FourVector &four_momentum, int log_area, bool &mass_warning,
545  bool &on_shell_warning);
546 
561 bool are_particles_identical_at_given_time(const ParticleData &p1,
562  const ParticleData &p2, double time);
563 
564 } // namespace smash
565 
566 #endif // SRC_INCLUDE_SMASH_PARTICLEDATA_H_
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
FourVector lorentz_boost(const ThreeVector &v) const
Returns the FourVector boosted with velocity v.
Definition: fourvector.cc:17
double sqr3() const
calculate the square of the spatial three-vector
Definition: fourvector.h:474
double x0() const
Definition: fourvector.h:313
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
Definition: fourvector.h:333
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:58
double formation_time_
Formation time at which the particle is fully formed given as an absolute value in the computational ...
Definition: particledata.h:459
PdgCode pdgcode() const
Get the pdgcode of the particle.
Definition: particledata.h:87
unsigned index_
Internal index in the Particles list.
Definition: particledata.h:430
void set_4momentum(const FourVector &momentum_vector)
Set the particle's 4-momentum directly.
Definition: particledata.h:164
bool is_proton() const
Definition: particledata.h:103
const ParticleType & type() const
Get the type of the particle.
Definition: particledata.h:128
BelongsTo belongs_to_
is it part of projectile or target nuclei?
Definition: particledata.h:470
void set_3position(const ThreeVector &pos)
Set particle's 3-position.
Definition: particledata.h:216
double inverse_gamma() const
Get the inverse of the gamma factor from the current velocity of the particle.
Definition: particledata.h:315
bool is_pion() const
Definition: particledata.h:109
ParticleData translated(const ThreeVector &delta) const
Translate the particle position.
Definition: particledata.h:224
int32_t id_
Each particle has a unique identifier.
Definition: particledata.h:420
double begin_formation_time_
time when the cross section scaling factor starts to increase to 1
Definition: particledata.h:461
void set_4position(const FourVector &pos)
Set the particle's 4-position directly.
Definition: particledata.h:209
bool is_nucleus() const
Definition: particledata.h:97
double xsec_scaling_factor(double delta_time=0.) const
Return the cross section scaling factor at a given time.
Definition: particledata.cc:86
bool operator<(int id_a) const
Check whether the particle's id is smaller than the given id.
Definition: particledata.h:364
void set_history(int ncoll, uint32_t pid, ProcessType pt, double time_of_or, const ParticleList &plist)
Store history information.
Definition: particledata.cc:34
bool is_hadron() const
Definition: particledata.h:91
static double formation_power_
Power with which the cross section scaling factor grows in time.
Definition: particledata.h:389
bool hole_
If true, the object is an entry in Particles::data_ and does not hold valid particle data.
Definition: particledata.h:450
uint32_t id_process() const
Get the id of the last action.
Definition: particledata.h:134
ParticleData(const ParticleType &particle_type, int unique_id=-1)
Create a new particle with the given particle_type and optionally a specific unique_id.
Definition: particledata.h:69
double begin_formation_time() const
Get the absolute time, where the cross section scaling factor slowly starts increasing from the given...
Definition: particledata.h:242
void set_id(int i)
Set id of the particle.
Definition: particledata.h:81
const FourVector & momentum() const
Get the particle's 4-momentum.
Definition: particledata.h:158
BelongsTo belongs_to() const
Getter for belongs_to label.
Definition: particledata.h:339
void copy_to(ParticleData &dst) const
Copies some information of the particle to the given particle dst.
Definition: particledata.h:402
bool operator==(int id_a) const
Check if the particle has a given id.
Definition: particledata.h:359
FourVector momentum_
momenta of the particle: x0, x1, x2, x3 as E, px, py, pz
Definition: particledata.h:453
double formation_time() const
Get the absolute formation time of the particle.
Definition: particledata.h:236
bool is_neutron() const
Definition: particledata.h:106
ThreeVector velocity() const
Get the velocity 3-vector.
Definition: particledata.h:301
double initial_xsec_scaling_factor_
Initial cross section scaling factor.
Definition: particledata.h:466
bool is_baryon() const
Definition: particledata.h:94
bool is_rho() const
Definition: particledata.h:100
bool operator<(const ParticleData &a) const
Check if this particle has a smaller id than another particle.
Definition: particledata.h:352
double effective_mass() const
Get the particle's effective mass.
Definition: particledata.cc:24
int32_t id() const
Get the id of the particle.
Definition: particledata.h:76
ParticleData()=default
Default constructor.
HistoryData get_history() const
Get history information.
Definition: particledata.h:139
const double & initial_xsec_scaling_factor() const
Get the initially assigned cross section scaling factor.
Definition: particledata.h:278
void set_4momentum(double mass, double px, double py, double pz)
Set the momentum of the particle.
Definition: particledata.h:186
void set_cross_section_scaling_factor(const double &xsec_scal)
Set the particle's initial cross_section_scaling_factor.
Definition: particledata.h:293
FourVector position_
position in space: x0, x1, x2, x3 as t, x, y, z
Definition: particledata.h:455
double pole_mass() const
Get the particle's pole mass ("on-shell").
Definition: particledata.h:115
bool operator==(const ParticleData &a) const
Check whether two particles have the same id.
Definition: particledata.h:346
ParticleTypePtr type_
A reference to the ParticleType object for this particle (this contains all the static information).
Definition: particledata.h:436
void set_3momentum(const ThreeVector &mom)
Set the momentum of the particle without modifying the energy.
Definition: particledata.h:196
void set_slow_formation_times(double begin_form_time, double form_time)
Set the time, when the cross section scaling factor begins, and finishes to increase from the given c...
Definition: particledata.h:265
void set_formation_time(const double &form_time)
Set the absolute formation time.
Definition: particledata.h:251
void boost_momentum(const ThreeVector &v)
Apply a Lorentz-boost to only the momentum.
Definition: particledata.h:332
ParticleData(const ParticleType &ptype, int uid, int index)
Construct a particle with the given type, id and index in Particles.
Definition: particledata.h:376
void set_belongs_to(BelongsTo label)
Setter for belongs_to label.
Definition: particledata.h:337
HistoryData history_
history information
Definition: particledata.h:468
void boost(const ThreeVector &v)
Apply a full Lorentz boost of momentum and position.
Definition: particledata.h:323
const FourVector & position() const
Get the particle's position in Minkowski space.
Definition: particledata.h:204
void set_4momentum(double mass, const ThreeVector &mom)
Set the momentum of the particle given its mass and momentum three-vector.
Definition: particledata.h:174
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:676
Particle type contains the static properties of a particle species.
Definition: particletype.h:98
PdgCode pdgcode() const
Definition: particletype.h:157
bool is_rho() const
Definition: particletype.h:228
bool is_hadron() const
Definition: particletype.h:198
double mass() const
Definition: particletype.h:145
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
Definition: pdgcode.h:111
bool is_pion() const
Definition: pdgcode.h:457
bool is_nucleus() const
Definition: pdgcode.h:364
bool is_proton() const
Definition: pdgcode.h:403
bool is_baryon() const
Definition: pdgcode.h:391
bool is_neutron() const
Definition: pdgcode.h:409
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:31
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
Definition: action.h:547
PrintParticleListDetailed detailed(const ParticleList &list)
Request the ParticleList to be printed in full detail (i.e.
Definition: particledata.h:500
constexpr int p
Proton.
Definition: action.h:24
ProcessType
ProcessTypes are used to identify the type of the process.
Definition: processbranch.h:39
@ None
See here for a short description.
bool are_particles_identical_at_given_time(const ParticleData &p1, const ParticleData &p2, double time)
Utility function to compare two ParticleData instances with respect to their PDG code,...
ParticleData create_valid_smash_particle_matching_provided_quantities(PdgCode pdgcode, double mass, const FourVector &four_position, const FourVector &four_momentum, int log_area, bool &mass_warning, bool &on_shell_warning)
This function creates a SMASH particle validating the provided information.
A structure to hold information about the history of the particle, e.g.
Definition: particledata.h:30
double time_last_collision
Time of the last action (excluding walls), time of kinetic freeze_out for HBT analysis this time shou...
Definition: particledata.h:43
int32_t id_process
id of the last action
Definition: particledata.h:34
PdgCode p2
PdgCode of the second parent particles.
Definition: particledata.h:47
PdgCode p1
PdgCode of the first parent particles.
Definition: particledata.h:45
int32_t collisions_per_particle
Collision counter per particle, zero only for initially present particles.
Definition: particledata.h:32
ProcessType process_type
type of the last action
Definition: particledata.h:36
const ParticleList & list
Particle list.
Definition: particledata.h:493