Belle II Software light-2406-ragdoll
Const::Cluster Class Reference

Provides a type-safe way to pass members of the clusterSet set. More...

#include <Const.h>

Inheritance diagram for Const::Cluster:
Collaboration diagram for Const::Cluster:

Public Member Functions

 Cluster (const ParticleType &p)
 Constructor from the more general ParticleType.
 
 Cluster (int pdg)
 Constructor from PDG code.
 
bool operator< (const ParticleType &other) const
 Comparison operator to be usable in sets.
 
bool operator== (const ParticleType &o) const
 Test equality.
 
bool operator!= (const ParticleType &o) const
 Test inequality.
 
ParticleTypeoperator* ()
 dummy dereferencing for range-based for.
 
ParticleTypeoperator++ ()
 Prefix increment.
 
ParticleType operator++ (int)
 Postfix increment.
 
 operator ParticleSet () const
 Conversion of ParticleType to ParticleSet.
 
int getIndex () const
 This particle's index in the associated set.
 
const TParticlePDG * getParticlePDG () const
 Accessor for ROOT TParticlePDG object.
 
int getPDGCode () const
 PDG code.
 
double getMass () const
 Particle mass.
 
std::string __repr__ () const
 String for printing in python.
 

Static Public Attributes

static const unsigned int c_SetSize = 6
 Number of elements (for use in array bounds etc.)
 

Private Attributes

int m_pdgCode
 PDG code of the particle.
 
const ParticleSetm_set
 set this particle belongs to, or NULL if stand-alone.
 
int m_index
 index in the associated set, -1 if there's no set.
 

Detailed Description

Provides a type-safe way to pass members of the clusterSet set.

As the defined static members (Const::photon, etc. ) are members of this set, this also defines a fixed index from 0 to 4 for each particle.

Definition at line 626 of file Const.h.

Constructor & Destructor Documentation

◆ Cluster() [1/2]

Cluster ( const ParticleType p)
inline

Constructor from the more general ParticleType.

Throws a runtime_error if p is not in chargedStableSet.

Definition at line 633 of file Const.h.

634 : ParticleType(clusterSet.find(p.getPDGCode()))
635 {
636 if ((*this) == invalidParticle) {
637 throw std::runtime_error("Given ParticleType is not a cluster particle!");
638 }
639 }
const ParticleType & find(int pdg) const
Returns particle in set with given PDG code, or invalidParticle if not found.
Definition: Const.h:571
ParticleType(int pdgCode, const ParticleSet *set=nullptr, int index=-1)
Constructor.
Definition: Const.h:417
static const ParticleSet clusterSet
set of cluster particles
Definition: Const.h:655
static const ParticleType invalidParticle
Invalid particle, used internally.
Definition: Const.h:681

◆ Cluster() [2/2]

Cluster ( int  pdg)
inlineexplicit

Constructor from PDG code.

Throws a runtime_error if pdg is not in chargedStableSet.

Definition at line 645 of file Const.h.

647 {
648 if ((*this) == invalidParticle) {
649 throw std::runtime_error("Given PDG code is not a cluster particle!");
650 }
651 }

Member Function Documentation

◆ __repr__()

std::string __repr__ ( ) const
inherited

String for printing in python.

Definition at line 361 of file UnitConst.cc.

362{
363 std::string result = "<type: ";
364 result += getParticlePDG()->GetName();
365 result += ">";
366 return result;
367}
const TParticlePDG * getParticlePDG() const
Accessor for ROOT TParticlePDG object.
Definition: UnitConst.cc:351

◆ getIndex()

int getIndex ( ) const
inlineinherited

This particle's index in the associated set.

In case the particle has no set, -1 is returned.

Definition at line 461 of file Const.h.

461{ return m_index; }
int m_index
index in the associated set, -1 if there's no set.
Definition: Const.h:489

◆ getMass()

double getMass ( ) const
inherited

Particle mass.

Returns
The mass of the particle.

Definition at line 356 of file UnitConst.cc.

357{
358 return getParticlePDG()->Mass();
359}

◆ getParticlePDG()

const TParticlePDG * getParticlePDG ( ) const
inherited

Accessor for ROOT TParticlePDG object.

Returns
The TParticlePDG object for this type of particle.

Definition at line 351 of file UnitConst.cc.

352{
353 return EvtGenDatabasePDG::Instance()->GetParticle(m_pdgCode);
354}
int m_pdgCode
PDG code of the particle.
Definition: Const.h:487
static EvtGenDatabasePDG * Instance()
Instance method that loads the EvtGen table.

◆ getPDGCode()

int getPDGCode ( ) const
inlineinherited

PDG code.

Returns
The PDG code of the particle.

Definition at line 473 of file Const.h.

473{return m_pdgCode;};

◆ operator ParticleSet()

operator ParticleSet ( ) const
inlineinherited

Conversion of ParticleType to ParticleSet.

Definition at line 455 of file Const.h.

455{ ParticleSet s; s.add(*this); return s; }

◆ operator!=()

bool operator!= ( const ParticleType o) const
inlineinherited

Test inequality.

Definition at line 435 of file Const.h.

435{ return !((*this) == o); }

◆ operator*()

ParticleType & operator* ( )
inlineinherited

dummy dereferencing for range-based for.

Definition at line 438 of file Const.h.

438{ return *this; }

◆ operator++() [1/2]

Const::ParticleType & operator++ ( )
inherited

Prefix increment.

Incrementing past the last element of a set will return an invalid particle.

Definition at line 333 of file UnitConst.cc.

334{
335 if (!m_set) {
336 *this = invalidParticle;
337 } else {
339 }
340
341 return *this;
342}
const ParticleType & at(unsigned int index) const
Return particle at given index, or end() if out of range.
Definition: Const.h:549
int getPDGCode() const
PDG code.
Definition: Const.h:473
const ParticleSet * m_set
set this particle belongs to, or NULL if stand-alone.
Definition: Const.h:488

◆ operator++() [2/2]

Const::ParticleType operator++ ( int  )
inherited

Postfix increment.

Incrementing past the last element of a set will yield an invalid particle.

Definition at line 344 of file UnitConst.cc.

345{
346 Const::ParticleType p = *this;
347 ++(*this);
348 return p;
349}
The ParticleType class for identifying different particle types.
Definition: Const.h:408

◆ operator<()

bool operator< ( const ParticleType other) const
inherited

Comparison operator to be usable in sets.

Parameters
otherthe type of the other particle for the comparison.

Definition at line 328 of file UnitConst.cc.

329{
330 return m_pdgCode < other.m_pdgCode;
331}

◆ operator==()

bool operator== ( const ParticleType o) const
inlineinherited

Test equality.

Definition at line 432 of file Const.h.

432{ return m_pdgCode == o.m_pdgCode; }

Member Data Documentation

◆ c_SetSize

const unsigned int c_SetSize = 6
static

Number of elements (for use in array bounds etc.)

Definition at line 652 of file Const.h.

◆ m_index

int m_index
privateinherited

index in the associated set, -1 if there's no set.

Definition at line 489 of file Const.h.

◆ m_pdgCode

int m_pdgCode
privateinherited

PDG code of the particle.

Definition at line 487 of file Const.h.

◆ m_set

const ParticleSet* m_set
privateinherited

set this particle belongs to, or NULL if stand-alone.

Definition at line 488 of file Const.h.


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