From d0b5b6d5fec132eddaf64267b8a325965ed86f79 Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Thu, 25 Feb 2021 17:25:56 +0800
Subject: [PATCH] Fix #153: avoid to use the assign operator of
 MCParticleCollection.

---
 Generator/src/GenEvent.cpp | 9 +++++----
 Generator/src/GenEvent.h   | 5 +++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/Generator/src/GenEvent.cpp b/Generator/src/GenEvent.cpp
index 3e40c65b..8d8c2542 100644
--- a/Generator/src/GenEvent.cpp
+++ b/Generator/src/GenEvent.cpp
@@ -1,7 +1,7 @@
 #include "GenEvent.h" 
 #include "edm4hep/MCParticleCollection.h"//plico
 
-using namespace std;
+// using namespace std;
 
 namespace MyHepMC{
 
@@ -17,7 +17,7 @@ GenEvent::GenEvent(edm4hep::MCParticleCollection& mcCol)
 }
 GenEvent::~GenEvent(){}
 
-void GenEvent::SetEventHeader(long event_id_, long run_id_, float time_, string det_name_){
+void GenEvent::SetEventHeader(long event_id_, long run_id_, float time_, const std::string& det_name_){
     m_event_id = event_id_;
     m_run_id = run_id_;
     m_time = time_;
@@ -28,8 +28,9 @@ void GenEvent::SetMCCollection(edm4hep::MCParticleCollection vec_){
 m_mc_vec = vec_;
 }
 */
-edm4hep::MCParticleCollection GenEvent::getMCVec(){
-return m_mc_vec;
+
+edm4hep::MCParticleCollection& GenEvent::getMCVec(){
+    return m_mc_vec;
 }
 
 long GenEvent::getID(){
diff --git a/Generator/src/GenEvent.h b/Generator/src/GenEvent.h
index 72895413..fd1dbe55 100644
--- a/Generator/src/GenEvent.h
+++ b/Generator/src/GenEvent.h
@@ -10,17 +10,18 @@ class GenEvent{
         //GenEvent();
         GenEvent(edm4hep::MCParticleCollection& mcCol);
         ~GenEvent();
-        void SetEventHeader(long event_id_, long run_id_, float time_, std::string det_name_);
+        void SetEventHeader(long event_id_, long run_id_, float time_, const std::string& det_name_);
         //void SetMCCollection(edm4hep::MCParticleCollection vec_);
         long getID();
         long getRun();
         long getTime();
         void ReSet();
         std::string getName();
-        edm4hep::MCParticleCollection getMCVec();
+        edm4hep::MCParticleCollection& getMCVec();
         edm4hep::MCParticleCollection& m_mc_vec;
         //edm4hep::MCParticleCollection m_mc_vec;
     private:
+
         long m_event_id;
         long m_run_id;
         float m_time;
-- 
GitLab