Belle II Software development
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
15using namespace std;
16using namespace Belle2;
17
18
19REG_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.");
25
26 addParam("particleLists", m_particleLists, "Keep the Particles and their daughters in these ParticleLists.");
27}
28
30{
33
34 for (const auto& l : m_particleLists) {
36 }
37}
38
40{
41 const int nBefore = m_particles.getEntries();
42
44
45 const int nAfter = m_particles.getEntries();
46
47 m_nTotal += nBefore;
48 m_nRemoved += nBefore - nAfter;
49}
50
52{
53 double perc = double(m_nRemoved) / m_nTotal * 100.0;
54 B2INFO(getName() << ": removed " << m_nRemoved << " Particles (" << perc << " % of total amount).");
55}
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
const std::string & getName() const
Returns the name of the module.
Definition: Module.h:187
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
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...
virtual void initialize() override
Initialize the Module.
virtual void event() override
process event
StoreArray< Particle > m_particles
StoreArray of Particles.
virtual void terminate() override
Terminate the Module.
unsigned long m_nTotal
number of particles before removal.
ParticleSubset m_subset
reduces the Particles array.
std::vector< std::string > m_particleLists
keep Particles and daughters in these lists.
unsigned long m_nRemoved
number of particles removed.
void registerSubset(const StoreArray< StoredClass > &set, DataStore::EStoreFlags storeFlags=DataStore::c_ErrorIfAlreadyRegistered)
Remove all non-selected objects from set.
Definition: SelectSubset.h:215
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.
STL namespace.