Files
sf-op/script/RFscan/RfEnergyCalib.py
gobbo_a 8beeb7dbc7
2023-08-17 15:16:51 +02:00

39 lines
1.5 KiB
Python

# single station calibration, dE is the desired energy gain (measured with bends: station on-station off)
# the scaling factors A,P are updated, the Acc voltage is set to dE, the V-Sum Amplitude and power should not change
station = "SINSB01"
dE = 77.25 # MeV
do_elog = True
# set RF on-delay
caput("SIN-TIMAST-TMA:Beam-RF-OnDelay-Sel", 1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
# scale RF calibration
A1 = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE") # MV/unit
P1 = caget(station + "-RSYS:SET-VOLT-POWER-SCALE") # MW/MV^2
VSA = caget(station + "-RSYS:GET-VSUM-AMPLT") # unit
PWR = caget(station + "-RSYS:GET-KLY-POWER-GATED") # MW
ACC1 = caget(station + "-RSYS:SET-ACC-VOLT") # MV
print(A1,P1,VSA,PWR,ACC1)
A2 = dE / VSA
P2 = PWR / dE**2
ACC2 = dE
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", A2)
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", P2)
time.sleep(2.0)
caput(station + "-RSYS:SET-ACC-VOLT", ACC2)
time.sleep(2.0)
VSA = caget(station + "-RSYS:GET-VSUM-AMPLT") # unit
PWR = caget(station + "-RSYS:GET-KLY-POWER-GATED") # MW
print(A2,P2,VSA,PWR,ACC2)
#Elog entry
if do_elog:
title = "Energy calibration" + station
log_msg = "Old energy gain: %0.2f" % ACC1 + " MeV/c\n"
log_msg = log_msg + "New energy gain: %0.2f" % ACC2 + " MeV/c\n\n"
log_msg = log_msg + " A1 A2 P1 P2 \n"
log_msg = log_msg + station + "%10.2f%10.2f%10.6f%10.6f" % (A1,A2,P1,P2) + " \n"
attachments = None
elog(title, log_msg)