forked from acts-project/traccc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticle.hpp
104 lines (85 loc) · 2.81 KB
/
particle.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
#pragma once
// traccc include(s).
#include "traccc/definitions/primitives.hpp"
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/edm/track_parameters.hpp"
// detray include(s).
#include <detray/definitions/pdg_particle.hpp>
// System include(s).
#include <stdexcept>
namespace traccc {
namespace detail {
template <typename scalar_t>
TRACCC_HOST_DEVICE inline detray::pdg_particle<scalar_t>
particle_from_pdg_number(const int pdg_num) {
switch (pdg_num) {
case 11:
return detray::electron<scalar_t>();
case -11:
return detray::positron<scalar_t>();
case 13:
return detray::muon<scalar_t>();
case -13:
return detray::antimuon<scalar_t>();
case 211:
return detray::pion_plus<scalar_t>();
case -211:
return detray::pion_minus<scalar_t>();
}
// TODO: Replace with `detray::invalid` in the future
return detray::pdg_particle<scalar_t>(0, 0.f, 0.f);
}
// Apply the charge operator to return the antimatter
template <typename scalar_t>
TRACCC_HOST_DEVICE inline detray::pdg_particle<scalar_t> charge_conjugation(
const detray::pdg_particle<scalar_t>& ptc) {
const auto pdg_num = ptc.pdg_num();
switch (pdg_num) {
case 11:
return detray::positron<scalar_t>();
case -11:
return detray::electron<scalar_t>();
case 13:
return detray::antimuon<scalar_t>();
case -13:
return detray::muon<scalar_t>();
case 211:
return detray::pion_minus<scalar_t>();
case -211:
return detray::pion_plus<scalar_t>();
}
// TODO: Replace with `detray::invalid` in the future
return detray::pdg_particle<scalar_t>(0, 0.f, 0.f);
}
// Return the consistent particle type based on the particle hypothesis and the
// charge of the track parameters
template <typename scalar_t>
TRACCC_HOST_DEVICE inline detray::pdg_particle<scalar_t>
correct_particle_hypothesis(
const detray::pdg_particle<scalar_t>& ptc_hypothesis,
const bound_track_parameters& params) {
if (ptc_hypothesis.charge() * params.qop() > 0.f) {
return ptc_hypothesis;
} else {
return charge_conjugation(ptc_hypothesis);
}
}
template <typename scalar_t>
TRACCC_HOST_DEVICE inline detray::pdg_particle<scalar_t>
correct_particle_hypothesis(
const detray::pdg_particle<scalar_t>& ptc_hypothesis,
const free_track_parameters& params) {
if (ptc_hypothesis.charge() * params.qop() > 0.f) {
return ptc_hypothesis;
} else {
return charge_conjugation(ptc_hypothesis);
}
}
} // namespace detail
} // namespace traccc