Version: SMASH-1.5
smash::QuantumNumbers Class Reference

#include <quantumnumbers.h>

A container for storing conserved values.

QuantumNumbers can be used to compare all values that should be conserved during the evolution, in particular for the whole system at fixed intervals, or for a subset of particles before- and after a DecayAction / ScatterAction / Action.

QuantumNumbers can also be used to store, and retrieve, the total value of the quantum numbers in e.g. a ScatterAction, before distributing it to the new particles.

Currently, momentum conservation (including energy conservation), charge-, isospin3-, (net-) strangeness-, (net-) bottomness-, (net-) charmness- and (net-) baryon number conservation are checked. (It should be noted, or repeated, that only the net quantities are conserved, hence this is what is stored and compared with this class.)

Usage

QuantumNumbers before(particlelist);
do_something_with(particlelist);
QuantumNumbers after(particlelist);
printf("%s", before.report_deviations(after).c_str());
if (before != after) {
throw std::runtime_error(before.report_deviations(after));
}

Definition at line 53 of file quantumnumbers.h.

Collaboration diagram for smash::QuantumNumbers:
[legend]

Public Member Functions

 QuantumNumbers ()
 Construct QuantumNumbers collection with all fields 0. More...
 
 QuantumNumbers (const FourVector &m, const int q, const int i3, const int s, const int c, const int b, const int B)
 
 QuantumNumbers (const Particles &particles)
 Construct QuantumNumbers collection from the conserved quantities found in a set of particles. More...
 
 QuantumNumbers (const ParticleList &part)
 Construct QuantumNumbers collection from a particle list. More...
 
void add_values (const ParticleData &p)
 Add the quantum numbers of a single particle to the collection. More...
 
FourVector momentum () const
 
int charge () const
 
int isospin3 () const
 
int strangeness () const
 
int charmness () const
 
int bottomness () const
 
int baryon_number () const
 
bool operator== (const QuantumNumbers &rhs) const
 
bool operator!= (const QuantumNumbers &rhs) const
 Logical complement of QuantumNumbers::operator==. More...
 
QuantumNumbers operator- (const QuantumNumbers &rhs) const
 
std::string report_deviations (const Particles &particles) const
 Checks if the current particle list has still the same values and reports about differences. More...
 
std::string report_deviations (const QuantumNumbers &rhs) const
 Reports on deviations between two QuantumNumbers collections. More...
 

Private Attributes

FourVector momentum_
 Total momentum four-vector [GeV]. More...
 
int charge_
 Total charge. More...
 
int isospin3_
 Total isospin-3. More...
 
int strangeness_
 Total strangeness. More...
 
int charmness_
 Total charm. More...
 
int bottomness_
 Total bottom. More...
 
int baryon_number_
 Total baryon number. More...
 

Constructor & Destructor Documentation

◆ QuantumNumbers() [1/4]

smash::QuantumNumbers::QuantumNumbers ( )
inline

Construct QuantumNumbers collection with all fields 0.

Definition at line 56 of file quantumnumbers.h.

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) {}
int charmness_
Total charm.
int bottomness_
Total bottom.
int strangeness_
Total strangeness.
int isospin3_
Total isospin-3.
int charge_
Total charge.
FourVector momentum_
Total momentum four-vector [GeV].
int baryon_number_
Total baryon number.

◆ QuantumNumbers() [2/4]

smash::QuantumNumbers::QuantumNumbers ( const FourVector m,
const int  q,
const int  i3,
const int  s,
const int  c,
const int  b,
const int  B 
)
inline
Returns
Constructed QuantumNumbers.
Parameters
[in]mMomentum FourVector [GeV]
[in]qCharge
[in]i3Isospin
[in]sStrangeness
[in]cCharmness
[in]bBottomness
[in]BBaryon number

Definition at line 75 of file quantumnumbers.h.

77  : momentum_(m),
78  charge_(q),
79  isospin3_(i3),
80  strangeness_(s),
81  charmness_(c),
82  bottomness_(b),
83  baryon_number_(B) {}
int charmness_
Total charm.
int bottomness_
Total bottom.
int strangeness_
Total strangeness.
int isospin3_
Total isospin-3.
int charge_
Total charge.
FourVector momentum_
Total momentum four-vector [GeV].
int baryon_number_
Total baryon number.

◆ QuantumNumbers() [3/4]

smash::QuantumNumbers::QuantumNumbers ( const Particles particles)
inlineexplicit

Construct QuantumNumbers collection from the conserved quantities found in a set of particles.

Parameters
[in]particlesset of particles for which quantum numbers are calculated and constructed
Returns
Constructed object.

Definition at line 92 of file quantumnumbers.h.

92  : QuantumNumbers() {
93  for (const ParticleData& data : particles) {
94  add_values(data);
95  }
96  }
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.
Here is the call graph for this function:

◆ QuantumNumbers() [4/4]

smash::QuantumNumbers::QuantumNumbers ( const ParticleList &  part)
inlineexplicit

Construct QuantumNumbers collection from a particle list.

Parameters
[in]partlist of particles for which quantum numbers are calculated and constructed
Returns
Constructed object.

Definition at line 104 of file quantumnumbers.h.

104  : QuantumNumbers() {
105  for (const auto& p : part) {
106  add_values(p);
107  }
108  }
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.
constexpr int p
Proton.
Here is the call graph for this function:

Member Function Documentation

◆ add_values()

void smash::QuantumNumbers::add_values ( const ParticleData p)
inline

Add the quantum numbers of a single particle to the collection.

Parameters
[in]pparticle whose quantum number is added to the collection

Definition at line 114 of file quantumnumbers.h.

114  {
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  }
int charmness_
Total charm.
int bottomness_
Total bottom.
int strangeness_
Total strangeness.
int isospin3_
Total isospin-3.
int charge_
Total charge.
FourVector momentum_
Total momentum four-vector [GeV].
constexpr int p
Proton.
int baryon_number_
Total baryon number.
Here is the caller graph for this function:

◆ momentum()

FourVector smash::QuantumNumbers::momentum ( ) const
inline
Returns
The total momentum four-vector. \(P^\mu = \sum_{i \in \mbox{particles}} (E_i, \vec p_i)\) [GeV]
See also
QuantumNumbers::momentum_
ParticleData::momentum()

Definition at line 131 of file quantumnumbers.h.

131 { return momentum_; }
FourVector momentum_
Total momentum four-vector [GeV].
Here is the caller graph for this function:

◆ charge()

int smash::QuantumNumbers::charge ( ) const
inline
Returns
The total electric charge. \(Q = \sum_{i \in \mbox{particles}} q_i\)
See also
QuantumNumbers::charge_
PdgCode::charge()

Definition at line 140 of file quantumnumbers.h.

140 { return charge_; }
int charge_
Total charge.
Here is the caller graph for this function:

◆ isospin3()

int smash::QuantumNumbers::isospin3 ( ) const
inline
Returns
Twice the total isospin-3 component. \(I = \sum_{i \in \mbox{particles}} 2{I_3}_i\)
See also
QuantumNumbers::isospin3_
PdgCode::isospin3()

Definition at line 148 of file quantumnumbers.h.

148 { return isospin3_; }
int isospin3_
Total isospin-3.

◆ strangeness()

int smash::QuantumNumbers::strangeness ( ) const
inline
Returns
The total strangeness. \(S = \sum_{i \in \mbox{particles}} S_i\)
See also
QuantumNumbers::strangeness_
PdgCode::strangeness()

Definition at line 156 of file quantumnumbers.h.

156 { return strangeness_; }
int strangeness_
Total strangeness.
Here is the caller graph for this function:

◆ charmness()

int smash::QuantumNumbers::charmness ( ) const
inline
Returns
The total charm. \(C = \sum_{i \in \mbox{particles}} C_i\)
See also
QuantumNumbers::charmness_
PdgCode::charmness()

Definition at line 164 of file quantumnumbers.h.

164 { return charmness_; }
int charmness_
Total charm.

◆ bottomness()

int smash::QuantumNumbers::bottomness ( ) const
inline
Returns
The total bottom. \(b = \sum_{i \in \mbox{particles}} b_i\)
See also
QuantumNumbers::bottomness_
PdgCode::bottomness()

Definition at line 172 of file quantumnumbers.h.

172 { return bottomness_; }
int bottomness_
Total bottom.

◆ baryon_number()

int smash::QuantumNumbers::baryon_number ( ) const
inline
Returns
The total baryon number. \(B = \sum_{i \in \mbox{particles}} B_i\)
See also
QuantumNumbers::baryon_number_
PdgCode::baryon_number()

Definition at line 180 of file quantumnumbers.h.

180 { return baryon_number_; }
int baryon_number_
Total baryon number.
Here is the caller graph for this function:

◆ operator==()

bool smash::QuantumNumbers::operator== ( const QuantumNumbers rhs) const
inline
Returns
true if all members compare true.
Parameters
rhsRight-hand side.

In the comparison of FourVectors, a little leeway is built-in, so this does not rely on an exact comparison of floating point values.

See also
FourVector::operator==

Definition at line 191 of file quantumnumbers.h.

191  {
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_ &&
199  baryon_number_ == rhs.baryon_number_);
200  // clang-format on
201  }
int charmness_
Total charm.
int bottomness_
Total bottom.
int strangeness_
Total strangeness.
int isospin3_
Total isospin-3.
int charge_
Total charge.
FourVector momentum_
Total momentum four-vector [GeV].
int baryon_number_
Total baryon number.

◆ operator!=()

bool smash::QuantumNumbers::operator!= ( const QuantumNumbers rhs) const
inline

Logical complement of QuantumNumbers::operator==.

Definition at line 203 of file quantumnumbers.h.

203 { return !(*this == rhs); }

◆ operator-()

QuantumNumbers smash::QuantumNumbers::operator- ( const QuantumNumbers rhs) const
inline
Returns
Entry-wise difference of two sets of QuantumNumbers.
Parameters
rhsRight-hand side.

If everything is conserved, all entries of the result should be zero.

Definition at line 212 of file quantumnumbers.h.

212  {
213  return {momentum_ - rhs.momentum_, charge_ - rhs.charge_,
214  isospin3_ - rhs.isospin3_, strangeness_ - rhs.strangeness_,
215  charmness_ - rhs.charmness_, bottomness_ - rhs.bottomness_,
216  baryon_number_ - rhs.baryon_number_};
217  }
int charmness_
Total charm.
int bottomness_
Total bottom.
int strangeness_
Total strangeness.
int isospin3_
Total isospin-3.
int charge_
Total charge.
FourVector momentum_
Total momentum four-vector [GeV].
int baryon_number_
Total baryon number.

◆ report_deviations() [1/2]

std::string smash::QuantumNumbers::report_deviations ( const Particles particles) const
inline

Checks if the current particle list has still the same values and reports about differences.

Parameters
[in]particlesSet of particles whose quantum number is compared
Returns
String reporting the deviations.
See also
QuantumNumbers::report_deviations(const QuantumNumbers&) const

Definition at line 227 of file quantumnumbers.h.

227  {
228  QuantumNumbers current_values(particles);
229  return report_deviations(current_values);
230  }
QuantumNumbers()
Construct QuantumNumbers collection with all fields 0.
std::string report_deviations(const Particles &particles) const
Checks if the current particle list has still the same values and reports about differences.
Here is the caller graph for this function:

◆ report_deviations() [2/2]

std::string smash::QuantumNumbers::report_deviations ( const QuantumNumbers rhs) const

Reports on deviations between two QuantumNumbers collections.

Parameters
[in]rhsOther QuantumNumbers collection.
Returns
A string with information about the differences.

If there are no differences, the returned string is empty; else, a descriptive warning message is returned, e.g.

Conservation law violations detected (old vs. new)
Deviation in Charge:
164 vs. 163
Deviation in Isospin 3:
-88 vs. -90

Definition at line 18 of file quantumnumbers.cc.

18  {
19  if (rhs == *this) {
20  return "";
21  }
22  std::stringstream error_msg;
23  error_msg << "Conservation law violations detected (old vs. new)\n";
24  if (momentum_ != rhs.momentum_) {
25  error_msg << "Deviation in Four-Momentum:\n" << std::scientific;
26  }
27  /* programmer's note: here, I'd like to simultaneously loop over an
28  * integer (for the output; so that we know which component is
29  * faulty) and both the current and rhs's momentum four-vector. If
30  * there is a better way to do this, feel free to implement.
31  *
32  * I chose mu < 4 as the breaking condition out of the vague feeling
33  * that comparing integers may be faster than accessing the
34  * iterators. */
35  int mu = 0;
36  for (auto here_iter = momentum_.cbegin(), rhs_iter = rhs.momentum_.cbegin();
37  mu < 4; ++here_iter, ++rhs_iter, ++mu) {
38  if (!almost_equal_physics(*here_iter, *rhs_iter)) {
39  error_msg << " P_" << mu << ": " << *here_iter << " vs. " << *rhs_iter
40  << "; Δ = " << (*here_iter - *rhs_iter) << "\n";
41  }
42  }
43  if (charge_ != rhs.charge_) {
44  error_msg << "Deviation in Charge:\n " << charge_ << " vs. " << rhs.charge_
45  << "\n";
46  }
47  if (isospin3_ != rhs.isospin3_) {
48  error_msg << "Deviation in Isospin 3:\n " << isospin3_ << " vs. "
49  << rhs.isospin3_ << "\n";
50  }
51  if (strangeness_ != rhs.strangeness_) {
52  error_msg << "Deviation in Strangeness:\n " << strangeness_ << " vs. "
53  << rhs.strangeness_ << "\n";
54  }
55  if (charmness_ != rhs.charmness_) {
56  error_msg << "Deviation in Charmness:\n " << charmness_ << " vs. "
57  << rhs.charmness_ << "\n";
58  }
59  if (bottomness_ != rhs.bottomness_) {
60  error_msg << "Deviation in Bottomness:\n " << bottomness_ << " vs. "
61  << rhs.bottomness_ << "\n";
62  }
63  if (baryon_number_ != rhs.baryon_number_) {
64  error_msg << "Deviation in Baryon Number:\n " << baryon_number_ << " vs. "
65  << rhs.baryon_number_ << "\n";
66  }
67  return error_msg.str();
68 }
int charmness_
Total charm.
int bottomness_
Total bottom.
int strangeness_
Total strangeness.
int isospin3_
Total isospin-3.
int charge_
Total charge.
const_iterator cbegin() const
Definition: fourvector.h:279
bool almost_equal_physics(const N x, const N y)
Same as smash::almost_equal, but for physical checks like energy-momentum conservation small_number i...
Definition: numerics.h:62
FourVector momentum_
Total momentum four-vector [GeV].
int baryon_number_
Total baryon number.
Here is the call graph for this function:

Member Data Documentation

◆ momentum_

FourVector smash::QuantumNumbers::momentum_
private

Total momentum four-vector [GeV].

See also
QuantumNumbers::momentum()

Definition at line 258 of file quantumnumbers.h.

◆ charge_

int smash::QuantumNumbers::charge_
private

Total charge.

See also
QuantumNumbers::charge()

Definition at line 265 of file quantumnumbers.h.

◆ isospin3_

int smash::QuantumNumbers::isospin3_
private

Total isospin-3.

See also
QuantumNumbers::isospin3()

Definition at line 271 of file quantumnumbers.h.

◆ strangeness_

int smash::QuantumNumbers::strangeness_
private

Total strangeness.

See also
QuantumNumbers::strangeness()

Definition at line 277 of file quantumnumbers.h.

◆ charmness_

int smash::QuantumNumbers::charmness_
private

Total charm.

See also
QuantumNumbers::charmness()

Definition at line 283 of file quantumnumbers.h.

◆ bottomness_

int smash::QuantumNumbers::bottomness_
private

Total bottom.

See also
QuantumNumbers::bottomness()

Definition at line 289 of file quantumnumbers.h.

◆ baryon_number_

int smash::QuantumNumbers::baryon_number_
private

Total baryon number.

See also
QuantumNumbers::baryon_number()

Definition at line 295 of file quantumnumbers.h.


The documentation for this class was generated from the following files: