Belle II Software development
SelectDaughtersModule.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/SelectDaughters/SelectDaughtersModule.h>
10
11// dataobjects
12#include <analysis/dataobjects/Particle.h>
13#include <analysis/dataobjects/ParticleList.h>
14
15// Magnetic field
16#include <framework/geometry/BFieldManager.h>
17
18using namespace std;
19
20using namespace Belle2;
21
22//-----------------------------------------------------------------
23// Register the Module
24//-----------------------------------------------------------------
25REG_MODULE(SelectDaughters);
26
27//-----------------------------------------------------------------
28// Implementation
29//-----------------------------------------------------------------
30
32{
33 // Set module properties
34 setDescription("SelectDaughters");
35
36 //Parameter definitions
37 addParam("listName", m_listName, "name of particle list", string(""));
38 addParam("decayString", m_decayString, "specifies which daughter particles will remain", string(""));
39
40}
41
43{
44 if (m_decayString != "") {
46 }
47}
48
50{
51
53 if (!plist) {
54 B2ERROR("ParticleList " << m_listName << " not found");
55 return;
56 }
57 if (m_decayString == "") {
58 B2ERROR("decay descriptor cannot be empty");
59 return;
60 }
61
62 unsigned int n = plist->getListSize();
63 for (unsigned i = 0; i < n; i++) {
64 Particle* particle = plist->getParticle(i);
65
66 std::vector<Particle*> daughters = particle->getDaughters();
67 std::vector<const Particle*> selParticles = m_decaydescriptor.getSelectionParticles(particle);
68
69 for (auto& daughter : daughters) {
70 bool isSel = false;
71 for (auto& selParticle : selParticles) {
72 if (daughter == selParticle) isSel = true;
73 }
74 if (!isSel) particle->removeDaughter(daughter);
75 }
76 }
77}
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
std::vector< const Particle * > getSelectionParticles(const Particle *particle)
Get a vector of pointers with selected daughters in the decay tree.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Class to store reconstructed particles.
Definition: Particle.h:75
virtual void initialize() override
set up datastore
virtual void event() override
process the event
std::string m_decayString
daughter particles selection
std::string m_listName
name of particle list
DecayDescriptor m_decaydescriptor
Decay descriptor of decays to look for.
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.