CbmRoot
_GTestCbmTrdHit.cxx
Go to the documentation of this file.
1 #include "CbmTrdHit.h"
2 
3 #include "gtest/gtest-spi.h"
4 #include "gtest/gtest.h"
5 
6 #include "compareTrdHit.h"
7 
8 TEST(_GTestCbmTrdHit, CheckDefaultConstructor) {
9  // Create object
10  CbmTrdHit test;
11 
13  kTRDHIT,
14  0.,
15  0.,
16  -1,
17  -1,
18  nullptr,
19  -1.,
20  -1.,
21  0.,
22  0.,
23  0.,
24  0.,
25  0.,
26  0,
27  -1.);
28 
29  CbmTrdHit* test1 = new CbmTrdHit();
30 
32  kTRDHIT,
33  0.,
34  0.,
35  -1,
36  -1,
37  nullptr,
38  -1.,
39  -1.,
40  0.,
41  0.,
42  0.,
43  0.,
44  0.,
45  0,
46  -1.);
47 }
48 
49 TEST(_GTestCbmTrdHit, CheckStandardConstructor) {
50  Int_t address {12345};
51  TVector3 pos {-3., 5.777, 123.765};
52  TVector3 error {0.77, 0.88, 0.99};
53  Double_t dxy {1.2};
54  Int_t refId {6};
55  Double_t eloss {123.};
56 
57  // Create object
58  CbmTrdHit test(address, pos, error, dxy, refId, eloss);
59 
61  kTRDHIT,
62  pos.Z(),
63  error.Z(),
64  refId,
65  address,
66  nullptr,
67  0.,
68  0.,
69  pos.X(),
70  error.X(),
71  pos.Y(),
72  error.Y(),
73  dxy,
74  0,
75  eloss);
76 
77 
78  CbmTrdHit* test1 = new CbmTrdHit(address, pos, error, dxy, refId, eloss);
79 
81  kTRDHIT,
82  pos.Z(),
83  error.Z(),
84  refId,
85  address,
86  nullptr,
87  0.,
88  0.,
89  pos.X(),
90  error.X(),
91  pos.Y(),
92  error.Y(),
93  dxy,
94  0,
95  eloss);
96 }
97 
98 TEST(_GTestCbmTrdHit, CheckStandardConstructorWithTime) {
99  Int_t address {12345};
100  TVector3 pos {-3., 5.777, 123.765};
101  TVector3 error {0.77, 0.88, 0.99};
102  Double_t dxy {1.2};
103  Int_t refId {6};
104  Double_t eloss {123.};
105  Double_t time {456.};
106  Double_t timeError {1.34};
107  // Create object
108  CbmTrdHit test(address, pos, error, dxy, refId, eloss, time, timeError);
109 
111  kTRDHIT,
112  pos.Z(),
113  error.Z(),
114  refId,
115  address,
116  nullptr,
117  time,
118  timeError,
119  pos.X(),
120  error.X(),
121  pos.Y(),
122  error.Y(),
123  dxy,
124  0,
125  eloss);
126 
127 
128  CbmTrdHit* test1 =
129  new CbmTrdHit(address, pos, error, dxy, refId, eloss, time, timeError);
130 
132  kTRDHIT,
133  pos.Z(),
134  error.Z(),
135  refId,
136  address,
137  nullptr,
138  time,
139  timeError,
140  pos.X(),
141  error.X(),
142  pos.Y(),
143  error.Y(),
144  dxy,
145  0,
146  eloss);
147 }
148 
149 TEST(_GTestCbmTrdHit, CheckSetBits) {
150  // Create object
151  CbmTrdHit test;
152 
154  kTRDHIT,
155  0.,
156  0.,
157  -1,
158  -1,
159  nullptr,
160  -1.,
161  -1.,
162  0.,
163  0.,
164  0.,
165  0.,
166  0.,
167  0,
168  -1.);
169 
170  test.SetMaxType(true);
172  kTRDHIT,
173  0.,
174  0.,
175  -1,
176  -1,
177  nullptr,
178  -1.,
179  -1.,
180  0.,
181  0.,
182  0.,
183  0.,
184  0.,
185  2,
186  -1.);
187 
188  test.SetClassType(true);
190  kTRDHIT,
191  0.,
192  0.,
193  -1,
194  -1,
195  nullptr,
196  -1.,
197  -1.,
198  0.,
199  0.,
200  0.,
201  0.,
202  0.,
203  3,
204  -1.);
205 
206  test.SetMaxType(false);
208  kTRDHIT,
209  0.,
210  0.,
211  -1,
212  -1,
213  nullptr,
214  -1.,
215  -1.,
216  0.,
217  0.,
218  0.,
219  0.,
220  0.,
221  1,
222  -1.);
223 
224  test.SetRowCross(true);
226  kTRDHIT,
227  0.,
228  0.,
229  -1,
230  -1,
231  nullptr,
232  -1.,
233  -1.,
234  0.,
235  0.,
236  0.,
237  0.,
238  0.,
239  5,
240  -1.);
241 
242  test.SetClassType(false);
244  kTRDHIT,
245  0.,
246  0.,
247  -1,
248  -1,
249  nullptr,
250  -1.,
251  -1.,
252  0.,
253  0.,
254  0.,
255  0.,
256  0.,
257  4,
258  -1.);
259 
260  test.SetOverFlow(true);
262  kTRDHIT,
263  0.,
264  0.,
265  -1,
266  -1,
267  nullptr,
268  -1.,
269  -1.,
270  0.,
271  0.,
272  0.,
273  0.,
274  0.,
275  12,
276  -1.);
277 
278  test.SetRowCross(false);
280  kTRDHIT,
281  0.,
282  0.,
283  -1,
284  -1,
285  nullptr,
286  -1.,
287  -1.,
288  0.,
289  0.,
290  0.,
291  0.,
292  0.,
293  8,
294  -1.);
295 
296  test.SetOverFlow(false);
298  kTRDHIT,
299  0.,
300  0.,
301  -1,
302  -1,
303  nullptr,
304  -1.,
305  -1.,
306  0.,
307  0.,
308  0.,
309  0.,
310  0.,
311  0,
312  -1.);
313 }
314 
315 TEST(_GTestCbmTrdHit, CheckSetEloss) {
316  // Create object
317  CbmTrdHit test;
318 
320  kTRDHIT,
321  0.,
322  0.,
323  -1,
324  -1,
325  nullptr,
326  -1.,
327  -1.,
328  0.,
329  0.,
330  0.,
331  0.,
332  0.,
333  0,
334  -1.);
335 
336  test.SetELoss(134.56);
338  kTRDHIT,
339  0.,
340  0.,
341  -1,
342  -1,
343  nullptr,
344  -1.,
345  -1.,
346  0.,
347  0.,
348  0.,
349  0.,
350  0.,
351  0,
352  134.56);
353 }
354 
355 TEST(_GTestCbmTrdHit, CheckToString) {
356  Int_t address {12345};
357  TVector3 pos {-3., 5.777, 123.765};
358  TVector3 error {0.77, 0.88, 0.99};
359  Double_t dxy {1.2};
360  Int_t refId {6};
361  Double_t eloss {123.};
362  Double_t time {456.};
363  Double_t timeError {1.34};
364  // Create object
365  CbmTrdHit test(address, pos, error, dxy, refId, eloss, time, timeError);
366 
368  kTRDHIT,
369  pos.Z(),
370  error.Z(),
371  refId,
372  address,
373  nullptr,
374  time,
375  timeError,
376  pos.X(),
377  error.X(),
378  pos.Y(),
379  error.Y(),
380  dxy,
381  0,
382  eloss);
383 
384 
385  EXPECT_STREQ("CbmPixelHit: address=12345 pos=(-3,5.777,123.765) "
386  "err=(0.77,0.88,0.99) dxy=1.2 refId=6\nCbmTrdHit: "
387  "time[ns]=456+-1.34 eloss=123 typ[R] RC=n Ovf=n\n",
388  test.ToString().c_str());
389 }
390 
391 
392 /*
393 TEST(_GTestCbmTrdHit , CheckCopyConstructor)
394 {
395  // Create object
396  CbmTrdHit test(5, 6.7);
397 
398  compareTrdHitDataMembers(test, 5, 6.7);
399 
400  // Create object by copy constructing
401  // test should be equal to test2 and
402  // test should not be changed
403  CbmTrdHit test2{test};
404 
405  compareTrdHitDataMembers(test2, 5, 6.7);
406 
407  // Test if the original object wasn't changed
408  compareTrdHitDataMembers(test, 5, 6.7);
409 }
410 
411 TEST(_GTestCbmTrdHit , CheckAssignmentOperator)
412 {
413  // Create object
414  CbmTrdHit test(5, 6.7);
415 
416  compareTrdHitDataMembers(test, 5, 6.7);
417 
418  // Create object by copy constructing
419  // test should be equal to test2 and
420  // test should not be changed
421  CbmTrdHit test2{};
422  test2 = test;
423 
424  compareTrdHitDataMembers(test2, 5, 6.7);
425 
426  // Test if the original object wasn't changed
427  compareTrdHitDataMembers(test, 5, 6.7);
428 }
429 
430 TEST(_GTestCbmTrdHit , CheckMoveConstructor)
431 {
432  // Create object
433  CbmTrdHit test(5, 6.7);
434 
435  compareTrdHitDataMembers(test, 5, 6.7);
436 
437  // Create object by copy constructing
438  // test should be equal to test2 and
439  // test should not be changed
440  CbmTrdHit test2{std::move(test)};
441 
442  compareTrdHitDataMembers(test2, 5, 6.7);
443 
444  // For objects with simple types move fall back to copy so
445  // the original object is kept unchanged
446  compareTrdHitDataMembers(test, 5, 6.7);
447 }
448 
449 TEST(_GTestCbmTrdHit , CheckAssignmentMoveConstructor)
450 {
451  // Create object
452  CbmTrdHit test(5, 6.7);
453 
454  compareTrdHitDataMembers(test, 5, 6.7);
455 
456  // Create object by copy constructing
457  // test should be equal to test2 and
458  // test should not be changed
459  CbmTrdHit test2{};
460  test2 = std::move(test);
461 
462  compareTrdHitDataMembers(test2, 5, 6.7);
463 
464  // For objects with simple types move fall back to copy so
465  // the original object is kept unchanged
466  compareTrdHitDataMembers(test, 5, 6.7);
467 }
468 
469 
470 
471 */
CbmTrdHit::SetELoss
void SetELoss(Double_t loss)
Definition: CbmTrdHit.h:86
CbmTrdHit
data class for a reconstructed Energy-4D measurement in the TRD
Definition: CbmTrdHit.h:35
CbmTrdHit::SetOverFlow
void SetOverFlow(Bool_t set=kTRUE)
Mark overflow in one or more digits which define the hit.
Definition: CbmTrdHit.h:88
compareTrdHit.h
CbmTrdHit.h
Class for hits in TRD detector.
CbmTrdHit::SetRowCross
void SetRowCross(Bool_t set=kTRUE)
Mark hit reconstructed between pad rows.
Definition: CbmTrdHit.h:92
kTRDHIT
@ kTRDHIT
Definition: CbmHit.h:25
TEST
TEST(_GTestCbmTrdHit, CheckDefaultConstructor)
Definition: _GTestCbmTrdHit.cxx:8
compareTrdHitDataMembers
void compareTrdHitDataMembers(CbmTrdHit &test, HitType type, Double_t z, Double_t dz, Int_t refid, Int_t address, CbmMatch *match, Double_t time, Double_t errortime, Double_t x, Double_t dx, Double_t y, Double_t dy, Double_t dxy, UChar_t define, Double_t eloss)
Definition: compareTrdHit.h:7
CbmTrdHit::SetMaxType
void SetMaxType(Bool_t set=kTRUE)
Extra bool definition for the hit (e.g. the type of maximum for triangular pads).
Definition: CbmTrdHit.h:100
CbmTrdHit::ToString
virtual std::string ToString() const
Inherited from CbmBaseHit.
Definition: CbmTrdHit.cxx:39
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
CbmTrdHit::SetClassType
void SetClassType(Bool_t set=kTRUE)
Type of pad layout used in reconstruction R[0], T[1].
Definition: CbmTrdHit.h:96