Belle II Software light-2406-ragdoll
|
ParticleList is a container class that stores a collection of Particle objects. More...
#include <ParticleList.h>
Public Types | |
enum | EParticleType { c_FlavorSpecificParticle = 0 , c_SelfConjugatedParticle } |
Type of Particle (determines in which of the two internal lists the particle is stored). More... | |
typedef ArrayIterator< ParticleList, Particle > | iterator |
STL-like iterator over the particles (not Particle*). | |
typedef ArrayIterator< ParticleList, const Particle > | const_iterator |
STL-like const_iterator over the particles (not Particle*). | |
Public Member Functions | |
ParticleList () | |
Default constructor. | |
void | initialize (int pdg, const std::string &name, const std::string &particleStoreName="Particles") |
Sets the PDG code and name of this ParticleList. | |
void | bindAntiParticleList (ParticleList &antiList, bool includingAntiList=true) |
Binds particle and anti-particle ParticleLists. | |
void | setParticleCollectionName (const std::string &name, bool forAntiParticle=true) |
Sets Particle store array name to which particle list refers. | |
void | addParticle (const Particle *particle) |
Adds a new particle to the list (safe method) | |
void | addParticle (unsigned iparticle, int pdg, Particle::EFlavorType flavorType, bool includingAntiList=true) |
Adds a new particle to the list (almost safe method) | |
void | removeParticles (const std::vector< unsigned int > &toRemove, bool removeFromAntiList=true) |
Remove given elements from list. | |
void | clear (bool includingAntiList=true) |
Remove all elements from list, afterwards getListSize() will be 0. | |
std::string | getParticleCollectionName () const |
Returns Particle store array name to which particle list refers. | |
int | getPDGCode () const |
Returns PDG code. | |
int | getAntiParticlePDGCode () const |
Returns PDG code of anti-particle. | |
const std::vector< int > & | getList (EParticleType K, bool forAntiParticle=false) const |
Returns list of StoreArray<Particle> indices. | |
std::string | getAntiParticleListName () const |
Returns the name the anti-particle ParticleList. | |
std::string | getParticleListName () const |
Returns the name this ParticleList. | |
unsigned | getListSize (bool includingAntiList=true) const |
Returns total number of particles in this list and anti list if requested. | |
Particle * | getParticle (unsigned i, bool includingAntiList=true) const |
Returns i-th particle from the list and anti list if requested. | |
Particle * | getParticleWithMdstIdx (unsigned int mdstIdx, bool includingAntiList=true) const |
Returns the particle from the list matching the given mdst array index, if any is found. | |
unsigned | getNParticlesOfType (EParticleType K, bool forAntiParticle=false) const |
Returns the number of flavor-specific particles or self-conjugated particles in this list or its anti-particle list. | |
bool | contains (const Particle *p, bool includingAntiList=true) const |
Returns true if and only if 'p' is already in this list. | |
int | getIndex (const Particle *p, bool includingAntiList=true) const |
Returns index of the given particle 'p' in this list. | |
void | print () const |
Prints the list. | |
void | setEditable (bool editable, bool includingAntiList=true) |
Sets m_isReserved so that the reserved list can be edited. | |
bool | getIsReserved () const |
Returns m_isReserved. | |
std::string | getInfoHTML () const |
Return a short summary of this object's contents in HTML format. | |
iterator | begin () |
Return iterator to first entry. | |
iterator | end () |
Return iterator to last entry +1. | |
const_iterator | begin () const |
Return const_iterator to first entry. | |
const_iterator | end () const |
Return const_iterator to last entry +1. | |
Particle * | operator[] (int index) const |
Convenience function to get particle with index. | |
Private Member Functions | |
ParticleList & | getAntiParticleList () const |
Returns bound anti-particle list. | |
ClassDef (ParticleList, 4) | |
Class to hold a list of particles, anti-particles and self-conjugated particles. | |
Private Attributes | |
int | m_pdg |
PDG code of Particle. | |
int | m_pdgbar |
PDG code of antiparticle. | |
std::vector< int > | m_fsList |
list of 0-based indices of flavor-specific Particles (particles that have an anti-particle) | |
std::vector< int > | m_scList |
list of 0-based indices of self-conjugated Particles (particles that do not have an anti-particle) | |
std::string | m_particleStore |
name of Particle store array | |
std::string | m_thisListName |
name of this ParticleList | |
std::string | m_antiListName |
name of ParticleList for anti-particles | |
StoreObjPtr< ParticleList > * | m_antiList |
keep anti-list around for performance. | |
bool | m_isReserved = false |
transient | |
Friends | |
class | ParticleSubset |
ParticleList is a container class that stores a collection of Particle objects.
The particles are internally stored in two std::vector<int> holding the indices of particles in StoreArray<Particle>: o) flavor specific particles (particles that have an anti-particle, e.g. pi-, K-, D+, D0) o) self-conjugated particles (particles that do not have an anti-particle, e.g. pi0, phi, or particles that have an anti-particle but are reconstructed in self-conjugated decay mode, e.g. K*0 -> K0s pi0, or D0 -> K- K+, ...) ParticleList can store only particles with same PDG code (which however can be reconstructed in different decay modes).
Each ParticleList can and should be bound with its anti-ParticleList at the time of creation of the lists. This bond for example enables automatic reconstruction of charged conjugated decays in ParticleCombiner module for example.
The unique identifier of the ParticleList is its name. According to the naming convention the ParticleList's name has to be of the form:
listName = particle_name:label,
where particle_name is the name of the particle as given in the evt.pdl and the label can be any string indicating the selection criteria or decay mode (or anything else) used to reconstruct the particles. Examples are: o) pi+:loose - pi+ candidates passing loose PID requirements o) D0:kpi - D0 candidates reconstructed in D0->Kpi decays
Particles and their anti-particles are stored in their own ParticleLists. Creation and connection of particle and anti-particle lists is performed in the following way (example for K- and K+ lists):
The following rules apply: o) ParticleList can contain only particles with same absolute value of the PDG code (e.g. only charged kaons, neutral D mesons, ...) o) All particles have to be stored in the same StoreArray<Particle>
Example:
where particle is a pointer to a Particle object. Note, if one adds anti-particle to ParticleLists for particles the particle will be actually added to the ParticleList for anti-particles. The following two lines of code give same result
To loop over all particles (as well as their anti-particles) do the following
If you would like to loop over the particles stored in a particular ParticleList without including the anti-particles as well, do the following (set the boolean parameter in the relevant functions to false)
You can also use C++11 range-based for loops to loop over all particles (and anti-particles):
Definition at line 140 of file ParticleList.h.
typedef ArrayIterator<ParticleList, const Particle> const_iterator |
STL-like const_iterator over the particles (not Particle*).
Definition at line 146 of file ParticleList.h.
typedef ArrayIterator<ParticleList, Particle> iterator |
STL-like iterator over the particles (not Particle*).
Definition at line 144 of file ParticleList.h.
enum EParticleType |
Type of Particle (determines in which of the two internal lists the particle is stored).
Definition at line 149 of file ParticleList.h.
|
inline |
Default constructor.
Definition at line 157 of file ParticleList.h.
~ParticleList | ( | ) |
Definition at line 25 of file ParticleList.cc.
void addParticle | ( | const Particle * | particle | ) |
Adds a new particle to the list (safe method)
The method determines based on the particle's properties (PDGcode, flavorType) to which particular list this particle belongs (flavor-specific or self-conjugated particle or anti-particle list)
particle | pointer to particle in the StoreArray<Particle> |
Definition at line 52 of file ParticleList.cc.
void addParticle | ( | unsigned | iparticle, |
int | pdg, | ||
Particle::EFlavorType | flavorType, | ||
bool | includingAntiList = true |
||
) |
Adds a new particle to the list (almost safe method)
iparticle | index of the particle in the StoreArray<Particle> |
pdg | particle PDG code |
flavorType | particle flavor type |
includingAntiList | include anti-particle list? |
Definition at line 86 of file ParticleList.cc.
|
inline |
Return iterator to first entry.
Definition at line 353 of file ParticleList.h.
|
inline |
Return const_iterator to first entry.
Definition at line 358 of file ParticleList.h.
void bindAntiParticleList | ( | ParticleList & | antiList, |
bool | includingAntiList = true |
||
) |
Binds particle and anti-particle ParticleLists.
After the lists are bound any action performed on ParticleList for particles will be performed by default also on ParticleList for anti-particles.
antiList | - anti-particle ParticleList of this ParticleList |
includingAntiList | - the "anti"-anti-particle list has to be set also for the anti-particle list |
Definition at line 74 of file ParticleList.cc.
void clear | ( | bool | includingAntiList = true | ) |
Remove all elements from list, afterwards getListSize() will be 0.
Definition at line 158 of file ParticleList.cc.
bool contains | ( | const Particle * | p, |
bool | includingAntiList = true |
||
) | const |
Returns true if and only if 'p' is already in this list.
Will check flavour-specific and self-conjugated list, and optionally (with includingAntiList=true) also the anti-particle list.
Definition at line 236 of file ParticleList.cc.
|
inline |
Return iterator to last entry +1.
Definition at line 355 of file ParticleList.h.
|
inline |
|
private |
Returns bound anti-particle list.
Aborts if no list is present (might occur with I/O problems). Please check m_antiListName is not empty() before calling this.
Definition at line 295 of file ParticleList.cc.
|
inline |
|
inline |
int getIndex | ( | const Particle * | p, |
bool | includingAntiList = true |
||
) | const |
Returns index of the given particle 'p' in this list.
If 'p' is not in this list, return -1. Will check flavour-specific and self-conjugated list, and optionally (with includingAntiList=true) also the anti-particle list.
Definition at line 250 of file ParticleList.cc.
std::string getInfoHTML | ( | ) | const |
Return a short summary of this object's contents in HTML format.
Definition at line 278 of file ParticleList.cc.
|
inline |
const std::vector< int > & getList | ( | EParticleType | K, |
bool | forAntiParticle = false |
||
) | const |
Returns list of StoreArray<Particle> indices.
Possible options are:
o) getList(ParticleList::c_FlavorSpecificParticle)
o) getList(ParticleList::c_SelfConjugatedParticle)
o) getList(ParticleList::c_FlavorSpecificParticle, true)
o) getList(ParticleList::c_SelfConjugatedParticle, true)
K | ParticleType - Particle, SelfConjugatedParticle |
forAntiParticle | - whether the Particle or SelfConjugatedParticle should be returned for this (false) or anti-particle list (true) |
Definition at line 220 of file ParticleList.cc.
unsigned getListSize | ( | bool | includingAntiList = true | ) | const |
Returns total number of particles in this list and anti list if requested.
includingAntiList |
Definition at line 203 of file ParticleList.cc.
|
inline |
Returns the number of flavor-specific particles or self-conjugated particles in this list or its anti-particle list.
K | ParticleType - Particle or SelfConjugatedParticle |
forAntiParticle | - whether the Particle or SelfConjugatedParticle should be returned for this (false) or anti-particle list (true) |
Definition at line 310 of file ParticleList.h.
Particle * getParticle | ( | unsigned | i, |
bool | includingAntiList = true |
||
) | const |
Returns i-th particle from the list and anti list if requested.
i | list index (i < getListSize()) |
includingAntiList | consider anti-particle list as well? |
Definition at line 172 of file ParticleList.cc.
|
inline |
Returns Particle store array name to which particle list refers.
Definition at line 234 of file ParticleList.h.
|
inline |
Particle * getParticleWithMdstIdx | ( | unsigned int | mdstIdx, |
bool | includingAntiList = true |
||
) | const |
Returns the particle from the list matching the given mdst array index, if any is found.
mdstIdx | mdst array index |
includingAntiList | consider anti-particle list as well? |
Definition at line 189 of file ParticleList.cc.
|
inline |
void initialize | ( | int | pdg, |
const std::string & | name, | ||
const std::string & | particleStoreName = "Particles" |
||
) |
Sets the PDG code and name of this ParticleList.
At this point it is assumed that this is self-conjugated list (PDG code = anti-PDG code). To bind the particle and anti-particle ParticleLists use bindAntiParticleList(ParticleList &antiList) method.
pdg | PDG code of particles to be hold in this list |
name | of the particle list |
particleStoreName | name of the Particle StoreArray |
Definition at line 30 of file ParticleList.cc.
|
inline |
void print | ( | ) | const |
Prints the list.
Definition at line 273 of file ParticleList.cc.
void removeParticles | ( | const std::vector< unsigned int > & | toRemove, |
bool | removeFromAntiList = true |
||
) |
Remove given elements from list.
toRemove | vector of Particle array indices to be removed |
removeFromAntiList | flag indicating whether to remove particle also from anti-particle list (default is true) |
Definition at line 131 of file ParticleList.cc.
|
inline |
Sets m_isReserved so that the reserved list can be edited.
Definition at line 336 of file ParticleList.h.
void setParticleCollectionName | ( | const std::string & | name, |
bool | forAntiParticle = true |
||
) |
Sets Particle store array name to which particle list refers.
By default this parameter is set to "Particles".
name | name of the Particle store array |
forAntiParticle | if true the name is set also for the anti-particle list |
Definition at line 44 of file ParticleList.cc.
|
friend |
Definition at line 391 of file ParticleList.h.
|
mutableprivate |
keep anti-list around for performance.
Definition at line 385 of file ParticleList.h.
|
private |
name of ParticleList for anti-particles
Definition at line 382 of file ParticleList.h.
|
private |
list of 0-based indices of flavor-specific Particles (particles that have an anti-particle)
Definition at line 375 of file ParticleList.h.
|
private |
|
private |
name of Particle store array
Definition at line 379 of file ParticleList.h.
|
private |
PDG code of Particle.
Definition at line 373 of file ParticleList.h.
|
private |
PDG code of antiparticle.
Definition at line 374 of file ParticleList.h.
|
private |
list of 0-based indices of self-conjugated Particles (particles that do not have an anti-particle)
Definition at line 377 of file ParticleList.h.
|
private |
name of this ParticleList
Definition at line 381 of file ParticleList.h.