diff --git a/Simulation/DetSimCore/CMakeLists.txt b/Simulation/DetSimCore/CMakeLists.txt index 7b1b227b7b5cd41eff8769c45e6a65f32b1f0438..f8a022fa826b818cc054422fb7cf3b173b2da574 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 81aab60f0dd173e752370a1eb7e0784887c28aaf..d7b29b326381f1421eb108eb15c3021b448cdff4 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 5c7371e3fb213d83df7779b2fa2350ff7dba3f89..d9c2a2f6b98606b9c6b7b20f25cf5cd2342f4932 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 0000000000000000000000000000000000000000..3f53c5807044c0e9b0f4d380bbcc6dff43041333 --- /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 0000000000000000000000000000000000000000..8418f6d4e90c3a450672c5d7be68b5d2db4b3c2b --- /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 4469d7d969bf7525fef089ce71906505e1cea21e..1eec6f6e84ca919543dcf62995c4ada9937649e4 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}