9#include <analysis/ParticleCombiner/ParticleCombiner.h>
11#include <analysis/DecayDescriptor/DecayDescriptor.h>
12#include <analysis/DecayDescriptor/DecayDescriptorParticle.h>
14#include <framework/logging/Logger.h>
16#include <mdst/dataobjects/ECLCluster.h>
18#include <Math/Vector4D.h>
98 m_types[i] = useSelfConjugatedDaughterList ? ParticleList::c_SelfConjugatedParticle : ParticleList::c_FlavorSpecificParticle;
116 bool valid = decaydescriptor.
init(decayString);
118 B2ERROR(
"Invalid input DecayString: " << decayString);
139 int daughterProperty = daughter->getProperty();
173 bool valid = decaydescriptor.
isInitOK();
175 B2ERROR(
"Given decaydescriptor failed to initialized");
194 int daughterProperty = daughter->getProperty();
241 unsigned inputParticlesCount = 0;
243 inputParticlesCount +=
m_plists[i]->getListSize();
253 bool sameSign = (listA->getPDGCode() == listB->getPDGCode());
265 listB->getList(ParticleList::c_FlavorSpecificParticle,
false), uniqueID);
267 listB->getList(ParticleList::c_FlavorSpecificParticle,
true), uniqueID);
270 listB->getList(ParticleList::c_FlavorSpecificParticle,
true), uniqueID);
272 listB->getList(ParticleList::c_FlavorSpecificParticle,
false), uniqueID);
276 listB->getList(ParticleList::c_SelfConjugatedParticle), uniqueID);
293 for (
int i : listA) {
296 if (not aIsAlreadyIn)
299 for (
int j : listB) {
308 copies = B->isCopyOf(A);
319 for (
int i : listA) {
322 if (not aIsAlreadyIn)
331 bool loadedNext =
false;
349 if (loadedNext)
return true;
355 sizes[i] =
m_plists[i]->getList(ParticleList::c_SelfConjugatedParticle,
false).size();
376 const auto& list =
m_plists[i]->getList(m_types[i], m_types[i] == ParticleList::c_FlavorSpecificParticle ? useAntiParticle :
false);
399 sizes[i] =
m_plists[i]->getList(m_types[i], m_types[i] == ParticleList::c_FlavorSpecificParticle ? useAntiParticle :
false).size();
419 m_indices[i] =
m_plists[i]->getList(ParticleList::c_SelfConjugatedParticle,
false) [ indices[i] ];
453 const ROOT::Math::PxPyPzEVector vec(px, py, pz,
E);
465 default: B2FATAL(
"You called getCurrentParticle although loadNext should have returned false!");
479 static std::vector<int> sources;
483 while (!stack.empty()) {
486 const std::vector<int>& daughters = p->getDaughterIndices();
488 if (daughters.empty()) {
489 int source = p->getMdstSource();
490 for (
int i : sources) {
491 if (source == i)
return false;
493 sources.push_back(source);
495 for (
int daughter : daughters) stack.push_back(
m_particleArray[daughter]);
504 std::set<int> indexSet;
512 return elementInserted;
518 if (
pair == collidingList)
526 unsigned nECLSource = 0;
528 static std::vector<int> connectedregions;
529 static std::vector<ECLCluster::EHypothesisBit> hypotheses;
530 connectedregions.clear();
534 while (!stack.empty()) {
537 const std::vector<int>& daughters = p->getDaughterIndices();
539 if (daughters.empty()) {
552 if (p->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster) {
554 auto* cluster = p->getECLCluster();
555 connectedregions.push_back(cluster->getConnectedRegionId());
556 hypotheses.push_back(p->getECLClusterEHypothesisBit());
559 for (
int daughter : daughters) stack.push_back(
m_particleArray[daughter]);
565 if (nECLSource < 2)
return true;
568 for (
unsigned icr = 0; icr < connectedregions.size(); ++icr)
569 for (
unsigned jcr = icr + 1; jcr < connectedregions.size(); ++jcr)
570 if (connectedregions[icr] == connectedregions[jcr])
571 if (hypotheses[icr] != hypotheses[jcr])
return false;
Represents a particle in the DecayDescriptor.
int getPDGCode() const
Return PDG code.
int getProperty() const
return property of the particle.
std::string getLabel() const
The label of this particle, "default" returned, when no label set.
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
bool isSelfConjugated() const
Is the decay or the particle self conjugated.
const DecayDescriptor * getDaughter(int i) const
return i-th daughter (0 based index).
bool isInitOK() const
Check if the object initialized correctly.
int getNDaughters() const
return number of direct daughters.
int getProperty() const
return property of the particle.
const DecayDescriptorParticle * getMother() const
return mother.
static std::unique_ptr< GeneralCut > compile(const std::string &cut)
unsigned int m_iCombination
The current position of the combination.
unsigned int m_numberOfLists
Number of lists which are combined.
std::vector< ParticleList::EParticleType > m_types
The current types of sublist of the ParticleLists for this combination.
unsigned int m_nCombinations
The total amount of combinations.
ListIndexGenerator m_listIndexGenerator
Makes the combinations of the types of sublists of the ParticleLists.
unsigned int m_iParticleType
The type of particle which is currently generated.
bool inputListsCollide() const
True if input lists collide (can contain copies of particles in the input lists).
std::unordered_set< std::set< int > > m_usedCombinations
already used combinations (as sets of indices or unique IDs).
Particle m_current_particle
The current Particle object generated by this combiner.
unsigned int m_numberOfLists
Number of lists which are combined.
std::vector< Particle * > m_particles
Pointers to the particle objects of the current combination.
std::unordered_map< int, int > m_indicesToUniqueIDs
map of store array indices of input Particles to their unique IDs.
std::unique_ptr< Variable::Cut > m_cut
cut object which performs the cuts
const StoreArray< Particle > m_particleArray
Global list of particles.
std::vector< int > m_daughterProperties
Daughter's particle properties.
ParticleIndexGenerator m_particleIndexGenerator
Makes the combinations of indices stored in the sublists of the ParticleLists.
std::vector< StoreObjPtr< ParticleList > > m_plists
particle lists
int m_pdgCode
PDG Code of the particle which is combined.
int m_properties
Particle property.
bool m_inputListsCollide
True if the daughter lists can contain copies of Particles.
std::vector< int > m_indices
Indices stored in the ParticleLists of the current combination.
std::vector< std::pair< unsigned, unsigned > > m_collidingLists
pairs of lists that can contain copies.
bool m_isSelfConjugated
True if the combined particle is self-conjugated.
unsigned int m_iCombination
The current position of the combination.
unsigned int m_numberOfLists
Number of lists which are combined.
std::vector< unsigned int > indices
The indices of the current loaded combination.
std::vector< unsigned int > sizes
The sizes of the particle lists which are combined.
unsigned int m_nCombinations
The total amount of combinations.
Class to store reconstructed particles.
@ c_Unflavored
Is its own antiparticle or we don't know whether it is a particle/antiparticle.
@ c_Flavored
Is either particle or antiparticle.
Type-safe access to single objects in the data store.
void init()
Initialises the generator to produce the given type of sublist.
void fillIndicesToUniqueIDMap(const std::vector< int > &listA, const std::vector< int > &listB, int &uniqueID)
Assigns unique IDs to all particles in list A, which do not have the unique ID already assigned.
int getUniqueID(int index) const
Returns the unique ID assigned to Particle with given index from the IndicesToUniqueID map.
void init(const std::vector< unsigned int > &_sizes)
Initialises the generator to produce combinations with the given sizes of each particle list.
bool currentCombinationHasDifferentSources()
Check that all FS particles of a combination differ.
bool currentCombinationIsECLCRUnique()
Check that: if the current combination has at least two particles from an ECL source,...
const std::vector< unsigned int > & getCurrentIndices() const
Returns theindices of the current loaded combination.
bool loadNextSelfConjugatedParticle()
Loads the next combination.
bool currentCombinationIsUnique()
Check that the combination is unique.
bool loadNext(bool loadAntiParticle=true)
Loads the next combination.
void initIndicesToUniqueIDMap()
In the case input daughter particle lists collide (two or more lists contain copies of Particles) the...
const std::vector< ParticleList::EParticleType > & getCurrentIndices() const
Returns the type of the sublist of the current loaded combination.
Particle getCurrentParticle() const
Returns the particle.
ParticleGenerator(const std::string &decayString, const std::string &cutParameter="")
Initialises the generator to produce the given type of sublist.
void init(unsigned int _numberOfLists)
Initialises the generator to produce the given type of sublist.
Particle createCurrentParticle() const
Create current particle object.
bool loadNextParticle(bool useAntiParticle)
Loads the next combination.
bool loadNext()
Loads the next combination.
Abstract base class for different kinds of events.