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
17using namespace std;
18using namespace Belle2;
19
20//-----------------------------------------------------------------
21// Register the Module
22//-----------------------------------------------------------------
23REG_MODULE(RestOfEventInterpreter);
24
25//-----------------------------------------------------------------
26// Implementation
27//-----------------------------------------------------------------
28
30{
31 // Set module properties
32 setDescription("Creates a mask (vector of boolean values) for tracks and clusters in RestOfEvent.");
34
35 // Add parameters
36 std::vector<std::tuple<std::string, std::string, std::string, std::string>> emptyROEMask;
37
38 addParam("particleList", m_particleListName, "Name of the ParticleList");
39
40 addParam("ROEMasks", m_ROEMasks,
41 "List of (maskName, trackSelectionCut, eclClusterSelectionCut) tuples that specify all ROE masks of a specific particle to be created.",
42 emptyROEMask);
43
44 addParam("update", m_update, "Set true for updating a-priori charged stable fractions used in calculation of ROE 4-momentum",
45 false);
46
47}
48
50{
51 // input
52 m_plist.isRequired(m_particleListName);
53
54 for (auto ROEMask : m_ROEMasks) {
55 // parsing of the input tuple (maskName, trackSelectionCut, eclClusterSelectionCut, fractions)
56
57 std::string maskName = get<0>(ROEMask);
58 std::string trackSelection = get<1>(ROEMask);
59 std::string eclClusterSelection = get<2>(ROEMask);
60 std::string klmClusterSelection = get<3>(ROEMask);
61
62 std::shared_ptr<Variable::Cut> trackCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(trackSelection));
63 std::shared_ptr<Variable::Cut> eclClusterCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(eclClusterSelection));
64 std::shared_ptr<Variable::Cut> klmClusterCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(klmClusterSelection));
65
66 m_maskNames.push_back(maskName);
67 m_trackCuts.insert(stringAndCutMap::value_type(maskName, trackCut));
68 m_eclClusterCuts.insert(stringAndCutMap::value_type(maskName, eclClusterCut));
69 m_klmClusterCuts.insert(stringAndCutMap::value_type(maskName, klmClusterCut));
70
71 B2INFO("RestOfEventInterpreter added ROEMask with specific fractions under name \'" << maskName << "\' with track cuts: " <<
72 trackSelection << " and eclCluster cuts: " << eclClusterSelection);
73 }
74}
75
77{
78 unsigned int nParts = m_plist->getListSize();
79
80 for (unsigned i = 0; i < nParts; i++) {
81 const Particle* particle = m_plist->getParticle(i);
82 auto* roe = particle->getRelatedTo<RestOfEvent>("ALL");
83 for (auto& maskName : m_maskNames) {
84 if (!m_update) {
85 roe->initializeMask(maskName, "ROEInterpreterModule");
86 }
87 roe->updateMaskWithCuts(maskName, m_trackCuts.at(maskName), m_eclClusterCuts.at(maskName), m_klmClusterCuts.at(maskName), m_update);
88 }
89 }
90}
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:76
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:129
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:649
Abstract base class for different kinds of events.
STL namespace.