Back to home page

EIC code displayed by LXR

 
 

    


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

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/GeoModelDetector/GeoModelGeant4DetectorConstruction.hpp"
0010 
0011 #include "ActsExamples/Geant4/Geant4ConstructionOptions.hpp"
0012 #include "ActsExamples/Geant4/RegionCreator.hpp"
0013 
0014 #include <G4LogicalVolume.hh>
0015 #include <G4PVPlacement.hh>
0016 #include <G4ThreeVector.hh>
0017 #include <G4VPhysicalVolume.hh>
0018 #include <GeoModel2G4/ExtParameterisedVolumeBuilder.h>
0019 #include <GeoModelKernel/GeoFullPhysVol.h>
0020 
0021 namespace ActsExamples {
0022 
0023 GeoModelGeant4DetectorConstruction::GeoModelGeant4DetectorConstruction(
0024     const Acts::GeoModelTree& geoModelTree,
0025     const Geant4ConstructionOptions& options)
0026     : G4VUserDetectorConstruction(),
0027       m_geoModelTree(geoModelTree),
0028       m_options(options) {
0029   if (geoModelTree.worldVolume == nullptr) {
0030     throw std::invalid_argument(
0031         "GeoModelGeant4DetectorConstruction: "
0032         "GeoModel world volume is nullptr");
0033   }
0034 }
0035 
0036 G4VPhysicalVolume* GeoModelGeant4DetectorConstruction::Construct() {
0037   if (m_g4World == nullptr) {
0038     ExtParameterisedVolumeBuilder builder(m_geoModelTree.worldVolumeName);
0039     G4LogicalVolume* g4WorldLog = builder.Build(m_geoModelTree.worldVolume);
0040     m_g4World =
0041         new G4PVPlacement(nullptr, G4ThreeVector(), g4WorldLog,
0042                           m_geoModelTree.worldVolumeName, nullptr, false, 0);
0043 
0044     // Create regions
0045     for (const auto& regionCreator : m_options.regionCreators) {
0046       regionCreator->buildRegion();
0047     }
0048   }
0049   return m_g4World;
0050 }
0051 
0052 }  // namespace ActsExamples