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;
111 m_listIndexGenerator(),
112 m_particleIndexGenerator()
116 bool valid = decaydescriptor.
init(decayString);
118 B2ERROR(
"Invalid input DecayString: " << decayString);
137 int daughterProperty = daughter->getProperty();
168 m_listIndexGenerator(),
169 m_particleIndexGenerator()
171 bool valid = decaydescriptor.
isInitOK();
173 B2ERROR(
"Given decaydescriptor failed to initialized");
192 int daughterProperty = daughter->getProperty();
239 unsigned inputParticlesCount = 0;
241 inputParticlesCount +=
m_plists[i]->getListSize();
251 bool sameSign = (listA->getPDGCode() == listB->getPDGCode());
263 listB->getList(ParticleList::c_FlavorSpecificParticle,
false), uniqueID);
265 listB->getList(ParticleList::c_FlavorSpecificParticle,
true), uniqueID);
268 listB->getList(ParticleList::c_FlavorSpecificParticle,
true), uniqueID);
270 listB->getList(ParticleList::c_FlavorSpecificParticle,
false), uniqueID);
274 listB->getList(ParticleList::c_SelfConjugatedParticle), uniqueID);
291 for (
int i : listA) {
294 if (not aIsAlreadyIn)
297 for (
int j : listB) {
306 copies = B->isCopyOf(A);
317 for (
int i : listA) {
320 if (not aIsAlreadyIn)
329 bool loadedNext =
false;
347 if (loadedNext)
return true;
353 sizes[i] =
m_plists[i]->getList(ParticleList::c_SelfConjugatedParticle,
false).size();
374 const auto& list =
m_plists[i]->getList(m_types[i], m_types[i] == ParticleList::c_FlavorSpecificParticle ? useAntiParticle :
false);
397 sizes[i] =
m_plists[i]->getList(m_types[i], m_types[i] == ParticleList::c_FlavorSpecificParticle ? useAntiParticle :
false).size();
417 m_indices[i] =
m_plists[i]->getList(ParticleList::c_SelfConjugatedParticle,
false) [ indices[i] ];
451 const ROOT::Math::PxPyPzEVector vec(px, py, pz,
E);
463 default: B2FATAL(
"You called getCurrentParticle although loadNext should have returned false!");
477 static std::vector<int> sources;
481 while (!stack.empty()) {
484 const std::vector<int>& daughters = p->getDaughterIndices();
486 if (daughters.empty()) {
487 int source = p->getMdstSource();
488 for (
int i : sources) {
489 if (source == i)
return false;
491 sources.push_back(source);
493 for (
int daughter : daughters) stack.push_back(
m_particleArray[daughter]);
502 std::set<int> indexSet;
510 return elementInserted;
516 if (pair == collidingList)
524 unsigned nECLSource = 0;
526 static std::vector<int> connectedregions;
527 static std::vector<ECLCluster::EHypothesisBit> hypotheses;
528 connectedregions.clear();
532 while (!stack.empty()) {
535 const std::vector<int>& daughters = p->getDaughterIndices();
537 if (daughters.empty()) {
550 if (p->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster) {
552 auto* cluster = p->getECLCluster();
553 connectedregions.push_back(cluster->getConnectedRegionId());
554 hypotheses.push_back(p->getECLClusterEHypothesisBit());
557 for (
int daughter : daughters) stack.push_back(
m_particleArray[daughter]);
563 if (nECLSource < 2)
return true;
566 for (
unsigned icr = 0; icr < connectedregions.size(); ++icr)
567 for (
unsigned jcr = icr + 1; jcr < connectedregions.size(); ++jcr)
568 if (connectedregions[icr] == connectedregions[jcr])
569 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)
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.
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
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.