Belle II Software light-2406-ragdoll
SignalSideParticleFilterModule.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/SignalSideParticleFilter/SignalSideParticleFilterModule.h>
10
11#include <framework/datastore/StoreArray.h>
12#include <framework/datastore/StoreObjPtr.h>
13
14#include <analysis/dataobjects/Particle.h>
15#include <analysis/dataobjects/ParticleList.h>
16#include <analysis/dataobjects/RestOfEvent.h>
17
18using namespace Belle2;
19
20//-----------------------------------------------------------------
21// Register the Module
22//-----------------------------------------------------------------
23REG_MODULE(SignalSideParticleFilter);
24
25//-----------------------------------------------------------------
26// Implementation
27//-----------------------------------------------------------------
28
30{
31 // Set module properties
32 setDescription("The module returns true if the current RestOfEvent object is related to\n"
33 "any of the Particles from the input ParticleList and passes selection criteria.\n"
34 "The module should be executed only in the for_each ROE path.");
35
36 // Parameter definitions
37 addParam("particleLists", m_particleLists, "Input ParticleList name", std::vector<std::string>());
38 addParam("selection", m_selection, "Additional selection criteria", std::string(""));
39}
40
42{
44
45 for (auto& iParticleListName : m_particleLists) {
46
47 StoreObjPtr<ParticleList> iParticlelist;
48 iParticlelist.isRequired(iParticleListName);
49
50 }
51
53
54}
55
57{
58 setReturnValue(false);
59
60 StoreObjPtr<RestOfEvent> roe("RestOfEvent");
61 if (!roe.isValid())
62 return;
63
64 const Particle* particle = roe->getRelatedFrom<Particle>();
65 if (!particle)
66 return;
67
68 for (auto& iParticleListName : m_particleLists) {
69 StoreObjPtr<ParticleList> iParticlelist(iParticleListName);
70
71 if (!iParticlelist) {
72 B2WARNING("Input list " << iParticlelist.getName() << " was not created?");
73 continue;
74 }
75
76 const unsigned int numParticles = iParticlelist->getListSize();
77 if (numParticles == 0)
78 continue;
79
80 if (iParticlelist->contains(particle)) {
81 // cut should be called only if the particle is in the ParticleList
82 if (m_cut->check(particle)) {
83 setReturnValue(true);
84 return;
85 }
86 }
87 }
88
89}
90
91
static std::unique_ptr< GeneralCut > compile(const std::string &cut)
Creates an instance of a cut and returns a unique_ptr to it, if you need a copy-able object instead y...
Definition: GeneralCut.h:84
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 setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:220
Class to store reconstructed particles.
Definition: Particle.h:75
std::string m_selection
Additional selection criteria.
virtual void initialize() override
initialize the module (setup the data store)
virtual void event() override
process event
std::unique_ptr< Variable::Cut > m_cut
cut object which performs the cuts
std::vector< std::string > m_particleLists
Name of the input particle lists.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:111
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