Belle II Software development
SkimFilterModule.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/SkimFilter/SkimFilterModule.h>
10#include <analysis/dataobjects/ParticleList.h>
11#include <framework/core/Environment.h>
12#include <framework/datastore/StoreObjPtr.h>
13
14#include <TString.h>
15
16using namespace Belle2;
17
18// Register module in the framework
19REG_MODULE(SkimFilter);
20
22{
23 //Set module properties
24 setDescription("Filter based on ParticleLists, by setting return value to true if at least one of the given lists is not empty.");
26 //Parameter definition
27 addParam("particleLists", m_strParticleLists, "List of ParticleLists",
28 std::vector<std::string>());
29
30 // initializing the rest of private members
31 m_nPass = 0;
32}
33
35{
36
37 int nParticleLists = m_strParticleLists.size();
38 B2INFO("Number of ParticleLists studied " << nParticleLists << " ");
39
40 m_nPass = 0;
41}
42
44{
45
47
48 // number of ParticleLists
49 int nParticleLists = m_strParticleLists.size();
50 bool pass = false;
51 for (int iList = 0; iList < nParticleLists; ++iList) {
52
54 if (!particlelist) {
55 B2INFO("ParticleList " << m_strParticleLists[iList] << " not found");
56 continue;
57 } else {
58 if (particlelist->getListSize() == 0)continue;
59 pass = true;
60 }
61
62 }
63
64 if (pass) m_nPass++;
65 //module condition
66 setReturnValue(pass);
67
68}
69
71{
72 B2INFO("SkimFilter Summary: \n");
73 std::ostringstream stream;
74 stream << "\n=======================================================\n";
75 stream << "Total Retention: " << Form("%6.4f\n", (float)m_nPass / (float)Environment::Instance().getNumberOfEvents());
76 stream << "\n=======================================================\n";
77 B2INFO(stream.str());
78}
static Environment & Instance()
Static method to get a reference to the Environment instance.
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
Module()
Constructor.
Definition Module.cc:30
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition Module.cc:220
@ 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
virtual void initialize() override
Initialises the module.
virtual void event() override
Method called for each event.
virtual void terminate() override
Write TTree to file, and close file if necessary.
std::vector< std::string > m_strParticleLists
Name of the lists.
int m_nPass
Number of events with Particle candidates.
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.