Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:44

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "ActsExamples/DD4hepDetector/DDG4DetectorConstruction.hpp"
0010 
0011 #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp"
0012 #include "ActsExamples/Geant4/RegionCreator.hpp"
0013 
0014 #include <DD4hep/DetElement.h>
0015 #include <DD4hep/Detector.h>
0016 #include <DDG4/Geant4Converter.h>
0017 #include <DDG4/Geant4GeometryInfo.h>
0018 #include <DDG4/Geant4Mapping.h>
0019 
0020 class G4VPhysicalVolume;
0021 
0022 namespace ActsExamples {
0023 
0024 DDG4DetectorConstruction::DDG4DetectorConstruction(
0025     std::shared_ptr<dd4hep::Detector> detector,
0026     const Geant4ConstructionOptions& options)
0027     : m_detector(std::move(detector)), m_options(options) {}
0028 
0029 // See DD4hep::Simulation::Geant4DetectorConstruction::Construct()
0030 G4VPhysicalVolume* DDG4DetectorConstruction::Construct() {
0031   if (m_world == nullptr) {
0032     dd4hep::sim::Geant4Mapping g4map(*m_detector);
0033     dd4hep::sim::Geant4Converter g4conv(*m_detector,
0034                                         dd4hep::PrintLevel::VERBOSE);
0035     dd4hep::sim::Geant4GeometryInfo* geoInfo =
0036         g4conv.create(m_detector->world()).detach();
0037     g4map.attach(geoInfo);
0038     // All volumes are deleted in ~G4PhysicalVolumeStore()
0039     m_world = geoInfo->world();
0040     // Create Geant4 volume manager
0041     g4map.volumeManager();
0042 
0043     // Create regions
0044     for (const auto& regionCreator : m_options.regionCreators) {
0045       regionCreator->buildRegion();
0046     }
0047   }
0048 
0049   return m_world;
0050 }
0051 
0052 }  // namespace ActsExamples