 |
Belle II Software
release-05-01-25
|
12 #include <analysis/ParticleCombiner/ParticleCombiner.h>
14 #include <analysis/DecayDescriptor/DecayDescriptor.h>
15 #include <analysis/DecayDescriptor/DecayDescriptorParticle.h>
17 #include <framework/logging/Logger.h>
19 #include <mdst/dataobjects/ECLCluster.h>
99 m_types[i] = useSelfConjugatedDaughterList ? ParticleList::c_SelfConjugatedParticle : ParticleList::c_FlavorSpecificParticle;
112 m_listIndexGenerator(),
113 m_particleIndexGenerator()
117 bool valid = decaydescriptor.
init(decayString);
119 B2ERROR(
"Invalid input DecayString: " << decayString);
125 m_pdgCode = mother->getPDGCode();
126 m_properties |= mother->getProperty();
136 m_plists.push_back(list);
138 int daughterProperty = daughter->getProperty();
139 m_daughterProperties.push_back(daughterProperty);
148 m_inputListsCollide =
false;
149 m_collidingLists.clear();
159 m_inputListsCollide =
true;
160 m_collidingLists.emplace_back(i, j);
169 m_listIndexGenerator(),
170 m_particleIndexGenerator()
172 bool valid = decaydescriptor.isInitOK();
174 B2ERROR(
"Given decaydescriptor failed to initialized");
193 int daughterProperty = daughter->getProperty();
240 unsigned inputParticlesCount = 0;
242 inputParticlesCount +=
m_plists[i]->getListSize();
252 bool sameSign = (listA->getPDGCode() == listB->getPDGCode());
264 listB->getList(ParticleList::c_FlavorSpecificParticle,
false), uniqueID);
266 listB->getList(ParticleList::c_FlavorSpecificParticle,
true), uniqueID);
269 listB->getList(ParticleList::c_FlavorSpecificParticle,
true), uniqueID);
271 listB->getList(ParticleList::c_FlavorSpecificParticle,
false), uniqueID);
275 listB->getList(ParticleList::c_SelfConjugatedParticle), uniqueID);
290 const Particle* A, *B;
292 for (
int i : listA) {
295 if (not aIsAlreadyIn)
298 for (
int j : listB) {
307 copies = B->isCopyOf(A);
318 for (
int i : listA) {
321 if (not aIsAlreadyIn)
330 bool loadedNext =
false;
348 if (loadedNext)
return true;
354 sizes[i] =
m_plists[i]->getList(ParticleList::c_SelfConjugatedParticle,
false).size();
375 const auto& list =
m_plists[i]->getList(m_types[i], m_types[i] == ParticleList::c_FlavorSpecificParticle ? useAntiParticle :
false);
398 sizes[i] =
m_plists[i]->getList(m_types[i], m_types[i] == ParticleList::c_FlavorSpecificParticle ? useAntiParticle :
false).size();
418 m_indices[i] =
m_plists[i]->getList(ParticleList::c_SelfConjugatedParticle,
false) [ indices[i] ];
453 const TLorentzVector 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;
std::vector< int > m_indices
Indices stored in the ParticleLists of the current combination.
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...
std::vector< unsigned int > indices
The indices of the current loaded combination.
ListIndexGenerator m_listIndexGenerator
listIndexGenerator makes the combinations of the types of sublists of the ParticleLists
void initIndicesToUniqueIDMap()
In the case input daughter particle lists collide (two or more lists contain copies of Particles) the...
void init()
Initialises the generator to produce the given type of sublist.
int getUniqueID(int index) const
Returns the unique ID assigned to Particle with given index from the IndicesToUniqueID map.
int m_pdgCode
PDG Code of the particle which is combined.
bool loadNextParticle(bool useAntiParticle)
Loads the next combination.
const std::vector< ParticleList::EParticleType > & getCurrentIndices() const
Returns the type of the sublist of the current loaded combination.
bool loadNext(bool loadAntiParticle=true)
Loads the next combination.
int getPDGCode() const
Return PDG code.
Represents a particle in the DecayDescriptor.
bool m_isSelfConjugated
True if the combined particle is self-conjugated.
const StoreArray< Particle > m_particleArray
Global list of particles.
std::unique_ptr< Variable::Cut > m_cut
cut object which performs the cuts
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
void fillIndicesToUniqueIDMap(const std::vector< int > &listA, const std::vector< int > &listB, int &uniqueID)
Assignes unique IDs to all particles in list A, which do not have the unique ID already assigned.
std::vector< std::pair< unsigned, unsigned > > m_collidingLists
pairs of lists that can contain copies.
std::vector< ParticleList::EParticleType > m_types
The current types of sublist of the ParticleLists for this combination.
unsigned int m_numberOfLists
Number of lists which are combined.
ParticleIndexGenerator m_particleIndexGenerator
particleIndexGenerator makes the combinations of indices stored in the sublists of the ParticleLists
bool inputListsCollide() const
True if input lists collide (can contain copies of particles in the input lists).
void init(const std::vector< unsigned int > &_sizes)
Initialises the generator to produce combinations with the given sizes of each particle list.
@ c_Flavored
Is either particle or antiparticle.
std::string getLabel() const
The label of this particle, "default" returned, when no label set.
std::vector< Particle * > m_particles
Pointers to the particle objects of the current combination.
bool currentCombinationHasDifferentSources()
Check that all FS particles of a combination differ.
ParticleGenerator(const std::string &decayString, const std::string &cutParameter="")
Initialises the generator to produce the given type of sublist.
Abstract base class for different kinds of events.
Type-safe access to single objects in the data store.
unsigned int m_numberOfLists
Number of lists which are combined.
std::unordered_map< int, int > m_indicesToUniqueIDs
map of store array indices of input Particles to their unique IDs.
Particle getCurrentParticle() const
Returns the particle.
bool loadNext()
Loads the next combination.
@ c_Unflavored
Is its own antiparticle or we don't know whether it is a particle/antiparticle.
unsigned int m_nCombinations
The total amount of combinations.
const DecayDescriptor * getDaughter(int i) const
return i-th daughter (0 based index).
std::vector< int > m_daughterProperties
Daughter's particle properties.
unsigned int m_iCombination
The current position of the combination.
unsigned int m_iParticleType
The type of particle which is currently generated.
int getNDaughters() const
return number of direct daughters.
unsigned int m_iCombination
The current position of the combination.
std::unordered_set< std::set< int > > m_usedCombinations
already used combinations (as sets of indices or unique IDs).
void init(unsigned int _numberOfLists)
Initialises the generator to produce the given type of sublist.
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
const std::vector< unsigned int > & getCurrentIndices() const
Returns theindices of the current loaded combination.
bool m_inputListsCollide
True if the daughter lists can contain copies of Particles.
Particle m_current_particle
The current Particle object generated by this combiner.
Class to store reconstructed particles.
std::vector< StoreObjPtr< ParticleList > > m_plists
particle lists
unsigned int m_nCombinations
The total amount of combinations.
bool currentCombinationIsECLCRUnique()
Check that: if the current combination has at least two particles from an ECL source,...
unsigned int m_numberOfLists
Number of lists which are combined.
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
bool currentCombinationIsUnique()
Check that the combination is unique.
int getProperty() const
return property of the particle.
std::vector< unsigned int > sizes
The sizes of the particle lists which are combined.
Particle createCurrentParticle() const
Create current particle object.
int m_properties
Particle property.
const DecayDescriptorParticle * getMother() const
return mother.
bool isSelfConjugated() const
Is the decay or the particle self conjugated.
bool loadNextSelfConjugatedParticle()
Loads the next combination.