From aa22f37a685eaaa6b0ddf3b87350cb066c5feb85 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Fri, 9 Aug 2019 10:47:33 +0800 Subject: [PATCH] WIP: add the dummy detector construction and a physics list. --- Simulation/DetSimCore/CMakeLists.txt | 3 +- Simulation/DetSimCore/src/DetSimAlg.cpp | 19 +++++- Simulation/DetSimCore/src/DetSimAlg.h | 1 + .../DetSimCore/src/DetectorConstruction.cpp | 63 +++++++++++++++++++ .../DetSimCore/src/DetectorConstruction.h | 25 ++++++++ Simulation/DetSimInterface/CMakeLists.txt | 2 +- 6 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 Simulation/DetSimCore/src/DetectorConstruction.cpp create mode 100644 Simulation/DetSimCore/src/DetectorConstruction.h diff --git a/Simulation/DetSimCore/CMakeLists.txt b/Simulation/DetSimCore/CMakeLists.txt index 7b1b227b..f8a022fa 100644 --- a/Simulation/DetSimCore/CMakeLists.txt +++ b/Simulation/DetSimCore/CMakeLists.txt @@ -9,7 +9,8 @@ find_package(Geant4) include(${Geant4_USE_FILE}) set(DetSimCore_srcs - src/*.cpp + src/DetSimAlg.cpp + src/DetectorConstruction.cpp ) gaudi_add_module(DetSimCore ${DetSimCore_srcs} diff --git a/Simulation/DetSimCore/src/DetSimAlg.cpp b/Simulation/DetSimCore/src/DetSimAlg.cpp index 81aab60f..d7b29b32 100644 --- a/Simulation/DetSimCore/src/DetSimAlg.cpp +++ b/Simulation/DetSimCore/src/DetSimAlg.cpp @@ -2,6 +2,11 @@ #include "G4RunManager.hh" +#include "DetectorConstruction.h" + +#include "G4PhysListFactory.hh" + + DECLARE_COMPONENT(DetSimAlg) DetSimAlg::DetSimAlg(const std::string& name, ISvcLocator* pSvcLocator) @@ -28,8 +33,18 @@ DetSimAlg::initialize() { return StatusCode::FAILURE; } - runmgr->SetUserInitialization((G4VUserDetectorConstruction*)0); - runmgr->SetUserInitialization((G4VUserPhysicsList*)0); + runmgr->SetUserInitialization(new DetectorConstruction()); + + G4VUserPhysicsList *physicsList = nullptr; + if (m_physics_lists_name.value() == "CEPC") { + + } else { + G4PhysListFactory *physListFactory = new G4PhysListFactory(); + physicsList = physListFactory->GetReferencePhysList(m_physics_lists_name.value()); + } + assert(physicsList); + runmgr->SetUserInitialization(physicsList); + runmgr->SetUserAction((G4VUserPrimaryGeneratorAction*)0); // after set up the user initialization and user actions, start the initialization. diff --git a/Simulation/DetSimCore/src/DetSimAlg.h b/Simulation/DetSimCore/src/DetSimAlg.h index 5c7371e3..d9c2a2f6 100644 --- a/Simulation/DetSimCore/src/DetSimAlg.h +++ b/Simulation/DetSimCore/src/DetSimAlg.h @@ -26,6 +26,7 @@ private: Gaudi::Property<std::vector<std::string>> m_run_cmds{this, "RunCmds"}; Gaudi::Property<std::vector<std::string>> m_vis_macs{this, "VisMacs"}; + Gaudi::Property<std::string> m_physics_lists_name{this, "PhysicsList", "QGSP_BERT"}; private: int i_event; }; diff --git a/Simulation/DetSimCore/src/DetectorConstruction.cpp b/Simulation/DetSimCore/src/DetectorConstruction.cpp new file mode 100644 index 00000000..3f53c580 --- /dev/null +++ b/Simulation/DetSimCore/src/DetectorConstruction.cpp @@ -0,0 +1,63 @@ +#include "DetectorConstruction.h" + +#include "G4SystemOfUnits.hh" +#include "G4PhysicalConstants.hh" + +#include "G4Isotope.hh" +#include "G4Element.hh" +#include "G4MaterialPropertiesTable.hh" + +#include "G4Box.hh" +#include "G4Sphere.hh" +#include "G4Tubs.hh" +#include "G4LogicalVolume.hh" +#include "G4PVPlacement.hh" +#include "G4SDManager.hh" +#include "G4Region.hh" +#include "G4RegionStore.hh" +#include "G4LogicalBorderSurface.hh" +#include "G4PhysicalVolumeStore.hh" +#include "G4OpticalSurface.hh" + +#include "G4VisAttributes.hh" +#include "G4Colour.hh" + +#include "G4ios.hh" + + +DetectorConstruction::DetectorConstruction() { + +} + +DetectorConstruction::~DetectorConstruction() { + +} + +G4VPhysicalVolume* +DetectorConstruction::Construct() { + // ======================================================================= + // Materials + // ======================================================================= + bool any_warnings = false; + + G4Material* Galactic = G4Material::GetMaterial("Galactic", any_warnings); + if (not Galactic) { + Galactic = new G4Material("Galactic", 1., 1.01*g/mole, universe_mean_density, kStateGas, 2.73*kelvin, 3.e-18*pascal); + } + + + // ======================================================================= + // World + // ======================================================================= + G4VSolid* solidWorld= new G4Box("sWorld", 60*m, 60*m, 60*m); + G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Galactic, "lWorld", 0, 0, 0); + G4VPhysicalVolume* physiWorld = new G4PVPlacement(0, // no rotation + G4ThreeVector(), // at (0,0,0) + logicWorld, // its logical volume + "pWorld", // its name + 0, // its mother volume + false, // no boolean operations + 0); // no field specific to volume + + return physiWorld; +} diff --git a/Simulation/DetSimCore/src/DetectorConstruction.h b/Simulation/DetSimCore/src/DetectorConstruction.h new file mode 100644 index 00000000..8418f6d4 --- /dev/null +++ b/Simulation/DetSimCore/src/DetectorConstruction.h @@ -0,0 +1,25 @@ +#ifndef DetectorConstruction_h +#define DetectorConstruction_h + +#include "globals.hh" +#include "G4VUserDetectorConstruction.hh" +#include "G4OpticalSurface.hh" +#include "G4Material.hh" + +// A concrete detector construction class. +// The base class is Geant4's G4VUserDetectorConstruction only. +// Another Gaudi tool is used to configure & create this object. + +class DetectorConstruction: public G4VUserDetectorConstruction { + +public: + DetectorConstruction(); + ~DetectorConstruction(); +public: + G4VPhysicalVolume* Construct(); + +private: + +}; + +#endif diff --git a/Simulation/DetSimInterface/CMakeLists.txt b/Simulation/DetSimInterface/CMakeLists.txt index 4469d7d9..1eec6f6e 100644 --- a/Simulation/DetSimInterface/CMakeLists.txt +++ b/Simulation/DetSimInterface/CMakeLists.txt @@ -3,7 +3,7 @@ gaudi_subdir(DetSimInterface v0r0) # DetSimInterface (headers only) set(DetSimInterface_srcs - src/*.cpp + src/IDetSimSvc.cpp ) gaudi_add_library(DetSimInterface ${DetSimInterface_srcs} -- GitLab