algorithms  2.2.0
Framework-independent algorithms for the EIC
Loading...
Searching...
No Matches
geo.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// Copyright (C) 2022 Wouter Deconinck, Sylvester Joosten
3//
4// Implementation of the geo service
5//
6#include <algorithms/geo.h>
7
8namespace algorithms {
9
10void GeoSvc::init(const dd4hep::Detector* det) {
11 if (det) {
12 info() << "Initializing geometry service from pre-initialized detector" << endmsg;
13 m_detector = det;
14 // no detector given, need to self-initialize
15 } else {
16 info() << "No external detector provided, self-initializing" << endmsg;
17 if (m_xml_list.empty()) {
18 raise<ServiceError>("No external detector provided and no compact files specified in "
19 "the 'detectors' property");
20 }
21 auto detector = dd4hep::Detector::make_unique("");
22 for (std::string_view name : m_xml_list) {
23 info() << fmt::format("Loading compact file: {}", name) << endmsg;
24 detector->fromCompact(std::string(name));
25 }
26 detector->volumeManager();
27 detector->apply("DD4hepVolumeManager", 0, nullptr);
28 m_detector_ptr = std::move(detector);
29 m_detector = m_detector_ptr.get();
30 }
31 // always: instantiate cellIDConverter
32 m_converter = std::make_unique<const dd4hep::rec::CellIDPositionConverter>(*m_detector);
33}
34} // namespace algorithms
35
void init(const dd4hep::Detector *=nullptr)
Definition geo.cpp:10
gsl::not_null< const dd4hep::Detector * > detector() const
Definition geo.h:29
static std::ostream & endmsg(std::ostream &os)
Definition logger.h:244
detail::LoggerStream info() const
Definition logger.h:198
void raise(std::string_view msg) const
Definition logger.h:238
std::string_view name() const
Definition name.h:17