Belle II Software  release-05-02-19
SignalSideParticleFilterModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Anze Zupanc *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <analysis/modules/SignalSideParticleFilter/SignalSideParticleFilterModule.h>
12 
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 
16 #include <analysis/dataobjects/Particle.h>
17 #include <analysis/dataobjects/ParticleList.h>
18 #include <analysis/dataobjects/RestOfEvent.h>
19 
20 using namespace Belle2;
21 
22 //-----------------------------------------------------------------
23 // Register the Module
24 //-----------------------------------------------------------------
25 REG_MODULE(SignalSideParticleFilter)
26 
27 //-----------------------------------------------------------------
28 // Implementation
29 //-----------------------------------------------------------------
30 
32 {
33  // Set module properties
34  setDescription("The module returns true if the current RestOfEvent object is related to\n"
35  "any of the Particles from the input ParticleList and passes selection criteria.\n"
36  "The module should be executed only in the for_each ROE path.");
37 
38  // Parameter definitions
39  addParam("particleLists", m_particleLists, "Input ParticleList name", std::vector<std::string>());
40  addParam("selection", m_selection, "Additional selection criteria", std::string(""));
41 }
42 
44 {
45  StoreArray<Particle>().isRequired();
46 
47  for (auto& iParticleListName : m_particleLists) {
48 
49  StoreObjPtr<ParticleList> iParticlelist;
50  iParticlelist.isRequired(iParticleListName);
51 
52  }
53 
55 
56 }
57 
59 {
60  setReturnValue(false);
61  bool inTheLists = false;
62 
63  StoreObjPtr<RestOfEvent> roe("RestOfEvent");
64  if (roe.isValid()) {
65  const Particle* particle = roe->getRelated<Particle>();
66  if (particle) {
67  if (m_cut->check(particle)) {
68  for (auto& iParticleListName : m_particleLists) {
69 
70  StoreObjPtr<ParticleList> iParticlelist(iParticleListName);
71 
72  if (!iParticlelist) {
73  B2WARNING("Input list " << iParticlelist.getName() << " was not created?");
74  continue;
75  }
76 
77  const unsigned int numParticles = iParticlelist->getListSize();
78  if (numParticles == 0)
79  continue;
80 
81  if (iParticlelist->contains(particle)) {
82  inTheLists = true; break;
83  }
84  }
85  }
86  }
87  }
88  setReturnValue(inTheLists);
89 }
90 
91 
Belle2::GeneralCut::compile
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:114
Belle2::SignalSideParticleFilterModule::m_cut
std::unique_ptr< Variable::Cut > m_cut
cut object which performs the cuts
Definition: SignalSideParticleFilterModule.h:59
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SignalSideParticleFilterModule::event
virtual void event() override
process event
Definition: SignalSideParticleFilterModule.cc:58
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::Module::setReturnValue
void setReturnValue(int value)
Sets the return value for this module as integer.
Definition: Module.cc:222
Belle2::SignalSideParticleFilterModule
The module returns true if the current RestOfEvent object is related to any of the Particles in the i...
Definition: SignalSideParticleFilterModule.h:43
Belle2::Particle
Class to store reconstructed particles.
Definition: Particle.h:77
Belle2::SignalSideParticleFilterModule::m_selection
std::string m_selection
Additional selection criteria.
Definition: SignalSideParticleFilterModule.h:58
Belle2::SignalSideParticleFilterModule::initialize
virtual void initialize() override
initialize the module (setup the data store)
Definition: SignalSideParticleFilterModule.cc:43
Belle2::SignalSideParticleFilterModule::m_particleLists
std::vector< std::string > m_particleLists
Name of the input particle lists.
Definition: SignalSideParticleFilterModule.h:57
Belle2::StoreArray< Particle >
Belle2::StoreObjPtr::isValid
bool isValid() const
Check whether the object was created.
Definition: StoreObjPtr.h:120