Files
sf-op/script/RFscan/RfEnergyCalib.py
2021-02-24 10:49:05 +01:00

47 lines
1.8 KiB
Python

E1 = 2428.0 # old energy gain
E2 = 2357.0 # new energy gain
do_elog = True
#stationlist = ("SINSB01","SINSB02","SINSB03","SINSB04","SINXB01")
#stationlist = ("S10CB01","S10CB02","S10CB03","S10CB04","S10CB05","S10CB06","S10CB07","S10CB08","S10CB09")
#stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04")
stationlist = ("S30CB01","S30CB02","S30CB03","S30CB04","S30CB05","S30CB06","S30CB07","S30CB08","S30CB09","S30CB10","S30CB11","S30CB12","S30CB13")
# set RF on-delay
caput("SIN-TIMAST-TMA:Beam-RF-OnDelay-Sel", 1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
# energy calibration
A1, A2 = {}, {}
P1, P2 = {}, {}
new_acc_volt = {}
for station in stationlist:
A = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE") # MV/unit
P = caget(station + "-RSYS:SET-VOLT-POWER-SCALE") # MW/MV^2
vsum_ampl = caget(station + "-RSYS:GET-VSUM-AMPLT") # unit
A1[station] = A
A2[station] = A * E2 / E1
P1[station] = P
P2[station] = P * (E1 / E2)**2
new_acc_volt[station] = vsum_ampl * A2[station]
for station in stationlist:
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", A2[station])
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", P2[station])
caput(station + "-RSYS:SET-ACC-VOLT", new_acc_volt[station])
# set RF on-beam
caput("SIN-TIMAST-TMA:Beam-RF-OnDelay-Sel", 0)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
#Elog entry
if do_elog:
title = "Energy calibration scaling"
log_msg = "Old energy gain: %0.2f" % E1 + " MeV/c\n"
log_msg = log_msg + "New energy gain: %0.2f" % E2 + " MeV/c\n\n"
log_msg = log_msg + " A1 A2 P1 P2 \n"
for station in stationlist:
log_msg = log_msg + station + "%10.2f%10.2f%10.6f%10.6f" % (A1[station],A2[station],P1[station],P2[station]) + " \n"
attachments = None
elog(title, log_msg)