ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeoConstruction.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GeoConstruction.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 
11 #include <stdexcept>
12 
13 #include "DD4hep/Detector.h"
14 #include "DD4hep/Plugins.h"
15 #include "DDG4/Geant4Converter.h"
16 
17 namespace FW {
18 namespace DD4hepG4 {
19 GeoConstruction::GeoConstruction(dd4hep::Detector& lcdd) : m_lcdd(lcdd) {}
20 
21 // method borrowed from
22 // DD4hep::Simulation::Geant4DetectorConstruction::Construct()
24  dd4hep::sim::Geant4Mapping& g4map = dd4hep::sim::Geant4Mapping::instance();
25  dd4hep::DetElement world = m_lcdd.world();
26  dd4hep::sim::Geant4Converter conv(m_lcdd, dd4hep::INFO);
27  dd4hep::sim::Geant4GeometryInfo* geo_info = conv.create(world).detach();
28  g4map.attach(geo_info);
29  // All volumes are deleted in ~G4PhysicalVolumeStore()
30  G4VPhysicalVolume* m_world = geo_info->world();
31  m_lcdd.apply("DD4hepVolumeManager", 0, 0);
32  // Create Geant4 volume manager
33  g4map.volumeManager();
34  return m_world;
35 }
36 } // namespace DD4hepG4
37 } // namespace FW