Version: SMASH-3.2.2
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 
55  public:
58  : momentum_(0., 0., 0., 0.),
59  charge_(0),
60  isospin3_(0),
61  strangeness_(0),
62  charmness_(0),
63  bottomness_(0),
64  baryon_number_(0) {}
65 
76  QuantumNumbers(const FourVector& m, const int q, const int i3, const int s,
77  const int c, const int b, const int B)
78  : momentum_(m),
79  charge_(q),
80  isospin3_(i3),
81  strangeness_(s),
82  charmness_(c),
83  bottomness_(b),
84  baryon_number_(B) {}
85 
93  explicit QuantumNumbers(const Particles& particles) : QuantumNumbers() {
94  for (const ParticleData& data : particles) {
95  add_values(data);
96  }
97  }
98 
104  explicit QuantumNumbers(const std::vector<Particles>& ensembles)
105  : QuantumNumbers() {
106  for (const Particles& particles : ensembles) {
107  for (const ParticleData& data : particles) {
108  add_values(data);
109  }
110  }
111  }
112 
119  explicit QuantumNumbers(const ParticleList& part) : QuantumNumbers() {
120  for (const auto& p : part) {
121  add_values(p);
122  }
123  }
124 
129  void add_values(const ParticleData& p) {
130  momentum_ += p.momentum();
131  charge_ += p.pdgcode().charge();
132  isospin3_ += p.pdgcode().isospin3();
133  strangeness_ += p.pdgcode().strangeness();
134  charmness_ += p.pdgcode().charmness();
135  bottomness_ += p.pdgcode().bottomness();
136  baryon_number_ += p.pdgcode().baryon_number();
137  }
138 
146  FourVector momentum() const { return momentum_; }
147 
155  int charge() const { return charge_; }
163  int isospin3() const { return isospin3_; }
171  int strangeness() const { return strangeness_; }
179  int charmness() const { return charmness_; }
187  int bottomness() const { return bottomness_; }
195  int baryon_number() const { return baryon_number_; }
196 
206  bool operator==(const QuantumNumbers& rhs) const {
207  return (momentum_ == rhs.momentum_ && charge_ == rhs.charge_ &&
208  isospin3_ == rhs.isospin3_ && strangeness_ == rhs.strangeness_ &&
209  charmness_ == rhs.charmness_ && bottomness_ == rhs.bottomness_ &&
211  }
213  bool operator!=(const QuantumNumbers& rhs) const { return !(*this == rhs); }
214 
223  return {momentum_ - rhs.momentum_, charge_ - rhs.charge_,
227  }
228 
238  std::string report_deviations(const std::vector<Particles>& ensembles) const {
239  QuantumNumbers current_values(ensembles);
240  return report_deviations(current_values);
241  }
242 
261  std::string report_deviations(const QuantumNumbers& rhs) const;
262 
263  private:
270 
276  int charge_;
307 };
308 
309 } // namespace smash
310 
311 #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:58
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