CbmRoot
Loading...
Searching...
No Matches
_GTestCbmPixelHit.cxx
Go to the documentation of this file.
1/* Copyright (C) 2016-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5#include "CbmPixelHit.h"
6
7#include <TVector3.h>
8
9#include <gtest/gtest-spi.h>
10#include <gtest/gtest.h>
11
12#include "comparePixelHit.h"
13
14TEST(_GTestCbmPixelHit, CheckDefaultConstructor)
15{
16 CbmPixelHit test;
17 {
18 SCOPED_TRACE("CheckDefaultConstructor");
19 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0.);
20 }
21}
22
23TEST(_GTestCbmPixelHit, CheckStandardConstructor)
24{
25 CbmPixelHit test {-1, 0., 0., 0., 0., 0., 0., 0., -1};
26 {
27 SCOPED_TRACE("CheckStandardConstructor");
28 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0.);
29 }
30}
31
32TEST(_GTestCbmPixelHit, CheckStandardConstructorWithTime)
33{
34 CbmPixelHit test {-1, 0., 0., 0., 0., 0., 0., 0., -1, -2., -2.};
35 {
36 SCOPED_TRACE("CheckStandardConstructorWithTime");
37 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -2., -2., 0., 0., 0., 0., 0.);
38 }
39}
40
41TEST(_GTestCbmPixelHit, CheckStandardConstructorTVector3)
42{
43 TVector3 pos {
44 0.,
45 0.,
46 0.,
47 };
48 TVector3 poserror {
49 0.,
50 0.,
51 0.,
52 };
53 CbmPixelHit test {-1, pos, poserror, 0., -1};
54 {
55 SCOPED_TRACE("CheckStandardConstructor");
56 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0.);
57 }
58}
59
60TEST(_GTestCbmPixelHit, CheckStandardConstructorTVector3WithTime)
61{
62 TVector3 pos {
63 0.,
64 0.,
65 0.,
66 };
67 TVector3 poserror {
68 0.,
69 0.,
70 0.,
71 };
72 CbmPixelHit test {-1, pos, poserror, 0., -1, -2., -2};
73 {
74 SCOPED_TRACE("CheckStandardConstructorWithTime");
75 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -2., -2., 0., 0., 0., 0., 0.);
76 }
77}
78
79TEST(_GTestCbmPixelHit, CheckSetters)
80{
81 CbmPixelHit test;
82 {
83 SCOPED_TRACE("CheckSetters: Initial Test");
84 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0.);
85 }
86
87 test.SetX(-11.);
88 {
89 SCOPED_TRACE("CheckSetters: SetX");
90 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., -11., 0., 0., 0., 0.);
91 }
92
93 test.SetDx(-12.);
94 {
95 SCOPED_TRACE("CheckSetters: SetDx");
96 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., -11., -12., 0., 0., 0.);
97 }
98
99 test.SetY(-13.);
100 {
101 SCOPED_TRACE("CheckSetters: SetY");
102 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., -11., -12., -13., 0., 0.);
103 }
104
105 test.SetDy(-14.);
106 {
107 SCOPED_TRACE("CheckSetters: SetDy");
108 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., -11., -12., -13., -14., 0.);
109 }
110
111 test.SetDxy(-15.);
112 {
113 SCOPED_TRACE("CheckSetters: SetDxy");
114 comparePixelHitDataMembers(test, kPIXELHIT, 0., 0., -1, -1, nullptr, -1., -1., -11., -12., -13., -14., -15.);
115 }
116
117 TVector3 pos {-21., -22., -23.};
118 test.SetPosition(pos);
119 {
120 SCOPED_TRACE("CheckSetters: SetPosition");
121 comparePixelHitDataMembers(test, kPIXELHIT, -23., 0., -1, -1, nullptr, -1., -1., -21., -12., -22., -14., -15.);
122 }
123
124 TVector3 poserror {-31., -32., -33.};
125 test.SetPositionError(poserror);
126 {
127 SCOPED_TRACE("CheckSetters: SetPosition");
128 comparePixelHitDataMembers(test, kPIXELHIT, -23., -33., -1, -1, nullptr, -1., -1., -21., -31., -22., -32., -15.);
129 }
130
131 TVector3 pos1;
132 test.Position(pos1);
133 EXPECT_FLOAT_EQ(pos1.X(), pos.X());
134 EXPECT_FLOAT_EQ(pos1.Y(), pos.Y());
135 EXPECT_FLOAT_EQ(pos1.Z(), pos.Z());
136
137 TVector3 poserror1;
138 test.PositionError(poserror1);
139 EXPECT_FLOAT_EQ(poserror1.X(), poserror.X());
140 EXPECT_FLOAT_EQ(poserror1.Y(), poserror.Y());
141 EXPECT_FLOAT_EQ(poserror1.Z(), poserror.Z());
142}
143
144TEST(_GTestCbmPixelHit, CheckToString)
145{
146 CbmPixelHit test;
147 EXPECT_STREQ("CbmPixelHit: address=-1 pos=(0,0,0) err=(0,0,0) dxy=0 refId=-1\n", test.ToString().c_str());
148}
@ kPIXELHIT
Definition CbmHit.h:23
TEST(_GTestCbmPixelHit, CheckDefaultConstructor)
void SetDxy(double dxy)
Definition CbmPixelHit.h:96
void SetDx(double dx)
Definition CbmPixelHit.h:94
void Position(TVector3 &pos) const
Copies hit position to pos.
void PositionError(TVector3 &dpos) const
Copies hit position error to pos.
void SetX(double x)
Definition CbmPixelHit.h:92
virtual std::string ToString() const
Inherited from CbmBaseHit.
void SetY(double y)
Definition CbmPixelHit.h:93
void SetPositionError(const TVector3 &dpos)
void SetDy(double dy)
Definition CbmPixelHit.h:95
void SetPosition(const TVector3 &pos)
Sets position of the hit.
void comparePixelHitDataMembers(CbmPixelHit &test, HitType type, double z, double dz, int32_t refid, int32_t address, CbmMatch *match, double time, double errortime, double x, double dx, double y, double dy, double dxy)