Belle II Software development
OnlineEventT0CreatorModule.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/* Own header. */
10#include <hlt/modules/onlineEventT0/OnlineEventT0CreatorModule.h>
11
12/* Basf2 headers. */
13#include <framework/core/Environment.h>
14#include <framework/logging/LogConfig.h>
15
16using namespace Belle2;
17
18REG_MODULE(OnlineEventT0Creator);
19
21{
22 setDescription("Module to write the EventT0s computed on the online systems (HLT). "
23 "By default, this module is run only on the online systems unless the user "
24 "specifically requires to execute it.");
25 addParam("executeThisModule", m_executeThisModule,
26 "Execute this module: if True, this module is executed durig the reconstruction, otherwise not.", false);
28}
29
31{
32 // If we are running online, execute the module regardless of what the user specified.
34 if (realm == LogConfig::c_Online)
36 // Run the usual checks only if the module is actually executed.
38 m_onlineEventT0.registerInDataStore();
39 m_eventT0.isRequired();
40 }
41}
42
44{
46 B2DEBUG(20, "OnlineEventT0 is not executed as requested");
47 return;
48 }
49 if (!m_eventT0.isValid()) {
50 B2DEBUG(20, "EventT0 object not created, cannot write OnlineEventT0");
51 return;
52 }
53 if (m_onlineEventT0.getEntries() > 0) {
54 B2DEBUG(20, "OnlineEventT0 object already present, do nothing");
55 return;
56 }
57 // check if ECL hypothesis exists
58 const auto bestECLHypo = m_eventT0->getBestECLTemporaryEventT0();
59 if (not bestECLHypo) {
60 B2DEBUG(20, "No ECL EventT0 available");
61 } else {
62 m_onlineEventT0.appendNew(bestECLHypo->eventT0, bestECLHypo->eventT0Uncertainty, Const::EDetector::ECL);
63 }
64 // check if a CDC hypothesis exists
65 const auto bestCDCHypo = m_eventT0->getBestCDCTemporaryEventT0();
66 if (not bestCDCHypo) {
67 B2DEBUG(20, "No CDC EventT0 available");
68 } else {
69 m_onlineEventT0.appendNew(bestCDCHypo->eventT0, bestCDCHypo->eventT0Uncertainty, Const::EDetector::CDC);
70 }
71 // check if a TOP hypothesis exists
72 const auto bestTOPHypo = m_eventT0->getBestTOPTemporaryEventT0();
73 if (not bestTOPHypo) {
74 B2DEBUG(20, "No TOP EventT0 available");
75 } else {
76 m_onlineEventT0.appendNew(bestTOPHypo->eventT0, bestTOPHypo->eventT0Uncertainty, Const::EDetector::TOP);
77 }
78 // check if a SVD hypothesis exists
79 const auto bestSVDHypo = m_eventT0->getBestSVDTemporaryEventT0();
80 if (not bestSVDHypo) {
81 B2DEBUG(20, "No SVD EventT0 available");
82 } else {
83 m_onlineEventT0.appendNew(bestSVDHypo->eventT0, bestSVDHypo->eventT0Uncertainty, Const::EDetector::SVD);
84 }
85}
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28
LogConfig::ELogRealm getRealm() const
Get the basf2 execution realm.
Definition: Environment.h:211
ELogRealm
Definition of the supported execution realms.
Definition: LogConfig.h:48
@ c_Online
Online data taking.
Definition: LogConfig.h:49
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
StoreObjPtr< EventT0 > m_eventT0
StoreArray of EventT0.
void initialize() override
Initialize: check DataStore content.
bool m_executeThisModule
Module parameter for executing the module or not.
void event() override
This method is called for each event.
StoreArray< OnlineEventT0 > m_onlineEventT0
StoreArray of OnlineEventT0.
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.