From 276a44bc651b33c54f9610ca000e666f15a71bc9 Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Tue, 20 Dec 2022 13:35:16 +0800
Subject: [PATCH] WIP: add user track info to record the extra information of
 track.

---
 Simulation/DetSimInterface/CMakeLists.txt     |  1 +
 .../DetSimInterface/CommonUserTrackInfo.hh    | 35 +++++++++++++++++++
 .../src/CommonUserTrackInfo.cc                | 22 ++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 Simulation/DetSimInterface/include/DetSimInterface/CommonUserTrackInfo.hh
 create mode 100644 Simulation/DetSimInterface/src/CommonUserTrackInfo.cc

diff --git a/Simulation/DetSimInterface/CMakeLists.txt b/Simulation/DetSimInterface/CMakeLists.txt
index b5fd1461..21963df1 100644
--- a/Simulation/DetSimInterface/CMakeLists.txt
+++ b/Simulation/DetSimInterface/CMakeLists.txt
@@ -5,6 +5,7 @@
 gaudi_add_library(DetSimInterface
                  SOURCES src/IDetSimSvc.cpp
                          src/CommonUserEventInfo.cc
+                         src/CommonUserTrackInfo.cc
                  LINK Gaudi::GaudiKernel
                       ${Geant4_LIBRARIES}
 )
diff --git a/Simulation/DetSimInterface/include/DetSimInterface/CommonUserTrackInfo.hh b/Simulation/DetSimInterface/include/DetSimInterface/CommonUserTrackInfo.hh
new file mode 100644
index 00000000..ce63e602
--- /dev/null
+++ b/Simulation/DetSimInterface/include/DetSimInterface/CommonUserTrackInfo.hh
@@ -0,0 +1,35 @@
+#ifndef CommonUserTrackInfo_hh
+#define CommonUserTrackInfo_hh
+
+/* Description:
+ *   This class is a part of simulation framework to extend the G4Track.
+ *
+ *   Some secondaries are created due to decay. However, their G4 Track IDs are
+ *   not valid until the tracks are tracking by geant4. In order to associate
+ *   these tracks and their edm4hep MC particle, we use the track information
+ *   to record the extra track information.
+ *
+ * Author:
+ *   Tao Lin <lintao AT ihep.ac.cn>
+ */
+
+#include "G4VUserTrackInformation.hh"
+
+class CommonUserTrackInfo: public G4VUserTrackInformation {
+public:
+    CommonUserTrackInfo();
+    ~CommonUserTrackInfo();
+
+public:
+
+    virtual void Print() const;
+
+    // get the idx in the EDM4hep MC particle collection
+    bool setIdxEdm4hep(int idxEdm4hep);
+    int idxEdm4hep() const;
+
+private:
+    int m_idxEdm4hep = -1;
+};
+
+#endif
diff --git a/Simulation/DetSimInterface/src/CommonUserTrackInfo.cc b/Simulation/DetSimInterface/src/CommonUserTrackInfo.cc
new file mode 100644
index 00000000..9a923a35
--- /dev/null
+++ b/Simulation/DetSimInterface/src/CommonUserTrackInfo.cc
@@ -0,0 +1,22 @@
+#include "DetSimInterface/CommonUserTrackInfo.hh"
+#include <iostream>
+
+CommonUserTrackInfo::CommonUserTrackInfo() {
+
+}
+
+CommonUserTrackInfo::~CommonUserTrackInfo() {
+
+}
+
+void CommonUserTrackInfo::Print() const {
+
+}
+
+bool CommonUserTrackInfo::setIdxEdm4hep(int idxEdm4hep) {
+    m_idxEdm4hep = idxEdm4hep;
+}
+
+int CommonUserTrackInfo::idxEdm4hep() const {
+    return m_idxEdm4hep;
+}
-- 
GitLab