Belle II Software  release-05-01-25
EventT0.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <framework/dataobjects/EventT0.h>
11 
12 #include <framework/logging/Logger.h>
13 
14 #include <algorithm>
15 #include <iterator>
16 
17 using namespace Belle2;
18 
19 // Final event t0
21 bool EventT0::hasEventT0() const
22 {
23  return m_hasEventT0;
24 }
25 
27 double EventT0::getEventT0() const
28 {
29  B2ASSERT("Not EventT0 available, but someone tried to acces it. Check with hasEventT0() method before!", hasEventT0());
30  return m_eventT0.eventT0;
31 }
32 
33 boost::optional<EventT0::EventT0Component> EventT0::getEventT0Component() const
34 {
35  if (hasEventT0()) {
36  return boost::make_optional(m_eventT0);
37  }
38 
39  return {};
40 }
41 
44 {
46 }
47 
49 void EventT0::setEventT0(double eventT0, double eventT0Uncertainty, const Const::DetectorSet& detector,
50  const std::string& algorithm)
51 {
52  setEventT0(EventT0Component(eventT0, eventT0Uncertainty, detector, algorithm));
53 }
54 
56 {
57  m_eventT0 = eventT0;
58  m_hasEventT0 = true;
59 }
60 
61 bool EventT0::hasTemporaryEventT0(const Const::DetectorSet& detectorSet) const
62 {
63  for (const EventT0Component& eventT0Component : m_temporaryEventT0List) {
64  if (detectorSet.contains(eventT0Component.detectorSet)) {
65  return true;
66  }
67  }
68 
69  return false;
70 }
71 
72 const std::vector<EventT0::EventT0Component>& EventT0::getTemporaryEventT0s() const
73 {
75 }
76 
77 const std::vector<EventT0::EventT0Component> EventT0::getTemporaryEventT0s(Const::EDetector detector) const
78 {
79  std::vector<EventT0::EventT0Component> detectorT0s;
80 
81  const auto lmdSelectDetector = [detector](EventT0::EventT0Component const & c) {return c.detectorSet.contains(detector);};
82  std::copy_if(m_temporaryEventT0List.begin(), m_temporaryEventT0List.end(),
83  std::back_inserter(detectorT0s), lmdSelectDetector);
84  return detectorT0s;
85 }
86 
87 
89 {
90  Const::DetectorSet temporarySet;
91 
92  for (const EventT0Component& eventT0Component : m_temporaryEventT0List) {
93  temporarySet += eventT0Component.detectorSet;
94  }
95 
96  return temporarySet;
97 }
98 
100 {
101  return m_temporaryEventT0List.size();
102 }
103 
105 {
106  m_temporaryEventT0List.push_back(eventT0);
107 }
108 
110 {
111  m_temporaryEventT0List.clear();
112 }
113 
115 {
116  m_hasEventT0 = false;
117 }
Belle2::EventT0::getTemporaryDetectors
Const::DetectorSet getTemporaryDetectors() const
Get the detectors that have determined temporary event T0s.
Definition: EventT0.cc:88
Belle2::EventT0::m_hasEventT0
bool m_hasEventT0
Internal storage of the final eventT0 is set.
Definition: EventT0.h:124
Belle2::EventT0::getNumberOfTemporaryEventT0s
unsigned long getNumberOfTemporaryEventT0s() const
Return the number of stored event T0s.
Definition: EventT0.cc:99
Belle2::EventT0::hasEventT0
bool hasEventT0() const
Check if a final event t0 is set.
Definition: EventT0.cc:21
Belle2::EventT0::m_eventT0
EventT0Component m_eventT0
Internal storage for the final event t0.
Definition: EventT0.h:122
Belle2::EventT0::EventT0Component::eventT0
double eventT0
Storage of the T0 estimation.
Definition: EventT0.h:55
Belle2::EventT0::EventT0Component::eventT0Uncertainty
double eventT0Uncertainty
Storage of the uncertainty of the T0 estimation.
Definition: EventT0.h:57
Belle2::EventT0::clearTemporaries
void clearTemporaries()
Clear the list of temporary event T0 estimations.
Definition: EventT0.cc:109
Belle2::Const::DetectorSet
The DetectorSet class for sets of detector IDs in the form of EDetector values.
Definition: Const.h:66
Belle2::EventT0::setEventT0
void setEventT0(double eventT0, double eventT0Uncertainty, const Const::DetectorSet &detector, const std::string &algorithm="")
Replace/set the final double T0 estimation.
Definition: EventT0.cc:49
Belle2::EventT0::m_temporaryEventT0List
std::vector< EventT0Component > m_temporaryEventT0List
Internal storage of the temporary event t0 list.
Definition: EventT0.h:120
Belle2::Const::EDetector
EDetector
Enum for identifying the detector components (detector and subdetector).
Definition: Const.h:44
Belle2::EventT0::getEventT0Component
boost::optional< EventT0Component > getEventT0Component() const
Return the final event t0, if one is set. Else, return an empty optional.
Definition: EventT0.cc:33
Belle2::EventT0::EventT0Component
Structure for storing the extracted event t0s together with its detector and its uncertainty.
Definition: EventT0.h:44
Belle2::EventT0::getEventT0Uncertainty
double getEventT0Uncertainty() const
Return the final event t0 uncertainty, if one is set. Else, return NAN.
Definition: EventT0.cc:43
Belle2::EventT0::hasTemporaryEventT0
bool hasTemporaryEventT0(const Const::DetectorSet &detectorSet=Const::allDetectors) const
Check if one of the detectors in the given set has a temporary t0 estimation.
Definition: EventT0.cc:61
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::EventT0::clearEventT0
void clearEventT0()
Clear the final EventT0, this is neded in case some algorithm has set one for an itertive t0 finding ...
Definition: EventT0.cc:114
Belle2::Const::DetectorSet::contains
bool contains(const DetectorSet &set) const
Check whether this set contains another set.
Definition: Const.h:116
Belle2::EventT0::getEventT0
double getEventT0() const
Return the final event t0, if one is set. Else, return NAN.
Definition: EventT0.cc:27
Belle2::EventT0::getTemporaryEventT0s
const std::vector< EventT0Component > & getTemporaryEventT0s() const
Return the list of all temporary event t0 estimations.
Definition: EventT0.cc:72
Belle2::EventT0::addTemporaryEventT0
void addTemporaryEventT0(const EventT0Component &eventT0)
Add another temporary double T0 estimation.
Definition: EventT0.cc:104