diff --git a/script/Alignment/Laser_gun_alignment.py b/script/Alignment/Laser_gun_alignment.py index 38bd7ee..1e55a70 100755 --- a/script/Alignment/Laser_gun_alignment.py +++ b/script/Alignment/Laser_gun_alignment.py @@ -6,16 +6,8 @@ # switch off all the magnets between the gun solenoid and the screen or BPM used for the measurement # change the phase of the gun RF # look at the centroid position (BPM or screen) downstream of the gun. - -if get_context().source == CommandSource.ui: - phi1 = 20.0 - phi2 = 30.0 - dphi = 1.0 - settling_time = 0.1 - -import org.apache.commons.math3.linear.Array2DRowRealMatrix as Matrix -import ch.psi.utils.Convert.toBidimensional as mono_to_bidi import datetime +from camtool import CamTool if get_context().source == CommandSource.ui: phi1 = 95.0 @@ -53,15 +45,23 @@ if zero_solenoids: # add here gun phase setting see wiki page -def br(): - pass +def br(): + if multiple_background: + camtool.captureBackground(number_backgrounds) + laser_on() + camtool.update() + def ar(): - pass + if multiple_background: + laser_off() r = None -laser_on() +if not multiple_background: + laser_on() try: - sensors = [cam_x, cam_y, cam_img] if plot_image else [cam_x, cam_y] + sensors = [camtool.com_x_mean, camtool.com_y_mean, camtool.com_x_var, camtool.com_y_var] + if plot_image: + sensors.append(camtool.image) r = lscan(gun_solenoid, sensors , I1, I2, dI, settling_time, before_read = br, after_read = ar) finally: laser_off() @@ -72,6 +72,7 @@ if centroid_excursion_plot: else: (hx,hy)= convex_hull(x=r.getReadable(0), y=r.getReadable(1)) hx.append(hx[0]); hy.append(hy[0]) + # save the entry in the logbook if do_elog: