Version: SMASH-3.3
quantumnumbers.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2020,2022-2023,2025
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_SMASH_QUANTUMNUMBERS_H_
11 #define SRC_INCLUDE_SMASH_QUANTUMNUMBERS_H_
12 
13 #include <string>
14 #include <vector>
15 
16 #include "particles.h"
17 
18 namespace smash {
19 
54  public:
57  : momentum_(0., 0., 0., 0.),
58  charge_(0),
59  isospin3_(0),
60  strangeness_(0),
61  charmness_(0),
62  bottomness_(0),
63  baryon_number_(0) {}
64 
75  QuantumNumbers(const FourVector& m, const int q, const int i3, const int s,
76  const int c, const int b, const int B)
77  : momentum_(m),
78  charge_(q),
79  isospin3_(i3),
80  strangeness_(s),
81  charmness_(c),
82  bottomness_(b),
83  baryon_number_(B) {}
84 
92  explicit QuantumNumbers(const Particles& particles) : QuantumNumbers() {
93  for (const ParticleData& data : particles) {
94  add_values(data);
95  }
96  }
97 
103  explicit QuantumNumbers(const std::vector<Particles>& ensembles)
104  : QuantumNumbers() {
105  for (const Particles& particles : ensembles) {
106  for (const ParticleData& data : particles) {
107  add_values(data);
108  }
109  }
110  }
111 
118  explicit QuantumNumbers(const ParticleList& part) : QuantumNumbers() {
119  for (const auto& p : part) {
120  add_values(p);
121  }
122  }
123 
128  void add_values(const ParticleData& p) {
129  momentum_ += p.momentum();
130  charge_ += p.pdgcode().charge();
131  isospin3_ += p.pdgcode().isospin3();
132  strangeness_ += p.pdgcode().strangeness();
133  charmness_ += p.pdgcode().charmness();
134  bottomness_ += p.pdgcode().bottomness();
135  baryon_number_ += p.pdgcode().baryon_number();
136  }
137 
145  FourVector momentum() const { return momentum_; }
146 
154  int charge() const { return charge_; }
162  int isospin3() const { return isospin3_; }
170  int strangeness() const { return strangeness_; }
178  int charmness() const { return charmness_; }
186  int bottomness() const { return bottomness_; }
194  int baryon_number() const { return baryon_number_; }
195 
205  bool operator==(const QuantumNumbers& rhs) const {
206  return (momentum_ == rhs.momentum_ && charge_ == rhs.charge_ &&
207  isospin3_ == rhs.isospin3_ && strangeness_ == rhs.strangeness_ &&
208  charmness_ == rhs.charmness_ && bottomness_ == rhs.bottomness_ &&
210  }
212  bool operator!=(const QuantumNumbers& rhs) const { return !(*this == rhs); }
213 
222  return {momentum_ - rhs.momentum_, charge_ - rhs.charge_,
226  }
227 
237  std::string report_deviations(const std::vector<Particles>& ensembles) const {
238  QuantumNumbers current_values(ensembles);
239  return report_deviations(current_values);
240  }
241 
260  std::string report_deviations(const QuantumNumbers& rhs) const;
261 
262  private:
269 
275  int charge_;
306 };
307 
308 } // namespace smash
309 
310 #endif // SRC_INCLUDE_SMASH_QUANTUMNUMBERS_H_
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:33
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:59
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
A container for storing conserved values.
void add_values(const ParticleData &p)
Add the quantum numbers of a single particle to the collection.
QuantumNumbers(const Particles &particles)
Construct QuantumNumbers collection from the conserved quantities found in a set of particles.
int bottomness_
Total bottom.
int isospin3_
Total isospin-3.
QuantumNumbers operator-(const QuantumNumbers &rhs) const
bool operator==(const QuantumNumbers &rhs) const
FourVector momentum_
Total momentum four-vector [GeV].
int charge_
Total charge.
FourVector momentum() const
int baryon_number_
Total baryon number.
QuantumNumbers()
Construct QuantumNumbers collection with all fields 0.
QuantumNumbers(const ParticleList &part)
Construct QuantumNumbers collection from a particle list.
int charmness_
Total charm.
int strangeness_
Total strangeness.
bool operator!=(const QuantumNumbers &rhs) const
Logical complement of QuantumNumbers::operator==.
QuantumNumbers(const FourVector &m, const int q, const int i3, const int s, const int c, const int b, const int B)
std::string report_deviations(const std::vector< Particles > &ensembles) const
Checks if the current particle list has still the same values and reports about differences.
QuantumNumbers(const std::vector< Particles > &ensembles)
Construct QuantumNumbers from several sets of particles.
constexpr int p
Proton.
Definition: action.h:24