Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:12

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 "ActsFatras/Geant4/DummyDetectorConstruction.hpp"
0010 
0011 #include "G4Box.hh"
0012 #include "G4LogicalVolume.hh"
0013 #include "G4Material.hh"
0014 #include "G4PVPlacement.hh"
0015 #include "G4RunManager.hh"
0016 #include "G4ThreeVector.hh"
0017 #include "QGSP_BERT.hh"
0018 
0019 class G4VUserPhysicsList;
0020 
0021 G4RunManager* ActsFatras::ensureGeant4RunManager() {
0022   // Test if there's already a G4RunManager
0023   if (G4RunManager::GetRunManager() == nullptr) {
0024     G4RunManager* runManager = new G4RunManager;
0025 
0026     // Initialise physics
0027     G4VUserPhysicsList* thePL = new QGSP_BERT;
0028     runManager->SetUserInitialization(thePL);
0029 
0030     // Build a dummy detector
0031     runManager->SetUserInitialization(new DummyDetectorConstruction());
0032 
0033     // Initialise the G4RunManager itself
0034     runManager->Initialize();
0035     return runManager;
0036   } else {
0037     // Return the existing G4RunManager
0038     return G4RunManager::GetRunManager();
0039   }
0040 }
0041 
0042 ActsFatras::DummyDetectorConstruction::~DummyDetectorConstruction() {
0043   delete (m_worldLog);
0044   delete (m_worldPhys);
0045 }
0046 
0047 void ActsFatras::DummyDetectorConstruction::dummyDetector() {
0048   G4ThreeVector materialPosition(0., 0., 0.);
0049 
0050   // Create the world setup
0051   G4Box* worldBox = new G4Box("WorldBox", 25000., 25000., 25000.);
0052 
0053   // G4 material: vacuum setup
0054   G4Material* g4vacuum = G4Material::GetMaterial("Vacuum", false);
0055   if (g4vacuum == nullptr) {
0056     g4vacuum =
0057         new G4Material("FatrasDummyVacuum", 1., 1.01 * CLHEP::g / CLHEP::mole,
0058                        CLHEP::universe_mean_density, kStateGas,
0059                        0.1 * CLHEP::kelvin, 1.e-19 * CLHEP::pascal);
0060   }
0061 
0062   // Build the logical and physical volume
0063   m_worldLog = m_worldLog != nullptr
0064                    ? new (m_worldLog)
0065                          G4LogicalVolume(worldBox, g4vacuum, "WorldLogical",
0066                                          nullptr, nullptr, nullptr)
0067                    : new G4LogicalVolume(worldBox, g4vacuum, "WorldLogical",
0068                                          nullptr, nullptr, nullptr);
0069   m_worldPhys =
0070       m_worldPhys != nullptr
0071           ? new (m_worldPhys)
0072                 G4PVPlacement(nullptr, G4ThreeVector(0., 0., 0),
0073                               "WorldPhysical", m_worldLog, nullptr, false, 0)
0074           : new G4PVPlacement(nullptr, materialPosition, "WorldPhysical",
0075                               m_worldLog, nullptr, false, 0);
0076 }
0077 
0078 G4VPhysicalVolume* ActsFatras::DummyDetectorConstruction::Construct() {
0079   // Construct the detector and return it
0080   dummyDetector();
0081   return m_worldPhys;
0082 }