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

WIP: move the construction of world's logical volume into a DetElemTool.

parent 93402515
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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") {
......
......@@ -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;
}
#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
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
)
#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;
}
#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
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