EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DD4hepGeometryService.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DD4hepGeometryService.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
19 
22  : BareService("DD4hepGeometryService", cfg.logLevel), m_cfg(cfg) {}
23 
25  if (m_lcdd)
26  m_lcdd->destroyInstance();
27 }
28 
31  m_lcdd = &(dd4hep::Detector::getInstance());
32  for (auto& file : m_cfg.xmlFileNames) {
33  m_lcdd->fromCompact(file.c_str());
34  }
35  m_lcdd->volumeManager();
36  m_lcdd->apply("DD4hepVolumeManager", 0, 0);
37  m_dd4hepGeometry = m_lcdd->world();
38 
40 }
41 
42 dd4hep::DetElement
44  if (!m_dd4hepGeometry)
45  buildDD4hepGeometry();
46  return m_dd4hepGeometry;
47 }
48 
49 dd4hep::Detector*
50 ActsExamples::DD4hep::DD4hepGeometryService::DD4hepGeometryService::lcdd() {
51  if (!m_lcdd)
52  buildDD4hepGeometry();
53  return m_lcdd;
54 }
55 
57  if (!m_dd4hepGeometry)
58  buildDD4hepGeometry();
59  return m_dd4hepGeometry.placement().ptr();
60 }
61 
64  const Acts::GeometryContext& gctx) {
65  // Set the tracking geometry
66  m_trackingGeometry = Acts::convertDD4hepDetector(
67  dd4hepGeometry(), m_cfg.logLevel, m_cfg.bTypePhi, m_cfg.bTypeR,
68  m_cfg.bTypeZ, m_cfg.envelopeR, m_cfg.envelopeZ,
69  m_cfg.defaultLayerThickness, m_cfg.sortDetectors, gctx,
70  m_cfg.matDecorator);
72 }
73 
74 std::unique_ptr<const Acts::TrackingGeometry>
76  const Acts::GeometryContext& gctx) {
77  if (!m_trackingGeometry) {
78  buildTrackingGeometry(gctx);
79  }
80  return std::move(m_trackingGeometry);
81 }