From 2e4f4023f7dfaa5930a9940fe279a6403b301cb4 Mon Sep 17 00:00:00 2001
From: naotoY <naotino@gmail.com>
Date: Thu, 14 Dec 2023 16:02:16 +0900
Subject: [PATCH] [add]  adding DFB_ig_phasor to monitor item

---
 mbtrack2/tracking/monitors/monitors.py | 9 +++++++++
 mbtrack2/tracking/rf.py                | 8 ++++++++
 2 files changed, 17 insertions(+)

diff --git a/mbtrack2/tracking/monitors/monitors.py b/mbtrack2/tracking/monitors/monitors.py
index 69c62ae..01794eb 100644
--- a/mbtrack2/tracking/monitors/monitors.py
+++ b/mbtrack2/tracking/monitors/monitors.py
@@ -1567,6 +1567,10 @@ class CavityMonitor(Monitor):
                 ring.h,
                 buffer_size,
             ),
+            "DFB_ig_phasor":(
+                ring.h, 
+                buffer_size,
+            ),
             "detune": (buffer_size, ),
             "psi": (buffer_size, ),
             "Vg": (buffer_size, ),
@@ -1595,6 +1599,10 @@ class CavityMonitor(Monitor):
                 ring.h,
                 total_size,
             ),
+            "DFB_ig_phasor":(
+                ring.h, 
+                total_size,
+            ),
             "detune": (total_size, ),
             "psi": (total_size, ),
             "Vg": (total_size, ),
@@ -1611,6 +1619,7 @@ class CavityMonitor(Monitor):
             "beam_phasor_record": complex,
             "generator_phasor_record": complex,
             "ig_phasor_record": complex,
+            "DFB_ig_phasor":complex,
             "detune": float,
             "psi": float,
             "Vg": float,
diff --git a/mbtrack2/tracking/rf.py b/mbtrack2/tracking/rf.py
index fedc7ab..2dba4de 100644
--- a/mbtrack2/tracking/rf.py
+++ b/mbtrack2/tracking/rf.py
@@ -579,6 +579,14 @@ class CavityResonator():
             if isinstance(FB, (ProportionalIntegralLoop, DirectFeedback)):
                 return FB.ig_phasor_record
         return np.zeros(self.ring.h)
+    
+    @property
+    def DFB_ig_phasor(self):
+        """Last current generator phasor of each bunch in [A]"""
+        for FB in self.feedback:
+            if isinstance(FB, (ProportionalIntegralLoop, DirectFeedback)):
+                return FB.DFB_ig_phasor
+        return np.zeros(self.ring.h)
 
     @property
     def cavity_voltage(self):
-- 
GitLab