Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DummyDetectorConstruction.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DummyDetectorConstruction.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 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 "G4Box.hh"
12 #include "G4LogicalVolume.hh"
13 #include "G4Material.hh"
14 #include "G4PVPlacement.hh"
15 #include "G4RunManager.hh"
16 #include "G4ThreeVector.hh"
17 #include "QGSP_BERT.hh"
18 
19 class G4VUserPhysicsList;
20 
22  // Test if there's already a G4RunManager
23  if (G4RunManager::GetRunManager() == nullptr) {
24  G4RunManager* runManager = new G4RunManager;
25 
26  // Initialise physics
27  G4VUserPhysicsList* thePL = new QGSP_BERT;
28  runManager->SetUserInitialization(thePL);
29 
30  // Build a dummy detector
31  runManager->SetUserInitialization(new DummyDetectorConstruction());
32 
33  // Initialise the G4RunManager itself
34  runManager->Initialize();
35  return runManager;
36  } else {
37  // Return the existing G4RunManager
38  return G4RunManager::GetRunManager();
39  }
40 }
41 
43  delete (m_worldLog);
44  delete (m_worldPhys);
45 }
46 
48  G4ThreeVector materialPosition(0., 0., 0.);
49 
50  // Create the world setup
51  G4Box* worldBox = new G4Box("WorldBox", 25000., 25000., 25000.);
52 
53  // G4 material: vacuum setup
54  G4Material* g4vacuum = G4Material::GetMaterial("Vacuum", false);
55  if (g4vacuum == nullptr) {
56  g4vacuum =
57  new G4Material("FatrasDummyVacuum", 1., 1.01 * CLHEP::g / CLHEP::mole,
58  CLHEP::universe_mean_density, kStateGas,
59  0.1 * CLHEP::kelvin, 1.e-19 * CLHEP::pascal);
60  }
61 
62  // Build the logical and physical volume
63  m_worldLog = m_worldLog != nullptr
64  ? new (m_worldLog)
65  G4LogicalVolume(worldBox, g4vacuum, "WorldLogical",
66  nullptr, nullptr, nullptr)
67  : new G4LogicalVolume(worldBox, g4vacuum, "WorldLogical",
68  nullptr, nullptr, nullptr);
69  m_worldPhys =
70  m_worldPhys != nullptr
71  ? new (m_worldPhys)
72  G4PVPlacement(nullptr, G4ThreeVector(0., 0., 0),
73  "WorldPhysical", m_worldLog, nullptr, false, 0)
74  : new G4PVPlacement(nullptr, materialPosition, "WorldPhysical",
75  m_worldLog, nullptr, false, 0);
76 }
77 
79  // Construct the detector and return it
80  dummyDetector();
81  return m_worldPhys;
82 }