Belle II Software development
|
Specialised SelectSubset<Particle> that also fixes daughter indices and all ParticleLists. More...
#include <ParticleSubset.h>
Public Member Functions | |
void | removeParticlesNotInLists (const std::vector< std::string > &listNames) |
Removes all Particles that are not in one of the given ParticleLists (or daughters of Particles in the lists). | |
void | select (std::function< bool(const Particle *)> f) |
select Particles for which f returns true, discard others | |
void | registerSubset (const StoreArray< Particle > &set, DataStore::EStoreFlags storeFlags=DataStore::c_ErrorIfAlreadyRegistered) |
Remove all non-selected objects from set. | |
void | registerSubset (const StoreArray< Particle > &set, const std::string &subsetName, DataStore::EStoreFlags storeFlags=DataStore::c_ErrorIfAlreadyRegistered) |
Register the StoreArray<StoredClass> that will contain the subset of selected elements. | |
void | inheritRelationsFrom (const StoreArray< T > &array, MoreArguments... moreArgs) |
Inherit relations pointing from Other to objects selected into this subset. | |
void | inheritRelationsTo (const StoreArray< T > &array, MoreArguments... moreArgs) |
Inherit relations pointing from objects selected into this subset to Other. | |
void | inheritAllRelations () |
Automatically inherit all relations to or from the original set (if registered when calling this function). | |
void | select (const std::function< bool(const Particle *)> &f) |
This method is the actual worker. | |
StoreAccessorBase * | getSet () override |
Get accessor for original set. | |
StoreAccessorBase * | getSubSet () override |
Get accessor for reduced set. | |
std::vector< std::string > | getInheritFromArrays () const |
Get list of arrays we inherit relations from. | |
std::vector< std::string > | getInheritToArrays () const |
Get list of arrays we inherit relations to. | |
bool | getInheritToSelf () const |
Do we inherit relations from original set to itself? | |
void | swapSetsAndDestroyOriginal () |
Swap set and subset (+relations), and keep only the reduced set. | |
Protected Member Functions | |
void | fixParticles (const std::map< int, int > &oldToNewMap) |
fix daughter indices, reset m_arrayPointer | |
void | fixParticleLists (const std::map< int, int > &oldToNewMap) |
fix contents of particlelists by updating indices or removing entries. | |
void | inheritRelationsFrom () |
Empty method to stop the recursion of the variadic template. | |
void | inheritRelationsTo () |
Empty method to stop the recursion of the variadic template. | |
std::map< int, int > | copySetWithRelations (std::function< bool(const Particle *)> f) |
Selects the elements, fill the subset and copies all the relations in which the set is involved. | |
void | copyRelationsToSelf () |
Copy any set -> set relations between selected objects. | |
Static Protected Member Functions | |
static void | fixVector (std::vector< int > &vec, const std::map< int, int > &oldToNewMap) |
replace entries in vec via oldToNewMap, removing those not found. | |
Protected Attributes | |
StoreArray< Particle > * | m_set |
The array we use as input. | |
StoreArray< Particle > * | m_subset |
The array we create. | |
DataStore::EStoreFlags | m_subsetFlags |
Flags used for m_subset. | |
std::vector< std::string > | m_inheritFromArrays |
array names we inherit relations from. | |
std::vector< std::string > | m_inheritToArrays |
array names we inherit relations to. | |
bool | m_inheritToSelf = false |
If true, relations from set objects to set objects are copied. | |
bool | m_reduceExistingSet = false |
If true, non-selected candidates are removed from m_set, m_subset only exists temporarily. | |
Specialised SelectSubset<Particle> that also fixes daughter indices and all ParticleLists.
Relations are already handled in SelectSubset.
Can be used like SelectSubset via select(), or by calling removeParticlesNotInLists() instead.
Definition at line 22 of file ParticleSubset.h.
|
protectedinherited |
Copy any set -> set relations between selected objects.
Definition at line 334 of file SelectSubset.h.
|
protectedinherited |
Selects the elements, fill the subset and copies all the relations in which the set is involved.
Definition at line 331 of file SelectSubset.h.
|
protected |
fix contents of particlelists by updating indices or removing entries.
Definition at line 69 of file ParticleSubset.cc.
|
protected |
fix daughter indices, reset m_arrayPointer
Definition at line 56 of file ParticleSubset.cc.
|
staticprotected |
replace entries in vec via oldToNewMap, removing those not found.
Definition at line 84 of file ParticleSubset.cc.
|
inlineinherited |
Get list of arrays we inherit relations from.
Definition at line 32 of file SelectSubset.h.
|
inlineinherited |
Get list of arrays we inherit relations to.
Definition at line 34 of file SelectSubset.h.
|
inlineinherited |
Do we inherit relations from original set to itself?
Definition at line 36 of file SelectSubset.h.
|
inlineoverridevirtualinherited |
Get accessor for original set.
Implements SelectSubsetBase.
Definition at line 325 of file SelectSubset.h.
|
inlineoverridevirtualinherited |
Get accessor for reduced set.
Implements SelectSubsetBase.
Definition at line 327 of file SelectSubset.h.
|
inlineinherited |
Automatically inherit all relations to or from the original set (if registered when calling this function).
Equivalent to calling inheritRelationsFrom()/To() for all related arrays.
Note: Do not combine with inheritRelationsFrom() and inheritRelationsTo().
Definition at line 301 of file SelectSubset.h.
|
inlineprotectedinherited |
Empty method to stop the recursion of the variadic template.
Definition at line 337 of file SelectSubset.h.
|
inlineinherited |
Inherit relations pointing from Other to objects selected into this subset.
You can specify an unlimited number of arrays as arguments to this function.
Definition at line 250 of file SelectSubset.h.
|
inlineprotectedinherited |
Empty method to stop the recursion of the variadic template.
Definition at line 339 of file SelectSubset.h.
|
inlineinherited |
Inherit relations pointing from objects selected into this subset to Other.
You can specify an unlimited number of arrays as arguments to this function.
Definition at line 275 of file SelectSubset.h.
|
inlineinherited |
Register the StoreArray<StoredClass> that will contain the subset of selected elements.
set | The StoreArray<StoredClass> from which the elements will be selected |
subsetName | The name of the StoreArray<StoredClass> that will contain the selected elements |
storeFlags | ORed combination of DataStore::EStoreFlags. |
Definition at line 229 of file SelectSubset.h.
|
inlineinherited |
Remove all non-selected objects from set.
All relations registered so far are retained. TODO: consider moving this into StoreArray itself
set | The StoreArray<StoredClass> from which to retain only selected elements |
storeFlags | flags used for temporary arrays and relations. Should be changed from the default if you want multiple instances. c_DontWriteOut is always used. |
Definition at line 215 of file SelectSubset.h.
void removeParticlesNotInLists | ( | const std::vector< std::string > & | listNames | ) |
Removes all Particles that are not in one of the given ParticleLists (or daughters of Particles in the lists).
Removal is done immediately, there is no need to call select() afterwards.
Definition at line 28 of file ParticleSubset.cc.
|
inherited |
This method is the actual worker.
It selects the elements, fill the subset and all the relations in which the subset is involved.
f | the pointer to the function (or a nameless lambda expression) returning true for the elements to be selected and false for the others. |
Definition at line 322 of file SelectSubset.h.
|
inline |
select Particles for which f returns true, discard others
Definition at line 31 of file ParticleSubset.h.
|
inherited |
Swap set and subset (+relations), and keep only the reduced set.
Subset and associated relations will be empty afterwards.
Definition at line 14 of file SelectSubset.cc.
|
protectedinherited |
array names we inherit relations from.
Definition at line 54 of file SelectSubset.h.
|
protectedinherited |
array names we inherit relations to.
Definition at line 56 of file SelectSubset.h.
|
protectedinherited |
If true, relations from set objects to set objects are copied.
(if both objects are selected!).
Definition at line 58 of file SelectSubset.h.
|
protectedinherited |
If true, non-selected candidates are removed from m_set, m_subset only exists temporarily.
Definition at line 60 of file SelectSubset.h.
|
protectedinherited |
The array we use as input.
Definition at line 342 of file SelectSubset.h.
|
protectedinherited |
The array we create.
Definition at line 344 of file SelectSubset.h.
|
protectedinherited |
Flags used for m_subset.
Definition at line 346 of file SelectSubset.h.