Online Bayesian Optimization for Beam Alignment in
the SECAR Recoil Mass Separator

Sara A. Miskovich∗
Department of Physics and Astronomy
Michigan State University
East Lansing, MI 48824 USA
Georg P. Berg
Department of Physics
University of Notre Dame
Notre Dame, IN 46556 USA

Fernando Montes
Department of Physics and Astronomy
Michigan State University
East Lansing, MI 48824 USA
Jeff Blackmon
Department of Physics and Astronomy
Louisiana State University
Baton Rouge, LA 70803 USA

Kelly A. Chipps
Physics Division
Oak Ridge National Laboratory
Oak Ridge, TN 37831 USA

Manoel Couder
Department of Physics
University of Notre Dame
Notre Dame, IN 46556 USA

Kirby Hermansen
Department of Physics and Astronomy
Michigan State University
East Lansing, MI 48824 USA

Ashley A. Hood
Cyclotron InstituteTexas A&M University
College Station, TX 77843 USA

Rahul Jain
Department of Physics and Astronomy
Michigan State University
East Lansing, MI 48824 USA

Hendrik Schatz
Department of Physics and Astronomy
Michigan State University
East Lansing, MI 48824 USA

Michael S. Smith
Physics Division
Oak Ridge National Laboratory
Oak Ridge, TN 37831 USA

Pelagia Tsintari
Department of Physics
Central Michigan University
Mt Pleasant, MI 48859 USA

Louis Wagner
Department of Physics and Astronomy
Michigan State University
East Lansing, MI 48824 USA

Abstract
The SEparator for CApture Reactions (SECAR) is a next-generation recoil separator system at the Facility for Rare Isotope Beams (FRIB) designed for the direct
measurement of capture reactions on unstable nuclei in inverse kinematics. To
maximize the performance of the device, careful beam alignment to the central ion∗
Corresponding author at: smiskov@slac.stanford.edu, SLAC National Accelerator Laboratory, Menlo
Park, 94025 California, USA. orcid=0000-0002-3302-838X

Fourth Workshop on Machine Learning and the Physical Sciences (NeurIPS 2021).

optical axis needs to be achieved. This can be difficult to attain through manual
tuning by human operators without potentially leaving the system in a sub-optimal
and irreproducible state. In this work, we present the first development of online
Bayesian optimization with a Gaussian process model to tune an ion beam througha nuclear astrophysics recoil separator. We show that the method achieves small
incoming angular deviations (0-1 mrad) in an efficient and reproducible mannerthat is at least 3× faster than standard hand-tuning. This method is now routinely
used for all separator tuning.

1

Introduction

The SEparator for CApture Reactions (SECAR) is a next-generation recoil separator system at the
Facility for Rare Isotope Beams (FRIB) optimized for direct studies of capture reaction rates ofproton and alpha particles on short-lived proton-rich nuclei. Direct measurements provide a higher
precision reaction rate estimate than otherwise possible, and are crucial to addressing open questions
regarding explosive stellar scenarios including nova explosions, X-ray bursts, and supernovae. Fora detailed description of the SECAR system, see [1]. To achieve precision measurements, SECAR
creates mass separation between nuclear reaction products (recoils) and the unreacted beam particles
leaving a target. The design separation goals require stringent conditions on the incoming beam angle(ideally 0 and up to 3 mrad) at the SECAR target in order to satisfy the ultimate physics requirements
SECAR aims to achieve.
Traditionally, beam intensity measurements are the main diagnostic used to manually optimize
the beam transmission and incoming angle. Optimization can be accomplished by minimizing theintensity on apertures installed in the target chamber that joins the beamline upstream of SECAR
and the SECAR beamline, while maximizing the transmission through the SECAR target chamber.
Trained operators manually adjust steering knobs to align the beam while monitoring intensity
readings at multiple points along the beamline. This process can take up a significant amount of beam
operation time. Tasks such as visual checks of tune quality can be operator dependent, and can leave
the device in an irreproducible state below optimal performance. Additionally, given the relatively
large angular acceptance of the aperture system in the target chamber (3.4 mrad), precise adjustments
to the required angles are challenging for operators to achieve manually. A more robust solution
would require an automated tune optimizer that enhances reproducibility, ensures objectivity whenassessing tune quality, and operates with an efficiency that surpasses the speed of manual tuning whensearching for the optimal parameters to achieve SECAR performance targets for each experiment.
Machine learning model-dependent optimization methods have been successfully applied in otherfacilities to automate the tuning and controls of complex accelerators (e.g. [2, 3, 4]). In contrast tothese prior studies, which focused on conventional and laser wakefield based acceleration of electron
beams, ion beams (in particular, proton-rich isotope beams) need to be controlled in SECAR. Since
SECAR is a novel complex device with a lack of previously recorded data (e.g. to train a neuralnetwork), online learning, where the model is trained incrementally as it collects individual data
instances sequentially from the live separator machine, is required. Online Bayesian optimization
presents a suitable choice to substitute the time consuming task of operator-dependent manual system
adjustments to find a suitable tune. In this paper, we demonstrate the first application of Bayesian
optimization with a Gaussian process model to the online image-based incoming ion beam alignment
in the SECAR recoil separator. We show this method to be a robust and objective way to achievesmall beam angular deviations (0-1 mrad) while improving on the efficiency of traditional tuning
methods.

2

MethodExperimental system In the absence of a direct way to simultaneously measure and minimize
the incoming beam angle at the SECAR target, an indirect method was used employing existing
beamline electromagnetic elements and diagnostics. When the incoming beam is deviated from theoptical axis of a quadrupole magnet, the beam experiences imbalanced forces and deviates (steers)from its incoming axis when the quadrupole magnet strength is varied. A perfectly tuned beam in
SECAR should be transmitted through the optical axis of all the magnets. Based on this behavior, a2(a) Layout of the incoming beamline (right) and the first section of SECAR (left) with input and output
variables of the optimization labeled.
Q1 - Q2 Nominal(4.8, 10.5)

Q1 - Q2 Zero

(6.4, 2.0)

Q1 at Half - Q2 Nominal

Q1 Nominal - Q2 at Half

(5.2, 5.5)

(7.3, 0.2)(b) Sampling an observation at the viewer at FP1. The mean steering distance between the four beam spots is
4.7 mm (X and Y in pixels, 1 pixels is ∼ 0.31 mm).

Figure 1: Experimental setup for Bayesian optimization of the incoming beam angular deviation.
tuning procedure of the two sets of electromagnetic horizontal (H1, H2) and vertical steerers (V1,
V2) installed upstream of SECAR (shown in Figure 1) was developed using the SECAR Q1 and Q2
quadrupoles. By selecting a suitable setting for the two sets of upstream steerers that minimizes thesteering produced by Q1 and Q2, a beam with an optimal incoming beam angle and transmission into
SECAR was achieved. A single number that quantifies the steering as a function of steerer strengths
was obtained using digitized images from the viewer at the first ion optical focus location (FP1 in
Figure 1). This was done by measuring the center location of the beam spot (X and Y in reference
to the viewer center) at four different Q1 and Q2 field strengths, and calculating the mean distance
between the four center locations. An example of this sampling is shown in Figure 1 (b).
Bayesian optimization Bayesian optimization is an iterative search for a better optimum that imposes a probabilistic distribution over the objective function values [5, 6, 7]. It utilizes an acquisition
function that places the criterion on how to select the next point based on the probability distribution
derived from the observed data, as well as any prior information available. In this work, we model
the beam steering in SECAR as a function of steerer magnet settings using a Bayesian approach, andemploying quadrupole magnets to obtain the objective function f at the viewer at FP1 (see Figure 1).
The model takes the steerer magnet current as inputs (H1, V 1, H2, V 2) and provides an estimate fwith a mean µ and standard deviation σ of the steering at FP1 due to quadrupole magnets.
GP We chose the popular Gaussian process (GP) [8] as the probabilistic model as it is flexible,
easy to implement, and conveniently provides uncertainty estimates along with its predictions. We
describe the beam’s response to changes in the settings of different magnetic elements in the beamline
by a squared exponential (SE) kernel. The SE function is infinitely differentiable and thus is verysmooth, providing a good model for beam response to magnetic field changes. In this work, a priorof a Gaussian form was initialized for the lengthscale ` and noise σn SE kernel hyperparameters3with a mean and variance based on past tuning experience. The covariance function learns the kernel
hyperparameters empirically and updates the priors through maximizing the log marginal likelihoodat each step.
Acquisition function Bayesian optimization utilizes the observed data to decide where to evaluate
the objective function at each step guided by a lower confidence bound (LCB) acquisition function[9]. It is constructed from the GP posterior mean function µ(x) and its standard deviation σ(x) as
LCB(x) = µ(x) − ξ σ(x). The user defined exploration weight ξ directly balances the trade-off
between exploiting regions of low mean and exploring regions areas of large uncertainty.
Algorithm At initialization, the steering (evaluated using different Q1 and Q2 settings) from a random selection of initial steerer inputs (H1, V 1, H2, V 2) is evaluated. Next, x∗ = argmin(LCB(x))
is computed, and these new steerer inputs x∗ are used to obtain the next evaluation of the steering f .
This new observation is added to the samples, and the sequence iterates until the steering is minimized
and the beam is fully transmitted.
Implementation This work was implemented using the Python GPy library [10] and the associated
GPyOpt tool [11] (BSD license), and integrated into the SECAR control system using PyEpics, aPython interface to the EPICS Channel Access (CA) library for the EPICS control system [12].

3Results from SECAR beam commissioning

The presented work was developed during initial SECAR stable beam commissioning as part of thedevelopment of beam tuning procedures and optimizations for the device. Beam species included
2 1+ 133
H , Cs41+ , and 20 Ne8+ , spanning a magnetic rigidity range of 0.1444 to 0.4667 Tm.
A typical 2D steerer optimization (two of the steerers were kept at fixed values) is shown in Figure 2.
Observations are shown as circular data points (starting with white and increasing in shade up to themost recent observation in red) overlayed on the mean and uncertainty standard deviation plots. The
hyperparameters were initialized with priors of `prior = N (10, 2) (A) and σn,prior = N (0.31, 0.22)(mm) in Figure 2 (a) and `prior = N (2, 1) (A) and σn,prior = N (0.21, 0.08) (mm) for Figure 2 (b).
Figure 3 shows the number of iterations to obtain convergence of the algorithm for 2D and 4D
optimizations with different beams. The domain of possible steerer values varied between (-3, 3) A up
to (-10, 10) A for the 2D and 4D cases, respectively. In general, all 2D optimizations converged within
15 to 20 iterations, while 4D optimizations generally took about double the number of iterations,occasionally needing around 60 when the tune was particularly difficult. At each iteration, adjustingof the quadrupoles takes up to 10 s until they settle. Thus, typical optimization times range between
20 to 40 minutes, which is a significant improvement over the total time spent manually tuning(at least 1-2 hours). The method was robust to changes in the initial conditions of the beam, andsensitive to the accelerator tune upstream. Large variations (large drift, energy re-tunes, hysteresisetc) in settings upstream can affect the final configuration for the steerers, but generally recovers
reproducibility along the SECAR as we realign to the beam axis.
While the amount of steering indicates how the angular deviation of the beam from the optical axis ischanging, quantifying the incoming angle is not straightforward. To that end, the COSY INFINITY
beam physics model [13] was used to model the incoming angle that could create the observed levelof steering for several runs. This was achieved by comparing beam spot locations in COSY to thoseobtained experimentally with each quadrupole tune used to calculate the steering. We found that theincoming angle could typically be reduced to 0.8 mrad after optimization based on the amount of
final steering observed experimentally. These results highlight the ability of this method to ensure
angles of <1 mrad that are needed for optimal SECAR performance.
The method shown here for the first section was applied to several similar combinations of quadrupoles and downstream viewers along the SECAR beamline. This was especially helpful to adjust
small angular deviations whose effects were negligible at upstream viewer locations, but significant
towards the last section of SECAR.
4

(a) Horizontal optimization, ` = 10.8 A, σn = 0.3 mm, ξ = 3(b) Vertical optimization, ` = 1.2 A, σn = 0.2 mm, ξ = 0.5

Figure 2: The posterior mean µ, standard deviation of the mean σ, and LCB function for two
optimization runs. The observations are shown by dots shaded by time of observation, with thedarkest shade being the most recent observation. The next sample point is indicated by the whitecross indicating the minimum of the LCB acquisition function.

Figure 3: Best steering distance reached as a function of number of GP iterations, for 2D and 4D
optimizations during two different beam commissioning runs.

4

Conclusion

In this paper, we present the first development of online Bayesian optimization for tuning an ion
beam in a nuclear astrophysics recoil separator. The method increases the efficiency in achieving thestringent requirements needed for optimal separator performance by at least 3 times as compared
to traditional manual tuning methods. We showed that an incoming beam angular deviation was
minimized within the specified requirements down to angles of 0-1 mrad. This method is now usedroutinely for all separator tuning, and can generally be applied to other similar beamlines.
Several improvements on the current optimization are being explored. For instance, the extensive
database of accelerator historical data may be used in implementing physics-informed optimizationsof incoming beam parameters. Additionally, beam specific priors can be developed by establishinga relationship between beam species, beam rigidity, and the GP kernel hyperparameters. Moregenerally, Bayesian optimization can be used to target other system parameters. One such target isthe beam rejection of the separator that can be improved by minimizing the beam size at the mass
separation focal planes. This was explored during commissioning as well using online image-based
Bayesian optimization of the ion optical system, and is being further studied for use ahead of futurescientific experiments.
5Impact statement
Recoil separators play an important role in the nuclear astrophysics community where there is aneed for precise capture reaction rate measurements to answer many open questions relevant to abreadth of stellar nucleosynthesis sites [14]. At astrophysical energies where the yields are low, it
becomes crucial to optimize the separators to maximize the rejection of unwanted beam particles. The
optimization of such complex high dimensional systems currently requires experienced operators thatare forced to balance the time spent on manual tuning, and the time spent on scientific data collection.
We presented an online Bayesian optimization method that achieves precise beam angular deviation
properties in an efficient and objective manner based on ion optical beam behavior. This method canbe extended to other recoil separators or similar beamlines that can benefit from automated online
tuning. While beam alignment is a common problem in nuclear and accelerator instruments, thisapproach is applicable with different targets (e.g. ion optical properties) that can be optimized withsimilar image-based beam analysis or potentially other diagnostics (Faraday cups, position monitors,etc). In the broader accelerator physics community, this work extends prior developments on electron
machines [15] to heavy isotope and ion beamlines, which presents additional challenges in control
due to complex beam dynamics considerations. These results emphasize the impact such methods
can make on increasing scientific output at heavy ion facilities, while supporting reproducible andobjective research. Negative ethical or societal impacts are not applicable for this work.

Acknowledgements and Disclosure of Funding
This material is based upon work supported by the U.S. Department of Energy, Office of Science,
Office of Nuclear Physics under award number DE-SC0014384, and the U.S. National Science
Foundation under award numbers PHY-1624942, PHY-1913554, PHY-1102511, and PHY 14-30152(JINA-CEE).

References[1] G. P. A. Berg, M. Couder, M. T. Moran, K. Smith, M. Wiescher, H. Schatz, U. Hager, C. Wrede,F. Montes, G. Perdikakis, X. Wu, A. Zeller, M. S. Smith, D. W. Bardayan, K. A. Chipps, S. D.
Pain, J. Blackmon, U. Greife, K. E. Rehm, and R. V.F. Janssens. Design of SECAR a recoil mass
separator for astrophysical capture reactions with radioactive beams. Nuclear Instruments andMethods in Physics Research, Section A: Accelerators, Spectrometers, Detectors and AssociatedEquipment, 877(March 2017):87 – 103, 2018. ISSN 01689002. doi: 10.1016/j.nima.2017.08.
048.
[2] M. McIntire, T. Cope, S. Ermon, D. Ratner. Bayesian Optimization of FEL Performance at
LCLS. In Proceedings of the 7th International Particle Accelerator Conference (IPAC), page
WEPOW055, 2016.
[3] J. Duris, D. Kennedy, A. Hanuka, J. Shtalenkova, A. Edelen, P. Baxevanis, A. Egger, T. Cope,
M. McIntire, S. Ermon, and D. Ratner. Bayesian optimization of a free-electron laser. Phys.
Rev. Lett., 124:124801, Mar 2020. doi: 10.1103/PhysRevLett.124.124801. URL https://link.aps.org/doi/10.1103/PhysRevLett.124.124801.
[4] R. J. Shalloo et al. Automation and control of laser wakefield accelerators using bayesian
optimization. Nature Communications, 11, Dec 2020. doi: https://doi.org/10.1038/
s41467-020-20245-6.
[5] H. J. Kushner. A new method of locating the maximum point of an arbitrary multipeak curve inthe presence of noise. Journal of Basic Engineering, 86:97–106, 1964.
[6] J. Močkus. On bayesian methods for seeking the extremum. In G. I. Marchuk, editor, Optimization Techniques IFIP Technical Conference Novosibirsk, July 1–7, 1974, pages 400–404, Berlin,
Heidelberg, 1975. Springer Berlin Heidelberg. ISBN 978-3-540-37497-8.
[7] E. Brochu, M. Cora V, and N. de Freitas. A tutorial on bayesian optimization of expensive
cost functions, with application to active user modeling and hierarchical reinforcement learning.
2010.
6

[8] C. E. Rasmussen and C. K. I. Williams. Gaussian Processes for Machine Learning. MIT Press,
Cambridge, 2018. doi: 10.7551/mitpress/3206.001.0001.
[9] D. D. Cox and S. John. SDO: A statistical method for global optimization. In in Multidisciplinary
Design Optimization: State-of-the-Art, pages 315–329, 1997.
[10] GPy. GPy: A gaussian process framework in python, 2012. URL http://github.com/
SheffieldML/GPy.
[11] The GPyOpt authors. GPyOpt: a Bayesian optimization framework in Python, 2016. URL
http://github.com/SheffieldML/GPyOpt.
[12] M. Newville, K. Lauer, Dchabot, T. A. Caswell, A. Péteut, S. Hartman, Rokvintar, R. Clarken,
D. Allan, and T. Birke. pyepics/pyepics 3.2.7. 2017. doi: 10.5281/zenodo.883159.
[13] K. Makino and M. Berz. Cosy infinity version 9. Nuclear Instruments and Methods in Physics
Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 558(1):346 – 350, 2006. ISSN 0168-9002. doi: https://doi.org/10.1016/j.nima.2005.11.109. URL http://www.sciencedirect.com/science/article/pii/S0168900205021522. Proceedingsof the 8th International Computational Accelerator Physics Conference.
[14] C. Ruiz, U. Greife, and U. Hager. Recoil separators for radiative capture using radioactive
ion beams. The European Physical Journal A, 50(99):1 – 31, 2014. doi: 10.1140/epja/i2014-14099-4.
[15] A. Edelen, C. Mayes, D. Bowring, D. Ratner, A. Adelmann, R. Ischebeck, J. Snuverink,
I. Agapov, R. Kammering, J. Edelen, I. Bazarov, G. Valentino, and J. Wenninger. Opportunities
in machine learning for particle accelerators. 2018. doi: 1811.03172.

Checklist
1. For all authors...
(a) Do the main claims made in the abstract and introduction accurately reflect the paper’s
contributions and scope? [Yes](b) Did you describe the limitations of your work? [N/A](c) Did you discuss any potential negative societal impacts of your work? [N/A](d) Have you read the ethics review guidelines and ensured that your paper conforms tothem? [Yes]2. If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results? [N/A](b) Did you include complete proofs of all theoretical results? [N/A]
3. If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? [N/A](b) Did you specify all the training details (e.g., data splits, hyperparameters, how they
were chosen)? [Yes](c) Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? [N/A](d) Did you include the total amount of compute and the type of resources used (e.g., typeof GPUs, internal cluster, or cloud provider)? [N/A]
4. If you are using existing assets (e.g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators? [Yes] See Section 2.
(b) Did you mention the license of the assets? [Yes] See Section 2.
(c) Did you include any new assets either in the supplemental material or as a URL? [N/A](d) Did you discuss whether and how consent was obtained from people whose data you’reusing/curating? [N/A]7

(e) Did you discuss whether the data you are using/curating contains personally identifiable
information or offensive content? [N/A]
5. If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if
applicable? [N/A](b) Did you describe any potential participant risks, with links to Institutional Review
Board (IRB) approvals, if applicable? [N/A](c) Did you include the estimated hourly wage paid to participants and the total amountspent on participant compensation? [N/A]8