Belle II Software light-2406-ragdoll
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#include <boost/algorithm/string/split.hpp>
14#include <boost/algorithm/string/replace.hpp>
15#include <boost/algorithm/string/classification.hpp>
16#include <TString.h>
17
18using namespace std;
19using namespace Belle2;
20using namespace boost::algorithm;
21
22// Register module in the framework
23REG_MODULE(SkimFilter);
24
26{
27 //Set module properties
28 setDescription("Filter based on ParticleLists, by setting return value to true if at least one of the given lists is not empty.");
30 //Parameter definition
31 addParam("particleLists", m_strParticleLists, "List of ParticleLists", vector<string>());
32
33 // initializing the rest of private members
34 m_nPass = 0;
35}
36
38{
39
40 int nParticleLists = m_strParticleLists.size();
41 B2INFO("Number of ParticleLists studied " << nParticleLists << " ");
42
43 m_nPass = 0;
44}
45
47{
48
50
51 // number of ParticleLists
52 int nParticleLists = m_strParticleLists.size();
53 bool pass = false;
54 for (int iList = 0; iList < nParticleLists; ++iList) {
55
57 if (!particlelist) {
58 B2INFO("ParticleList " << m_strParticleLists[iList] << " not found");
59 continue;
60 } else {
61 if (particlelist->getListSize() == 0)continue;
62 pass = true;
63 }
64
65 }
66
67 if (pass) m_nPass++;
68 //module condition
69 setReturnValue(pass);
70
71}
72
74{
75 B2INFO("SkimFilter Summary: \n");
76 std::ostringstream stream;
77 stream << "\n=======================================================\n";
78 stream << "Total Retention: " << Form("%6.4f\n", (float)m_nPass / (float)Environment::Instance().getNumberOfEvents());
79 stream << "\n=======================================================\n";
80 B2INFO(stream.str());
81}
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
Base class for Modules.
Definition: Module.h:72
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
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: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.
Definition: ClusterUtils.h:24
STL namespace.