From 1b7a8b5914cd311110b3f48e58111312264a453b Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Mon, 11 Oct 2021 11:54:09 +0800
Subject: [PATCH] Fix the problem: the mcCol is not initialized in tracking
 action.

---
 .../DetSimAna/src/Edm4hepWriterAnaElemTool.cpp  | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
index f038658b..9f63b7bf 100644
--- a/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
+++ b/Simulation/DetSimAna/src/Edm4hepWriterAnaElemTool.cpp
@@ -30,14 +30,7 @@ void
 Edm4hepWriterAnaElemTool::BeginOfEventAction(const G4Event* anEvent) {
     msg() << "Event " << anEvent->GetEventID() << endmsg;
 
-    // reset
-    m_track2primary.clear();
-
-}
-
-void
-Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
-    auto mcGenCol = m_mcParCol.get();
+    auto mcGenCol = m_mcParGenCol.get();
     mcCol = m_mcParCol.createAndPut();
 
     // copy the MC particle first
@@ -58,6 +51,14 @@ Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
     }
     
     msg() << "mcCol size: " << mcCol->size() << endmsg;
+
+    // reset
+    m_track2primary.clear();
+
+}
+
+void
+Edm4hepWriterAnaElemTool::EndOfEventAction(const G4Event* anEvent) {
     // save all data
 
     // create collections.
-- 
GitLab