Belle II Software  release-08-01-10
Const::ParticleSet Class Reference

A set of ParticleType objects, with defined order. More...

#include <Const.h>

Collaboration diagram for Const::ParticleSet:

Public Member Functions

 ParticleSet ()=default
 Emtpy constructor.
 
 ParticleSet (const ParticleSet &other)
 Copy constructor to make sure particles belong to correct set.
 
ParticleSetoperator= (const ParticleSet &other)
 Assignment operator.
 
void add (const ParticleType &p)
 Add a copy of the given ParticleType to this set. More...
 
bool contains (const ParticleType &p) const
 Returns true if and only if the set contains 'p'.
 
unsigned int size () const
 Returns number of particles in this set.
 
const ParticleTypeat (unsigned int index) const
 Return particle at given index, or end() if out of range.
 
ParticleType begin () const
 Returns first particle.
 
ParticleType end () const
 Returns an invalid particle to check if iteration should be stopped.
 
const ParticleTypefind (int pdg) const
 Returns particle in set with given PDG code, or invalidParticle if not found.
 

Private Attributes

std::vector< ParticleTypem_particles
 Actual particles.
 

Detailed Description

A set of ParticleType objects, with defined order.

Allows easy iteration over a set of particles, e.g. to print indices and PDG codes:

B2INFO("index -> PDG code");
const Const::ParticleSet set = Const::chargedStableSet;
//via range-based for
for(const Const::ChargedStable& pdgIter : set) {
B2INFO(pdgIter.getIndex() << " -> " << pdgIter.getPDGCode());
}
//or, using iterator syntax:
for(Const::ChargedStable pdgIter = set.begin(); pdgIter != set.end(); ++pdgIter) {
B2INFO(pdgIter.getIndex() << " -> " << pdgIter.getPDGCode());
}
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:609

ParticleSets can be created by merging ParticleType objects or other ParticleSets:

Const::ParticleSet set = Const::electron + Const::muon;
Const::ParticleSet set2 = set + Const::photon;
static const ChargedStable muon
muon particle
Definition: Const.h:651
static const ParticleType photon
photon particle
Definition: Const.h:664
static const ChargedStable electron
electron particle
Definition: Const.h:650

Definition at line 508 of file Const.h.

Member Function Documentation

◆ add()

void add ( const ParticleType p)

Add a copy of the given ParticleType to this set.

If the set already contains the given particle, it remains unchanged.

Definition at line 417 of file UnitConst.cc.


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