ECCE @ 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 
30  m_lcdd = &(dd4hep::Detector::getInstance());
31  for (auto& file : m_cfg.xmlFileNames) {
32  m_lcdd->fromCompact(file.c_str());
33  }
34  m_lcdd->volumeManager();
35  m_lcdd->apply("DD4hepVolumeManager", 0, 0);
36  m_dd4hepGeometry = m_lcdd->world();
37 
39 }
40 
42  if (!m_dd4hepGeometry)
43  buildDD4hepGeometry();
44  return m_dd4hepGeometry;
45 }
46 
47 dd4hep::Detector*
48 FW::DD4hep::DD4hepGeometryService::DD4hepGeometryService::lcdd() {
49  if (!m_lcdd)
50  buildDD4hepGeometry();
51  return m_lcdd;
52 }
53 
55  if (!m_dd4hepGeometry)
56  buildDD4hepGeometry();
57  return m_dd4hepGeometry.placement().ptr();
58 }
59 
61  const Acts::GeometryContext& gctx) {
62  // Set the tracking geometry
63  m_trackingGeometry = Acts::convertDD4hepDetector(
64  dd4hepGeometry(), m_cfg.logLevel, m_cfg.bTypePhi, m_cfg.bTypeR,
65  m_cfg.bTypeZ, m_cfg.envelopeR, m_cfg.envelopeZ,
66  m_cfg.defaultLayerThickness, m_cfg.sortDetectors, gctx,
67  m_cfg.matDecorator);
69 }
70 
71 std::unique_ptr<const Acts::TrackingGeometry>
73  const Acts::GeometryContext& gctx) {
74  if (!m_trackingGeometry) {
75  buildTrackingGeometry(gctx);
76  }
77  return std::move(m_trackingGeometry);
78 }