Belle II Software development
KLMEventT0Variables.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/* Basf2 headers. */
10#include <analysis/dataobjects/Particle.h>
11#include <analysis/VariableManager/Manager.h>
12#include <framework/dataobjects/EventT0.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/gearbox/Const.h>
15
16/* C++ headers. */
17#include <limits>
18#include <optional>
19#include <vector>
20
21namespace Belle2 {
26 namespace Variable {
27
29 std::optional<EventT0::EventT0Component> getKLMEventT0Component()
30 {
31 StoreObjPtr<EventT0> eventT0;
32 if (!eventT0.isValid())
33 return std::nullopt;
34 // getTemporaryEventT0s(detector) returns a copy, so the entry is returned by value
35 const std::vector<EventT0::EventT0Component> klmT0s = eventT0->getTemporaryEventT0s(Const::KLM);
36 if (klmT0s.empty())
37 return std::nullopt;
38 return klmT0s.back();
39 }
40
42 double klmEventT0(const Particle*)
43 {
44 const std::optional<EventT0::EventT0Component> klmT0 = getKLMEventT0Component();
45 if (!klmT0)
46 return std::numeric_limits<double>::quiet_NaN();
47 return klmT0->eventT0;
48 }
49
51 double klmEventT0Uncertainty(const Particle*)
52 {
53 const std::optional<EventT0::EventT0Component> klmT0 = getKLMEventT0Component();
54 if (!klmT0)
55 return std::numeric_limits<double>::quiet_NaN();
56 return klmT0->eventT0Uncertainty;
57 }
58
59 VARIABLE_GROUP("KLM event T0 calibration");
60 REGISTER_VARIABLE("klmEventT0", klmEventT0, R"DOC(
61**[Calibration][Eventbased]** Returns the event time measured with the KLM: the KLM entry that ``KLMEventT0Estimator``
62adds to the ``EventT0`` object, alongside the values of the other detectors.
63Available on cDST only. Requires a KLM module in the path, for example ``KLMEventT0Estimator``; NaN if
64``KLMEventT0Estimator`` did not run.
65)DOC", "ns");
66 REGISTER_VARIABLE("klmEventT0Uncertainty", klmEventT0Uncertainty, R"DOC(
67**[Calibration][Eventbased]** Returns the uncertainty of :b2:var:`klmEventT0`, propagated from the calibrated per-hit
68time resolution. Requires a KLM module in the path, as :b2:var:`klmEventT0` does; NaN if :b2:var:`klmEventT0` is NaN.
69)DOC", "ns");
70
71 }
73}
Abstract base class for different kinds of events.