Skip to content
Snippets Groups Projects
Commit 9a820558 authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

WIP: construct logical volume from DD4hep and place the logical volume in mother volume.

parent c8939dd6
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ gaudi_depends_on_subdirs( ...@@ -7,6 +7,7 @@ gaudi_depends_on_subdirs(
find_package(Geant4 REQUIRED ui_all vis_all) find_package(Geant4 REQUIRED ui_all vis_all)
include(${Geant4_USE_FILE}) include(${Geant4_USE_FILE})
find_package(DD4hep COMPONENTS DDG4 REQUIRED)
set(DetSimGeom_srcs set(DetSimGeom_srcs
src/WorldDetElemTool.cpp src/WorldDetElemTool.cpp
...@@ -14,6 +15,6 @@ set(DetSimGeom_srcs ...@@ -14,6 +15,6 @@ set(DetSimGeom_srcs
) )
gaudi_add_module(DetSimGeom ${DetSimGeom_srcs} gaudi_add_module(DetSimGeom ${DetSimGeom_srcs}
INCLUDE_DIRS DetSimInterface GaudiKernel Geant4 INCLUDE_DIRS DetSimInterface DD4hep GaudiKernel Geant4
LINK_LIBRARIES DetSimInterface GaudiKernel Geant4 LINK_LIBRARIES DetSimInterface DD4hep ${DD4hep_COMPONENT_LIBRARIES} GaudiKernel Geant4
) )
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#include "G4PhysicalVolumeStore.hh" #include "G4PhysicalVolumeStore.hh"
#include "G4OpticalSurface.hh" #include "G4OpticalSurface.hh"
#include "DD4hep/Detector.h"
#include "DDG4/Geant4Converter.h"
#include "DDG4/Geant4Mapping.h"
DECLARE_COMPONENT(AnExampleDetElemTool) DECLARE_COMPONENT(AnExampleDetElemTool)
...@@ -30,6 +33,32 @@ AnExampleDetElemTool::getLV() { ...@@ -30,6 +33,32 @@ AnExampleDetElemTool::getLV() {
G4VSolid* solidAnExample= new G4Box("sAnExample", m_x.value(), m_y.value(), m_z.value()); G4VSolid* solidAnExample= new G4Box("sAnExample", m_x.value(), m_y.value(), m_z.value());
G4LogicalVolume* logicAnExample= new G4LogicalVolume( solidAnExample, Galactic, "lAnExample", 0, 0, 0); G4LogicalVolume* logicAnExample= new G4LogicalVolume( solidAnExample, Galactic, "lAnExample", 0, 0, 0);
// Following is an example to get the DD4hep volume
dd4hep::Detector* dd4hep_geo = &(dd4hep::Detector::getInstance());
dd4hep_geo->fromCompact(m_dd4hep_xmls.value());
dd4hep::DetElement world = dd4hep_geo->world();
dd4hep::sim::Geant4Converter conv((*dd4hep_geo), dd4hep::DEBUG);
dd4hep::sim::Geant4GeometryInfo* geo_info = conv.create(world).detach();
dd4hep::sim::Geant4Mapping& g4map = dd4hep::sim::Geant4Mapping::instance();
g4map.attach(geo_info);
// All volumes are deleted in ~G4PhysicalVolumeStore()
G4VPhysicalVolume* m_world = geo_info->world();
G4LogicalVolume* logicDD4hepExample = m_world->GetLogicalVolume();
if (logicDD4hepExample) {
new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
logicDD4hepExample, // logical volume
"lDD4hepExampleDetElem", // name
logicAnExample, // mother volume
false, // no boolean operations
0); // no field
} else {
warning() << "Can't Find the logical volume lDD4hepExampleDetElem " << std::endl;
}
return logicAnExample; return logicAnExample;
} }
......
...@@ -22,6 +22,8 @@ private: ...@@ -22,6 +22,8 @@ private:
Gaudi::Property<double> m_x{this, "X", 30.*m}; Gaudi::Property<double> m_x{this, "X", 30.*m};
Gaudi::Property<double> m_y{this, "Y", 30.*m}; Gaudi::Property<double> m_y{this, "Y", 30.*m};
Gaudi::Property<double> m_z{this, "Z", 30.*m}; Gaudi::Property<double> m_z{this, "Z", 30.*m};
// DD4hep XML compact file path
Gaudi::Property<std::string> m_dd4hep_xmls{this, "detxml"};
}; };
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment