Belle II Software  release-08-01-10
eventT0.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 <framework/dataobjects/EventT0.h>
10 #include <gtest/gtest.h>
11 
12 using namespace Belle2;
13 
14 namespace {
15 
17  TEST(EventT0, UncertaintyCalculation)
18  {
19  EventT0 t0;
20 
21  ASSERT_FALSE(t0.hasEventT0());
22 
23  t0.setEventT0(-1, 42, Const::CDC);
24  ASSERT_TRUE(t0.hasEventT0());
25  ASSERT_EQ(t0.getEventT0(), -1);
26  ASSERT_EQ(t0.getEventT0Uncertainty(), 42);
27 
28  t0.setEventT0(-2, 43, Const::CDC);
29  ASSERT_TRUE(t0.hasEventT0());
30  ASSERT_EQ(t0.getEventT0(), -2);
31  ASSERT_EQ(t0.getEventT0Uncertainty(), 43);
32 
33  t0.addTemporaryEventT0(EventT0::EventT0Component(2, 3, Const::SVD, ""));
34  ASSERT_EQ(t0.getEventT0(), -2);
35  ASSERT_EQ(t0.getEventT0Uncertainty(), 43);
36 
37  ASSERT_EQ(t0.getNumberOfTemporaryEventT0s(), 1);
38  ASSERT_TRUE(t0.hasTemporaryEventT0());
39  ASSERT_TRUE(t0.hasTemporaryEventT0(Const::SVD));
40  ASSERT_FALSE(t0.hasTemporaryEventT0(Const::CDC));
41  ASSERT_EQ(t0.getTemporaryDetectors(), Const::SVD);
42  ASSERT_EQ(t0.getTemporaryEventT0s().front().eventT0, 2);
43  ASSERT_EQ(t0.getTemporaryEventT0s().front().eventT0Uncertainty, 3);
44  ASSERT_TRUE(t0.getTemporaryEventT0s().front().detectorSet.contains(Const::SVD));
45  }
46 
48  TEST(EventT0, RetrievalOfTemporary)
49  {
50  EventT0 t0;
51 
52  ASSERT_FALSE(t0.hasEventT0());
53 
54  t0.addTemporaryEventT0(EventT0::EventT0Component(-1, 42, Const::CDC, ""));
55  t0.addTemporaryEventT0(EventT0::EventT0Component(-2, 43, Const::CDC, ""));
56  t0.addTemporaryEventT0(EventT0::EventT0Component(-3, 44, Const::ECL, ""));
57  t0.addTemporaryEventT0(EventT0::EventT0Component(-5, 45, Const::TOP, ""));
58 
59  ASSERT_TRUE(t0.hasTemporaryEventT0(Const::CDC));
60  ASSERT_TRUE(t0.hasTemporaryEventT0(Const::ECL));
61  ASSERT_TRUE(t0.hasTemporaryEventT0(Const::TOP));
62  ASSERT_FALSE(t0.hasTemporaryEventT0(Const::SVD));
63 
64  const auto cdcTemporaries = t0.getTemporaryEventT0s(Const::CDC);
65  ASSERT_EQ(cdcTemporaries.size(), 2);
66 
67  ASSERT_DOUBLE_EQ(cdcTemporaries[0].eventT0, -1.0f);
68  ASSERT_DOUBLE_EQ(cdcTemporaries[1].eventT0, -2.0f);
69  }
70 }
Storage element for the eventwise T0 estimation.
Definition: EventT0.h:29
void setEventT0(double eventT0, double eventT0Uncertainty, const Const::DetectorSet &detector, const std::string &algorithm="")
Replace/set the final double T0 estimation.
Definition: EventT0.cc:47
double getEventT0() const
Return the final event t0, if one is set. Else, return NAN.
Definition: EventT0.cc:25
bool hasEventT0() const
Check if a final event t0 is set.
Definition: EventT0.cc:19
void addTemporaryEventT0(const EventT0Component &eventT0)
Add another temporary double T0 estimation.
Definition: EventT0.cc:102
const std::vector< EventT0Component > & getTemporaryEventT0s() const
Return the list of all temporary event t0 estimations.
Definition: EventT0.cc:70
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:59
unsigned long getNumberOfTemporaryEventT0s() const
Return the number of stored event T0s.
Definition: EventT0.cc:97
Const::DetectorSet getTemporaryDetectors() const
Get the detectors that have determined temporary event T0s.
Definition: EventT0.cc:86
double getEventT0Uncertainty() const
Return the final event t0 uncertainty, if one is set. Else, return NAN.
Definition: EventT0.cc:41
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
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:33