Belle II Software  release-06-00-14
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 
19 using namespace std;
20 
21 namespace Belle2 {
27  //-----------------------------------------------------------------
28  // Register the Module
29  //-----------------------------------------------------------------
30  REG_MODULE(RestOfEventInterpreter)
31 
32  //-----------------------------------------------------------------
33  // Implementation
34  //-----------------------------------------------------------------
35 
37  {
38  // Set module properties
39  setDescription("Creates a mask (vector of boolean values) for tracks and clusters in RestOfEvent.");
40  setPropertyFlags(c_ParallelProcessingCertified);
41 
42  // Add parameters
43  std::vector<std::tuple<std::string, std::string, std::string, std::string>> emptyROEMask;
44 
45  addParam("particleList", m_particleListName, "Name of the ParticleList");
46 
47  addParam("ROEMasks", m_ROEMasks,
48  "List of (maskName, trackSelectionCut, eclClusterSelectionCut) tuples that specify all ROE masks of a specific particle to be created.",
49  emptyROEMask);
50 
51  addParam("update", m_update, "Set true for updating a-priori charged stable fractions used in calculation of ROE 4-momentum",
52  false);
53 
54  }
55 
56  void RestOfEventInterpreterModule::initialize()
57  {
58  // input
59  m_plist.isRequired(m_particleListName);
60 
61  for (auto ROEMask : m_ROEMasks) {
62  // parsing of the input tuple (maskName, trackSelectionCut, eclClusterSelectionCut, fractions)
63 
64  std::string maskName = get<0>(ROEMask);
65  std::string trackSelection = get<1>(ROEMask);
66  std::string eclClusterSelection = get<2>(ROEMask);
67  std::string klmClusterSelection = get<3>(ROEMask);
68 
69  std::shared_ptr<Variable::Cut> trackCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(trackSelection));
70  std::shared_ptr<Variable::Cut> eclClusterCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(eclClusterSelection));
71  std::shared_ptr<Variable::Cut> klmClusterCut = std::shared_ptr<Variable::Cut>(Variable::Cut::compile(klmClusterSelection));
72 
73  m_maskNames.push_back(maskName);
74  m_trackCuts.insert(stringAndCutMap::value_type(maskName, trackCut));
75  m_eclClusterCuts.insert(stringAndCutMap::value_type(maskName, eclClusterCut));
76  m_klmClusterCuts.insert(stringAndCutMap::value_type(maskName, klmClusterCut));
77 
78  B2INFO("RestOfEventInterpreter added ROEMask with specific fractions under name \'" << maskName << "\' with track cuts: " <<
79  trackSelection << " and eclCluster cuts: " << eclClusterSelection);
80  }
81  }
82 
83  void RestOfEventInterpreterModule::event()
84  {
85  unsigned int nParts = m_plist->getListSize();
86 
87  for (unsigned i = 0; i < nParts; i++) {
88  const Particle* particle = m_plist->getParticle(i);
89  auto* roe = particle->getRelatedTo<RestOfEvent>("ALL");
90  for (auto& maskName : m_maskNames) {
91  if (!m_update) {
92  roe->initializeMask(maskName, "ROEInterpreterModule");
93  }
94  roe->updateMaskWithCuts(maskName, m_trackCuts.at(maskName), m_eclClusterCuts.at(maskName), m_klmClusterCuts.at(maskName), m_update);
95  }
96  }
97  }
98 
100 }
Base class for Modules.
Definition: Module.h:72
Class to store reconstructed particles.
Definition: Particle.h:74
Creates a mask (vector of boolean values) for tracks and clusters in RestOfEvent regarding their usag...
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:135
#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.