Belle II Software light-2406-ragdoll
CreateConsistencyInfoModule.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 <framework/core/CreateConsistencyInfoModule.h>
10
11using namespace Belle2;
12
13//-----------------------------------------------------------------
14// Register module
15//-----------------------------------------------------------------
16REG_MODULE(CreateConsistencyInfo);
17
18//-----------------------------------------------------------------
19// Implementation
20//-----------------------------------------------------------------
21
23{
24 setDescription("This module checks if events that will be merged are consistent (otherwise events will be skipped later).");
25
27}
28
29CreateConsistencyInfoModule::~CreateConsistencyInfoModule() = default;
30
31void CreateConsistencyInfoModule::init(const std::string& option, bool eventMixing)
32{
33 m_option = option;
34 m_eventMixing = eventMixing;
35}
36
38{
40 if (!m_EventExtraInfo_main.isOptional() or !m_EventExtraInfo_indep.isOptional()) {
41 B2WARNING("EventExtraInfo does not exist in both paths. Cannot check events for consistency.");
42 }
43
44 if (!m_option.empty() && m_option != "charge") {
45 B2ERROR("Only available options for consistency check are 'charge' or no check at all.");
46 }
47}
48
50{
52 m_mergedEventConsistency->setConsistent(true);
53
54 if (m_option == "charge") {
55 if (m_EventExtraInfo_main.isValid() && m_EventExtraInfo_indep.isValid()) {
56 if (!m_EventExtraInfo_main->hasExtraInfo("charge") || !m_EventExtraInfo_indep->hasExtraInfo("charge")) {
57 B2ERROR("No EventExtraInfo 'charge' found.");
58 return;
59 }
60 int charge_main = m_EventExtraInfo_main->getExtraInfo("charge");
61 int charge_indep = m_EventExtraInfo_indep->getExtraInfo("charge");
62 if (m_eventMixing) {
63 // charge of both removed tags has to be opposite
64 if (charge_main == charge_indep) {
65 m_mergedEventConsistency->setConsistent(false);
66 }
67 } else {
68 // charge of embedded object has to correspond to charge of removed tag
69 if (charge_main != charge_indep) {
70 m_mergedEventConsistency->setConsistent(false);
71 }
72 }
73 }
74 }
75}
76
StoreObjPtr< MergedEventConsistency > m_mergedEventConsistency
object that stores whether events are consistent
virtual void initialize() override
Initialize the Module.
bool m_eventMixing
do event mixing (merge each event of main path with each event of independent path)
virtual void event() override
This method is the core of the module.
std::string m_option
different options foreseen to check consistency (right now only charge)
StoreObjPtr< EventExtraInfo > m_EventExtraInfo_main
EventExtraInfo from main path.
void init(const std::string &option, bool eventMixing)
setter for Path.
StoreObjPtr< EventExtraInfo > m_EventExtraInfo_indep
EventExtraInfo from independent path.
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:71
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
#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.
Definition: ClusterUtils.h:24