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

WIP: using SD tool to create a SD for calorimeter.

parent f5909157
No related branches found
No related tags found
No related merge requests found
......@@ -92,7 +92,26 @@ AnExampleDetElemTool::ConstructSDandField() {
<< endmsg;
// continue;
// Sensitive detectors are deleted in ~G4SDManager
G4VSensitiveDetector* g4sd = dd4hep::PluginService::Create<G4VSensitiveDetector*>(typ, nam, lcdd);
G4VSensitiveDetector* g4sd = nullptr;
// try to use SD tool to find the SD
if (!g4sd) {
if (typ=="calorimeter") {
m_calo_sdtool = ToolHandle<ISensDetTool>("CalorimeterSensDetTool");
if (m_calo_sdtool) {
info() << "Find the CalorimeterSensDetTool." << endmsg;
g4sd = m_calo_sdtool->createSD(nam);
info() << "create g4SD: " << g4sd << endmsg;
}
} else if (typ=="tracker") {
}
}
if (!g4sd) {
g4sd = dd4hep::PluginService::Create<G4VSensitiveDetector*>(typ, nam, lcdd);
}
if (g4sd == nullptr) {
std::string tmp = typ;
tmp[0] = ::toupper(tmp[0]);
......
......@@ -3,11 +3,14 @@
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/Property.h"
#include "DetSimInterface/IDetElemTool.h"
#include <GaudiKernel/ToolHandle.h>
#include "G4SystemOfUnits.hh"
#include "G4PhysicalConstants.hh"
#include "DetInterface/IGeoSvc.h"
#include "DetSimInterface/IDetElemTool.h"
#include "DetSimInterface/ISensDetTool.h"
class AnExampleDetElemTool: public extends<AlgTool, IDetElemTool> {
......@@ -29,7 +32,7 @@ private:
Gaudi::Property<std::string> m_dd4hep_xmls{this, "detxml"};
SmartIF<IGeoSvc> m_geosvc;
ToolHandle<ISensDetTool> m_calo_sdtool;
};
#endif
......@@ -3,6 +3,7 @@ gaudi_subdir(DetSimSD v0r0)
gaudi_depends_on_subdirs(
FWCore
Detector/DetInterface
Simulation/DetSimInterface
)
......
......@@ -2,12 +2,24 @@
#include "G4VSensitiveDetector.hh"
#include "DetSimSD/DDG4SensitiveDetector.h"
#include "DD4hep/Detector.h"
DECLARE_COMPONENT(CalorimeterSensDetTool);
StatusCode
CalorimeterSensDetTool::initialize() {
StatusCode sc;
m_geosvc = service<IGeoSvc>("GeoSvc");
if (!m_geosvc) {
error() << "Failed to find GeoSvc." << endmsg;
return StatusCode::FAILURE;
}
return sc;
}
......@@ -21,7 +33,11 @@ CalorimeterSensDetTool::finalize() {
G4VSensitiveDetector*
CalorimeterSensDetTool::createSD(const std::string& name) {
return nullptr;
dd4hep::Detector* dd4hep_geo = m_geosvc->lcdd();
G4VSensitiveDetector* sd = new DDG4SensitiveDetector(name, *dd4hep_geo);
return sd;
}
......@@ -9,6 +9,7 @@
#include "GaudiKernel/AlgTool.h"
#include "DetSimInterface/ISensDetTool.h"
#include "DetInterface/IGeoSvc.h"
class CalorimeterSensDetTool: public extends<AlgTool, ISensDetTool> {
......@@ -25,6 +26,8 @@ public:
private:
// in order to initialize SD, we need to get the lcdd()
SmartIF<IGeoSvc> m_geosvc;
};
......
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