31 ATH_MSG_DEBUG(
"Initializing device detector description provider service ");
36 auto hostDesign = std::make_unique<traccc::detector_design_description::host>(*
m_MRs->hostMR());
37 auto hostCond = std::make_unique<traccc::detector_conditions_description::host>(*
m_MRs->hostMR());
39 std::unique_ptr<traccc::detector_design_description::buffer> deviceDesign;
40 std::unique_ptr<traccc::detector_conditions_description::buffer> deviceCond;
42 auto copy =
m_copy->copy(EventContext{});
49 return StatusCode::FAILURE;
59 auto hostDetector = std::make_unique<traccc::host_detector>();
60 traccc::io::read_detector(
61 *hostDetector, *
m_MRs->hostMR(),
67 std::make_unique<traccc::detector_buffer>(traccc::buffer_from_host_detector(*hostDetector,
m_MRs->mainMR(),
const_cast<vecmem::copy&
>(*copy)));
72 traccc::io::read_detector_description(
73 *hostDesign, *hostCond,
77 traccc::data_format::json);
80 << hostCond->size() <<
" conditions entries");
83 std::vector<unsigned int> sizes;
84 sizes.reserve(hostDesign->size());
85 for (std::size_t i = 0; i < hostDesign->size(); ++i) {
86 const auto& e = hostDesign->at(i);
87 sizes.push_back(
static_cast<unsigned int>(
88 std::max(e.bin_edges_x().size(), e.bin_edges_y().size())));
92 std::make_unique<traccc::detector_design_description::buffer>(
94 vecmem::data::buffer_type::resizable);
95 (*copy).setup(*deviceDesign)->wait();
96 (*copy)(vecmem::get_data(*hostDesign), *deviceDesign)->wait();
100 std::make_unique<traccc::detector_conditions_description::buffer>(
101 static_cast<traccc::detector_conditions_description::buffer::size_type
>(
104 (*copy).setup(*deviceCond)->wait();
105 (*copy)(vecmem::get_data(*hostCond), *deviceCond)->wait();
111 constexpr bool allowMods =
false;
121 return StatusCode::SUCCESS;
127 ATH_MSG_FATAL(
"MapFile not set — detray<->Athena maps will be empty");
128 return StatusCode::FAILURE;
134 if (!mapFile.is_open()) {
136 return StatusCode::FAILURE;
141 std::unordered_map<uint64_t, Identifier> detrayToAthenaFromFile;
144 while (std::getline(mapFile, line)) {
145 if (line.empty())
continue;
146 std::stringstream
ss(line);
147 std::string athenaStr, detrayStr;
148 if (!std::getline(
ss, athenaStr,
',') ||
149 !std::getline(
ss, detrayStr,
','))
continue;
151 if (athenaStr.empty()) {
152 ATH_MSG_ERROR(
"Empty Athena identifier string in map file — skipping");
153 return StatusCode::FAILURE;
157 athenaId.
set(athenaStr);
159 uint64_t detrayId = 0;
161 detrayId = std::stoull(detrayStr);
162 }
catch (
const std::exception& e) {
163 ATH_MSG_ERROR(
"Failed to parse detray identifier '" << detrayStr <<
"': " << e.what());
164 return StatusCode::FAILURE;
167 detrayToAthenaFromFile.emplace(detrayId, athenaId);
171 <<
" detray<->Athena entries from file");
176 m_idMapping = std::make_unique<ActsTrk::GeometryIdMapping>();
177 const auto& itkDetector = hostDetector->as<traccc::itk_detector>();
178 const std::size_t nSurfaces = itkDetector.surfaces().size();
181 std::size_t nMatched = 0;
182 for (
const auto& surface : itkDetector.surfaces()) {
183 const Acts::GeometryIdentifier acts_geom_id{surface.source};
185 auto sf = detray::tracking_surface{itkDetector, surface};
186 const auto detrayId = sf.identifier().value();
188 std::optional<Identifier> athenaId;
189 if (
auto it = detrayToAthenaFromFile.find(detrayId);
190 it != detrayToAthenaFromFile.end()) {
191 athenaId = it->second;
195 m_idMapping->addEntry(detrayId, acts_geom_id.value(), athenaId);
199 <<
" detray/ACTS surfaces, " << nMatched
200 <<
" matched to an Athena module");
204 return StatusCode::SUCCESS;