19 #include <unordered_map>
23 std::string name, std::vector<std::shared_ptr<DetectorVolume>> rootVolumes,
26 m_rootVolumes(std::
move(rootVolumes)),
27 m_detectorVolumeUpdator(std::
move(detectorVolumeUpdator)) {
29 throw std::invalid_argument(
"Detector: no volume were given.");
32 throw std::invalid_argument(
33 "Detector: volume finder delegate is not connected.");
37 auto collectVolumes = [&]() {
38 std::vector<std::shared_ptr<DetectorVolume>>
volumes;
39 auto recurse = [&
volumes](
const std::shared_ptr<DetectorVolume>& volume,
40 auto& callback) ->
void {
41 volumes.push_back(volume);
42 for (
const auto&
v : volume->volumePtrs()) {
43 callback(
v, callback);
47 recurse(
root, recurse);
55 std::unordered_map<GeometryIdentifier, const Surface*> surfaceGeoIdMap;
59 v->assignDetector(*
this);
65 throw std::invalid_argument(
"Detector: duplicate volume name " + vName +
70 for (
const auto*
s :
v->surfaces()) {
71 auto sgeoID =
s->geometryId();
72 if (surfaceGeoIdMap.find(sgeoID) != surfaceGeoIdMap.end()) {
75 throw std::invalid_argument(
76 "Detector: duplicate sensitive surface geometry id '" + ss.str() +
77 "' detected. Make sure a GeometryIdGenerator is used.");
79 surfaceGeoIdMap.emplace(sgeoID,
s);
83 std::vector<std::pair<GeometryIdentifier, const Surface*>> surfaceGeoIdVec;
84 surfaceGeoIdVec.reserve(surfaceGeoIdMap.size());
85 for (
auto [geoID,
surface] : surfaceGeoIdMap) {
86 surfaceGeoIdVec.emplace_back(geoID,
surface);
92 std::shared_ptr<Acts::Experimental::Detector>
94 std::string name, std::vector<std::shared_ptr<DetectorVolume>> rootVolumes,
96 return std::shared_ptr<Detector>(
101 std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>>&
103 return m_rootVolumes.internal;
106 const std::vector<const Acts::Experimental::DetectorVolume*>&
108 return m_rootVolumes.external;
111 std::vector<std::shared_ptr<Acts::Experimental::DetectorVolume>>&
113 return m_volumes.internal;
116 const std::vector<const Acts::Experimental::DetectorVolume*>&
118 return m_volumes.external;
123 m_detectorVolumeUpdator =
std::move(detectorVolumeUpdator);
128 return m_detectorVolumeUpdator;
135 std::shared_ptr<Acts::Experimental::Detector>
137 return shared_from_this();
140 std::shared_ptr<const Acts::Experimental::Detector>
142 return shared_from_this();
147 m_detectorVolumeUpdator(gctx, nState);
156 m_detectorVolumeUpdator(gctx, nState);
163 auto vCandidate = m_volumeNameIndex.find(name);
164 if (vCandidate != m_volumeNameIndex.end()) {
165 return m_volumes.external[vCandidate->second];
172 return m_sensitiveHierarchyMap;