Belle II Software development
TOPCalEventT0Offset.h
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#pragma once
10
11#include <TObject.h>
12#include <map>
13#include <vector>
14#include <framework/gearbox/Const.h>
15#include <framework/logging/Logger.h>
16
17namespace Belle2 {
27 class TOPCalEventT0Offset: public TObject {
28
29 public:
30
34 struct OffsetData {
35 float offset = 0;
36 float sigma = 0;
37 Const::EDetector component = Const::invalidDetector;
43 {}
44
51 OffsetData(double T0, double sig, Const::EDetector det): offset(T0), sigma(sig), component(det)
52 {}
53 };
54
59 {}
60
67 void set(Const::EDetector detector, double offset, double sigma)
68 {
69 if (sigma > 0) {
70 m_data.push_back(OffsetData(offset, sigma, detector));
71 } else {
72 B2ERROR("TOPCalEventT0Offset::set: time resolution must be a positive number. Entry ignored"
73 << LogVar("detector component", detector));
74 }
75 }
76
82 const OffsetData& get(Const::EDetector detector) const
83 {
84 if (m_calibrations.empty()) set();
85 return m_calibrations[detector];
86 }
87
93 bool isAvailable(Const::EDetector detector) const
94 {
95 if (m_calibrations.empty()) set();
96 return (m_calibrations[detector].sigma > 0);
97 }
98
103 bool isEmpty() const {return m_data.empty();}
104
105 private:
106
110 void set() const
111 {
112 for (const auto& data : m_data) m_calibrations[data.component] = data;
113 }
114
115 std::vector<OffsetData> m_data;
117 mutable std::map<Const::EDetector, OffsetData> m_calibrations;
118
121 };
122
124}
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:42
Class to store the calibrated EventT0 offsets of other detector components The offsets are measured r...
TOPCalEventT0Offset()
Default class constructor.
const OffsetData & get(Const::EDetector detector) const
Getter.
bool isAvailable(Const::EDetector detector) const
Is calibration available for a given detector component?
void set(Const::EDetector detector, double offset, double sigma)
Setter.
ClassDef(TOPCalEventT0Offset, 1)
do not write out
std::map< Const::EDetector, OffsetData > m_calibrations
cache
bool isEmpty() const
Is object empty?
void set() const
Set the cache.
std::vector< OffsetData > m_data
calibration data
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.
Calibration constants of a detector component.
OffsetData(double T0, double sig, Const::EDetector det)
Full constructor.
Const::EDetector component
detector component
float sigma
time resolution of the detector component