9#include <analysis/dataobjects/ParticleList.h>
12#include <framework/datastore/StoreArray.h>
13#include <framework/datastore/StoreObjPtr.h>
16#include <framework/logging/Logger.h>
17#include <framework/utilities/HTML.h>
25ParticleList::~ParticleList()
55 B2FATAL(
"ParticleList::addParticle The ParticleList " <<
m_thisListName <<
56 " is reserved and forbidden to be manipulated.");
59 B2ERROR(
"ParticleList::addParticle particle is from different store array, not added");
65 B2ERROR(
"ParticleList::addParticle particle is not in a store array, not added");
80 B2ERROR(
"ParticleList::bindAntiParticleList invalid (inconsistent) PDG codes!");
82 if (includingAntiList)
89 B2FATAL(
"ParticleList::addParticle The ParticleList " <<
m_thisListName <<
90 " is reserved and forbidden to be manipulated.");
93 B2ERROR(
"ParticleList::addParticle PDG codes do not match, not added");
105 B2WARNING(
"ParticleList::addParticle Trying to add Particle with index=" << iparticle
106 <<
" to the ParticleList=" <<
m_thisListName <<
" that is already included!");
114 unsigned antiParticle = (pdg ==
getPDGCode()) ? 0 : 1;
122 B2WARNING(
"ParticleList::addParticle Trying to add Particle with index=" << iparticle
123 <<
" to the ParticleList=" <<
m_thisListName <<
"that is already included! Particle not added");
127 B2ERROR(
"ParticleList::addParticle invalid flavor type, not added");
134 B2FATAL(
"ParticleList::removeParticles The ParticleList " <<
m_thisListName <<
135 " is reserved and forbidden to be manipulated.");
137 std::vector<int> newList;
140 if (std::find(toRemove.begin(), toRemove.end(), i) == toRemove.end())
141 newList.push_back(i);
148 if (std::find(toRemove.begin(), toRemove.end(), i) == toRemove.end())
149 newList.push_back(i);
161 B2FATAL(
"ParticleList::clear The ParticleList " <<
m_thisListName <<
162 " is reserved and forbidden to be manipulated.");
191 const unsigned int n = this->
getListSize(includingAntiList);
192 for (
unsigned i = 0; i < n; i++) {
194 auto particle = this->
getParticle(i, includingAntiList);
196 if (particle->getMdstArrayIndex() == mdstIdx) {
212 if (includingAntiList) {
222 if (!forAntiParticle) {
223 if (K == c_FlavorSpecificParticle)
228 const static std::vector<int> emptyList;
238 const int index = p->getArrayIndex();
239 for (
int i = 0; i < 3; i++) {
240 if (i == 1 && !includingAntiList)
243 const std::vector<int>& currentList =
getList((i < 2) ? c_FlavorSpecificParticle : c_SelfConjugatedParticle, i == 1);
244 if (std::find(currentList.begin(), currentList.end(), index) != currentList.end())
252 const int index = p->getArrayIndex();
256 return std::distance(
m_fsList.begin(), it_fs);
280 std::stringstream stream;
287 stream <<
" ParticleLists: " <<
m_thisListName <<
" (" << thisFSCount <<
"+" << thisSCCount <<
")"
288 <<
" + " <<
m_antiListName <<
" (" << antiFSCount <<
"+" << antiSCCount <<
")";
290 stream <<
" ParticleList : " <<
m_thisListName <<
" (" << thisFSCount <<
"+" << thisSCCount <<
")";
301 " not found, even though one was set via bindAntiParticleList(). Maybe you only saved one list into a .root file?");
The ParticleType class for identifying different particle types.
static const ParticleSet finalStateParticlesSet
set of final set particles that can be created by the ParticleLoader
ParticleList is a container class that stores a collection of Particle objects.
void bindAntiParticleList(ParticleList &antiList, bool includingAntiList=true)
Binds particle and anti-particle ParticleLists.
int getPDGCode() const
Returns PDG code.
std::string m_antiListName
name of ParticleList for anti-particles
Particle * getParticle(unsigned i, bool includingAntiList=true) const
Returns i-th particle from the list and anti list if requested.
void addParticle(const Particle *particle)
Adds a new particle to the list (safe method)
bool m_isReserved
transient
bool contains(const Particle *p, bool includingAntiList=true) const
Returns true if and only if 'p' is already in this list.
const std::vector< int > & getList(EParticleType K, bool forAntiParticle=false) const
Returns list of StoreArray<Particle> indices.
ParticleList & getAntiParticleList() const
Returns bound anti-particle list.
unsigned getListSize(bool includingAntiList=true) const
Returns total number of particles in this list and anti list if requested.
void setParticleCollectionName(const std::string &name, bool forAntiParticle=true)
Sets Particle store array name to which particle list refers.
int m_pdg
PDG code of Particle.
std::string m_particleStore
name of Particle store array
int getIndex(const Particle *p, bool includingAntiList=true) const
Returns index of the given particle 'p' in this list.
std::string m_thisListName
name of this ParticleList
void clear(bool includingAntiList=true)
Remove all elements from list, afterwards getListSize() will be 0.
StoreObjPtr< ParticleList > * m_antiList
keep anti-list around for performance.
std::vector< int > m_fsList
list of 0-based indices of flavor-specific Particles (particles that have an anti-particle)
std::string getParticleListName() const
Returns the name this ParticleList.
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...
int m_pdgbar
PDG code of antiparticle.
EParticleType
Type of Particle (determines in which of the two internal lists the particle is stored).
void print() const
Prints the list.
std::string getInfoHTML() const
Return a short summary of this object's contents in HTML format.
std::vector< int > m_scList
list of 0-based indices of self-conjugated Particles (particles that do not have an anti-particle)
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.
void initialize(int pdg, const std::string &name, const std::string &particleStoreName="Particles")
Sets the PDG code and name of this ParticleList.
void removeParticles(const std::vector< unsigned int > &toRemove, bool removeFromAntiList=true)
Remove given elements from list.
Class to store reconstructed particles.
EFlavorType getFlavorType() const
Returns flavor type of the decay (for FS particles: flavor type of particle)
int getPDGCode(void) const
Returns PDG code.
EFlavorType
describes flavor type, see getFlavorType().
@ c_Unflavored
Is its own antiparticle or we don't know whether it is a particle/antiparticle.
@ c_Flavored
Is either particle or antiparticle.
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
std::string escape(const std::string &str)
Convert &, <, > etc.
std::string htmlToPlainText(const std::string &html)
Reformat given HTML string into terminal-friendly plain text.
Abstract base class for different kinds of events.