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>
96 m_types[i] = useSelfConjugatedDaughterList ? ParticleList::c_SelfConjugatedParticle : ParticleList::c_FlavorSpecificParticle;
109 m_listIndexGenerator(),
110 m_particleIndexGenerator()
114 bool valid = decaydescriptor.
init(decayString);
116 B2ERROR(
"Invalid input DecayString: " << decayString);
135 int daughterProperty = daughter->getProperty();
166 m_listIndexGenerator(),
167 m_particleIndexGenerator()
169 bool valid = decaydescriptor.
isInitOK();
171 B2ERROR(
"Given decaydescriptor failed to initialized");
190 int daughterProperty = daughter->getProperty();
237 unsigned inputParticlesCount = 0;
239 inputParticlesCount +=
m_plists[i]->getListSize();
249 bool sameSign = (listA->getPDGCode() == listB->getPDGCode());
261 listB->getList(ParticleList::c_FlavorSpecificParticle,
false), uniqueID);
263 listB->getList(ParticleList::c_FlavorSpecificParticle,
true), uniqueID);
266 listB->getList(ParticleList::c_FlavorSpecificParticle,
true), uniqueID);
268 listB->getList(ParticleList::c_FlavorSpecificParticle,
false), uniqueID);
272 listB->getList(ParticleList::c_SelfConjugatedParticle), uniqueID);
289 for (
int i : listA) {
292 if (not aIsAlreadyIn)
295 for (
int j : listB) {
304 copies = B->isCopyOf(A);
315 for (
int i : listA) {
318 if (not aIsAlreadyIn)
327 bool loadedNext =
false;
345 if (loadedNext)
return true;
351 sizes[i] =
m_plists[i]->getList(ParticleList::c_SelfConjugatedParticle,
false).size();
372 const auto& list =
m_plists[i]->getList(m_types[i], m_types[i] == ParticleList::c_FlavorSpecificParticle ? useAntiParticle :
false);
395 sizes[i] =
m_plists[i]->getList(m_types[i], m_types[i] == ParticleList::c_FlavorSpecificParticle ? useAntiParticle :
false).size();
415 m_indices[i] =
m_plists[i]->getList(ParticleList::c_SelfConjugatedParticle,
false) [ indices[i] ];
450 const TLorentzVector vec(px, py, pz, E);
462 default: B2FATAL(
"You called getCurrentParticle although loadNext should have returned false!");
476 static std::vector<int> sources;
480 while (!stack.empty()) {
483 const std::vector<int>& daughters = p->getDaughterIndices();
485 if (daughters.empty()) {
486 int source = p->getMdstSource();
487 for (
int i : sources) {
488 if (source == i)
return false;
490 sources.push_back(source);
492 for (
int daughter : daughters) stack.push_back(
m_particleArray[daughter]);
501 std::set<int> indexSet;
509 return elementInserted;
515 if (pair == collidingList)
523 unsigned nECLSource = 0;
525 static std::vector<int> connectedregions;
526 static std::vector<ECLCluster::EHypothesisBit> hypotheses;
527 connectedregions.clear();
531 while (!stack.empty()) {
534 const std::vector<int>& daughters = p->getDaughterIndices();
536 if (daughters.empty()) {
549 if (p->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster) {
551 auto* cluster = p->getECLCluster();
552 connectedregions.push_back(cluster->getConnectedRegionId());
553 hypotheses.push_back(p->getECLClusterEHypothesisBit());
556 for (
int daughter : daughters) stack.push_back(
m_particleArray[daughter]);
562 if (nECLSource < 2)
return true;
565 for (
unsigned icr = 0; icr < connectedregions.size(); ++icr)
566 for (
unsigned jcr = icr + 1; jcr < connectedregions.size(); ++jcr)
567 if (connectedregions[icr] == connectedregions[jcr])
568 if (hypotheses[icr] != hypotheses[jcr])
return false;
Represents a particle in the DecayDescriptor.
int getPDGCode() const
Return PDG code.
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 DecayDescriptorParticle * getMother() const
return mother.
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 DecayDescriptor * getDaughter(int i) const
return i-th daughter (0 based index).
static std::unique_ptr< GeneralCut > compile(const std::string &cut)
Creates an instance of a cut and returns a unique_ptr to it, if you need a copy-able object instead y...
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
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
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.