Version: SMASH-2.0
particledata.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2020
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 
24 struct HistoryData {
28  int32_t id_process = 0;
37  double time_last_collision = 0.0;
39  PdgCode p1 = 0x0;
41  PdgCode p2 = 0x0;
42 };
43 
52 class ParticleData {
53  public:
63  explicit ParticleData(const ParticleType &particle_type, int unique_id = -1)
64  : id_(unique_id), type_(&particle_type) {}
65 
70  int32_t id() const { return id_; }
75  void set_id(int i) { id_ = i; }
76 
81  PdgCode pdgcode() const { return type_->pdgcode(); }
82 
83  // Convenience accessors to PdgCode:
85  bool is_hadron() const { return type_->is_hadron(); }
86 
88  bool is_baryon() const { return pdgcode().is_baryon(); }
89 
91  bool is_nucleus() const { return pdgcode().is_nucleus(); }
92 
94  bool is_rho() const { return type_->is_rho(); }
95 
97  bool is_proton() const { return pdgcode().is_proton(); }
98 
100  bool is_neutron() const { return pdgcode().is_neutron(); }
101 
103  bool is_pion() const { return pdgcode().is_pion(); }
104 
109  double pole_mass() const { return type_->mass(); }
117  double effective_mass() const;
122  const ParticleType &type() const { return *type_; }
123 
128  uint32_t id_process() const { return history_.id_process; }
133  HistoryData get_history() const { return history_; }
145  void set_history(int ncoll, uint32_t pid, ProcessType pt, double time_of_or,
146  const ParticleList &plist);
147 
152  const FourVector &momentum() const { return momentum_; }
153 
158  void set_4momentum(const FourVector &momentum_vector) {
159  momentum_ = momentum_vector;
160  }
161 
168  void set_4momentum(double mass, const ThreeVector &mom) {
169  momentum_ = FourVector(std::sqrt(mass * mass + mom * mom), mom);
170  }
171 
180  void set_4momentum(double mass, double px, double py, double pz) {
181  momentum_ = FourVector(std::sqrt(mass * mass + px * px + py * py + pz * pz),
182  px, py, pz);
183  }
190  void set_3momentum(const ThreeVector &mom) {
191  momentum_ = FourVector(momentum_.x0(), mom);
192  }
193 
198  const FourVector &position() const { return position_; }
203  void set_4position(const FourVector &pos) { position_ = pos; }
210  void set_3position(const ThreeVector &pos) {
211  position_ = FourVector(position_.x0(), pos);
212  }
213 
218  ParticleData translated(const ThreeVector &delta) const {
219  ParticleData p = *this;
220  p.position_[1] += delta[0];
221  p.position_[2] += delta[1];
222  p.position_[3] += delta[2];
223  return p;
224  }
225 
230  double formation_time() const { return formation_time_; }
236  double begin_formation_time() const { return begin_formation_time_; }
237 
245  void set_formation_time(const double &form_time) {
246  formation_time_ = form_time;
247  // cross section scaling factor will be a step function in time
248  begin_formation_time_ = form_time;
249  }
259  void set_slow_formation_times(double begin_form_time, double form_time) {
260  begin_formation_time_ = begin_form_time;
261  formation_time_ = form_time;
262  }
263 
272  const double &initial_xsec_scaling_factor() const {
274  }
287  void set_cross_section_scaling_factor(const double &xsec_scal) {
288  initial_xsec_scaling_factor_ = xsec_scal;
289  }
290 
295  ThreeVector velocity() const { return momentum_.velocity(); }
296 
309  double inverse_gamma() const {
310  return std::sqrt(1. - momentum_.sqr3() / (momentum_.x0() * momentum_.x0()));
311  }
312 
317  void boost(const ThreeVector &v) {
320  }
321 
326  void boost_momentum(const ThreeVector &v) {
328  }
329 
335  bool operator==(const ParticleData &a) const { return this->id_ == a.id_; }
341  bool operator<(const ParticleData &a) const { return this->id_ < a.id_; }
342 
348  bool operator==(int id_a) const { return this->id_ == id_a; }
353  bool operator<(int id_a) const { return this->id_ < id_a; }
354 
365  ParticleData(const ParticleType &ptype, int uid, int index)
366  : id_(uid), index_(index), type_(&ptype) {}
367 
375  double xsec_scaling_factor(double delta_time = 0.) const;
376 
378  static double formation_power_;
379 
380  private:
381  friend class Particles;
383  ParticleData() = default;
384 
391  void copy_to(ParticleData &dst) const {
392  dst.history_ = history_;
393  dst.momentum_ = momentum_;
394  dst.position_ = position_;
398  }
399 
408  int32_t id_ = -1;
409 
418  unsigned index_ = std::numeric_limits<unsigned>::max();
419 
425 
426  // this leaves us two Bytes padding to use for "free"
427  static_assert(sizeof(ParticleTypePtr) == 2, "");
428  // make sure we don't exceed that space
429  static_assert(sizeof(bool) <= 2, "");
438  bool hole_ = false;
439 
447  double formation_time_ = 0.0;
449  double begin_formation_time_ = 0.0;
457 };
458 
463 std::ostream &operator<<(std::ostream &s, const ParticleData &p);
464 
470 std::ostream &operator<<(std::ostream &out, const ParticleList &particle_list);
471 
479  const ParticleList &list;
480 };
486 inline PrintParticleListDetailed detailed(const ParticleList &list) {
487  return {list};
488 }
489 
496 std::ostream &operator<<(std::ostream &out,
497  const PrintParticleListDetailed &particle_list);
498 
499 } // namespace smash
500 
501 #endif // SRC_INCLUDE_SMASH_PARTICLEDATA_H_
smash::ParticleData::translated
ParticleData translated(const ThreeVector &delta) const
Translate the particle position.
Definition: particledata.h:218
smash::ParticleData::set_3momentum
void set_3momentum(const ThreeVector &mom)
Set the momentum of the particle without modifying the energy.
Definition: particledata.h:190
smash::ParticleData::is_proton
bool is_proton() const
Definition: particledata.h:97
smash
Definition: action.h:24
smash::PrintParticleListDetailed::list
const ParticleList & list
Particle list.
Definition: particledata.h:479
smash::ParticleData::id_
int32_t id_
Each particle has a unique identifier.
Definition: particledata.h:408
smash::ParticleData::set_4momentum
void set_4momentum(double mass, double px, double py, double pz)
Set the momentum of the particle.
Definition: particledata.h:180
processbranch.h
smash::ParticleData::xsec_scaling_factor
double xsec_scaling_factor(double delta_time=0.) const
Return the cross section scaling factor at a given time.
Definition: particledata.cc:78
smash::ParticleData::operator<
bool operator<(int id_a) const
Check whether the particle's id is smaller than the given id.
Definition: particledata.h:353
smash::ParticleData::ParticleData
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:63
smash::ParticleData::is_hadron
bool is_hadron() const
Definition: particledata.h:85
smash::ParticleData::momentum
const FourVector & momentum() const
Get the particle's 4-momentum.
Definition: particledata.h:152
smash::HistoryData::p1
PdgCode p1
PdgCode of the first parent particles.
Definition: particledata.h:39
smash::ParticleData::is_pion
bool is_pion() const
Definition: particledata.h:103
smash::ParticleData::history_
HistoryData history_
history information
Definition: particledata.h:456
smash::HistoryData::collisions_per_particle
int32_t collisions_per_particle
Collision counter per particle, zero only for initially present particles.
Definition: particledata.h:26
smash::ParticleData::pole_mass
double pole_mass() const
Get the particle's pole mass ("on-shell").
Definition: particledata.h:109
smash::ParticleData
Definition: particledata.h:52
smash::ParticleData::initial_xsec_scaling_factor
const double & initial_xsec_scaling_factor() const
Get the initially assigned cross section scaling factor.
Definition: particledata.h:272
smash::ParticleData::type_
ParticleTypePtr type_
A reference to the ParticleType object for this particle (this contains all the static information).
Definition: particledata.h:424
smash::ParticleData::id
int32_t id() const
Get the id of the particle.
Definition: particledata.h:70
smash::ParticleData::inverse_gamma
double inverse_gamma() const
Get the inverse of the gamma factor from the current velocity of the particle.
Definition: particledata.h:309
smash::ParticleData::boost
void boost(const ThreeVector &v)
Apply a full Lorentz boost of momentum and position.
Definition: particledata.h:317
smash::ParticleData::set_id
void set_id(int i)
Set id of the particle.
Definition: particledata.h:75
smash::PdgCode::is_pion
bool is_pion() const
Definition: pdgcode.h:381
smash::ParticleData::set_slow_formation_times
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:259
smash::ParticleData::ParticleData
ParticleData()=default
Default constructor.
smash::ParticleData::begin_formation_time
double begin_formation_time() const
Get the absolute time, where the cross section scaling factor slowly starts increasing from the given...
Definition: particledata.h:236
smash::ParticleData::effective_mass
double effective_mass() const
Get the particle's effective mass.
Definition: particledata.cc:21
smash::HistoryData
A structure to hold information about the history of the particle, e.g.
Definition: particledata.h:24
smash::ParticleData::get_history
HistoryData get_history() const
Get history information.
Definition: particledata.h:133
smash::ParticleData::formation_time_
double formation_time_
Formation time at which the particle is fully formed given as an absolute value in the computational ...
Definition: particledata.h:447
smash::operator<<
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Definition: action.h:518
smash::ParticleType::mass
double mass() const
Definition: particletype.h:144
smash::PdgCode::is_nucleus
bool is_nucleus() const
Definition: pdgcode.h:288
smash::ParticleData::pdgcode
PdgCode pdgcode() const
Get the pdgcode of the particle.
Definition: particledata.h:81
smash::ParticleType::pdgcode
PdgCode pdgcode() const
Definition: particletype.h:156
smash::ParticleData::id_process
uint32_t id_process() const
Get the id of the last action.
Definition: particledata.h:128
fourvector.h
smash::HistoryData::process_type
ProcessType process_type
type of the last action
Definition: particledata.h:30
smash::ParticleData::set_4momentum
void set_4momentum(const FourVector &momentum_vector)
Set the particle's 4-momentum directly.
Definition: particledata.h:158
smash::ParticleData::ParticleData
ParticleData(const ParticleType &ptype, int uid, int index)
Construct a particle with the given type, id and index in Particles.
Definition: particledata.h:365
smash::HistoryData::time_last_collision
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:37
smash::PdgCode::is_proton
bool is_proton() const
Definition: pdgcode.h:327
forwarddeclarations.h
smash::ParticleTypePtr
Definition: particletype.h:665
smash::ThreeVector
Definition: threevector.h:31
smash::ParticleData::operator<
bool operator<(const ParticleData &a) const
Check if this particle has a smaller id than another particle.
Definition: particledata.h:341
smash::ParticleData::formation_time
double formation_time() const
Get the absolute formation time of the particle.
Definition: particledata.h:230
smash::ParticleData::set_3position
void set_3position(const ThreeVector &pos)
Set particle's 3-position.
Definition: particledata.h:210
smash::ParticleData::initial_xsec_scaling_factor_
double initial_xsec_scaling_factor_
Initial cross section scaling factor.
Definition: particledata.h:454
smash::ParticleData::set_formation_time
void set_formation_time(const double &form_time)
Set the absolute formation time.
Definition: particledata.h:245
smash::ParticleData::boost_momentum
void boost_momentum(const ThreeVector &v)
Apply a Lorentz-boost to only the momentum.
Definition: particledata.h:326
smash::ParticleData::is_baryon
bool is_baryon() const
Definition: particledata.h:88
smash::FourVector::x0
double x0() const
Definition: fourvector.h:303
smash::ParticleData::hole_
bool hole_
If true, the object is an entry in Particles::data_ and does not hold valid particle data.
Definition: particledata.h:438
smash::ParticleType::is_hadron
bool is_hadron() const
Definition: particletype.h:197
smash::ParticleData::position
const FourVector & position() const
Get the particle's position in Minkowski space.
Definition: particledata.h:198
smash::ParticleData::position_
FourVector position_
position in space: x0, x1, x2, x3 as t, x, y, z
Definition: particledata.h:443
smash::ParticleData::begin_formation_time_
double begin_formation_time_
time when the cross section scaling factor starts to increase to 1
Definition: particledata.h:449
smash::PrintParticleListDetailed
Definition: particledata.h:477
smash::ParticleType
Definition: particletype.h:97
smash::ParticleData::is_rho
bool is_rho() const
Definition: particledata.h:94
smash::ParticleData::momentum_
FourVector momentum_
momenta of the particle: x0, x1, x2, x3 as E, px, py, pz
Definition: particledata.h:441
particletype.h
smash::ParticleData::operator==
bool operator==(int id_a) const
Check if the particle has a given id.
Definition: particledata.h:348
smash::ParticleData::copy_to
void copy_to(ParticleData &dst) const
Copies some information of the particle to the given particle dst.
Definition: particledata.h:391
smash::ParticleData::formation_power_
static double formation_power_
Power with which the cross section scaling factor grows in time.
Definition: particledata.h:378
smash::PdgCode
Definition: pdgcode.h:108
smash::HistoryData::id_process
int32_t id_process
id of the last action
Definition: particledata.h:28
smash::HistoryData::p2
PdgCode p2
PdgCode of the second parent particles.
Definition: particledata.h:41
smash::FourVector::velocity
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
Definition: fourvector.h:323
smash::ParticleData::operator==
bool operator==(const ParticleData &a) const
Check whether two particles have the same id.
Definition: particledata.h:335
smash::PdgCode::is_neutron
bool is_neutron() const
Definition: pdgcode.h:333
smash::ParticleData::set_4momentum
void set_4momentum(double mass, const ThreeVector &mom)
Set the momentum of the particle given its mass and momentum three-vector.
Definition: particledata.h:168
smash::ParticleType::is_rho
bool is_rho() const
Definition: particletype.h:221
smash::ParticleData::set_cross_section_scaling_factor
void set_cross_section_scaling_factor(const double &xsec_scal)
Set the particle's initial cross_section_scaling_factor.
Definition: particledata.h:287
smash::Particles
Definition: particles.h:33
smash::ParticleData::set_history
void set_history(int ncoll, uint32_t pid, ProcessType pt, double time_of_or, const ParticleList &plist)
Store history information.
Definition: particledata.cc:31
smash::detailed
PrintParticleListDetailed detailed(const ParticleList &list)
Definition: particledata.h:486
pdgcode.h
smash::ParticleData::set_4position
void set_4position(const FourVector &pos)
Set the particle's 4-position directly.
Definition: particledata.h:203
smash::DensityType::None
smash::FourVector
Definition: fourvector.h:33
smash::pdg::p
constexpr int p
Proton.
Definition: pdgcode_constants.h:28
smash::PdgCode::is_baryon
bool is_baryon() const
Definition: pdgcode.h:315
smash::FourVector::lorentz_boost
FourVector lorentz_boost(const ThreeVector &v) const
Returns the FourVector boosted with velocity v.
Definition: fourvector.cc:16
smash::FourVector::sqr3
double sqr3() const
calculate the square of the spatial three-vector
Definition: fourvector.h:464
smash::ParticleData::type
const ParticleType & type() const
Get the type of the particle.
Definition: particledata.h:122
smash::ParticleData::velocity
ThreeVector velocity() const
Get the velocity 3-vector.
Definition: particledata.h:295
smash::ParticleData::is_nucleus
bool is_nucleus() const
Definition: particledata.h:91
smash::ParticleData::is_neutron
bool is_neutron() const
Definition: particledata.h:100
smash::ParticleData::index_
unsigned index_
Internal index in the Particles list.
Definition: particledata.h:418
smash::ProcessType
ProcessType
Process Types are used to identify the type of the process.
Definition: processbranch.h:25