Belle II Software development
RestOfEventInterpreterModule.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/RestOfEventInterpreter/RestOfEventInterpreterModule.h>
10
11#include <analysis/dataobjects/Particle.h>
12#include <analysis/dataobjects/RestOfEvent.h>
13
14#include <framework/logging/Logger.h>
15#include <framework/core/ModuleParam.templateDetails.h>
16
17#include <iostream>
18
19using namespace std;
20using namespace Belle2;
21
22//-----------------------------------------------------------------
23// Register the Module
24//-----------------------------------------------------------------
25REG_MODULE(RestOfEventInterpreter);
26
27//-----------------------------------------------------------------
28// Implementation
29//-----------------------------------------------------------------
30
32{
33 // Set module properties
34 setDescription("Creates a mask (vector of boolean values) for tracks and clusters in RestOfEvent.");
36
37 // Add parameters
38 std::vector<std::tuple<std::string, std::string, std::string, std::string>> emptyROEMask;
39
40 addParam("particleList", m_particleListName, "Name of the ParticleList");
41
42 addParam("ROEMasks", m_ROEMasks,
43 "List of (maskName, trackSelectionCut, eclClusterSelectionCut) tuples that specify all ROE masks of a specific particle to be created.",
44 emptyROEMask);
45
46 addParam("update", m_update, "Set true for updating a-priori charged stable fractions used in calculation of ROE 4-momentum",
47 false);
48
49}
50
52{
53 // input
54 m_plist.isRequired(m_particleListName);
55
56 for (auto ROEMask : m_ROEMasks) {
57 // parsing of the input tuple (maskName, trackSelectionCut, eclClusterSelectionCut, fractions)
58
59 std::string maskName = get<0>(ROEMask);
60 std::string trackSelection = get<1>(ROEMask);
61 std::string eclClusterSelection = get<2>(ROEMask);
62 std::string klmClusterSelection = get<3>(ROEMask);
63
64 std::shared_ptr<Variable::Cut> trackCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(trackSelection));
65 std::shared_ptr<Variable::Cut> eclClusterCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(eclClusterSelection));
66 std::shared_ptr<Variable::Cut> klmClusterCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(klmClusterSelection));
67
68 m_maskNames.push_back(maskName);
69 m_trackCuts.insert(stringAndCutMap::value_type(maskName, trackCut));
70 m_eclClusterCuts.insert(stringAndCutMap::value_type(maskName, eclClusterCut));
71 m_klmClusterCuts.insert(stringAndCutMap::value_type(maskName, klmClusterCut));
72
73 B2INFO("RestOfEventInterpreter added ROEMask with specific fractions under name \'" << maskName << "\' with track cuts: " <<
74 trackSelection << " and eclCluster cuts: " << eclClusterSelection);
75 }
76}
77
79{
80 unsigned int nParts = m_plist->getListSize();
81
82 for (unsigned i = 0; i < nParts; i++) {
83 const Particle* particle = m_plist->getParticle(i);
84 auto* roe = particle->getRelatedTo<RestOfEvent>("ALL");
85 for (auto& maskName : m_maskNames) {
86 if (!m_update) {
87 roe->initializeMask(maskName, "ROEInterpreterModule");
88 }
89 roe->updateMaskWithCuts(maskName, m_trackCuts.at(maskName), m_eclClusterCuts.at(maskName), m_klmClusterCuts.at(maskName), m_update);
90 }
91 }
92}
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 setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ 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
Class to store reconstructed particles.
Definition: Particle.h:75
std::string m_particleListName
Name of the ParticleList.
RestOfEventInterpreterModule()
Constructor: Sets the description, the properties and the parameters of the module.
virtual void initialize() override
Overridden initialize method.
virtual void event() override
Overridden event method.
std::vector< std::string > m_maskNames
Container for added mask names of ROE interpretations.
std::vector< std::tuple< std::string, std::string, std::string, std::string > > m_ROEMasks
Container for tuples.
stringAndCutMap m_trackCuts
Cut object which performs the cuts on the remaining tracks for a single ROE interpretation.
bool m_update
Set true for updating a-priori charged stable fractions.
stringAndCutMap m_eclClusterCuts
Cut object which performs the cuts on the remaining ECL clusters for a single ROE interpretation.
StoreObjPtr< ParticleList > m_plist
input particle list
stringAndCutMap m_klmClusterCuts
Cut object which performs the cuts on the remaining KLM clusters for a single ROE interpretation.
This is a general purpose class for collecting reconstructed MDST data objects that are not used in r...
Definition: RestOfEvent.h:57
void initializeMask(const std::string &name, const std::string &origin="unknown")
Initialize new mask.
Definition: RestOfEvent.cc:134
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.