diff --git a/Simulation/DetSimGeom/CMakeLists.txt b/Simulation/DetSimGeom/CMakeLists.txt index 5169f233c21f4c085e34d509881874b128f70dbb..f35a12b7c98a88d37d5adc0d3918b7490cf7751a 100644 --- a/Simulation/DetSimGeom/CMakeLists.txt +++ b/Simulation/DetSimGeom/CMakeLists.txt @@ -10,6 +10,7 @@ include(${Geant4_USE_FILE}) set(DetSimGeom_srcs src/WorldDetElemTool.cpp + src/AnExampleDetElemTool.cpp ) gaudi_add_module(DetSimGeom ${DetSimGeom_srcs} diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e2b297fc5e03e27ad108f1804f2e31b091278c6b --- /dev/null +++ b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp @@ -0,0 +1,46 @@ +#include "AnExampleDetElemTool.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(AnExampleDetElemTool) + +G4LogicalVolume* +AnExampleDetElemTool::getLV() { + + G4Material* Galactic = G4Material::GetMaterial("Galactic"); + + G4VSolid* solidAnExample= new G4Box("sAnExample", m_x.value(), m_y.value(), m_z.value()); + G4LogicalVolume* logicAnExample= new G4LogicalVolume( solidAnExample, Galactic, "lAnExample", 0, 0, 0); + + return logicAnExample; +} + +StatusCode +AnExampleDetElemTool::initialize() { + StatusCode sc; + return sc; +} + +StatusCode +AnExampleDetElemTool::finalize() { + StatusCode sc; + return sc; +} diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.h b/Simulation/DetSimGeom/src/AnExampleDetElemTool.h new file mode 100644 index 0000000000000000000000000000000000000000..dcf4cae0b906c91d8e4aa7f09f3a10bce7bfb330 --- /dev/null +++ b/Simulation/DetSimGeom/src/AnExampleDetElemTool.h @@ -0,0 +1,27 @@ +#ifndef AnExampleDetElemTool_h +#define AnExampleDetElemTool_h + +#include "GaudiKernel/AlgTool.h" +#include "GaudiKernel/Property.h" +#include "DetSimInterface/IDetElemTool.h" +#include "G4SystemOfUnits.hh" +#include "G4PhysicalConstants.hh" + + +class AnExampleDetElemTool: public extends<AlgTool, IDetElemTool> { + +public: + using extends::extends; + + G4LogicalVolume* getLV() override; + + StatusCode initialize() override; + StatusCode finalize() override; + +private: + Gaudi::Property<double> m_x{this, "X", 30.*m}; + Gaudi::Property<double> m_y{this, "Y", 30.*m}; + Gaudi::Property<double> m_z{this, "Z", 30.*m}; +}; + +#endif diff --git a/Simulation/DetSimGeom/src/WorldDetElemTool.cpp b/Simulation/DetSimGeom/src/WorldDetElemTool.cpp index 93b92a9304d05a98cd3e8296adba309def2b2260..c4c766c1354944e04174e968d30c36c205d821ed 100644 --- a/Simulation/DetSimGeom/src/WorldDetElemTool.cpp +++ b/Simulation/DetSimGeom/src/WorldDetElemTool.cpp @@ -1,5 +1,7 @@ #include "WorldDetElemTool.h" +#include <GaudiKernel/ToolHandle.h> + #include "G4SystemOfUnits.hh" #include "G4PhysicalConstants.hh" @@ -30,6 +32,21 @@ WorldDetElemTool::getLV() { G4VSolid* solidWorld= new G4Box("sWorld", 60*m, 60*m, 60*m); G4LogicalVolume* logicWorld= new G4LogicalVolume( solidWorld, Galactic, "lWorld", 0, 0, 0); + // An example, get a detelem first, then place the detector components inside world. + ToolHandle<IDetElemTool> inner_detelem_tool("AnExampleDetElemTool"); + G4LogicalVolume* inner_lv = inner_detelem_tool->getLV(); + + if (inner_lv) { + new G4PVPlacement(0, // no rotation + G4ThreeVector(), // at (0,0,0) + inner_lv, // logical volume + "pAnExampleDetElem", // name + logicWorld, // mother volume + false, // no boolean operations + 0); // no field + } else { + warning() << "Can't Find the logical volume ExampleDetElem " << std::endl; + } return logicWorld; }