CbmRoot
Loading...
Searching...
No Matches
_GTestCbmTrdHit.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5#include "CbmTrdHit.h"
6
7#include "compareTrdHit.h"
8#include "gtest/gtest-spi.h"
9#include "gtest/gtest.h"
10
11TEST(_GTestCbmTrdHit, CheckDefaultConstructor)
12{
13 // Create object
14 CbmTrdHit test;
15
16 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 0, -1.);
17
18 CbmTrdHit* test1 = new CbmTrdHit();
19
20 compareTrdHitDataMembers(*test1, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 0, -1.);
21}
22
23TEST(_GTestCbmTrdHit, CheckStandardConstructor)
24{
25 int32_t address {12345};
26 TVector3 pos {-3., 5.777, 123.765};
27 TVector3 error {0.77, 0.88, 0.99};
28 double dxy {1.2};
29 int32_t refId {6};
30 double eloss {123.};
31
32 // Create object
33 CbmTrdHit test(address, pos, error, dxy, refId, eloss);
34
35 compareTrdHitDataMembers(test, kTRDHIT, pos.Z(), error.Z(), refId, address, nullptr, 0., 0., pos.X(), error.X(),
36 pos.Y(), error.Y(), dxy, 0, eloss);
37
38
39 CbmTrdHit* test1 = new CbmTrdHit(address, pos, error, dxy, refId, eloss);
40
41 compareTrdHitDataMembers(*test1, kTRDHIT, pos.Z(), error.Z(), refId, address, nullptr, 0., 0., pos.X(), error.X(),
42 pos.Y(), error.Y(), dxy, 0, eloss);
43}
44
45TEST(_GTestCbmTrdHit, CheckStandardConstructorWithTime)
46{
47 int32_t address {12345};
48 TVector3 pos {-3., 5.777, 123.765};
49 TVector3 error {0.77, 0.88, 0.99};
50 double dxy {1.2};
51 int32_t refId {6};
52 double eloss {123.};
53 double time {456.};
54 double timeError {1.34};
55 // Create object
56 CbmTrdHit test(address, pos, error, dxy, refId, eloss, time, timeError);
57
58 compareTrdHitDataMembers(test, kTRDHIT, pos.Z(), error.Z(), refId, address, nullptr, time, timeError, pos.X(),
59 error.X(), pos.Y(), error.Y(), dxy, 0, eloss);
60
61
62 CbmTrdHit* test1 = new CbmTrdHit(address, pos, error, dxy, refId, eloss, time, timeError);
63
64 compareTrdHitDataMembers(*test1, kTRDHIT, pos.Z(), error.Z(), refId, address, nullptr, time, timeError, pos.X(),
65 error.X(), pos.Y(), error.Y(), dxy, 0, eloss);
66}
67
68TEST(_GTestCbmTrdHit, CheckSetBits)
69{
70 // Create object
71 CbmTrdHit test;
72
73 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 0, -1.);
74
75 test.SetMaxType(true);
76 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 2, -1.);
77
78 test.SetClassType(true);
79 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 3, -1.);
80
81 test.SetMaxType(false);
82 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 1, -1.);
83
84 test.SetRowCross(true);
85 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 5, -1.);
86
87 test.SetClassType(false);
88 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 4, -1.);
89
90 test.SetOverFlow(true);
91 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 12, -1.);
92
93 test.SetRowCross(false);
94 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 8, -1.);
95
96 test.SetOverFlow(false);
97 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 0, -1.);
98}
99
100TEST(_GTestCbmTrdHit, CheckSetEloss)
101{
102 // Create object
103 CbmTrdHit test;
104
105 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 0, -1.);
106
107 test.SetELoss(134.56);
108 compareTrdHitDataMembers(test, kTRDHIT, 0., 0., -1, -1, nullptr, -1., -1., 0., 0., 0., 0., 0., 0, 134.56);
109}
110
111TEST(_GTestCbmTrdHit, CheckToString)
112{
113 int32_t address {12345};
114 TVector3 pos {-3., 5.777, 123.765};
115 TVector3 error {0.77, 0.88, 0.99};
116 double dxy {1.2};
117 int32_t refId {6};
118 double eloss {123.};
119 double time {456.};
120 double timeError {1.34};
121 // Create object
122 CbmTrdHit test(address, pos, error, dxy, refId, eloss, time, timeError);
123
124 compareTrdHitDataMembers(test, kTRDHIT, pos.Z(), error.Z(), refId, address, nullptr, time, timeError, pos.X(),
125 error.X(), pos.Y(), error.Y(), dxy, 0, eloss);
126
127
128 EXPECT_STREQ("CbmPixelHit: address=12345 pos=(-3,5.777,123.765) "
129 "err=(0.77,0.88,0.99) dxy=1.2 refId=6\nCbmTrdHit1D: "
130 "time[ns]=456+-1.34 eloss=123 RC=n Ovf=n\n",
131 test.ToString().c_str());
132}
133
134
135/*
136TEST(_GTestCbmTrdHit , CheckCopyConstructor)
137{
138 // Create object
139 CbmTrdHit test(5, 6.7);
140
141 compareTrdHitDataMembers(test, 5, 6.7);
142
143 // Create object by copy constructing
144 // test should be equal to test2 and
145 // test should not be changed
146 CbmTrdHit test2{test};
147
148 compareTrdHitDataMembers(test2, 5, 6.7);
149
150 // Test if the original object wasn't changed
151 compareTrdHitDataMembers(test, 5, 6.7);
152}
153
154TEST(_GTestCbmTrdHit , CheckAssignmentOperator)
155{
156 // Create object
157 CbmTrdHit test(5, 6.7);
158
159 compareTrdHitDataMembers(test, 5, 6.7);
160
161 // Create object by copy constructing
162 // test should be equal to test2 and
163 // test should not be changed
164 CbmTrdHit test2{};
165 test2 = test;
166
167 compareTrdHitDataMembers(test2, 5, 6.7);
168
169 // Test if the original object wasn't changed
170 compareTrdHitDataMembers(test, 5, 6.7);
171}
172
173TEST(_GTestCbmTrdHit , CheckMoveConstructor)
174{
175 // Create object
176 CbmTrdHit test(5, 6.7);
177
178 compareTrdHitDataMembers(test, 5, 6.7);
179
180 // Create object by copy constructing
181 // test should be equal to test2 and
182 // test should not be changed
183 CbmTrdHit test2{std::move(test)};
184
185 compareTrdHitDataMembers(test2, 5, 6.7);
186
187 // For objects with simple types move fall back to copy so
188 // the original object is kept unchanged
189 compareTrdHitDataMembers(test, 5, 6.7);
190}
191
192TEST(_GTestCbmTrdHit , CheckAssignmentMoveConstructor)
193{
194 // Create object
195 CbmTrdHit test(5, 6.7);
196
197 compareTrdHitDataMembers(test, 5, 6.7);
198
199 // Create object by copy constructing
200 // test should be equal to test2 and
201 // test should not be changed
202 CbmTrdHit test2{};
203 test2 = std::move(test);
204
205 compareTrdHitDataMembers(test2, 5, 6.7);
206
207 // For objects with simple types move fall back to copy so
208 // the original object is kept unchanged
209 compareTrdHitDataMembers(test, 5, 6.7);
210}
211
212
213
214*/
@ kTRDHIT
Definition CbmHit.h:30
Class for hits in TRD detector.
TEST(_GTestCbmTrdHit, CheckDefaultConstructor)
data class for a reconstructed Energy-4D measurement in the TRD
Definition CbmTrdHit.h:40
void SetELoss(double loss)
Definition CbmTrdHit.h:87
virtual std::string ToString() const
Inherited from CbmBaseHit.
Definition CbmTrdHit.cxx:42
void SetClassType(bool set=true)
Type of pad layout used in reconstruction R[0], T[1].
Definition CbmTrdHit.h:93
void SetOverFlow(bool set=true)
Mark overflow in one or more digits which define the hit.
Definition CbmTrdHit.h:89
void SetMaxType(bool set=true)
Extra bool definition for the hit (e.g. the type of maximum for triangular pads).
Definition CbmTrdHit.h:95
void SetRowCross(bool set=true)
Mark hit reconstructed between pad rows.
Definition CbmTrdHit.h:91
void compareTrdHitDataMembers(CbmTrdHit &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, uint8_t define, double eloss)