17 #include "Acts/Geometry/TrackingGeometry.hpp"
29 return StatusCode::SUCCESS;
35 if (volumeIdTodetectorElementCollMap.isValid()) {
36 return StatusCode::SUCCESS;
42 ATH_CHECK( acts_tracking_geometry !=
nullptr);
44 std::unique_ptr<ActsTrk::ActsVolumeIdToDetectorElementCollectionMap>
45 volume_id_to_detector_element_collection_map = std::make_unique<ActsTrk::ActsVolumeIdToDetectorElementCollectionMap>();
48 std::unordered_map<unsigned long long, unsigned int> detector_element_to_volume_id;
50 detector_element_to_volume_id);
55 volumeIdTodetectorElementCollMap.addDependency(det_ele_col);
57 unsigned int vol_id = detector_element_to_volume_id.at(det_ele->identify().get_compact());
63 for (
unsigned char col_i : volume_id_to_detector_element_collection_map->
collecionMap()) {
65 ATH_MSG_DEBUG(
"Mapping " << vol_i <<
" -> " <<
static_cast<unsigned int>(col_i)
66 <<
" : " <<
static_cast<const void *
>(volume_id_to_detector_element_collection_map->
collection(vol_i)));
72 ATH_CHECK( volumeIdTodetectorElementCollMap.record( std::move(volume_id_to_detector_element_collection_map) ) );
74 return StatusCode::SUCCESS;
79 std::unordered_map<
unsigned long long,
80 unsigned int> &detector_element_to_volume_id)
83 using Counter =
struct {
unsigned int n_detector_elements, n_missing_detector_elements, n_wrong_type; };
85 acts_tracking_geometry.visitSurfaces([&
counter, &detector_element_to_volume_id](
const Acts::Surface *surface_ptr) {
86 if (!surface_ptr)
return;
87 const Acts::Surface &surface = *surface_ptr;
88 const Acts::DetectorElementBase*detector_element = surface.associatedDetectorElement();
89 if (detector_element) {
91 if (acts_detector_element) {
93 if(trk_detector_element !=
nullptr) {
94 detector_element_to_volume_id.insert( std::make_pair( trk_detector_element->identify().get_compact(), surface.geometryId().volume()));
106 ++
counter.n_missing_detector_elements;
110 ATH_MSG_DEBUG(
"Surfaces without associated detector elements " <<
counter.n_missing_detector_elements
111 <<
" (with " <<
counter.n_detector_elements <<
")" );
112 if (
counter.n_detector_elements==0) {
113 ATH_MSG_ERROR(
"No surface with associated detector element" );
116 ATH_MSG_WARNING(
"Surfaces associated to detector elements not of type Trk::TrkDetElementBase :" <<
counter.n_wrong_type);