From 8c308f631a7b1a77e9d192556c5f042c3eb17f92 Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Mon, 11 Oct 2021 22:50:12 +0800
Subject: [PATCH] add the parser.

---
 Generator/src/GtBeamBackgroundTool.cpp    |  2 +-
 Generator/src/IBeamBackgroundFileParser.h | 44 +++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 Generator/src/IBeamBackgroundFileParser.h

diff --git a/Generator/src/GtBeamBackgroundTool.cpp b/Generator/src/GtBeamBackgroundTool.cpp
index 28f4f352..8eea3cf2 100644
--- a/Generator/src/GtBeamBackgroundTool.cpp
+++ b/Generator/src/GtBeamBackgroundTool.cpp
@@ -1,5 +1,5 @@
 #include "GtBeamBackgroundTool.h"
-
+#include "IBeamBackgroundFileParser.h"
 DECLARE_COMPONENT(GtBeamBackgroundTool)
 
 StatusCode GtBeamBackgroundTool::initialize() {
diff --git a/Generator/src/IBeamBackgroundFileParser.h b/Generator/src/IBeamBackgroundFileParser.h
new file mode 100644
index 00000000..fedc6fab
--- /dev/null
+++ b/Generator/src/IBeamBackgroundFileParser.h
@@ -0,0 +1,44 @@
+#ifndef IBeamBackgroundFileParser_h
+#define IBeamBackgroundFileParser_h
+
+/*
+ * Description:
+ *   This interface is used to load the beam background information, such as:
+ *     - pdgid (optional)
+ *         About the pdgid, it will be e+/e- in most cases.
+ *     - x/y/z
+ *     - t (optional) 
+ *     - px/py/pz
+ *         About the time, it could be set in the GtBeamBackgroundTool.
+ *
+ * Author:
+ *   Tao Lin <lintao AT ihep.ac.cn>
+ */
+
+class IBeamBackgroundFileParser {
+public:
+    // Internal used Data
+    struct BeamBackgroundData {
+        int pdgid;
+
+        double x; // unit: mm
+        double y; // unit: mm
+        double z; // unit: mm
+        double t; // unit: ns
+
+        double px; // unit: GeV
+        double py; // unit: GeV
+        double pz; // unit: GeV
+        double mass; // unit: GeV
+
+        BeamBackgroundData() 
+          : pdgid(11), x(0), y(0), z(0), t(0), 
+            px(0), py(0), pz(0), mass(0) {}
+        
+    };
+
+    // return false if failed to load the data
+    virtual bool load(BeamBackgroundData&) = 0;
+};
+
+#endif
-- 
GitLab