Belle II Software  release-06-00-14
RemoveParticlesNotInLists.cc
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 #include <analysis/modules/RemoveParticlesNotInLists/RemoveParticlesNotInLists.h>
10 #include <analysis/dataobjects/ParticleList.h>
11 
12 #include <framework/logging/Logger.h>
13 #include <framework/datastore/StoreObjPtr.h>
14 
15 using namespace std;
16 using namespace Belle2;
17 
18 
19 REG_MODULE(RemoveParticlesNotInLists)
20 
22 {
23  setDescription("Removes all Particles that are not in one of the given ParticleLists (or daughters of Particles in the lists). All relations from/to Particles, daughter indices, and other ParticleLists are fixed. Note that this does not currently touch any data used to create final state particles, which might make up a large fraction of the total file size.");
24  setPropertyFlags(c_ParallelProcessingCertified);
25 
26  addParam("particleLists", m_particleLists, "Keep the Particles and their daughters in these ParticleLists.");
27 }
28 
29 void RemoveParticlesNotInListsModule::initialize()
30 {
31  m_particles.isRequired();
32  m_subset.registerSubset(m_particles);
33 
34  for (const auto& l : m_particleLists) {
36  }
37 }
38 
39 void RemoveParticlesNotInListsModule::event()
40 {
41  const int nBefore = m_particles.getEntries();
42 
43  m_subset.removeParticlesNotInLists(m_particleLists);
44 
45  const int nAfter = m_particles.getEntries();
46 
47  m_nTotal += nBefore;
48  m_nRemoved += nBefore - nAfter;
49 }
50 
51 void RemoveParticlesNotInListsModule::terminate()
52 {
53  double perc = double(m_nRemoved) / m_nTotal * 100.0;
54  B2INFO(getName() << ": removed " << m_nRemoved << " Particles (" << perc << " % of total amount).");
55 }
Removes all Particles that are not in a given list of ParticleLists (or daughters of those).
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.