From 93402515b86b2fbce795e967b024cc6c385949b2 Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Mon, 12 Aug 2019 21:58:52 +0800
Subject: [PATCH] WIP: construct detector from root detector element.

---
 Simulation/DetSimCore/src/DetSimAlg.cpp       |  1 +
 Simulation/DetSimCore/src/DetSimAlg.h         |  3 +++
 .../DetSimInterface/IDetElemTool.h            | 25 +++++++++++++++++++
 3 files changed, 29 insertions(+)
 create mode 100644 Simulation/DetSimInterface/DetSimInterface/IDetElemTool.h

diff --git a/Simulation/DetSimCore/src/DetSimAlg.cpp b/Simulation/DetSimCore/src/DetSimAlg.cpp
index 70dde30c..49eeedab 100644
--- a/Simulation/DetSimCore/src/DetSimAlg.cpp
+++ b/Simulation/DetSimCore/src/DetSimAlg.cpp
@@ -41,6 +41,7 @@ DetSimAlg::initialize() {
     }
 
     // Detector Construction
+    m_root_detelem = ToolHandle<IDetElemTool>(m_root_det_elem.value());
     runmgr->SetUserInitialization(new DetectorConstruction());
     // Physics List
     G4VUserPhysicsList *physicsList = nullptr;
diff --git a/Simulation/DetSimCore/src/DetSimAlg.h b/Simulation/DetSimCore/src/DetSimAlg.h
index 08ee2489..ff484969 100644
--- a/Simulation/DetSimCore/src/DetSimAlg.h
+++ b/Simulation/DetSimCore/src/DetSimAlg.h
@@ -10,6 +10,7 @@
 
 #include <DetSimInterface/IDetSimSvc.h>
 #include <DetSimInterface/IAnaElemTool.h>
+#include <DetSimInterface/IDetElemTool.h>
 
 class DetSimAlg: public Algorithm {
 public:
@@ -22,6 +23,7 @@ public:
 private:
     SmartIF<IDetSimSvc> m_detsimsvc;
     ToolHandleArray<IAnaElemTool> m_anaelemtools;
+    ToolHandle<IDetElemTool> m_root_detelem;
 
 private:
 
@@ -32,6 +34,7 @@ private:
     Gaudi::Property<std::string> m_physics_lists_name{this, "PhysicsList", "QGSP_BERT"};
 
     Gaudi::Property<std::vector<std::string>> m_ana_elems{this, "AnaElems"};
+    Gaudi::Property<std::string> m_root_det_elem{this, "RootDetElem"};
 
 
 private:
diff --git a/Simulation/DetSimInterface/DetSimInterface/IDetElemTool.h b/Simulation/DetSimInterface/DetSimInterface/IDetElemTool.h
new file mode 100644
index 00000000..37a36179
--- /dev/null
+++ b/Simulation/DetSimInterface/DetSimInterface/IDetElemTool.h
@@ -0,0 +1,25 @@
+#ifndef IDetElemTool_h
+#define IDetElemTool_h
+
+// IDetElemTool is used to wrap the construction of G4LogicalVolume.
+// Please note that the placement of logical volume is fixed in the code.
+// If necessary, another IDetElemPosTool can be used to produce the positions
+// of the daughters.
+// IDetElemTool should represent the high level detectors/modules.
+
+#include "GaudiKernel/IAlgTool.h"
+
+class G4LogicalVolume;
+
+class IDetElemTool: virtual public IAlgTool {
+public:
+    DeclareInterfaceID(IDetElemTool, 0, 1);
+
+    virtual ~IDetElemTool() {}
+
+    // return the constructed detector
+    virtual G4LogicalVolume* getLV() = 0;
+
+};
+
+#endif
-- 
GitLab