From 0f85604b7754f6f80628754dfbe39ce0317a9d1b Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Fri, 12 Jun 2020 22:06:00 +0800
Subject: [PATCH] WIP: prepare DDG4SensitiveDetector.

---
 .../DetSimSD/DetSimSD/DDG4SensitiveDetector.h | 74 +++++++++++++++++++
 .../DetSimSD/src/DDG4SensitiveDetector.cpp    | 31 ++++++++
 2 files changed, 105 insertions(+)
 create mode 100644 Simulation/DetSimSD/DetSimSD/DDG4SensitiveDetector.h
 create mode 100644 Simulation/DetSimSD/src/DDG4SensitiveDetector.cpp

diff --git a/Simulation/DetSimSD/DetSimSD/DDG4SensitiveDetector.h b/Simulation/DetSimSD/DetSimSD/DDG4SensitiveDetector.h
new file mode 100644
index 00000000..e86ea10f
--- /dev/null
+++ b/Simulation/DetSimSD/DetSimSD/DDG4SensitiveDetector.h
@@ -0,0 +1,74 @@
+#ifndef DDG4SensitiveDetector_h
+#define DDG4SensitiveDetector_h
+
+/*
+ * In order to access ID from DDG4, some utilities are necessary to retrieve information
+ * from DDG4. This base class defines such interfaces and utilities.
+ * 
+ * Refer to the class DDG4/include/DDG4/Geant4SensitiveDetector.h for some APIs usage.
+ *
+ * We keep to reuse some types already defined in DDG4:
+ * - Geant4Hits
+ *
+ * -- 12 June 2020, Tao Lin <lintao@ihep.ac.cn>
+ */
+
+
+#include "DD4hep/Detector.h"
+#include "DDG4/Geant4Hits.h"
+
+#include "G4Step.hh"
+#include "G4HCofThisEvent.hh"
+#include "G4TouchableHistory.hh"
+#include "G4VSensitiveDetector.hh"
+#include "G4THitsCollection.hh"
+
+
+class DDG4SensitiveDetector: public G4VSensitiveDetector {
+public:
+    typedef G4THitsCollection<dd4hep::sim::Geant4Hit> HitCollection;
+    typedef dd4hep::sim::Geant4Hit::Contribution      HitContribution;
+    typedef dd4hep::sim::Geant4StepHandler            StepHandler;
+
+public:
+    DDG4SensitiveDetector();
+
+public:
+    // Geant4 interface
+
+    virtual void Initialize(G4HCofThisEvent* HCE);
+    virtual G4bool ProcessHits(G4Step* step,G4TouchableHistory* history);
+    virtual void EndOfEvent(G4HCofThisEvent* HCE);
+
+public:
+    // DDG4 utilities
+    /// Returns the volumeID of the sensitive volume corresponding to the step -
+    /// combining the VolIDS of the complete geometry path (Geant4TouchableHistory)
+    //  from the current sensitive volume to the world volume
+    virtual long long getVolumeID(G4Step* step);
+
+    /// Returns the volumeID of the sensitive volume corresponding to the step -
+    /// combining the VolIDS of the complete geometry path (Geant4TouchableHistory)
+    //  from the current sensitive volume to the world volume
+    virtual long long getCellID(G4Step* step);
+
+
+protected:
+    /// Reference to the detector description object
+    dd4hep::Detector& m_detDesc;
+
+    /// Reference to the detector element describing this sensitive element
+    dd4hep::DetElement m_detector;
+
+    /// Reference to the sensitive detector element
+    dd4hep::SensitiveDetector m_sensitive;
+
+    /// Reference to the readout structure
+    dd4hep::Readout m_readout;
+
+    /// Geant4 event context
+    G4HCofThisEvent* m_hce;
+
+};
+
+#endif
diff --git a/Simulation/DetSimSD/src/DDG4SensitiveDetector.cpp b/Simulation/DetSimSD/src/DDG4SensitiveDetector.cpp
new file mode 100644
index 00000000..ed293b02
--- /dev/null
+++ b/Simulation/DetSimSD/src/DDG4SensitiveDetector.cpp
@@ -0,0 +1,31 @@
+#include "DetSimSD/DDG4SensitiveDetector.h"
+
+void
+DDG4SensitiveDetector::Initialize(G4HCofThisEvent* HCE) {
+
+}
+
+G4bool
+DDG4SensitiveDetector::ProcessHits(G4Step* step, G4TouchableHistory*) {
+    
+    return true;
+}
+
+void
+DDG4SensitiveDetector::EndOfEvent(G4HCofThisEvent* HCE) {
+
+}
+
+long long
+DDG4SensitiveDetector::getVolumeID(G4Step* step) {
+    long long vid = 0;
+
+    return vid;
+}
+
+long long
+DDG4SensitiveDetector::getCellID(G4Step* step) {
+    long long vid = 0;
+
+    return vid;
+}
-- 
GitLab