Belle II Software light-2406-ragdoll
ParticleCombiner.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <analysis/dataobjects/ParticleList.h>
12#include <analysis/dataobjects/Particle.h>
13#include <analysis/VariableManager/Utility.h>
14#include <analysis/DecayDescriptor/DecayDescriptor.h>
15
16#include <framework/datastore/StoreArray.h>
17#include <framework/datastore/StoreObjPtr.h>
18
19#include <vector>
20#include <set>
21#include <unordered_set>
22#include <unordered_map>
23
24#include <utility>
25
26#include <boost/functional/hash/extensions.hpp>
27
28namespace std {
30 template<> struct hash<std::set<int>> {
32 std::size_t operator()(const std::set<int>& v) const
33 {
34 return boost::hash_value(v);
35 }
36 };
37}
38
39namespace Belle2 {
50
51 public:
56
61 void init(const std::vector<unsigned int>& _sizes);
62
66 bool loadNext();
67
71 const std::vector<unsigned int>& getCurrentIndices() const;
72
73
74 private:
75
76 unsigned int m_numberOfLists;
77 unsigned int m_iCombination;
78 unsigned int m_nCombinations;
79 std::vector<unsigned int> indices;
80 std::vector<unsigned int> sizes;
82 };
83
92 public:
97
102 void init(unsigned int _numberOfLists);
103
107 bool loadNext();
108
112 const std::vector<ParticleList::EParticleType>& getCurrentIndices() const;
113
114 private:
115
116 unsigned int m_numberOfLists;
117 unsigned int m_iCombination;
118 unsigned int m_nCombinations;
119 std::vector<ParticleList::EParticleType> m_types;
121 };
122
127 public:
128
129 public:
135 explicit ParticleGenerator(const std::string& decayString, const std::string& cutParameter = "");
136
142 explicit ParticleGenerator(const DecayDescriptor& decaydescriptor, const std::string& cutParameter = "");
143
147 void init();
148
152 bool loadNext(bool loadAntiParticle = true);
153
158
166 bool inputListsCollide() const {return m_inputListsCollide; };
167
173 bool inputListsCollide(const std::pair<unsigned, unsigned>& pair) const;
174
182 int getUniqueID(int index) const;
183
184 private:
189
193 bool loadNextParticle(bool useAntiParticle);
194
199
209
224
233
241
247 void fillIndicesToUniqueIDMap(const std::vector<int>& listA, const std::vector<int>& listB, int& uniqueID);
248
252 void fillIndicesToUniqueIDMap(const std::vector<int>& listA, int& uniqueID);
253
254 private:
255
258 unsigned int m_iParticleType;
260 std::vector<int> m_daughterProperties;
262 unsigned int m_numberOfLists;
263 std::vector<StoreObjPtr<ParticleList>> m_plists;
271 std::vector<Particle*> m_particles;
272 std::vector<int> m_indices;
273 std::unordered_set<std::set<int>> m_usedCombinations;
276 std::vector<std::pair<unsigned, unsigned>> m_collidingLists;
277 std::unordered_map<int, int>
280 std::unique_ptr<Variable::Cut> m_cut;
283 };
284
285
287}
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
ListIndexGenerator is a generator for all the combinations of the sublists (FlavorSpecificParticle = ...
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.
ListIndexGenerator()
Default constructor.
unsigned int m_nCombinations
The total amount of combinations.
ParticleGenerator is a generator for all the particles combined from the given ParticleLists.
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.
ParticleIndexGenerator is a generator for all the combinations of the particle indices stored in the ...
unsigned int m_iCombination
The current position of the combination.
unsigned int m_numberOfLists
Number of lists which are combined.
ParticleIndexGenerator()
Default constructor.
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.
Definition: Particle.h:75
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
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.
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.
Definition: ClusterUtils.h:24
STL namespace.
std::size_t operator()(const std::set< int > &v) const
Actual work done by boost.