Belle II Software  release-06-00-14
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 #include <hlt/modules/onlineEventT0/OnlineEventT0CreatorModule.h>
10 
11 
12 using namespace Belle2;
13 
14 REG_MODULE(OnlineEventT0Creator)
15 
17 {
18  setDescription("Module to write the EventT0s computed on HLT");
19 
20  setPropertyFlags(c_ParallelProcessingCertified);
21 }
22 
24 {
25 
26  m_onlineEventT0.registerInDataStore();
27 
28  m_eventT0.isRequired();
29 
30 }
31 
33 {
34  if (!m_eventT0.isValid()) {
35  B2DEBUG(20, "EventT0 object not created, cannot write OnlineEventT0");
36  return;
37  }
38 
39  if (m_onlineEventT0.getEntries() > 0) {
40  B2DEBUG(20, "OnlineEventT0 object already present, do nothing");
41  return;
42  }
43 
44  // check if ECL hypothesis exists
45  auto eclHypos = m_eventT0->getTemporaryEventT0s(Const::EDetector::ECL);
46  if (eclHypos.size() == 0) {
47  B2DEBUG(20, "No ECL EventT0 available");
48  } else {
49  // get the most accurate ECL evenT0 (smallest chi2/quality)
50  auto eclBestT0 = std::min_element(eclHypos.begin(), eclHypos.end(), [](EventT0::EventT0Component c1,
51  EventT0::EventT0Component c2) {return c1.quality < c2.quality;});
52  m_onlineEventT0.appendNew(eclBestT0->eventT0, eclBestT0->eventT0Uncertainty, Const::EDetector::ECL);
53  }
54 
55  // check if a CDC hypothesis exists
56  auto cdcHypos = m_eventT0->getTemporaryEventT0s(Const::EDetector::CDC);
57  if (cdcHypos.size() == 0) {
58  B2DEBUG(20, "No CDC EventT0 available");
59  } else {
60  // get the most accurate CDC evenT0 (latest)
61  const auto& cdcBestT0 = cdcHypos.back();
62  m_onlineEventT0.appendNew(cdcBestT0.eventT0, cdcBestT0.eventT0Uncertainty, Const::EDetector::CDC);
63  }
64 
65  // check if a TOP hypothesis exists
66  auto topHypos = m_eventT0->getTemporaryEventT0s(Const::EDetector::TOP);
67  if (topHypos.size() == 0) {
68  B2DEBUG(20, "No TOP EventT0 available");
69  } else {
70  // get the most accurate TOP eventT0 (there is only one)
71  const auto& topBestT0 = topHypos.back();
72  m_onlineEventT0.appendNew(topBestT0.eventT0, topBestT0.eventT0Uncertainty, Const::EDetector::TOP);
73  }
74 
75 }
76 
77 
Base class for Modules.
Definition: Module.h:72
Module to write the EventT0s computed on HLT.
StoreObjPtr< EventT0 > m_eventT0
StoreArray of EventT0.
void initialize() override
initialize: check DataStore content
void event() override
This method is called for each event.
StoreArray< OnlineEventT0 > m_onlineEventT0
StoreArray of OnlineEventT0.
#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.
Structure for storing the extracted event t0s together with its detector and its uncertainty.
Definition: EventT0.h:34