From 6fc69ab67b3174e21d97b0adb8e8dbaa57a089d1 Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Wed, 20 Oct 2021 23:09:52 +0800
Subject: [PATCH] Allow to change the mass of chargedgeantino in the
 G4PrimaryCnvTool

---
 Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp | 8 ++++++++
 Simulation/DetSimCore/src/G4PrimaryCnvTool.h   | 1 +
 2 files changed, 9 insertions(+)

diff --git a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp
index 5e795dbc..c756412f 100644
--- a/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp
+++ b/Simulation/DetSimCore/src/G4PrimaryCnvTool.cpp
@@ -59,6 +59,14 @@ bool G4PrimaryCnvTool::mutate(G4Event* anEvent) {
                                                           momentum.y*CLHEP::GeV,
                                                           momentum.z*CLHEP::GeV);
 
+        // modify the mass of the chargedgeantino
+        if (pdgcode == 0 && p.getCharge() == 1) {
+            info() << "The mass of G4ChargedGeantino is "
+                   << m_chargedgeantino_mass.value() 
+                   << endmsg;
+            g4prim->SetMass(m_chargedgeantino_mass.value());
+        }
+
         g4vtx->SetPrimary(g4prim);
 
         anEvent->AddPrimaryVertex(g4vtx);
diff --git a/Simulation/DetSimCore/src/G4PrimaryCnvTool.h b/Simulation/DetSimCore/src/G4PrimaryCnvTool.h
index 09f724ee..1e477721 100644
--- a/Simulation/DetSimCore/src/G4PrimaryCnvTool.h
+++ b/Simulation/DetSimCore/src/G4PrimaryCnvTool.h
@@ -18,6 +18,7 @@ public:
 private:
     DataHandle<edm4hep::MCParticleCollection> m_mcParCol{"MCParticle", Gaudi::DataHandle::Reader, this};
 
+    Gaudi::Property<double> m_chargedgeantino_mass{this, "ChargedGeantinoMass"};
 };
 
 #endif
-- 
GitLab