Version: SMASH-1.5
quantumnumbers.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2014-2018
4  * SMASH Team
5  *
6  * GNU General Public License (GPLv3 or later)
7  *
8  */
9 
10 #ifndef SRC_INCLUDE_QUANTUMNUMBERS_H_
11 #define SRC_INCLUDE_QUANTUMNUMBERS_H_
12 
13 #include <string>
14 
15 #include "particles.h"
16 
17 namespace smash {
18 
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 
104  explicit QuantumNumbers(const ParticleList& part) : QuantumNumbers() {
105  for (const auto& p : part) {
106  add_values(p);
107  }
108  }
109 
114  void add_values(const ParticleData& p) {
115  momentum_ += p.momentum();
116  charge_ += p.pdgcode().charge();
117  isospin3_ += p.pdgcode().isospin3();
118  strangeness_ += p.pdgcode().strangeness();
119  charmness_ += p.pdgcode().charmness();
120  bottomness_ += p.pdgcode().bottomness();
121  baryon_number_ += p.pdgcode().baryon_number();
122  }
123 
131  FourVector momentum() const { return momentum_; }
132 
140  int charge() const { return charge_; }
148  int isospin3() const { return isospin3_; }
156  int strangeness() const { return strangeness_; }
164  int charmness() const { return charmness_; }
172  int bottomness() const { return bottomness_; }
180  int baryon_number() const { return baryon_number_; }
181 
191  bool operator==(const QuantumNumbers& rhs) const {
192  // clang-format off
193  return (momentum_ == rhs.momentum_ &&
194  charge_ == rhs.charge_ &&
195  isospin3_ == rhs.isospin3_ &&
196  strangeness_ == rhs.strangeness_ &&
197  charmness_ == rhs.charmness_ &&
198  bottomness_ == rhs.bottomness_ &&
200  // clang-format on
201  }
203  bool operator!=(const QuantumNumbers& rhs) const { return !(*this == rhs); }
204 
213  return {momentum_ - rhs.momentum_, charge_ - rhs.charge_,
217  }
218 
227  std::string report_deviations(const Particles& particles) const {
228  QuantumNumbers current_values(particles);
229  return report_deviations(current_values);
230  }
231 
250  std::string report_deviations(const QuantumNumbers& rhs) const;
251 
252  private:
259 
265  int charge_;
296 };
297 
298 } // namespace smash
299 
300 #endif // SRC_INCLUDE_QUANTUMNUMBERS_H_
int charmness_
Total charm.
int bottomness_
Total bottom.
int strangeness_
Total strangeness.
QuantumNumbers(const Particles &particles)
Construct QuantumNumbers collection from the conserved quantities found in a set of particles...
int isospin3_
Total isospin-3.
int charge_
Total charge.
QuantumNumbers()
Construct QuantumNumbers collection with all fields 0.
void add_values(const ParticleData &p)
Add the quantum numbers of a single particle to the collection.
QuantumNumbers(const ParticleList &part)
Construct QuantumNumbers collection from a particle list.
std::string report_deviations(const Particles &particles) const
Checks if the current particle list has still the same values and reports about differences.
bool operator!=(const QuantumNumbers &rhs) const
Logical complement of QuantumNumbers::operator==.
A container for storing conserved values.
QuantumNumbers(const FourVector &m, const int q, const int i3, const int s, const int c, const int b, const int B)
bool operator==(const QuantumNumbers &rhs) const
FourVector momentum_
Total momentum four-vector [GeV].
QuantumNumbers operator-(const QuantumNumbers &rhs) const
constexpr int p
Proton.
The Particles class abstracts the storage and manipulation of particles.
Definition: particles.h:33
int baryon_number_
Total baryon number.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
Definition: fourvector.h:32
FourVector momentum() const
ParticleData contains the dynamic information of a certain particle.
Definition: particledata.h:52
Definition: action.h:24