Version: SMASH-1.5
particledata.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2018
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  uint32_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  int 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_rho() const { return type_->is_rho(); }
96  double pole_mass() const { return type_->mass(); }
104  double effective_mass() const;
109  const ParticleType &type() const { return *type_; }
110 
115  uint32_t id_process() const { return history_.id_process; }
120  HistoryData get_history() const { return history_; }
132  void set_history(int ncoll, uint32_t pid, ProcessType pt, double time_of_or,
133  const ParticleList &plist);
134 
139  const FourVector &momentum() const { return momentum_; }
140 
145  void set_4momentum(const FourVector &momentum_vector) {
146  momentum_ = momentum_vector;
147  }
148 
155  void set_4momentum(double mass, const ThreeVector &mom) {
156  momentum_ = FourVector(std::sqrt(mass * mass + mom * mom), mom);
157  }
158 
167  void set_4momentum(double mass, double px, double py, double pz) {
168  momentum_ = FourVector(std::sqrt(mass * mass + px * px + py * py + pz * pz),
169  px, py, pz);
170  }
177  void set_3momentum(const ThreeVector &mom) {
178  momentum_ = FourVector(momentum_.x0(), mom);
179  }
180 
185  const FourVector &position() const { return position_; }
190  void set_4position(const FourVector &pos) { position_ = pos; }
197  void set_3position(const ThreeVector &pos) {
198  position_ = FourVector(position_.x0(), pos);
199  }
200 
205  ParticleData translated(const ThreeVector &delta) const {
206  ParticleData p = *this;
207  p.position_[1] += delta[0];
208  p.position_[2] += delta[1];
209  p.position_[3] += delta[2];
210  return p;
211  }
212 
217  double formation_time() const { return formation_time_; }
223  double begin_formation_time() const { return begin_formation_time_; }
224 
232  void set_formation_time(const double &form_time) {
233  formation_time_ = form_time;
234  // cross section scaling factor will be a step function in time
235  begin_formation_time_ = form_time;
236  }
246  void set_slow_formation_times(double begin_form_time, double form_time) {
247  begin_formation_time_ = begin_form_time;
248  formation_time_ = form_time;
249  }
250 
259  const double &initial_xsec_scaling_factor() const {
261  }
274  void set_cross_section_scaling_factor(const double &xsec_scal) {
275  initial_xsec_scaling_factor_ = xsec_scal;
276  }
277 
282  ThreeVector velocity() const { return momentum_.velocity(); }
283 
296  double inverse_gamma() const {
297  return std::sqrt(1. - momentum_.sqr3() / (momentum_.x0() * momentum_.x0()));
298  }
299 
304  void boost(const ThreeVector &v) {
307  }
308 
313  void boost_momentum(const ThreeVector &v) {
315  }
316 
322  bool operator==(const ParticleData &a) const { return this->id_ == a.id_; }
328  bool operator<(const ParticleData &a) const { return this->id_ < a.id_; }
329 
335  bool operator==(int id_a) const { return this->id_ == id_a; }
340  bool operator<(int id_a) const { return this->id_ < id_a; }
341 
352  ParticleData(const ParticleType &ptype, int uid, int index)
353  : id_(uid), index_(index), type_(&ptype) {}
354 
362  double xsec_scaling_factor(double delta_time = 0.) const;
363 
365  static double formation_power_;
366 
367  private:
368  friend class Particles;
370  ParticleData() = default;
371 
378  void copy_to(ParticleData &dst) const {
379  dst.history_ = history_;
380  dst.momentum_ = momentum_;
381  dst.position_ = position_;
385  }
386 
395  int id_ = -1;
396 
405  unsigned index_ = std::numeric_limits<unsigned>::max();
406 
412 
413  // this leaves us two Bytes padding to use for "free"
414  static_assert(sizeof(ParticleTypePtr) == 2, "");
415  // make sure we don't exceed that space
416  static_assert(sizeof(bool) <= 2, "");
425  bool hole_ = false;
426 
434  double formation_time_ = 0.0;
436  double begin_formation_time_ = 0.0;
444 };
445 
450 std::ostream &operator<<(std::ostream &s, const ParticleData &p);
451 
457 std::ostream &operator<<(std::ostream &out, const ParticleList &particle_list);
458 
466  const ParticleList &list;
467 };
473 inline PrintParticleListDetailed detailed(const ParticleList &list) {
474  return {list};
475 }
476 
483 std::ostream &operator<<(std::ostream &out,
484  const PrintParticleListDetailed &particle_list);
485 
486 } // namespace smash
487 
488 #endif // SRC_INCLUDE_PARTICLEDATA_H_
double mass() const
Definition: particletype.h:134
double begin_formation_time_
time when the cross section scaling factor starts to increase to 1
Definition: particledata.h:436
The ThreeVector class represents a physical three-vector with the components .
Definition: threevector.h:30
const ParticleList & list
Particle list.
Definition: particledata.h:466
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
Definition: fourvector.h:310
ParticleData(const ParticleType &ptype, int uid, int index)
Construct a particle with the given type, id and index in Particles.
Definition: particledata.h:352
double effective_mass() const
Get the particle&#39;s effective mass.
Definition: particledata.cc:21
FourVector LorentzBoost(const ThreeVector &v) const
Returns the FourVector boosted with velocity v.
Definition: fourvector.cc:16
ProcessType
Process Types are used to identify the type of the process.
Definition: processbranch.h:25
void set_4momentum(double mass, const ThreeVector &mom)
Set the momentum of the particle given its mass and momentum three-vector.
Definition: particledata.h:155
void set_id(int i)
Set id of the particle.
Definition: particledata.h:75
void set_3momentum(const ThreeVector &mom)
Set the momentum of the particle without modifying the energy.
Definition: particledata.h:177
int id_
Each particle has a unique identifier.
Definition: particledata.h:395
double pole_mass() const
Get the particle&#39;s pole mass ("on-shell").
Definition: particledata.h:96
bool operator==(const ParticleData &a) const
Check whether two particles have the same id.
Definition: particledata.h:322
const double & initial_xsec_scaling_factor() const
Get the initially assigned cross section scaling factor.
Definition: particledata.h:259
PdgCode p2
PdgCode of the second parent particles.
Definition: particledata.h:41
const FourVector & momentum() const
Get the particle&#39;s 4-momentum.
Definition: particledata.h:139
PrintParticleListDetailed detailed(const ParticleList &list)
Request the ParticleList to be printed in full detail (i.e.
Definition: particledata.h:473
FourVector momentum_
momenta of the particle: x0, x1, x2, x3 as E, px, py, pz
Definition: particledata.h:428
void boost(const ThreeVector &v)
Apply a full Lorentz boost of momentum and position.
Definition: particledata.h:304
double x0() const
Definition: fourvector.h:290
HistoryData history_
history information
Definition: particledata.h:443
bool operator==(int id_a) const
Check if the particle has a given id.
Definition: particledata.h:335
uint32_t id_process
id of the last action
Definition: particledata.h:28
void set_formation_time(const double &form_time)
Set the absolute formation time.
Definition: particledata.h:232
PdgCode p1
PdgCode of the first parent particles.
Definition: particledata.h:39
void copy_to(ParticleData &dst) const
Copies some information of the particle to the given particle dst.
Definition: particledata.h:378
A structure to hold information about the history of the particle, e.g.
Definition: particledata.h:24
double sqr3() const
calculate the square of the spatial three-vector
Definition: fourvector.h:451
ParticleTypePtr type_
A reference to the ParticleType object for this particle (this contains all the static information)...
Definition: particledata.h:411
bool is_rho() const
Definition: particledata.h:91
FourVector position_
position in space: x0, x1, x2, x3 as t, x, y, z
Definition: particledata.h:430
bool is_baryon() const
Definition: particledata.h:88
double formation_time_
Formation time at which the particle is fully formed given as an absolute value in the computational ...
Definition: particledata.h:434
bool operator<(int id_a) const
Check whether the particle&#39;s id is smaller than the given id.
Definition: particledata.h:340
bool is_hadron() const
Definition: particledata.h:85
bool hole_
If true, the object is an entry in Particles::data_ and does not hold valid particle data...
Definition: particledata.h:425
const FourVector & position() const
Get the particle&#39;s position in Minkowski space.
Definition: particledata.h:185
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
double formation_time() const
Get the absolute formation time of the particle.
Definition: particledata.h:217
double initial_xsec_scaling_factor_
Initial cross section scaling factor.
Definition: particledata.h:441
Particle type contains the static properties of a particle species.
Definition: particletype.h:87
void set_4momentum(const FourVector &momentum_vector)
Set the particle&#39;s 4-momentum directly.
Definition: particledata.h:145
void set_4momentum(double mass, double px, double py, double pz)
Set the momentum of the particle.
Definition: particledata.h:167
uint32_t id_process() const
Get the id of the last action.
Definition: particledata.h:115
double inverse_gamma() const
Get the inverse of the gamma factor from the current velocity of the particle.
Definition: particledata.h:296
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
Definition: pdgcode.h:108
static double formation_power_
Power with which the cross section scaling factor grows in time.
Definition: particledata.h:365
ProcessType process_type
type of the last action
Definition: particledata.h:30
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
void set_3position(const ThreeVector &pos)
Set particle&#39;s 3-position.
Definition: particledata.h:197
bool is_baryon() const
Definition: pdgcode.h:318
constexpr int p
Proton.
const ParticleType & type() const
Get the type of the particle.
Definition: particledata.h:109
unsigned index_
Internal index in the Particles list.
Definition: particledata.h:405
ParticleData()=default
Default constructor.
void set_4position(const FourVector &pos)
Set the particle&#39;s 4-position directly.
Definition: particledata.h:190
PdgCode pdgcode() const
Get the pdgcode of the particle.
Definition: particledata.h:81
ThreeVector velocity() const
Get the velocity 3-vector.
Definition: particledata.h:282
A pointer-like interface to global references to ParticleType objects.
Definition: particletype.h:660
bool operator<(const ParticleData &a) const
Check if this particle has a smaller id than another particle.
Definition: particledata.h:328
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
int collisions_per_particle
Collision counter per particle, zero only for initially present particles.
Definition: particledata.h:26
int id() const
Get the id of the particle.
Definition: particledata.h:70
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
Definition: action.h:457
void set_cross_section_scaling_factor(const double &xsec_scal)
Set the particle&#39;s initial cross_section_scaling_factor.
Definition: particledata.h:274
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:32
ParticleData translated(const ThreeVector &delta) const
Translate the particle position.
Definition: particledata.h:205
void set_history(int ncoll, uint32_t pid, ProcessType pt, double time_of_or, const ParticleList &plist)
Store history information.
Definition: particledata.cc:31
bool is_hadron() const
Definition: particletype.h:184
bool is_rho() const
Definition: particletype.h:208
PdgCode pdgcode() const
Definition: particletype.h:146
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:52
void boost_momentum(const ThreeVector &v)
Apply a Lorentz-boost to only the momentum.
Definition: particledata.h:313
HistoryData get_history() const
Get history information.
Definition: particledata.h:120
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:246
double begin_formation_time() const
Get the absolute time, where the cross section scaling factor slowly starts increasing from the given...
Definition: particledata.h:223
Definition: action.h:24
double xsec_scaling_factor(double delta_time=0.) const
Return the cross section scaling factor at a given time.
Definition: particledata.cc:69