Belle II Software  release-05-02-19
RemoveParticlesNotInLists.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Christian Pulvermacher *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <analysis/modules/RemoveParticlesNotInLists/RemoveParticlesNotInLists.h>
12 #include <analysis/dataobjects/ParticleList.h>
13 
14 #include <framework/logging/Logger.h>
15 #include <framework/datastore/StoreObjPtr.h>
16 
17 using namespace std;
18 using namespace Belle2;
19 
20 
21 REG_MODULE(RemoveParticlesNotInLists)
22 
24 {
25  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.");
26  setPropertyFlags(c_ParallelProcessingCertified);
27 
28  addParam("particleLists", m_particleLists, "Keep the Particles and their daughters in these ParticleLists.");
29 }
30 
31 void RemoveParticlesNotInListsModule::initialize()
32 {
33  StoreArray<Particle> particles;
34  particles.isRequired();
35  m_subset.registerSubset(particles);
36 
37  for (const auto& l : m_particleLists) {
38  StoreObjPtr<ParticleList>(l).isRequired();
39  }
40 }
41 
42 void RemoveParticlesNotInListsModule::event()
43 {
44  StoreArray<Particle> particles;
45  const int nBefore = particles.getEntries();
46 
47  m_subset.removeParticlesNotInLists(m_particleLists);
48 
49  const int nAfter = particles.getEntries();
50 
51  m_nTotal += nBefore;
52  m_nRemoved += nBefore - nAfter;
53 }
54 
55 void RemoveParticlesNotInListsModule::terminate()
56 {
57  double perc = double(m_nRemoved) / m_nTotal * 100.0;
58  B2INFO(getName() << ": removed " << m_nRemoved << " Particles (" << perc << " % of total amount).");
59 }
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::RemoveParticlesNotInListsModule
Removes all Particles that are not in a given list of ParticleLists (or daughters of those).
Definition: RemoveParticlesNotInLists.h:37
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::StoreArray< Particle >