Version: SMASH-1.8
particledata.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2019
3  * SMASH Team
4  *
5  * GNU General Public License (GPLv3 or later)
6  */
7 #ifndef SRC_INCLUDE_PARTICLEDATA_H_
8 #define SRC_INCLUDE_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(); }
99  double pole_mass() const { return type_->mass(); }
107  double effective_mass() const;
112  const ParticleType &type() const { return *type_; }
113 
118  uint32_t id_process() const { return history_.id_process; }
123  HistoryData get_history() const { return history_; }
135  void set_history(int ncoll, uint32_t pid, ProcessType pt, double time_of_or,
136  const ParticleList &plist);
137 
142  const FourVector &momentum() const { return momentum_; }
143 
148  void set_4momentum(const FourVector &momentum_vector) {
149  momentum_ = momentum_vector;
150  }
151 
158  void set_4momentum(double mass, const ThreeVector &mom) {
159  momentum_ = FourVector(std::sqrt(mass * mass + mom * mom), mom);
160  }
161 
170  void set_4momentum(double mass, double px, double py, double pz) {
171  momentum_ = FourVector(std::sqrt(mass * mass + px * px + py * py + pz * pz),
172  px, py, pz);
173  }
180  void set_3momentum(const ThreeVector &mom) {
181  momentum_ = FourVector(momentum_.x0(), mom);
182  }
183 
188  const FourVector &position() const { return position_; }
193  void set_4position(const FourVector &pos) { position_ = pos; }
200  void set_3position(const ThreeVector &pos) {
201  position_ = FourVector(position_.x0(), pos);
202  }
203 
208  ParticleData translated(const ThreeVector &delta) const {
209  ParticleData p = *this;
210  p.position_[1] += delta[0];
211  p.position_[2] += delta[1];
212  p.position_[3] += delta[2];
213  return p;
214  }
215 
220  double formation_time() const { return formation_time_; }
226  double begin_formation_time() const { return begin_formation_time_; }
227 
235  void set_formation_time(const double &form_time) {
236  formation_time_ = form_time;
237  // cross section scaling factor will be a step function in time
238  begin_formation_time_ = form_time;
239  }
249  void set_slow_formation_times(double begin_form_time, double form_time) {
250  begin_formation_time_ = begin_form_time;
251  formation_time_ = form_time;
252  }
253 
262  const double &initial_xsec_scaling_factor() const {
264  }
277  void set_cross_section_scaling_factor(const double &xsec_scal) {
278  initial_xsec_scaling_factor_ = xsec_scal;
279  }
280 
285  ThreeVector velocity() const { return momentum_.velocity(); }
286 
299  double inverse_gamma() const {
300  return std::sqrt(1. - momentum_.sqr3() / (momentum_.x0() * momentum_.x0()));
301  }
302 
307  void boost(const ThreeVector &v) {
310  }
311 
316  void boost_momentum(const ThreeVector &v) {
318  }
319 
325  bool operator==(const ParticleData &a) const { return this->id_ == a.id_; }
331  bool operator<(const ParticleData &a) const { return this->id_ < a.id_; }
332 
338  bool operator==(int id_a) const { return this->id_ == id_a; }
343  bool operator<(int id_a) const { return this->id_ < id_a; }
344 
355  ParticleData(const ParticleType &ptype, int uid, int index)
356  : id_(uid), index_(index), type_(&ptype) {}
357 
365  double xsec_scaling_factor(double delta_time = 0.) const;
366 
368  static double formation_power_;
369 
370  private:
371  friend class Particles;
373  ParticleData() = default;
374 
381  void copy_to(ParticleData &dst) const {
382  dst.history_ = history_;
383  dst.momentum_ = momentum_;
384  dst.position_ = position_;
388  }
389 
398  int32_t id_ = -1;
399 
408  unsigned index_ = std::numeric_limits<unsigned>::max();
409 
415 
416  // this leaves us two Bytes padding to use for "free"
417  static_assert(sizeof(ParticleTypePtr) == 2, "");
418  // make sure we don't exceed that space
419  static_assert(sizeof(bool) <= 2, "");
428  bool hole_ = false;
429 
437  double formation_time_ = 0.0;
439  double begin_formation_time_ = 0.0;
447 };
448 
453 std::ostream &operator<<(std::ostream &s, const ParticleData &p);
454 
460 std::ostream &operator<<(std::ostream &out, const ParticleList &particle_list);
461 
469  const ParticleList &list;
470 };
476 inline PrintParticleListDetailed detailed(const ParticleList &list) {
477  return {list};
478 }
479 
486 std::ostream &operator<<(std::ostream &out,
487  const PrintParticleListDetailed &particle_list);
488 
489 } // namespace smash
490 
491 #endif // SRC_INCLUDE_PARTICLEDATA_H_
smash::ParticleData::translated
ParticleData translated(const ThreeVector &delta) const
Translate the particle position.
Definition: particledata.h:208
smash::ParticleData::set_3momentum
void set_3momentum(const ThreeVector &mom)
Set the momentum of the particle without modifying the energy.
Definition: particledata.h:180
smash
Definition: action.h:24
smash::PrintParticleListDetailed::list
const ParticleList & list
Particle list.
Definition: particledata.h:469
smash::ParticleData::id_
int32_t id_
Each particle has a unique identifier.
Definition: particledata.h:398
smash::ParticleData::set_4momentum
void set_4momentum(double mass, double px, double py, double pz)
Set the momentum of the particle.
Definition: particledata.h:170
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:74
smash::ParticleData::operator<
bool operator<(int id_a) const
Check whether the particle's id is smaller than the given id.
Definition: particledata.h:343
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:142
smash::HistoryData::p1
PdgCode p1
PdgCode of the first parent particles.
Definition: particledata.h:39
smash::ParticleData::history_
HistoryData history_
history information
Definition: particledata.h:446
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:99
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:262
smash::ParticleData::type_
ParticleTypePtr type_
A reference to the ParticleType object for this particle (this contains all the static information).
Definition: particledata.h:414
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:299
smash::ParticleData::boost
void boost(const ThreeVector &v)
Apply a full Lorentz boost of momentum and position.
Definition: particledata.h:307
smash::ParticleData::set_id
void set_id(int i)
Set id of the particle.
Definition: particledata.h:75
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:249
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:226
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:123
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:437
smash::operator<<
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Definition: action.h:463
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:118
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:148
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:355
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
forwarddeclarations.h
smash::ParticleTypePtr
Definition: particletype.h:663
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:331
smash::ParticleData::formation_time
double formation_time() const
Get the absolute formation time of the particle.
Definition: particledata.h:220
smash::ParticleData::set_3position
void set_3position(const ThreeVector &pos)
Set particle's 3-position.
Definition: particledata.h:200
smash::ParticleData::initial_xsec_scaling_factor_
double initial_xsec_scaling_factor_
Initial cross section scaling factor.
Definition: particledata.h:444
smash::ParticleData::set_formation_time
void set_formation_time(const double &form_time)
Set the absolute formation time.
Definition: particledata.h:235
smash::ParticleData::boost_momentum
void boost_momentum(const ThreeVector &v)
Apply a Lorentz-boost to only the momentum.
Definition: particledata.h:316
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:428
smash::ParticleType::is_hadron
bool is_hadron() const
Definition: particletype.h:194
smash::ParticleData::position
const FourVector & position() const
Get the particle's position in Minkowski space.
Definition: particledata.h:188
smash::ParticleData::position_
FourVector position_
position in space: x0, x1, x2, x3 as t, x, y, z
Definition: particledata.h:433
smash::ParticleData::begin_formation_time_
double begin_formation_time_
time when the cross section scaling factor starts to increase to 1
Definition: particledata.h:439
smash::PrintParticleListDetailed
Definition: particledata.h:467
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:431
particletype.h
smash::ParticleData::operator==
bool operator==(int id_a) const
Check if the particle has a given id.
Definition: particledata.h:338
smash::ParticleData::copy_to
void copy_to(ParticleData &dst) const
Copies some information of the particle to the given particle dst.
Definition: particledata.h:381
smash::ParticleData::formation_power_
static double formation_power_
Power with which the cross section scaling factor grows in time.
Definition: particledata.h:368
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:325
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:158
smash::ParticleType::is_rho
bool is_rho() const
Definition: particletype.h:218
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:277
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:476
pdgcode.h
smash::ParticleData::set_4position
void set_4position(const FourVector &pos)
Set the particle's 4-position directly.
Definition: particledata.h:193
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:112
smash::ParticleData::velocity
ThreeVector velocity() const
Get the velocity 3-vector.
Definition: particledata.h:285
smash::ParticleData::is_nucleus
bool is_nucleus() const
Definition: particledata.h:91
smash::ParticleData::index_
unsigned index_
Internal index in the Particles list.
Definition: particledata.h:408
smash::ProcessType
ProcessType
Process Types are used to identify the type of the process.
Definition: processbranch.h:25