diff --git a/Examples/options/tut_detsim.py b/Examples/options/tut_detsim.py index dae38dd93927d8952dae6371629beea2e5cc1578..b536129ac5c60387aa168d2787e1d679c4dc22cc 100644 --- a/Examples/options/tut_detsim.py +++ b/Examples/options/tut_detsim.py @@ -6,6 +6,9 @@ from Configurables import DetSimSvc detsimsvc = DetSimSvc("DetSimSvc") +# from Configurables import ExampleAnaElemTool +# example_anatool = ExampleAnaElemTool("ExampleAnaElemTool") + from Configurables import DetSimAlg detsimalg = DetSimAlg("DetSimAlg") @@ -15,6 +18,11 @@ detsimalg.VisMacs = ["vis.mac"] detsimalg.RunCmds = [ "/tracking/verbose 1", ] +detsimalg.AnaElems = [ + # example_anatool.name() + "ExampleAnaElemTool" +] +detsimalg.RootDetElem = "WorldDetElemTool" # ApplicationMgr from Configurables import ApplicationMgr diff --git a/Simulation/DetSimCore/src/DetSimAlg.cpp b/Simulation/DetSimCore/src/DetSimAlg.cpp index 49eeedab573b3c28006fa3f01123ffdaefda4011..34420d42268573bf7519bc4966c30dfb163f39ca 100644 --- a/Simulation/DetSimCore/src/DetSimAlg.cpp +++ b/Simulation/DetSimCore/src/DetSimAlg.cpp @@ -42,7 +42,7 @@ DetSimAlg::initialize() { // Detector Construction m_root_detelem = ToolHandle<IDetElemTool>(m_root_det_elem.value()); - runmgr->SetUserInitialization(new DetectorConstruction()); + runmgr->SetUserInitialization(new DetectorConstruction(m_root_detelem)); // Physics List G4VUserPhysicsList *physicsList = nullptr; if (m_physics_lists_name.value() == "CEPC") { diff --git a/Simulation/DetSimCore/src/DetectorConstruction.cpp b/Simulation/DetSimCore/src/DetectorConstruction.cpp index 3f53c5807044c0e9b0f4d380bbcc6dff43041333..f365b4746dc028e02bb61b31ed97048f6fb61b70 100644 --- a/Simulation/DetSimCore/src/DetectorConstruction.cpp +++ b/Simulation/DetSimCore/src/DetectorConstruction.cpp @@ -25,7 +25,8 @@ #include "G4ios.hh" -DetectorConstruction::DetectorConstruction() { +DetectorConstruction::DetectorConstruction(ToolHandle<IDetElemTool>& root_elem) + : m_root_detelem(root_elem) { } @@ -49,8 +50,8 @@ DetectorConstruction::Construct() { // ======================================================================= // World // ======================================================================= - G4VSolid* solidWorld= new G4Box("sWorld", 60*m, 60*m, 60*m); - G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Galactic, "lWorld", 0, 0, 0); + G4LogicalVolume* logicWorld = m_root_detelem->getLV(); + G4VPhysicalVolume* physiWorld = new G4PVPlacement(0, // no rotation G4ThreeVector(), // at (0,0,0) logicWorld, // its logical volume @@ -60,4 +61,5 @@ DetectorConstruction::Construct() { 0); // no field specific to volume return physiWorld; + } diff --git a/Simulation/DetSimCore/src/DetectorConstruction.h b/Simulation/DetSimCore/src/DetectorConstruction.h index 8418f6d4e90c3a450672c5d7be68b5d2db4b3c2b..f757cb3272b3be2bc6a56e568cd65e50c620990e 100644 --- a/Simulation/DetSimCore/src/DetectorConstruction.h +++ b/Simulation/DetSimCore/src/DetectorConstruction.h @@ -1,6 +1,9 @@ #ifndef DetectorConstruction_h #define DetectorConstruction_h +#include "GaudiKernel/ToolHandle.h" +#include "DetSimInterface/IDetElemTool.h" + #include "globals.hh" #include "G4VUserDetectorConstruction.hh" #include "G4OpticalSurface.hh" @@ -13,13 +16,13 @@ class DetectorConstruction: public G4VUserDetectorConstruction { public: - DetectorConstruction(); + DetectorConstruction(ToolHandle<IDetElemTool>& root_elem); ~DetectorConstruction(); public: G4VPhysicalVolume* Construct(); private: - + ToolHandle<IDetElemTool>& m_root_detelem; }; #endif diff --git a/Simulation/DetSimGeom/CMakeLists.txt b/Simulation/DetSimGeom/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5169f233c21f4c085e34d509881874b128f70dbb --- /dev/null +++ b/Simulation/DetSimGeom/CMakeLists.txt @@ -0,0 +1,18 @@ + +gaudi_subdir(DetSimGeom v0r0) + +gaudi_depends_on_subdirs( + Simulation/DetSimInterface +) + +find_package(Geant4 REQUIRED ui_all vis_all) +include(${Geant4_USE_FILE}) + +set(DetSimGeom_srcs + src/WorldDetElemTool.cpp +) + +gaudi_add_module(DetSimGeom ${DetSimGeom_srcs} + INCLUDE_DIRS DetSimInterface GaudiKernel Geant4 + LINK_LIBRARIES DetSimInterface GaudiKernel Geant4 +) diff --git a/Simulation/DetSimGeom/src/WorldDetElemTool.cpp b/Simulation/DetSimGeom/src/WorldDetElemTool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..93b92a9304d05a98cd3e8296adba309def2b2260 --- /dev/null +++ b/Simulation/DetSimGeom/src/WorldDetElemTool.cpp @@ -0,0 +1,46 @@ +#include "WorldDetElemTool.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" + + +DECLARE_COMPONENT(WorldDetElemTool) + +G4LogicalVolume* +WorldDetElemTool::getLV() { + + G4Material* Galactic = G4Material::GetMaterial("Galactic"); + + G4VSolid* solidWorld= new G4Box("sWorld", 60*m, 60*m, 60*m); + G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Galactic, "lWorld", 0, 0, 0); + + return logicWorld; +} + +StatusCode +WorldDetElemTool::initialize() { + StatusCode sc; + return sc; +} + +StatusCode +WorldDetElemTool::finalize() { + StatusCode sc; + return sc; +} diff --git a/Simulation/DetSimGeom/src/WorldDetElemTool.h b/Simulation/DetSimGeom/src/WorldDetElemTool.h new file mode 100644 index 0000000000000000000000000000000000000000..7612e75e8f67cfecdf2e8b4c82cec6622aa9cbf8 --- /dev/null +++ b/Simulation/DetSimGeom/src/WorldDetElemTool.h @@ -0,0 +1,23 @@ +#ifndef WorldDetElemTool_h +#define WorldDetElemTool_h + +#include "GaudiKernel/AlgTool.h" +#include "DetSimInterface/IDetElemTool.h" + +class WorldDetElemTool: public extends<AlgTool, IDetElemTool> { + +public: + using extends::extends; + + G4LogicalVolume* getLV() override; + + StatusCode initialize() override; + StatusCode finalize() override; + +private: + double m_x; + double m_y; + double m_z; +}; + +#endif