Belle II Software development
SVDRecoDigit.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/SVDRecoDigit.h>
11#include <vector>
12#include <string>
13#include <cmath>
14#include <gtest/gtest.h>
15
16namespace Belle2 {
21 namespace SVD {
22
26 TEST(SVDRecoDigit, ConstructEmpty)
27 {
28 // Create an empty 6-digit
29 SVDRecoDigit digit;
30 // Test getters
31 EXPECT_EQ(VxdID{0}, digit.getSensorID());
32 EXPECT_TRUE(digit.isUStrip());
33 EXPECT_EQ(0, digit.getCellID());
34 EXPECT_EQ(0, digit.getAmplitude());
35 EXPECT_EQ(10, digit.getAmplitudeError());
36 EXPECT_EQ(0, digit.getTime());
37 EXPECT_EQ(100, digit.getTimeError());
39 for (auto prob : pdf)
40 EXPECT_EQ(SVDRecoDigit::OutputProbType(1.0), prob);
41 EXPECT_EQ(100.0, digit.getChi2Ndf());
42 }
43
47 TEST(SVDRecoDigit, ConstructFromContainer)
48 {
49 // Create an arbitrary recodigit
50 VxdID sensorID(3, 4, 1);
51 short int cellID = 132;
52 float init_charge = 23456;
53 float init_chargeErr = 1234;
54 float init_time = -16;
55 float init_timeErr = 3.21;
56 float init_chi2 = 2.34;
57
58 std::vector<float> init_probs({0.0, 0.01, 0.10, 0.79, 0.06, 0.04});
59 SVDRecoDigit digit(sensorID, false, cellID, init_charge, init_chargeErr, init_time,
60 init_timeErr, init_probs, init_chi2);
61 // Test getters
62 EXPECT_EQ(sensorID, digit.getSensorID());
63 EXPECT_FALSE(digit.isUStrip());
64 EXPECT_EQ(cellID, digit.getCellID());
65 EXPECT_EQ(init_charge, digit.getCharge());
66 EXPECT_EQ(init_chargeErr, digit.getAmplitudeError());
67 EXPECT_EQ(init_time, digit.getTime());
68 EXPECT_EQ(init_timeErr, digit.getTimeError());
69 const SVDRecoDigit::OutputProbArray pdf = digit.getProbabilities();
70 for (size_t ip = 0; ip < pdf.size(); ++ip)
71 EXPECT_LE(fabs(static_cast<SVDRecoDigit::OutputProbType>(init_probs[ip]) - pdf[ip]), 1.0 / SVDRecoDigit::storedProbArrayNorm);
72 // Also, norm must be 1
73 float outputNorm = std::accumulate(pdf.begin(), pdf.end(), 0.0);
74 EXPECT_LE(fabs(1.0 - outputNorm), 1.0e-6);
75 EXPECT_EQ(init_chi2, digit.getChi2Ndf());
76
77 }
81 TEST(SVDRecoDigit, ToString)
82 {
83 // Create an arbitrary recodigit
84 VxdID sensorID(3, 4, 1);
85 short int cellID = 132;
86 float init_charge = 23456;
87 float init_chargeErr = 1234;
88 float init_time = -16;
89 float init_timeErr = 3.21;
90 float init_chi2 = 2.34;
91
92 std::vector<float> init_probs({0.0, 0.01, 0.10, 0.79, 0.06, 0.04});
93 SVDRecoDigit digit(sensorID, false, cellID, init_charge, init_chargeErr, init_time,
94 init_timeErr, init_probs, init_chi2);
95 // Test getters
96 std::string
97 digitString("VXDID : 25632 = 3.4.1 strip: V-132 Amplitude: 23456 +/- 1234 Time: -16 +/- 3.21\n probabilities: 0 655 6553 51772 3932 2621 Chi2/ndf: 2.34\n");
98 EXPECT_EQ(digitString, digit.toString());
99 }
100
101 } // namespace SVD
103} // namespace Belle2
The SVD RecoDigit class.
Definition: SVDRecoDigit.h:43
double OutputProbType
Type for output probability array.
Definition: SVDRecoDigit.h:56
OutputProbArray getProbabilities() const
Get signal time pdf.
Definition: SVDRecoDigit.h:144
float getTime() const
Get time estimate.
Definition: SVDRecoDigit.h:134
float getAmplitude() const
Get amplitude estimate.
Definition: SVDRecoDigit.h:119
float getChi2Ndf() const
Get waveform fit chi2/ndf.
Definition: SVDRecoDigit.h:163
VxdID getSensorID() const
Get the sensor ID.
Definition: SVDRecoDigit.h:98
static const uint16_t storedProbArrayNorm
some constant
Definition: SVDRecoDigit.h:51
float getAmplitudeError() const
Get amplitude error.
Definition: SVDRecoDigit.h:129
std::vector< OutputProbType > OutputProbArray
vector of OutProbType objects
Definition: SVDRecoDigit.h:57
short int getCellID() const
Get strip ID.
Definition: SVDRecoDigit.h:114
bool isUStrip() const
Get strip direction.
Definition: SVDRecoDigit.h:109
float getTimeError() const
Get time error.
Definition: SVDRecoDigit.h:139
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
Abstract base class for different kinds of events.