Belle II Software  release-08-01-10
ParticleSubset.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 #pragma once
9 
10 #include <framework/datastore/SelectSubset.h>
11 #include <analysis/dataobjects/Particle.h>
12 
13 namespace Belle2 {
22  class ParticleSubset : public SelectSubset<Particle> {
23  public:
28  void removeParticlesNotInLists(const std::vector<std::string>& listNames);
29 
31  void select(std::function<bool (const Particle*)> f)
32  {
33  const std::map<int, int>& oldToNewMap = copySetWithRelations(f);
34 
35  if (m_inheritToSelf) {
37  }
38 
39  if (m_reduceExistingSet) {
41  }
42 
43  fixParticles(oldToNewMap);
44 
45  fixParticleLists(oldToNewMap);
46  }
47 
48  protected:
50  void fixParticles(const std::map<int, int>& oldToNewMap);
51 
53  void fixParticleLists(const std::map<int, int>& oldToNewMap);
54 
56  static void fixVector(std::vector<int>& vec, const std::map<int, int>& oldToNewMap);
57 
58  };
60 }
Specialised SelectSubset<Particle> that also fixes daughter indices and all ParticleLists.
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 th...
void select(std::function< bool(const Particle *)> f)
select Particles for which f returns true, discard others
static void fixVector(std::vector< int > &vec, const std::map< int, int > &oldToNewMap)
replace entries in vec via oldToNewMap, removing those not found.
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.
Class to store reconstructed particles.
Definition: Particle.h:75
bool m_inheritToSelf
If true, relations from set objects to set objects are copied.
Definition: SelectSubset.h:58
bool m_reduceExistingSet
If true, non-selected candidates are removed from m_set, m_subset only exists temporarily.
Definition: SelectSubset.h:60
void swapSetsAndDestroyOriginal()
Swap set and subset (+relations), and keep only the reduced set.
Definition: SelectSubset.cc:14
Class to create a subset of a given StoreArray together with the relations with other StoreArrays.
Definition: SelectSubset.h:193
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.
Definition: SelectSubset.h:351
void copyRelationsToSelf()
Copy any set -> set relations between selected objects.
Definition: SelectSubset.h:390
Abstract base class for different kinds of events.