Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
HitTests.cpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file HitTests.cpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2020 CERN for the benefit of the Acts project
4
//
5
// This Source Code Form is subject to the terms of the Mozilla Public
6
// License, v. 2.0. If a copy of the MPL was not distributed with this
7
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
#include <boost/test/unit_test.hpp>
10
11
#include "
Acts/Geometry/GeometryIdentifier.hpp
"
12
#include "
Acts/Tests/CommonHelpers/FloatComparisons.hpp
"
13
#include "
ActsFatras/EventData/Barcode.hpp
"
14
#include "
ActsFatras/EventData/Hit.hpp
"
15
16
#include <limits>
17
18
using namespace
ActsFatras;
19
20
namespace
{
21
constexpr
auto
eps
= std::numeric_limits<Hit::Scalar>::epsilon();
22
const
auto
pid
=
Barcode
().
setVertexPrimary
(12).
setParticle
(23);
23
const
auto
gid
=
24
Acts::GeometryIdentifier
().
setVolume
(1).
setLayer
(2).
setSensitive
(3);
25
}
// namespace
26
27
BOOST_AUTO_TEST_SUITE(FatrasHit)
28
29
BOOST_AUTO_TEST_CASE
(WithoutInteraction) {
30
// some hit position
31
auto
p4 =
Hit::Vector4
(1, 2, 3, 4);
32
// before/after four-momenta are the same
33
auto
m4 =
Hit::Vector4
(1, 1, 1, 4);
34
auto
h
=
Hit
(
gid
,
pid
, p4, m4, m4, 12
u
);
35
36
BOOST_CHECK_EQUAL(
h
.geometryId(),
gid
);
37
BOOST_CHECK_EQUAL(
h
.particleId(),
pid
);
38
BOOST_CHECK_EQUAL(
h
.index(), 12
u
);
39
CHECK_CLOSE_REL
(
h
.fourPosition(), p4,
eps
);
40
CHECK_CLOSE_REL
(
h
.position(),
Hit::Vector3
(1, 2, 3),
eps
);
41
CHECK_CLOSE_REL
(
h
.time(), 4,
eps
);
42
CHECK_CLOSE_REL
(
h
.momentum4Before(), m4,
eps
);
43
CHECK_CLOSE_REL
(
h
.momentum4After(), m4,
eps
);
44
CHECK_CLOSE_REL
(
h
.directionBefore(),
Hit::Vector3
(1, 1, 1).normalized(),
eps
);
45
CHECK_CLOSE_REL
(
h
.directionAfter(),
Hit::Vector3
(1, 1, 1).normalized(),
eps
);
46
CHECK_CLOSE_REL
(
h
.direction(),
Hit::Vector3
(1, 1, 1).normalized(),
eps
);
47
CHECK_SMALL
(
h
.depositedEnergy(),
eps
);
48
}
49
50
BOOST_AUTO_TEST_CASE
(WithEnergyLoss) {
51
// some hit position
52
auto
p4 =
Hit::Vector4
(1, 2, 3, 4);
53
// before/after four-momenta differ by energy loss, use zero mass to simplify
54
auto
m40 =
Hit::Vector4
(2, 0, 0, 2);
55
auto
m41 =
Hit::Vector4
(1.5, 0, 0, 1.5);
56
auto
h
=
Hit
(
gid
,
pid
, p4, m40, m41, 13
u
);
57
58
BOOST_CHECK_EQUAL(
h
.geometryId(),
gid
);
59
BOOST_CHECK_EQUAL(
h
.particleId(),
pid
);
60
BOOST_CHECK_EQUAL(
h
.index(), 13
u
);
61
CHECK_CLOSE_REL
(
h
.fourPosition(), p4,
eps
);
62
CHECK_CLOSE_REL
(
h
.position(),
Hit::Vector3
(1, 2, 3),
eps
);
63
CHECK_CLOSE_REL
(
h
.time(), 4,
eps
);
64
CHECK_CLOSE_OR_SMALL
(
h
.momentum4Before(), m40,
eps
,
eps
);
65
CHECK_CLOSE_OR_SMALL
(
h
.momentum4After(), m41,
eps
,
eps
);
66
CHECK_CLOSE_OR_SMALL
(
h
.directionBefore(),
Hit::Vector3
(1, 0, 0),
eps
,
eps
);
67
CHECK_CLOSE_OR_SMALL
(
h
.directionAfter(),
Hit::Vector3
(1, 0, 0),
eps
,
eps
);
68
CHECK_CLOSE_OR_SMALL
(
h
.direction(),
Hit::Vector3
(1, 0, 0),
eps
,
eps
);
69
CHECK_CLOSE_REL
(
h
.depositedEnergy(), 0.5,
eps
);
70
}
71
72
BOOST_AUTO_TEST_CASE
(WithScattering) {
73
// some hit position
74
auto
p4 =
Hit::Vector4
(1, 2, 3, 4);
75
// before/after four-momenta differ only by direction
76
auto
m40 =
Hit::Vector4
(2, 0, 2, 5);
77
auto
m41 =
Hit::Vector4
(0, -2, 2, 5);
78
auto
h
=
Hit
(
gid
,
pid
, p4, m40, m41, 42
u
);
79
80
BOOST_CHECK_EQUAL(
h
.geometryId(),
gid
);
81
BOOST_CHECK_EQUAL(
h
.particleId(),
pid
);
82
BOOST_CHECK_EQUAL(
h
.index(), 42
u
);
83
CHECK_CLOSE_REL
(
h
.fourPosition(), p4,
eps
);
84
CHECK_CLOSE_REL
(
h
.position(),
Hit::Vector3
(1, 2, 3),
eps
);
85
CHECK_CLOSE_REL
(
h
.time(), 4,
eps
);
86
CHECK_CLOSE_OR_SMALL
(
h
.momentum4Before(), m40,
eps
,
eps
);
87
CHECK_CLOSE_OR_SMALL
(
h
.momentum4After(), m41,
eps
,
eps
);
88
CHECK_CLOSE_OR_SMALL
(
h
.directionBefore(),
Hit::Vector3
(1, 0, 1).normalized(),
89
eps
,
eps
);
90
CHECK_CLOSE_OR_SMALL
(
h
.directionAfter(),
Hit::Vector3
(0, -1, 1).normalized(),
91
eps
,
eps
);
92
CHECK_CLOSE_REL
(
h
.direction(),
Hit::Vector3
(1, -1, 2).normalized(),
eps
);
93
CHECK_SMALL
(
h
.depositedEnergy(),
eps
);
94
}
95
96
BOOST_AUTO_TEST_CASE
(WithEverything) {
97
// some hit position
98
auto
p4 =
Hit::Vector4
(1, 2, 3, 4);
99
// before/after four-momenta differ by direction and norm
100
auto
m40 =
Hit::Vector4
(3, 2, 2, 5);
101
auto
m41 =
Hit::Vector4
(2, 1, 2, 4);
102
auto
h
=
Hit
(
gid
,
pid
, p4, m40, m41, 1
u
);
103
104
BOOST_CHECK_EQUAL(
h
.geometryId(),
gid
);
105
BOOST_CHECK_EQUAL(
h
.particleId(),
pid
);
106
BOOST_CHECK_EQUAL(
h
.index(), 1
u
);
107
CHECK_CLOSE_REL
(
h
.fourPosition(), p4,
eps
);
108
CHECK_CLOSE_REL
(
h
.position(),
Hit::Vector3
(1, 2, 3),
eps
);
109
CHECK_CLOSE_REL
(
h
.time(), 4,
eps
);
110
CHECK_CLOSE_OR_SMALL
(
h
.momentum4Before(), m40,
eps
,
eps
);
111
CHECK_CLOSE_OR_SMALL
(
h
.momentum4After(), m41,
eps
,
eps
);
112
CHECK_CLOSE_REL
(
h
.directionBefore(),
Hit::Vector3
(3, 2, 2).normalized(),
eps
);
113
CHECK_CLOSE_REL
(
h
.directionAfter(),
Hit::Vector3
(2, 1, 2).normalized(),
eps
);
114
CHECK_CLOSE_REL
(
115
h
.direction(),
116
Hit::Vector3
(0.7023994590205035, 0.41229136135810396, 0.5802161953247991),
117
eps
);
118
CHECK_CLOSE_REL
(
h
.depositedEnergy(), 1,
eps
);
119
}
120
121
BOOST_AUTO_TEST_SUITE_END()
acts
blob
sPHENIX
Tests
UnitTests
Fatras
EventData
HitTests.cpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:45
using
1.8.2 with
sPHENIX GitHub integration