From c47eaf3713455e3087399112da98b73e1d2c8073 Mon Sep 17 00:00:00 2001
From: Zhan Li <lizhan@ihep.ac.cn>
Date: Wed, 7 Aug 2024 06:03:38 +0000
Subject: [PATCH] Beam bkg charge added

---
 .gitignore                                   | 2 +-
 Generator/src/BeamBackgroundFileParserV1.cpp | 1 +
 Generator/src/BeamBackgroundFileParserV1.h   | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index ff7ac6fe..1d3c15ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,4 @@ spack*
 ./Generator/output/
 ./Generator/options/
 
-InstallArea/
\ No newline at end of file
+InstallArea/
diff --git a/Generator/src/BeamBackgroundFileParserV1.cpp b/Generator/src/BeamBackgroundFileParserV1.cpp
index 478aca94..7f1e5408 100644
--- a/Generator/src/BeamBackgroundFileParserV1.cpp
+++ b/Generator/src/BeamBackgroundFileParserV1.cpp
@@ -51,6 +51,7 @@ bool BeamBackgroundFileParserV1::load(IBeamBackgroundFileParser::BeamBackgroundD
         // Now, we get a almost valid data
         const double m2mm = 1e3; // convert from m to mm
         result.pdgid = pid;
+        result.charge = (pid == 11) ? -1 : (pid == -11) ? 1 : -1;
         result.x     = x * m2mm;
         result.y     = y * m2mm;
         result.z     = (z+dz) * m2mm;
diff --git a/Generator/src/BeamBackgroundFileParserV1.h b/Generator/src/BeamBackgroundFileParserV1.h
index 6485207c..00527a2d 100644
--- a/Generator/src/BeamBackgroundFileParserV1.h
+++ b/Generator/src/BeamBackgroundFileParserV1.h
@@ -23,7 +23,7 @@ private:
     double m_timewindow; 
 
     double x, y, z, cosx, cosy, dz, dp, cosz;
-    int pid;
+    int pid, charge;
 
 };
 
-- 
GitLab