Belle II Software development
SVDRecoTimeBase.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 <vxd/dataobjects/VxdID.h>
10#include <svd/dataobjects/SVDRecoTimeBase.h>
11#include <vector>
12#include <string>
13#include <gtest/gtest.h>
14
15namespace Belle2 {
20 namespace SVD {
21
25 TEST(SVDRecoTimeBase, ConstructEmpty)
26 {
27 // Create an empty time base
28 SVDRecoTimeBase timeBase;
29 // Test getters
30 EXPECT_EQ(VxdID{0}, timeBase.getSensorID());
31 EXPECT_TRUE(timeBase.isUStrip());
32 const SVDRecoTimeBase::BinEdgesArray bins = timeBase.getBins();
33 EXPECT_EQ(0, timeBase.getNBins());
34 for (auto bin : bins)
35 EXPECT_EQ(SVDRecoTimeBase::BinnedDataType(0.0), bin);
36 }
37
41 TEST(SVDRecoTimeBase, ConstructFromContainer)
42 {
43 // Create an arbitrary recotimeBase
44 VxdID sensorID(3, 4, 1);
45 std::vector<float> init_bins({ -5.0, -3.0, -1.0, 1.0, 3.0, 5.0});
46 SVDRecoTimeBase timeBase(sensorID, false, init_bins);
47 // Test getters
48 EXPECT_EQ(sensorID, timeBase.getSensorID());
49 EXPECT_FALSE(timeBase.isUStrip());
50 EXPECT_EQ(init_bins.size() - 1, timeBase.getNBins());
51 const SVDRecoTimeBase::BinEdgesArray& bins = timeBase.getBins();
52 for (size_t ib = 0; ib < bins.size(); ++ib)
53 EXPECT_EQ(init_bins[ib], bins[ib]);
54 }
58 TEST(SVDRecoTimeBase, toString)
59 {
60 // Create an arbitrary recotimeBase
61 VxdID sensorID(3, 4, 1);
62 std::vector<float> init_bins({ -5.0, -3.0, -1.0, 1.0, 3.0, 5.0});
63 SVDRecoTimeBase timeBase(sensorID, false, init_bins);
64 // Test toString method
65 EXPECT_EQ("VXDID : 25632 = 3.4.1 side: V bins: -5 -3 -1 1 3 5 ", timeBase.toString());
66 }
67
68 } // namespace SVD
70} // namespace Belle2
The SVD RecoTimeBase class.
std::size_t getNBins() const
Get number of bins.
const BinEdgesArray & getBins() const
Get the bins array.
float BinnedDataType
Types for bins array.
VxdID getSensorID() const
Get the sensor ID.
std::vector< BinnedDataType > BinEdgesArray
BinEdgesArray[i] is the left edge of bin i.
bool isUStrip() const
Get strip direction.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
Abstract base class for different kinds of events.