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
DetectorVolumeFinders.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file DetectorVolumeFinders.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2022-2023 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
#pragma once
10
11
#include "
Acts/Detector/Detector.hpp
"
12
#include "
Acts/Detector/DetectorVolume.hpp
"
13
#include "
Acts/Geometry/GeometryContext.hpp
"
14
#include "
Acts/Navigation/NavigationDelegates.hpp
"
15
#include "
Acts/Navigation/NavigationState.hpp
"
16
#include "
Acts/Navigation/NavigationStateFillers.hpp
"
17
#include "
Acts/Navigation/NavigationStateUpdators.hpp
"
18
#include "
Acts/Utilities/detail/Axis.hpp
"
19
#include "
Acts/Utilities/detail/Grid.hpp
"
20
21
#include <stdexcept>
22
23
namespace
Acts {
24
namespace
Experimental {
25
26
struct
NoopFinder
:
public
INavigationDelegate
{
27
inline
void
update
(
const
GeometryContext
&
/*gctx*/
,
28
NavigationState
&
/*nState*/
)
const
{}
29
};
30
31
struct
RootVolumeFinder
:
public
INavigationDelegate
{
32
inline
void
update
(
const
GeometryContext
&
gctx
,
33
NavigationState
&
nState
)
const
{
34
if
(nState.
currentDetector
==
nullptr
) {
35
throw
std::runtime_error(
36
"DetectorVolumeFinders: no detector set to navigation state."
);
37
}
38
39
const
auto
&
volumes
= nState.
currentDetector
->
rootVolumes
();
40
for
(
const
auto
v
:
volumes
) {
41
if
(
v
->inside(gctx, nState.
position
)) {
42
nState.
currentVolume
=
v
;
43
v
->detectorVolumeUpdator()(
gctx
,
nState
);
44
return
;
45
}
46
}
47
nState.
currentVolume
=
nullptr
;
48
}
49
};
50
51
struct
TrialAndErrorVolumeFinder
:
public
INavigationDelegate
{
52
inline
void
update
(
const
GeometryContext
&
gctx
,
53
NavigationState
&
nState
)
const
{
54
if
(nState.
currentVolume
==
nullptr
) {
55
throw
std::runtime_error(
56
"DetectorVolumeFinders: no volume set to navigation state."
);
57
}
58
59
const
auto
&
volumes
= nState.
currentVolume
->
volumes
();
60
for
(
const
auto
v
:
volumes
) {
61
if
(
v
->inside(gctx, nState.
position
)) {
62
nState.
currentVolume
=
v
;
63
v
->detectorVolumeUpdator()(
gctx
,
nState
);
64
return
;
65
}
66
}
67
}
68
};
69
71
inline
static
DetectorVolumeUpdator
tryRootVolumes
() {
72
DetectorVolumeUpdator
vFinder;
73
vFinder.connect<&
RootVolumeFinder::update
>(
74
std::make_unique<const RootVolumeFinder>());
75
return
vFinder;
76
}
77
79
inline
static
DetectorVolumeUpdator
tryAllSubVolumes
() {
80
DetectorVolumeUpdator
vFinder;
81
vFinder.connect<&
TrialAndErrorVolumeFinder::update
>(
82
std::make_unique<const TrialAndErrorVolumeFinder>());
83
return
vFinder;
84
}
85
87
inline
static
DetectorVolumeUpdator
tryNoVolumes
() {
88
DetectorVolumeUpdator
vFinder;
89
vFinder.connect<&
NoopFinder::update
>(std::make_unique<const NoopFinder>());
90
return
vFinder;
91
}
92
95
struct
IndexedDetectorVolumeExtractor
{
103
inline
static
const
DetectorVolume
*
extract
(
104
[[maybe_unused]]
const
GeometryContext
&
gctx
,
105
const
NavigationState
&
nState
,
size_t
index
) noexcept(
false
) {
106
if
(
nState
.
currentDetector
==
nullptr
) {
107
throw
std::runtime_error(
"IndexedVolumeExtractor: no detector given."
);
108
}
109
// Get the volume container from the detector
110
const
auto
&
volumes
=
nState
.
currentDetector
->
volumes
();
111
return
volumes
[
index
];
112
}
113
};
114
118
template
<
typename
gr
id
_type>
119
using
IndexedDetectorVolumeImpl
=
120
IndexedUpdatorImpl<grid_type, IndexedDetectorVolumeExtractor,
121
DetectorVolumeFiller
>;
122
123
}
// namespace Experimental
124
}
// namespace Acts
acts
blob
sPHENIX
Core
include
Acts
Navigation
DetectorVolumeFinders.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:33
using
1.8.2 with
sPHENIX GitHub integration