algorithms  2.2.0
Framework-independent algorithms for the EIC
Loading...
Searching...
No Matches
geo.h
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// DD4hep Geometry service exposing a detector(), world(), and cellIDPositionConverter()
5// Meant to be set by the calling framework, but can also load DD4hep itself
6// when given a compact file as Property.
7//
8#pragma once
9
10#include <gsl/gsl>
11#include <memory>
12
13#include "DDRec/CellIDPositionConverter.h"
14#include <DD4hep/Detector.h>
15
16#include <algorithms/logger.h>
17#include <algorithms/service.h>
18
19namespace algorithms {
20
21class GeoSvc : public LoggedService<GeoSvc> {
22public:
23 // Initialize the geometry service, to be called after with a global detector
24 // pointer (will not re-initialize), or after at least the detectors property was specified
25 // (will load XML and then fully initialize)
26 void init(const dd4hep::Detector* = nullptr);
27
28 // TODO check const-ness
29 gsl::not_null<const dd4hep::Detector*> detector() const { return m_detector; }
30 dd4hep::DetElement world() const { return detector()->world(); }
31 gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> cellIDPositionConverter() const {
32 return m_converter.get();
33 }
34
35private:
36 const dd4hep::Detector* m_detector = nullptr;
37 std::unique_ptr<const dd4hep::Detector> m_detector_ptr;
38 std::unique_ptr<const dd4hep::rec::CellIDPositionConverter> m_converter;
39
40 // Configuration variables. These only need to be specified if we are actually running
41 // in "standalone" mode (hence they're optional)
42 Property<std::vector<std::string>> m_xml_list{
43 this, "detectors", {}, "List of DD4hep compact files for standalone operation"};
44
46};
47
48} // namespace algorithms
void init(const dd4hep::Detector *=nullptr)
Definition geo.cpp:10
dd4hep::DetElement world() const
Definition geo.h:30
gsl::not_null< const dd4hep::Detector * > detector() const
Definition geo.h:29
gsl::not_null< const dd4hep::rec::CellIDPositionConverter * > cellIDPositionConverter() const
Definition geo.h:31
LoggedService(std::string_view name)
Definition logger.h:273
#define ALGORITHMS_DEFINE_LOGGED_SERVICE(className)
Definition logger.h:278