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/Geant4Detector/GdmlDetectorConstruction.hpp"
0010 
0011 #include "ActsExamples/Geant4/Geant4ConstructionOptions.hpp"
0012 #include "ActsExamples/Geant4/RegionCreator.hpp"
0013 
0014 #include <utility>
0015 
0016 #include <G4GDMLParser.hh>
0017 
0018 namespace ActsExamples {
0019 
0020 GdmlDetectorConstruction::GdmlDetectorConstruction(
0021     std::string path, const Geant4ConstructionOptions& options)
0022     : G4VUserDetectorConstruction(),
0023       m_path(std::move(path)),
0024       m_options(options) {}
0025 
0026 G4VPhysicalVolume* GdmlDetectorConstruction::Construct() {
0027   if (m_world == nullptr) {
0028     G4GDMLParser parser;
0029     // TODO how to handle errors
0030     parser.Read(m_path);
0031     m_world = parser.GetWorldVolume();
0032 
0033     // Create regions
0034     for (const auto& regionCreator : m_options.regionCreators) {
0035       regionCreator->buildRegion();
0036     }
0037   }
0038   return m_world;
0039 }
0040 
0041 }  // namespace ActsExamples