First simultaneous measurement of sextupolar and octupolar resonance driving terms in a circular accelerator from turn-by-turn beam position monitors data

Beam lifetime in storage rings and colliders is affected by, among other effects, lattice nonlinearities. Their control are of great benefit to the dynamic aperture of an accelerator, whose enlargement leads in general to more efficient injection and longer lifetime. This article describes a procedure to evaluate and correct unwanted nonlinearities by using turn-by-turn beam position monitor data, which is an evolution of previous works on the resonance driving terms (RDTs). Effective sextupole magnetic errors and tilts at the ESRF electron storage ring are evaluated and corrected (when possible) by using this technique. For the first time, also octupolar RDTs could be measured and used to define an octupolar model for the main quadrupoles. Most of the deviations from the model observed in the sextupolar RDTs of the ESRF storage ring turned out to be generated by focusing errors rather than by sextupole errors. These results could be achieved thanks to new analytical formulas describing the harmonic content of the nonlinear betatron motion to the second order. For the first time, RDTs have been also used for beam-based calibration of individual sextupole magnets. They also proved to be a powerful tool in predicting faulty magnets and in validating magnetic models. This technique provides also a figure of merit for a self-assessment of the reliability of the data analysis.


I. INTRODUCTION AND MOTIVATION
Many factors make the implementation of a magnetic optics in a circular accelerator different from the nominal one: deviations from the magnet calibration curves and from the ideal magnetic lengths, displacements from the reference position and axis, unknown multipole components, and the like. This generally results in machine performances below expectations: low beam lifetime and dynamic aperture, poor injection efficiency, large emittances (in lepton machines) and limited luminosity (in colliders).
While an artillery of different methods and algorithms has been developed and successfully implemented in routine operation for the evaluation and correction of focusing errors (linear optics) and betatron coupling, their extension to the nonlinear modelling and correction remains difficult, because either time-consuming or requiring diagnostic tools unavailable a decade ago. In most cases, such as at the ESRF storage ring, the correction of the nonlinear optics is done by trials and errors seeking heuristically longer lifetime. Nevertheless, the installation of beam position monitors (BPMs) with turn-byturn (TbT) acquisition system in many circular accelerators and the parallel development of a theoretical formalism for the description of the harmonic content of the acquired data paved the way for more rapid and deterministic measurement and correction of the nonlinear optics. This paper proposes a new method aiming at such characteristics.
Several approaches for the evaluation of the nonlinear lattice model exist and any attempt to offer a coverage of the pertinent literature would be incomplete. However, in the context of this paper a few works may be recalled, either for their proximity or because they rep-resented milestones for this work. A pioneering work on the exploitation of TbT BPM data dates back to the early '90s [1]. The application of the normal form approach [2,3] to single-particle tracking data of Ref. [4] introduced for the first time an explicit correspondence between spectral lines of TbT data and resonance driving terms (RDTs). A breakthrough was represented by the experience at the CERN Super Proton Synchrotron, where sextupolar RDTs along the entire ring were measured and used to detect faulty sextupole magnets [5] and to extract strength and polarity of some sextupoles [6,7]. More recently independent component analysis (ICA) was applied to TbT BPM data for the extraction of lattice linear and nonlinear properties [8]. Of interest are also the experimental results of Ref. [9], where the nonlinear model was fit to the spectral content of TbT data, even though not via the RDTs. In Ref. [10] simultaneous measurements of two RDTs, one sextupolar and one octupolar, are reported.
The paper is structured as follows. After highlighting and anticipating both advantages and limitations of the proposed method in Sec. II, the technique is introduced and discussed in its main results in Sec. III (all mathematical derivations are put in separate appendices). The experimental results of the new method in evaluating the nonlinear model, calibrating sextupole magnets and computing a corrector setting are presented in Sec. IV. The evaluation of octupolar terms in the lattice from the same TbT data is described in Sec. V.

II. NOVELTIES AND LIMITATIONS OF THE PROPOSED METHOD
The main novelties of the proposed scheme (compared to other methods for the measurement and correction of nonlinear lattice model) may be listed as follows: (i) The harmonic analysis is performed on the pure position data x (y), rather than on the complex signal x − ip x (y − ip y ) of Ref. [4,5], hence with no concern about errors in the evaluation of the momentum p x (p y ) and about BPM synchronization; (ii) The possibility of measuring at the same time linear combinations of all sextupolar (normal and skew) and most of octupolar RDTs offers a complete and simultaneous picture of all resonances at a given working point, rather than having to shift the tunes close to a single resonant condition to excite a specific mode, as in Ref. [8]; (iii) The nonlinear problem of inferring sextupole and octupole strengths from the betatron beam motion is translated into a linear system to be inverted (with due preliminary precautions) when RDTs are used as observables, hence rendering the model fit and correction straightforward; (iv) Last but not least, the quality of the analysis of sextupolar RDTs may be self-assessed, so to optimize the experimental conditions as well as the initial lattice model.
Of course, this approach suffers from some practical limitations too.
First, the quality of the analysis is limited by the spectral resolution, here defined as the ratio between the amplitudes of the harmonics and the background noise. The resolution scales with the number of turns of acquired data exploitable for a Fast Fourier Transform (FFT). Ideally, the greater the number of turns with exploitable data, the higher the spectral resolution and hence the quality of the RDT measurement. Data filtering and interpolation [11,12], may provide excellent resolution already with tens of turns, though the presence of noise [13] and the need of detecting spectral lines whose amplitudes are orders of magnitude lower than the tune line necessitate several hundred of exploitable oscillation turns. Chromaticity and decoherence (induced by nonzero amplitude dependent detuning) modulate and damp the TbT signal [14]. This multi-particle effect is not contemplated here, the baseline model being of a beam moving rigidly as a single particle. Most of the operational settings optimized for beam lifetime and stability result in nonzero chromaticity and detuning with amplitude. In the case of the ESRF storage ring, the exploitable number of turns ranges from about 30 to 60 turns, depending on the optics put in operation, insufficient to detect sextupolar harmonics whose amplitude is typically 2 or 3 orders of magnitude lower than the tune line. Therefore, a special optics was designed to provide almost zero linear chromaticity and detuning. For hadron machines this may be sufficient to obtain thousands of exploitable TbT data, as in Ref. [8]. In lepton machines radiation damping depresses naturally the TbT signal. At the ESRF storage ring, the damping time being of about 2500 turns, the signal is sufficiently depressed to compromise the whole measurement already after 1024 turns (see Fig. 23). Usually either 256 or 512 turns are used for the FFT, as radiation damping would enhance the background spectral noise.
Second in the list of limitations is the BPM electronic resolution and noise. The commercial Libera Brilliance [15] BPMs installed in the ESRF storage ring are equipped with a standard electronic filter that covers several turns, resulting in TbT data corrupted from the neighbor turns. Even though a convolution may be carried out to extract clean TbT data, the spectral resolution remained insufficient for a detailed nonlinear analysis. A great improvement was achieved when implementing a moving-average filter (MAF) [16]. All results presented here are based on acquisitions carried out with this filter.
The dedicated optics designed and implemented for having zero chromaticity and amplitude detuning sets a limit on the capability of inferring sextupole errors for other operational optics, these having different sextupole settings. A way out would be to evaluate the relative field error for each magnet and to export it in all other optics, though this assumes that the relative errors are constant along the entire range of sextupole currents (i.e. strengths). The situation at the ESRF storage ring turned out to be rather relaxed in this sense, because almost all sextupole errors inferred from this method lay well within the specified ±1%. Moreover, most of the deviations observed from the ideal model are originated by the focusing errors, through the modulated beta functions present in the definitions of the RDTs. A first correction, hence, may be carried out by assuming ideal sextupoles and using the best linear model (easy to infer with other techniques) to evaluate the modulated RDTs and use sextupole correctors to restore at the best their periodicity.
A last limitation is linked to the linear system to be pseudo-inverted to extract the nonlinear model. The singular value decomposition (SVD) has been used for this purpose. The resulting model shall be then considered as effective and the inferred sextupole errors depend clearly on the numerical parameters (such as number of eigen-vectors, choice of weights among different possible sources of errors, and the like).

III. COMBINED RESONANCE DRIVING TERMS FROM (DUAL-PLANE) BPM DATA
A. Theoretical introduction A charged particle circulating inside a circular accelerator or storage ring will execute a turn-by-turn oscillation around the closed orbit, if displaced transversely by a pulsed magnet, such as a magnet kicker. In phase space this oscillation describes a closed curve which reflects the local characteristics of the magnetic lattice. In an ideally linear machine this curve will be an ellipse.
In the presence of strong sextupoles, at sufficiently large oscillation amplitudes the curve takes the shape of a triangle. With strong betatron coupling, the curves in the two transverse phase spaces (x, p x ) and (y, p y ) are linear combinations of the original ones. As long as the curve in phase space is closed and reasonably continuous (i.e. the motion is stable), the Fourier theorem ensures that it may be expressed as the sum of a series of sine or cosine terms (called the Fourier series), each of which has specific amplitude and phase coefficients known as Fourier coefficients. In other words, each closed curve may be described (after a linear transformation) as the superposition of circles. The harmonic content of the ideal ellipse in phase space will be represented by a single pair of amplitude and phase (the tune line): After the Courant-Snyder (C-S) transformation, the ellipse becomes a circle, whose radius corresponds to the amplitude and its position along the circumference is defined by the phase. Two additional harmonics (i.e. circles) are excited with betatron coupling (the tune of the other plane and its opposite). The triangular-shaped curve will instead require several harmonics to be properly described.
The three examples are depicted in Fig. 1. Intuitively, the stronger the sextupoles, the more triangular is the horizontal phase space curve and the larger are the additional harmonics. It is indeed possible to correlate quantita- tively (up to a certain precision) these deformations, and hence these harmonics, to the strengths of the magnets installed in the machine. More important, this correlation is in most cases linear with a precision much larger than the experimental resolution. The fundamental ingredient to establish this correlation is provided by the resonance driving terms (RDTs) of Refs. [4][5][6][7]. These may be evaluated both from analytic formulas (rather simple in most cases) and from the harmonic analysis of the phase space curves, i.e. from their Fourier coefficients of the TbT BPM data. In Appendix A the theoretical description establishing this correlation is recalled and extended (when needed). The results of interest in the context of this paper are summarized in the next section. Throughout the paper, all RDTs and machine parameters (linear and nonlinear) from the model are evaluated by MADX-PTC [17]. Tracking simulations to simulate and validate the harmonic analysis of TbT BPM data have been also carried out with this code. No significant difference has been observed in the RDTs when representing sextupoles either as thin or thick elements and when including fringe fields. As far as nonlinear parameters (such as amplitude dependent detuning and chromaticity) are concerned, significant differences between the three representations appear and only the thick-lens model with fringe field has been used.

B. Theoretical results
In this section the correlation between the harmonic content of an ideal TbT oscillation in the two transverse planes, x and y, and the RDTs is discussed. For ideal it is meant here a free oscillation of an instantaneously displaced particle beam without any damping (from radiation, chromaticity, amplitude-dependent detuning, and the like) and with perfectly calibrated BPMs. Forced oscillations induced by resonant devices, such as AC dipoles, require a different description [18,19].
In Table I the spectral lines of the signals x(N ) = x(N )/ √ β x andỹ(N ) = y(N )/ β y , where β denotes the Courant-Snyder (C-S) parameter, are listed together with the corresponding RDTs. Higherorder octupolar lines are analyzed in Sec. V. As discussed in Appendix B, for the evaluation of the RDTs the complete phase space curve (x, p x ) and (y, p y ) generated by the TbT oscillation is necessary, which in turn requires the combination of signals from 2 synchronized BPMs. By analyzing its projection on the x and y axis, i.e. by using single-BPM TbT data, RDTs are no longer measurable. However, their linear combinations, the combined RDTs (CRDTs) F xy , F yx , F N S and F SS are still observables. CRDTs are defined in the fourth column of Table I and are derived in Appendix D. In Table II formulas to infer their amplitudes and phases from the spectral lines are reported, whereas analytic formulas for the computation of first-order RDTs, and hence of the CRDTs, from the lattice model are listed in Table III.
Combined RDT amplitude phase qF  Before entering in the perilous terrain of higher orders, it is worthwhile to define what actually order means. in Appendix A it is shown how the nonlinear betatron motion may be described in terms of truncated Lie series: the degree of precision (and difficulty) of the description is related to the order at which these series are truncated. RDTs depends on the strengths of the corresponding magnets K = (δK 1 , J 1 , K 2 , J 2 , K 3 , ...) where δK 1 is the quadrupole error field not included in the computation of the C-S parameters, J 1 is the skew quadrupole field, K 2 and J 2 is the normal and skew sextupole fields, K 3 refers to the octupole and so on. First-order RDTs f (1) result from Lie series truncated to the first term, are generated by the specific corresponding magnet, as in Table III, and scale linearly with their strengths. Schematically they may be represented by the following chart When the Lie series are truncated to the second order, cross-products between the magnet strengths appear and the picture becomes more complicated for the secondorder RDTs f (2) focusing errors The above scheme simplifies considerably under three reasonable assumptions. First, if the C-S parameters (β and φ) used in Table III are evaluated from the lattice model including focusing errors, δK 1 ≡ 0. Second, no strong skew sextupole is installed or powered in the machine and J 1 is generated by slightly tilted normal sextupoles, K 2 >> J 2 and J 1 ⊗ J 2 ≃ 0, betatron coupling being also weak. Third, coupling is assumed to be weak so that J 1 ⊗ J 1 ≃ 0. The above RDTs then reduce to focusing errors These considerations (detailed mathematical derivations may be found in Appendix A) indicate that the first-order analytic formulas for coupling and normal sextupole RDTs of Table III are valid also to the second order, provided that the used C-S parameters (β and φ) are evaluated from the lattice model including focusing errors. By doing so, first-order beta-beating RDTs are automatically zero.
Second-order terms are instead to be computed and included in the evaluation of skew sextupole RDTs, which are excited to the first order by J 2 (introduced by tilted sextupoles and/or displaced octupoles), and to the second order by the cross-product between coupling and normal sextupoles, K 2 ⊗ J 1 . In machines with strong focusing, such as light sources, strong normal sextupole (K 2 ), even if multiplied by low (i.e. well corrected) coupling (J 1 ), render the second-order contribution to the skew sextupole RDTs comparable to that of the first order, i.e. K 2 ⊗ J 1 ≃ J 2 . Similar considerations apply for octupolar RDTs.
Another complication appearing when second-order terms are to be taken into account is that RDTs f = f (1) + f (2) are no longer observables from the harmonic analysis of turn-by-turn position data. The Observable RDTs (ORDTs) g jklm may be written as where L is a linear function and jklm = pqrt = tuvz. For this reason in Table I the ORDTs g jklm replace the first-order f (1) jklm in the four lines corresponding to skew sextupole harmonics. Formulas for the computation of the ORDTs from the lattice model are derived in Appendix A and may be easily implemented numerically. An example may help clarifying the nature of L and revealing a counterintuitive feature: The skew sextupole ORDT g 0030 reads whereh (2) (s) 0030 andĥ 0030 are computed in Eqs.(A57) and (A62) respectively, whereas all other first order RDTs f (1) are defined in Table III. The counterintuitive feature exhibited by the additional term L f (1) ⊗ f (1) is that a skew sextupole resonance, the (0,3) in the case of g 0030 , may be excited even in the absence of skew sextupole sources f 0030 = 0 and far away from the resonant condition 1 − e 2πi(3Qy ) ≃ 1 and f (2) 0030 ≃ 0, for example in the presence of large coupling and close to the difference resonance |f (1) 1020 | and the normal sextupole RDT f (1) 1020 may be arbitrarily large.
In summary, the Combined RDTs (CRDTs) F are measurable from turn-by-turn position data (Table II). They may be also computed from the model (fourth column of Table I) via the first-order RDTs (Table III) or, if second-order contributions may not be neglected, via the Observable RDTs (ORDTs) of Appendix A. The logical scheme to be followed in the nonlinear lattice modelling discussed in this paper is the following: Tables III,I, Appendix A initial lattice model

C. Experimental precautions
An important condition necessary to ensure the applicability of the single-BPM TbT data analysis is that monitors are dual-plane. In fact, in order to extract the CRDTs the knowledge of amplitude (2I) and phase (ψ 0 ) of both tune lines is mandatory , which in turn requires the possibility of measuring TbT data in both planes at the same BPM. Another requirement is that the beam does not experience decoherence, otherwise additional factors are to be included, as discussed in Ref. [5]. A further condition is that BPMs have no tilt or calibration error. Uncalibrated BPMs would provide TbT data in the form ofx(N ) BP M = η xx (N ), where η x = 1. An example may help explaining their impact on the formulas of Table II. A hypothetical signalx(N )s contains two harmonics, the tune H(1, 0) and a sextupolar H(−2, 0), in the form of Table II). An uncalibrated BPM would instead generatẽ The above normalization would carry the calibration factor, corrupting the CRDT measurement, since |H(−2, 0)|/[4|H(1, 0)| 2 ] = |F N S3 |/η x . The impact of BPM tilts on the harmonic analysis is similar, though less obvious, and is assumed here to be negligible.
The dependence of the RDTs (hence of the CRDTs and, in turn, of the spectral lines) on the phase advances ∆φ between the observation point (the BPM) and the magnets results in the dependence on the longitudinal position along the ring. Ideally, they shall modulate according to the machine periodicity. This feature is of particular interest, for the detection of malfunctioning magnets, as reported in Ref. [5], or for a direct measurement of their strengths and polarities [6,7].
On the other hand, the amplitude of the tune lines |H(1, 0)| and |V (0, 1)| shall be constant along the ring, as indicated by the first two lines of Table I . There it is indeed assumed that focusing errors are already included in the model (i.e. in the beta functions used to normalize the TbT BPM data) and hence the beta-beating RDTs f 2000 and f 0020 of Eqs. (C11)-(C12) are zero. If the tune line amplitudes measured at all BPMs are not constant, three are the possible causes to be evaluated and removed prior to any further analysis involving other spectral lines.
First, the linear lattice model used to evaluate the beta functions at the BPMs is incorrect. This shall result in non-zero quadrupolar RDTs f 2000 and f 2000 , in a modulation of the beta functions (beta-beating) and in wrong phase advances between BPMs. In Appendix C it is shown how the beta-beating is correlated to the RDTs and how to infer it from the tune line amplitudes measured at each BPM. Even if elegant and handy, such formulas are of limited applicability for several reasons: (i) it is impossible to disentangle beta modulation from BPM calibration factors or tilts, (ii) quadrupoles RDTs are not measurable from the harmonic analysis of the single-BPM TbT data, (iii) second and higher order RDTs do modify the tune line amplitudes introducing a dependence on the position along the ring. Fortunately, none of these elements affects the phase of the tune line, and the difference between its value at two consecutive BPMs corresponds to the betatron phase advance. Hence by comparing and fitting the measured BPM phase advance, a reliable focusing model may be built and used to evaluate correctly the beta functions at the BPMs. As discussed in Sec. V, some octupolar CRDTs may indeed perturb the phase of the tune lines, though this effect may be controlled by a careful choice of the initial excitation (i.e. kicker strength). It is worthwhile reminding that the fit of the BPM phase advance shall be accompanied by a fit of the measured dispersion function for a reliable model.
Second, if a modulation persists even after fitting the BPM phase advance (and dispersion), it shall be verified whether second-order sextupole terms may introduce a dependence on the longitudinal position. As discussed in Appendix C, this perturbation depends on the initial oscillation amplitude (or the action), i.e. on the kicker strength, and may be evaluated from preliminary single-particle tracking simulations. For the measurement procedure discussed here, it is hence necessary to limit the kicker strength so to keep the natural modu-lation of the tune line amplitude induced by sextupoles well below the desired experimental resolution. This contrasts with the desire of having a large signal-to-noise ratio between spectral noise and amplitude of the sextupolar lines, which would require a strong initial excitation. Eventually a trade off shall be found with the help of tracking simulations and measured data at different kicker strengths.
The third source of tune line amplitude modulation is represented by BPM calibration factors η = 1 and tilts. Assuming that the latter are negligible compared to other sources of errors, the only way to infer η and remove them before carrying out the spectral analysis is to impose constant tune line amplitude at all BPMs after having verified the previous two points. The Fourier transform redone after scaling the measured data by η may then be used for the analysis of the nonlinear model.
A last interesting figure to evaluate the quality of the TbT BPM data and of its harmonic analysis is represented by a cancellation condition that shall be satisfied by some measured CRDTs. According to the definitions of the normal sextupole terms of Table I it is straightforward to prove that anywhere in the ring: the closer F 0 is to zero, the more reliable is the harmonic analysis described here. Note that the measured F 0 along the ring depends only on: (i) the linear lattice model (β functions used to normalize the BPM TbT data); (ii) the BPM calibration factors, spatial and spectral resolution, electronic noise and the like; (iii) initial beam excitation, i.e. kicker strength. Luckily enough, it does not depend on the nonlinear lattice model, being valid for any sextupole setting.

D. From normal sextupole CRDTs to sextupole errors
Let us assume to have acquired N TbT data from N BP M BPMs. From the harmonic analysis of Table II it is possible to infer the four normal sextupole CRDTs F N S3 , F N S2 , F N S1 and F N S0 , at all BPMs. Being these all complex quantities, a N BP M · 4 · 2 vector #» F N S,meas may be defined containing the measured real and imaginary parts of the four CDRTs An equivalent vector may be defined from the model (C-S parameters including focusing errors,β and φ, and sextupole integrated gradients, K 2 ): The RDTs f 3000 , f 1200 , f 1020 , f 0120 and f 0111 may be evaluated from Table III, to be used for the evaluation of the model CRDTs through the fourth column of Table I. Being all passages from the integrated strengths to the CRDTs linear, the model vector may be defined as where #» K 2 contains all N sext known sources of sextupolar field along the ring, and 8 · N BP M × N sext matrix M NS depends on the linear lattice only, through the beta functions, the phase advances between BPMs and sextupoles and the tunes. The difference between measured and model CRDTs then reads where # » ∆K 2 contains the N sext sextupole field errors to be inferred after pseudo-inverting (via SVD, for instance) the above linear system. Note how the choice of defining the CRDTs vector with the real and imaginary parts ensures the linearity of the system, whereas the choice of decomposing these complex quantities in amplitude and phases, as in Ref. [9], would have introduced an unnecessary and avoidable nonlinearity in the problem, thus requiring a nonlinear minimization routine for the evaluation of # » ∆K 2 . The linear system of Eq. (10) may be also used for the calibration of an individual sextupole. The optics model in this case is necessary for the evaluation of the After pseudo-inverting the above system, the inferred δK 2 may be compared with the expected value from the change of current in the sextupole and its calibration curve. The latter may be reconstructed and compared with the magnetic model (or measurement) by repeating the procedure at different δK 2 . Again, the problem of calibrating a nonlinear magnetic element is reduced to a linear system when looking at the CRDTs.

E. From normal sextupole CRDTs to sextupole correction
The natural extension of Eq. (10) is a system for the evaluation of a sextupole corrector setting. If all sextupole magnets have independent power supplies and other sources of sextupolar fields (such as fringe fields in bending magnets) may be neglected, the pseudoinversion of Eq. (10) provides already the set of corrections # » δK 2 to insert in the sextupoles. If this is not the case and only N cor corrector sextupoles are available (which is the case at the ESRF storage rings, with 224 sextupoles grouped in 7 families and only 12 sextupole correctors available), the system then reads where #» K cor 2 contains the strengths of the N cor sextupole correctors to be evaluated after pseudo-inverting the above system, and the 8 · N BP M × N cor matrix M NS,cor depends on the beta functions and the phase advances between BPMs and the correctors. Note that #» F N S,ref (reference or desired vector) has been used in place of #» F N S,mod (model vector). The difference may be of importance for those machines (like the ESRF storage ring) where beta-beating is corrected up to some percents and special insertion optics break up significantly the machine natural periodicity.
#» F N S,ref may refer hence to the ideal lattice without any insertion optics, whereas #» F N S,mod refers to the actual model including insertion optics (if any) and all known lattice errors. It is assumed here that the best CRDT correction shall be based on the ideal vector #» F N S,ref , rather than on #» F N S,mod . Once more, the problem of correcting nonlinear magnetic elements is reduced to a linear system, Eq. (12), to be pseudo-inverted.

F. From skew sextupole CRDTs to sextupole tilts
The procedure described in Sec. III E may be repeated, with some precautions, for the evaluation of sextupole tilts. From the harmonic analysis of the TbT BPM data and Table II it is possible to infer the four skew sextupole CRDTs F SS3 , F SS2 , F SS1 and F SS0 , at all BPMs, and cast them in a N BP M · 4 · 2 vector #» F SS,meas The evaluation of the corresponding vector from the model require a preliminary step. As discussed in Sec. III B, contrary to normal sextupole terms, it is not possible to ignore the second-order contribution to the skew sextupole CRDTs due to cross-terms between coupling and normal sextupole RDTs, see Eq.
(3). In other words, ideal skew sextupoles CRDTs shall all be zero, but even with perfectly upright sextupoles they may be nonzero because any residual coupling in the machine transfers normal sextupole spectral harmonics in the other plane, hence generating skew sextupole harmonics and corresponding CRDTs. Not taking into account this natural contribution would corrupt the evaluation of sextupole tilts. For this reason new analytic formulas valid to second order have been derived. They are presented in Appendix A and shall be used for the evaluation of the skew sextupole ORDTs g jklm , and hence of the CRDTs F SS . Provided that betatron coupling is well modelled, the second-order contribution to the CRDTs F SS may be then computed and any difference between the model vector #» F SS,mod and the measured one #» F SS,meas will depend on the sextupole tilts only, i.e.
where the angles θ can be extracted from J 2 according to since the skew sextupole strength introduced by a tilted sextupole is J 2 = −K 2 sin (3θ). It is worthwhile mentioning that measuring skew sextupolar CRDTs will be unavoidably more difficult than extracting normal sextupole CRDTs, the latter scaling with the (strong) sextupole gradients, while the former scale with the (small) sextupole tilts. Depending on the lattice configuration and coupling correction, #» F SS may be one or two orders of magnitude lower than #» F N S . In machine with skew sextupole correctors, the system of Eq. (12) may be modified as where the reference vector #» F SS,ref in this case is zero. In machine without skew sextupole correction, skew quadrupoles may be used to correct, along with coupling, skew sextupole CRDTs, via the second-order contributions f (2) jklm . This later option, however, would require to solve a more complex (but still linear in the skew quadrupole strengths) system not discussed here.

A. Preparing measurements
The TbT acquisition of the commercial Libera-Brilliance BPMs installed in the ESRF storage ring requires some care in its preparation. Even though the measurement is rather quick, a series of machine studies were carried out between 2010 and 2011 for the correct setup.
First of all, in the case of the ESRF storage ring the ideal beam filling pattern is the 1/3, i.e. with a train of about 330 bunches separated by about 660 empty RF buckets. The interest of this pattern is threefold. First, it allows a straightforward synchronization among all 224 BPMs and the bunch train, by using the booster (whose circumference is exactly 1/3 the one of the storage ring) and fast monitors in the transfer line. Second, both the horizontal and the vertical kickers may by synchronized so to have the bunch train on their flattop: The measured invariants and CRDTs would be corrupted if part of the beam experiences the kicker pulse rise and/or fall. Third, this filling mode maximizes the BPM resolution, the beam signal being integrated over 1/3 of the revolution frequency, whereas a few-bunch pattern would provide intense peak signal with a noisier integrated value.
Another parameter to be adjusted to minimize the BPM noise and to prevent a saturation of the signal (and hence a corrupted harmonic analysis) is the beam current against the amplification factor of the acquisition system. In order to have the best dynamic range from a few µA to 200 mA, the ESRF BPMs apply a variable signal amplification. The special optics implemented for this measurement with almost zero linear chromaticity and amplitude dependent detuning may sustain up to 10 mA before losing the beam. However, in order to maximize the BPM resolution during the signal digitization, measurements are carried out with 7 mA for a kicker excitation so to displace horizontally the beam from 1.3 to 5.5 mm. With a β function of 36.6 m this corresponds to an invariant between about 10 −4 and 4 × 10 −4 m 1/2 . Higher beam current would result in a different amplification range with lower digitization resolution, whereas stronger excitations risk to saturate the BPM signal.
As mentioned in Sec. III C the kicker strengths shall be a trade-off between spectral resolution (the stronger, the better) and second-order terms affecting the invariance of the tune line amplitude (the weaker, the better). Measurements are usually repeated at different kicker strengths. For the final analysis of sextupolar CRDTs only the data set of 50 repeated measurements with both invariants ≃ 2.0 × 10 −4 m 1/2 is used (corresponding to displacement of about 2.5 mm horizontally and 1.0 mm vertically, with β functions of 36.6 and 6.0 m). For the octupolar model, instead, data with stronger excitations are used. Note that hereafter, unless specified otherwise, the invariant is referred to as 1/2 √ 2I so to be equal to the tune line amplitude (see first two rows in Table I).
As discussed in Sec. II, even though more than 2000 turns may be stored by the BPMs and the weak decoherence ensures about 1000 turns of exploitable data, it will be shown how the best results are obtained when only 256 turns are used for the analysis of sextupolar CRDTs (512 turns for the octupolar).

B. Linear analysis of TbT BPM data
The starting linear optics model used to evaluate the expected CRDTs and the β functions at the BPMs (necessary for the construction of TbT signals to be analyzed on the preliminary measurement and fit of the orbit response matrix (ORM) and dispersion [28]. To this end, only quadrupole and dipole relative errors are introduced, with a cutoff in the fit so not to overcome the specifications of 10 −3 for the quadrupoles. No other source of errors is introduced at this stage. As figure of merit to assess the quality of the linear lattice model, the BPM phase advances are used: The smaller the deviation from the theoretical values, the better the model. The BPM phase is nothing else than the phase of the tune line (i.e. the first harmonic of the FFT of the TbT data) plus an arbitrary initial phase which depends on the trigger of the acquisition system. Assuming that all BPMs are well synchronized, the difference between the tune phases at two monitors shall correspond to the BPM phase advance, the arbitrary phase being canceled out. At each pair of BPMs along the ring, the difference between measured and model phase advances may be evaluated and plotted. Its root-mean-square (rms) value over all BPMs may be also computed and used as single figure of merit. In Fig. 2  from the ORM, until the one(s) matching the measured BPM phase advances, the rms variation along the ring of the tune line amplitude, i.e. of the invariant, is also reduced, as displayed in Table IV. It is also worthwhile noticing how the residual rms error on the BPM phase advance has a minimum for the fifth data set of Table IV, with a kicker excitation so to generate an invariant of about 2 × 10 −4 m 1/2 . Larger excitations seem to induce greater errors that could not be correlated to linear lattice elements. Octupolar terms affecting the tune lines may be the source of this larger discrepancy.
As far as the tune line amplitude variation along the ring is concerned, all data set with excitation lower than 2.6 × 10 −4 m 1/2 show a modulation below 1% (with the TbT model). According to tracking simulation results of Table XVI, second-order sextupolar terms contribute for a fraction of this modulation only. When comparing modulation observed in single-particle tracking (Fig. 28) and that measured with the strongest excitation ( Fig. 3), even though a similar pattern may be guessed in the horizontal plane, the fast modulation observed in the vertical plane is unexpected. This indeed can be explained by small differences in the signal attenuation induced by BPM cables of different lengths (an effect visible in the sum BPM signal). For sake of completion effective BPM gains have been computed so to cancel the tune line amplitude modulation corresponding to the fifth data set of Table IV, though they turned out to play a limited role in the nonlinear analysis.
A brief digression on the effective linear lattice model inferred from the the BPM phase advance (and dispersion) response matrix is worth to be introduced. The matrix has been built having different error sources: besides quadrupole field errors and rotation (for coupling), quadrupole and sextupole displacements (longitudinal, horizontal and vertical) have been introduced along with longitudinal dislocations of BPMs. It turned out that longitudinal displacements have a negligible impact on  Table IV   TABLE IV. Kicker strengths and corresponding invariants for the 8 sets of TbT BPM data (50 repeated acquisitions). The rms modulation of the tune line amplitude (i.e. of the invariant) and the rms deviation from the model BPM phase advance are measured with three different linear lattice models: ideal with no error, with errors inferred from precedent ORM measurement and fit, and from the harmonic analysis of TbT data. Horizontal and vertical data for the BPM phase advance are merged together when computing the rms deviation. ideal lattice model model with errors (ORM) model with errors (TbT) the BPM phase advances, whereas this is not the case for the other two axes. The best SVD fit was obtained with the error model displayed in the centre plot of Fig. 6. The corresponding rms values are compatible with specifications and well within the results from survey measurements [20]. Such a model, however, is difficult to handle, because magnet displacement would require the distorted orbit to be taken into account, complicating the overall analysis. Nevertheless, the same SVD fit could be obtained with quadrupole field errors only, at the price of increasing unrealistically their values, well above their specifications (bottom plot of Fig. 6). Nonetheless, this has the advantage of not introducing any complication with the orbit and large quadrupole errors are to be considered as representative of the sextupole displacement too. The nonlinear analysis discussed in the next section is based on this later baseline linear model.
Even though not used for the determination of linear lattice model, it is interesting to note how the CRDTs cancellation condition defined by F 0 of Eq. (7) is improved when the BPM phase advance is corrected. In general, the closer F 0 is to zero among all BPMs, the more accurate is the harmonic analysis. F 0 is evaluated with the CRDTs measured from the sextupolar spectral lines according to Table II. Its rms values (for the fifth data set of Table IV)  In conclusion, the linear analysis of the tune line (amplitude and phase) provided an effective linear model that improves considerably the quality of the harmonic analysis. The deviation between model and measured BPM phase advance is reduced by a factor greater than ten. The modulation of the tune line (i.e. of the invariant) is reduced from 2% to less than 1%. The cancellation term F 0 is reduced by about 20%. Effective BPM gains could be inferred from the tune line amplitude modulation.

C. Nonlinear analysis of TbT BPM data
The effective linear lattice error model discussed in the previous section may now be used to evaluate the modulated C-S parameters necessary to normalize the TbT data (β functions) and to evaluate the model CRDTs from Tables III and I. The measured CRDTs are instead inferred from the sextupolar lines H(−2, 0), H(0, −2) and V (±1, −1) according to Table II. These lines are represented in blue in the example of measured spectra of Fig. 7. As for the linear analysis, a data set among those acquired at different kicker strengths is to be chosen, considering that a too weak excitation may affect the measurement because of the low signal-to-noise ratio, whereas a too strong excitation may introduce high- order terms not included in the present analysis. As discussed in Sec. III C, the nonlinear analysis presented here is valid as long as the CRDT residual F 0 of Eq. (7) is much lower than the average CRDT amplitudes. The rms values of F 0 (computed after averaging among the 224 BPMs and the 50 acquisitions) for each data set and for different linear lattice models are reported in Table V.
Because of the ESRF storage ring tune working point (Q x = 36.440 and Q y = 13.390) two sextupolar lines, H(0, −2) and V (−1, −1), necessary for the evaluation of as many CRDTs receive a contribution from higher-order octupolar terms, as shown in Fig. 7. A complete list of the octupolar spectral lines may be found in Ref. [4]. If not taken into account or avoided, this superposition will corrupt the CRDT measurement and the overall nonlinear model. Even though it is not possible to disentangle the individual contributions, the CRDT residual F 0 may be evaluated: the closer to zero, the less detrimental are the octupolar-like terms. Another way out may be found by slightly detuning the machine so to ensure a sufficient separation between these lines: By setting for example Q x = 36.438 and Q y = 13.385 a separation of 0.022 in tune units would be assured. In the acquired data (at nominal tunes) the mean value of F 0 is always very close to zero (between -0.4 and 0.8 m −1/2 , depending on the data set). The lowest rms F 0 (3.7 m −1/2 ) is obtained for an excitation corresponding to a mean invariant (in both planes) of 2.0 × 10 −4 m 1/2 . The CRDTs measured from this data set are then used for the nonlinear lattice modelling.
As for the linear analysis, a figure of merit needs to be defined to quantify the goodness of the sextupole model. The difference between the measured CRDT vector and the one for model may be used to this end. The rms value of this vector, i.e. the residual R, provides a figure   Table V. A special sextupole setting was used to reduce detuning with amplitude and chromaticity and to enhance the normal sextupole spectral lines. Higher-order octupolar-like lines (in maroon) are also excited and measurable, though they may overlap the sextupolar-like, corrupting the CRDTs measurement and resulting in large F0. of merit for the model, where N = 8 · N BP M (the 4 CRDTs are complex quantities, separated in real and imaginary parts, see Eq. (8)). It is worthwhile noticing that R depends greatly on the lattice: Different machines and optics may result in different residuals for a similarly good sextupole model. In order to compare different storage rings or settings, the residual may be normalized by the mean CRDT amplitude.
A convenient way to display measured and model CRDTs is to separate their phase and amplitude. In the left plot of Fig. 8 the measured CRDT phases are shown together with the corresponding expectation from the ideal model of the ESRF storage ring. The agreement is already remarkable, as are the small statistical error bars. When comparing the CRDT amplitude instead (right plot of Fig. 8), the 16-fold periodicity of the ideal curves is modulated in the measured CRDTs. The overall residual is R = 7.7 m −1/2 .
Interestingly, in an earlier analysis based on a sextupole calibration curve measured in 2001 the initial residual was about 10% higher (R = 8.4 m −1/2 ) and the magnetic errors inferred from the measured CRTDs yielded suspiciously large errors in some sextupole families. This curve was indeed obtained after cycling a spare The observed modulation of the CRDT amplitudes on top of the 16-fold periodicity is greatly reproduced after introducing in the model the linear lattice errors, as shown in the left plot of Fig. 9. The modulated β functions and phase advances seem to be an important source, the residual R dropping by more than 60% to 3.2 m −1/2 . It should be mentioned that the ESRF storage ring suffers from large β beating (about 2 − 3% rms) compared to more recent third generation light sources (well below 1%), because only 32 corrector quadrupoles are available for its correction (out of 256 magnets grouped in 6 families). The modulation of the CRDT amplitudes in other machines, then, shall depend greatly on their level of β beating. As far as the ESRF storage ring is concerned, this second-order effect of quadrupole errors on sextupole resonances generates in some regions CRDTs about 50% (up to 100% for the vertical CRDT F N S0 ) larger than in an ideal machine (see right plot of Fig. 8). This may have a considerable impact on the dynamic aperture of the ring (the larger the CRDTs, the greater the phase space distortion), independently on any possible sextupole error.
Before performing the SVD pseudo-inversion of the linear system of Eq. (10) to infer sextupole errors, the measured CRDTs are compared to the model after introducing sextupolar fields in the 64 main bending magnets. Measurements performed on prototypes in the early 90s [21] indicated an integrated sextupole field of −1.8 ± 0.1 T/m. The plot of Fig. 10 shows how the residual R reaches a minimum with a field of −1.77 ± 0.09 T/m, The agreement is excellent, again confirming the reliability of this measurement. Interestingly, when solving the system of Eq. (10) to evaluate the sextupole errors, the average error per family is reduced by about one order of magnitude after introducing the -1.77 T/m sextupole field in all 64 bending magnets, as reported in Table VI. However, in both cases the sextupole family S4 seems to have a larger rms spread (0.8%) compared to other families (between 0.1% and 0.4%). The magnets exhibiting the largest deviations turned out to be the only four (recently installed) independent sextupoles, with a relative error of about −1.5%. These are shorter than the standard ones (20 cm instead of 40 cm) and have been displaced by 10 cm with respect to the nominal position so to lengthen two straight sections. New positions and calibration curves have been included in the model (the integrated strength shall be the same of the standard S4 sextupoles). A more detailed analysis on these magnets is reported in Sec. IV E. When introducing the sextupole field in the bending magnets and fitting the 224 magnet  errors by inverting the system of Eq. (10), the residual drops to R = 1.8 m −1/2 : The corresponding CRDT amplitudes are displayed in the right plot of Fig. 9, while the errors (mean and rms of each family) are reported in the last column of Table VI: The great majority of the sextupole errors is well below the ±1% specification, as displayed in Fig. 11. Of course, results vary according to the parameters for the SVD pseudo-inversion of Eq. (10). All the results shown in this section are derived by cutting the number of eigen-vectors to 26 (out of 224): more vectors induce a limited reduction of less than 0.1 m −1/2 in the final residual R at the expenses of large sextupole errors, well beyond 1%.
The sextupole field errors of Fig. 11 are computed assuming that all 224 sextupoles are placed at their nominal longitudinal position along the ring. Any displacement along s, e.g. the circumference, would change the CRDTs through the β functions and phases φ (see Table III) because of the dependence of the latter on s. Part of the  Table VI. field errors attributed to the magnets by the CRDTs may actually be a combination of magnetic imperfection and longitudinal displacement. Periodic metrological surveys and adjustments are carried out at the ESRF storage ring twice per year. However, they ensure a state-of-the-art alignment on the transverse plane only. A longitudinal alignment was carried out in the early 90s during the installation only, with an accuracy estimated in the mm range. To understand the contribution of longitudinal displacements δs on the CRDTs and, hence, on the equivalent field errors in the sextupole, the response matrix of Eq. (10) was extended, namely where #» δs contains the N sext = 224 sextupole longitudinal displacements, whereas w K and w s = 1 − w K are introduced to weigh out the two contributions. M NS is now a 8 · N BP M × 2 · N sext response matrix. The above system has been inverted with three different sets of weights. It has been observed that by allowing rms longitudinal displacement up to about 3 mm the magnetic errors drop by about 15%.
In Fig. 7 four spectral lines excited by skew sextupolar terms, H(±1, −1), V (−2, 0) and V (0, −2) are visible, hence measurable. Since no physical skew sextupole is installed in the machine, they are generated only by tilts of the main normal sextupoles (or their residual skew components) and by the cross product between residual coupling and normal sextupoles. The former is a first-order contribution, i.e. it can be well described by the RDTs f jklm of Table III, whereas the latter is a second-order term that can be correctly described only by the secondorder RDTs g jklm of Table I, to be evaluated from the model as described in Table XIV of Appendix A. From these four spectral lines, skew sextupole CRDTs F SS can be measured after applying the corresponding formulas of Table II. However, because of the low coupling and small sextupole rotations, the lines are about one order of magnitude lower than those excited by normal sextupoles (see Fig. 7). Hence, the signal-to-noise ratio becomes an issue and the measurement of the skew sextupole CRDTs is less reliable, as can be seen from the top left plot of Fig. 12 where the error bars (evaluated from the statistics over 50 acquisitions) are of the same order of magnitude of the baseline skew sextupole CRDTs. In order to enhance the signal-to-noise ratio of the four lines, another series of measurements have been taken after introducing large coupling, by powering a well-calibrated skew quadrupole corrector. By doing so, the second-order contribution to #» F SS,mod of Eq. (14)   magnets installed onto them may account for more than 1 mrad. An alternative explanation for such large skew sextupole components has been proposed and is currently being investigated. During magnetic measurements of new quadrupole magnets a large skew quadrupole component was measured each time the two halves of the yoke were not properly aligned (see left picture of Fig. 13): For that specific magnet, as a rule of thumb, a horizontal displacement between the two yokes of 100 µm would generated a skew quadrupole field, corresponding to about 1 mrad equivalent rotation. This sensitivity is suspected to be of importance for sextupoles too, these being actually separated in three yokes (right picture of Fig. 13). Numerical simulations and magnetic measurements are planned to validate this conjecture. If confirmed, hence, the large skew sextupole components observed in the ESRF storage ring may be induced by the limited precision in the assembly of the three sextupole yokes, rather than by the physical magnet rotation as a whole.

D. Correction of sextupolar CRDTs
After building up a realistic sextupolar error model, the natural further step would be to use the measured CRDTs ( #» F N S,meas ) and the desired one ( #» F N S,ref ), insert them in the linear system of Eq. (12), and pseudo-invert it to evaluate the strengths of the available sextupole correctors. The desired CRDTs are those assuming an ideal lattice, with neither errors (linear and nonlinear) nor betatron coupling. If special insertions spoiling the machine periodicity are present, they may induce large CRDT modulations. This is the case of the ESRF as of 2013, when a straight section was lengthened from 5 to 7 m and a special insertion optics was implemented. The impact on the normal sextupole CRDTs is strong, as shown in Fig. 14. When correcting the CRDTs, the reference vector #» F N S,ref corresponding to the fully pe-riodic machine (i.e. without the insertion) was chosen.
The result of such an exercise is shown in Fig. 15, where the difference vector #» F N S,meas -#» F N S,ref is plotted before and after the correction, together with the corresponding strengths of the 19 available sextupole correctors.
Even if elegant and efficient (the rms residual is almost halved with just 19 correctors out of 224 sources of errors), this approach is rather inconvenient. The reason is three-fold. First, the sextupole error model may depend on the implemented optics. The one used for these measurements has been specifically tuned so to have high spectral resolution but would be impractical for operational purposes. On the other hand, it would be impossible to extract an error model from the operational settings with the same accuracy, because of their larger chromaticity and detuning. Depending on the filling mode, chromatic sextupoles may vary considerably, and so may their errors, being the magnets close to saturation. Second, while focusing errors and coupling may be evaluated and corrected routinely from ORM measurements, the setup for the TbT BPM acquisition is less obvious and difficult to perform with the same regularity, even admitting that a sufficient spectral resolution may be found. Third, the special sextupole setting would not permit to verify whether the CRDT correction is beneficial to the beam lifetime, the chromaticity being too low for storing more than 10 mA, whereas 200 mA are usually delivered to users.
A rapid look at the evolution of the residual R as a function of the lattice models may provide a handy, though not perfect, solution. Table VII summarizes this dependence. Because of the relatively large persistent βbeating in the ESRF storage ring, the main contribution to the the measured CRDTs (∼ 50%) originates from focusing errors, whereas only 25% seems to stem from sextupole errors and a further 25% is not accounted for (possibly because of higher-order terms affecting the sextupolar spectral lines, as shown in Fig. 7). This means that a detailed linear lattice model would describe the true CRDTs with an accuracy sufficient for their rough correction, even ignoring sextupole errors. This corresponds to use and correct the black (model) curves in the left plot of Fig. 9 instead of the (measured) red curves:   Even if not perfect, the model CRDTs may already be used for an effective and rapid correction. This may be a peculiarity of machines like the one at the ESRF. For more recent accelerators with independent magnets, and hence with much lower residual focusing errors, this may not be the case.
To verify this conjecture, a test during machinededicated time was carried out. The software application for the measurement of the ORM and correction of focusing and coupling errors was modified to compute the nor-mal sextupole CRDTs F N S from the lattice model ( i.e. from Tables III and I), including all errors. These were inserted in the #» F N S,meas vector, whereas the ideal C-S parameters were used to compute the ideal (and desired) CRDTs,r #» F N S,ref .
The system of Eq. (12) was then pseudo-inverted to infer the strengths of the sextupole correctors. This procedure was applied to a standard multibunch optics optimized for a train of 868 bunches (7/8 of the storage ring circumference) filled with 200 mA (i.e. 0.23 mA per bunch). To enhance the Touschek effect which is believed to be presently the main limitation for the lifetime, another filling pattern with 192 bunches, each of about 1 mA, was stored. With all sextupole correctors turned off and a vertical emittance ǫ y = 7.1 pm (ǫ x = 4 nm), a lifetime of 16.2 hours was measured. After applying the standard manual optimization of the four sextupolar resonance stopbands, the lifetime reached 24.2 hours. When the strength computed automatically from Eq. (12) were used, the measured lifetime was 22.4 hours. This proved the effectiveness of the method, which can be used for a first correction from scratch before trimming the correctors by hand with the standard ESRF procedure. Nevertheless, it turned out to be not yet optimal. Another test was carried out to a different optics with higher chromaticity (to stabilize higher charges per bunch) clearly showed a poorer performance of the CRDT correction compared to the standard procedure. The reason for this dependence on the implemented optics has not been yet understood. For two correctors in cell 8 of the ESRF storage ring the curves have been measured in detail with several points: S20C8 is hosted in a chromatic sextupole (top plot) close to saturation, hence with a coefficient lower than in the correctors installed in the harmonic sextupoles, such as S24C8 (centre plot), which are still in the linear regime. The measured coefficients (i.e. the slopes of the above plots) for all twelve trim coils are reported in the bottom chart.

E. Beam-based calibration of independent sextupoles via CRDTs
As discussed in the last paragraph of Sec. III E, the measurement of CRDTs F N S may be repeated for different gradients of individual sextupoles or correctors to obtain a calibration curve, (integrated) strength Vs current. The ESRF storage ring comprises of 224 sextupoles mostly grouped in seven families, each sharing a common power supply. Six new short magnets recently installed to lengthen three straight sections are fed independently, and two standard sextupoles have been stripped out and paired on a single power supply. The correction of sextupolar resonances is carried out by twelve correctors (trim coils) hosted in as many magnets of the families S24 (eight) and S20 (four). Even though magnetically identical, because of the different working points, the (stronger) chromatic S20 are close to saturation, whereas the (weaker) harmonic S24 are still in the linear regime. This results in trim coils with different calibration curves, i.e. the slopes C f of the linear curve K 2 = C f · I, where I denotes the imparted current.
By measuring the CRDTs it is then possible to validate the calibration of both the trim coils and the six independent short sextupoles S4. The first check is necessary for the effectiveness of the automatic resonance correction discussed in the previous section, whereas the latter is to confirm the hypothesis raised in Sec. IV C of having short sextupoles weaker than expected.
For two trim coils in cell 8 (S20C8 and S24C8) the measurement has been carried out with several points and the calibration coefficient is obtained from a linear fit of the curve K 2 = C f · I. As shown in the upper plots of Fig. 16 the agreement with the model is nearly perfect for the corrector S20C8, and compatible within 10% for S24C8. The same measurement was then repeated for the other ten correctors. Results are reported in the bottom chart of Fig. 16. Because of the limited available machine time, the linear fit for the remaining ten correctors was carried out with two points only, at ±1 A. Between each measurement, magnets were not cycled and the persistence of some remaining magnetic fields could not be excluded. If these arguments may explain the poorer agreement between model and measured coefficients for these ten correctors, they cannot justify the large discrepancy observed for two trim coils, in S24C23 and S24C29 respectively. As far as the corrector in cell 23 is concerned, the explanation is rather simple: As of 2013 the standard 40 cm long main magnet has been replaced by a new short type. As a result, the calibration for its corrector is almost halved (C f from 0.443 to 0.239 A −1 m 2 ), consistent with the measured value. In the case of the trim coils of S24C29, an inconsistency was indeed found between the power supplies (recent 2-A types) and one of the two driver cards (still set for an old 5-A type). This incongruity resulted in a corrector about 30% weaker than normal (C f from 0.443 to 0.310 A −1 m 2 ), again consistent with measurements. Following these findings, the software driving the trim coil S24C23 has been updated (it was not when testing the automatic resonance correction), and the driver card of S24C29 was updated.
Results from the same measurement carried out for one of the six new (short and independent) sextupoles in cell 15, S4C15, are reported in Fig. 17. This beam-based calibration (C f = 0.0238 ± 0.002 A −1 m 2 ) is compatible with magnetic measurement (C f = 0.0241). Figure 7 reveals the existence of four spectral lines well above noise level (and hence measurable) excited by octupolar CRDTs, namely H(3, 0), H(−1, 2), V (2, 1) and V (2, −1). As shown in the same figure and described in Table VIII, two additional lines are excited by these terms, H(1, 2) and V (0, 3). However, the latter are indistinguishable from the sextupolar lines H(0, −2) and V (−1, −1), respectively, because of the tune working point. Hence the corresponding CRDTs F N O4 and F N O5 of Table VIII are not observable in our case. The best setting for the ESRF storage ring turned out to be the last of Table IV, with the horizontal kicker fired at 400 A and the vertical at 3.0 kV. The formulas of Table IX to infer the octupolar CRTDs from the spectral lines have been corrected in the analysis by using the tune line amplitudes averaged among all 224 BPMs, i.e. |H(1, 0)| →< |H(1, 0)| > and |V (0, 1)| →< |V (0, 1)| > in order to reduce the impact of octupolar terms on the tune line (see discussion in the last part of Appendix D).

V. GOING BEYOND: OCTUPOLAR SPECTRAL LINES, CRDTS AND MODELLING
Even though no physical octupole is installed in the ESRF storage ring, the nonlinear model including sextupoles (with errors and tilts) alone does not suffice to reproduce global nonlinear parameters such as amplitude dependent detuning ν ′ = ∂Q/∂(2I), as reported in Table X and Fig. 18. The agreement between this model and measurements is however already good as far as the second-order chromatic terms Q ′′ = ∂ 2 Q/∂δ 2 are concerned. As stressed in Sec. III A, no significant difference has been observed in the RDTs when representing sextupoles either as thin or thick elements and when including fringe fields. This is not the case for the global nonlinear parameters and in Table X values for the three different models are reported. Plots and fit (of global parameters and octupolar CRDTs) however refer to the thick model and including fringe fields.    Table I), expressions for its amplitude and phase are given. The tune lines H(1, 0) and V (0, 1) are also affected by octupolar terms that are however not observable. Quadrupole errors are to be included in the model when computing the Courant-Snyder (C-S) parameters used to evaluatex(N ),ỹ(N ) and the CRDTs g jklm , which are defined in Table XV. spectral line amplitude phase φ Combined RDT resonances magnetic term   To the first order, sextupoles do not drive any detuning with amplitude, which is a second-order effect (i.e. induced by cross-product between sextupole terms). Octupolar CRDTs too are excited by second-order sextupolar terms even in absence of physical octupoles. This can be seen when comparing the four measured octupolar CRDTs with those evaluated from the lattice model (including all errors), as shown in the left plot of Fig. 19. Even though the global behavior is rather well reproduced by the model, a clear ingredient looks missing. Model CRDTs are evaluated by using the same procedure developed for the skew sextupole terms and described in Appendix A.
The first natural source of octupolar fields in a storage ring is represented by normal quadrupoles, because of the shape of their poles, fringe fields and their geometry in two halves (any variation of the vertical distance between the two yokes generates octupolar fields). The linear lattice of the ESRF storage ring is based on eight quadrupoles per cell (256 magnets in total), with two pairs of identical magnets in the achromat fed by common power supplies, hence leaving six degrees of freedom. The first step in building the octupolar lattice model was to introduce six octupolar fields in the corresponding quadrupole families to best reproduce the five nonlinear parameters (three detuning coefficients and two second-order chromatic terms). The 256 octupole fields have been then adjusted independently so to best reproduce the measured CRDTs of Fig. 19. As for the skew sextupole analysis, even though model and measured CRDTs are excited mainly by second-order contributions stemming from sextupoles, their difference will depend linearly on the octupolar field, and the same SVD pseudo-inversion carried out in the previous sections may be generalized to octupoles. The results of such a fit are shown in the right plot of Fig. 19 as far as the CRDTs are concerned, whereas the values of the global nonlinear parameters are reported in the last column of Table X and in Fig. 18.
It shall be mentioned that measurements of octupolar CRDTs may be partially affected by BPM nonlinearities, these scaling with x 3 (y 3 ) to the first order [29] and the largest BPM data used for this analysis reaching about 6 mm. On the other hand, the software driving the ESRF BPMs computes the beam position using a nonlinear calibration curve, based on finite-element simulations of the BPM block, that accounts already for such nonlinearities.

VI. CONCLUSION
This paper has shown how the harmonic analysis of turn-by-turn data from beam position monitors may be exploited for the reconstruction and correction of machine nonlinearities up to octupolar terms. An important peculiarity of this approach is that the systems to be solved are always linear, even though referring to nonlinear magnets. This represents a considerable step forward compared to precedent works on the same subject. Handy formulas have been derived and tested with real data for the quantitative evaluation of realistic magnetic model, for the calibration of individual nonlinear magnets and for the correction of the resonance driving terms. The analysis of the latter could predict the sextupolar field component measured in bending magnets, as well some inconsistencies with the calibration curves of sextupole magnets. Correcting sextupolar resonance driving terms in the ESRF storage ring with a low-chromaticity optics (for low-intensity multi-bunch modes) resulted in increased lifetime, though the gain was minimal when applied to optics with larger chromaticity (for high-intensity few-bunch filling patterns).

VII. ACKNOWLEDGMENTS
We are grateful to the ESRF Operation Group for its support in preparing and carrying out measurements, to F. Epaud for adjusting the BPM device server to our needs, to M. Dubrulle for setting up the kickers, and to F. Taoutaou for helping with the magnetic measurements. We are also indebted with R. Tomás, for proofreading the original manuscript and making valuable suggestions. For a reliable analysis of the ESRF nonlinear lattice model, the normal form and RDT description of Refs. [4][5][6][7] needs to be extended to the second order. The theoretical background has been already developed in previous works, among which the fundamental Ref. [22]. The first part of this Appendix does not provide any further development to that work: Results of main interest in the context of this article are reported for sake of consistency and nomenclature only. In order to tackle the heavy mathematics of second-order computations, it may be desirable to briefly review the concept of nonresonant normal forms of Refs. [2,3].
In the linear uncoupled case the turn-by-turn dynamics is described by the one-turn matrix M (s) according to where C is the ring circumference and s a generic position along the ring. The corresponding phase space portrait (x, p x ) of the betatronic motion inside a circular accelerator is typically a tilted ellipse (identical considerations apply of course to the vertical plane). Tilt and main axis vary along the ring according to the focusing lattice (normal quadrupoles). Any regular (i.e. noncahotic) closed curve in phase-space may be transformed into a circle. The Courant-Snyder change of coordinates (Fig. 20) is one among the possible transformations preserving the phase-space. The Courant-Snyder (C-S) parameters in the above matrix contain all the information regarding the linear lattice. The circle is invariant along the ring in amplitude (i.e. radius and surface) and rotation frequency (i.e. the tune), which is independent on the initial conditions. The system is equivalent to a harmonic oscillator and the motion to a rotation. In the nonlinear case the one-turn map M(s) replaces the linear matrix M (s) where the map is the composition of linear transfer matrices M w and Lie operators corresponding to localized nonlinear magnets, such as sextupoles, see Fig. 21: where W is the total number of nonlinear elements in the machine. Besides Ref. [22], detailed derivation within the RDT formalism may be found in Refs. [4][5][6]. In the complex Courant-Snyder coordinates, h q,± =q ± ip q = 2J q e ∓i(φq+φq,0) , the system reduces to w,x +(l−m)∆φ (s) where h w,q,± is the coordinate at the generic magnet w, while ∆φ (s) w,q is the phase advance between the latter and the observation point s. n denotes the magnet order: n = 2, 3, 4 for quadrupoles, sextupoles and octupoles, respectively. The coefficients within the sums read net strengths of the multipole expansion (MADX definition) from which Eqs. (A6) and (A7) are derived when moving from the Cartesian coordinates to the complex Courant-Snyder's: x w = β w,x (h w,x,− + h w,x,+ )/2 and y w = β w,y (h w,y,− + h w,y,+ )/2. If nonlinear terms are of relevance, at sufficiently large amplitudes the phase space is deformed from ellipses to more complex curves. In the case of normal sextupoles, the horizontal phase space (x, p x ) assumes a typical triangular shape, as a result of additional harmonics excited by these magnets (see Table I). The Courant-Snyder transformation, being linear, will just remove the dependence on the linear parameters, rotating the triangle in an upright position and smoothing out its distortion. However, the invariant circle may not retrieved, since the linear transformation may not include nonlinearities, see upper right portrait of Fig. 22. The phase-space trajectory being still closed and regular, it must still exist a transformation to retrieve a circle. Such transformation indeed exists and is a polynomial function F where n denotes the multipole order, f jklm are the RDTs and ζ q,± = 2I q e ∓i(ψq+ψq,0) are the new complex normal form coordinates, which are the nonlinear generalization of the complex Courant-Snyder complex variable of h q,± . The normal form approach for the turn-by-turn betatron motion is usually depicted in the scheme of Ref. [2]:  (N + 1). The second strategy, even if longer, turns out to be indeed the most effective. In fact, analytical expressions for the RDTs f jklm (and hence for F ) may be derived up to a certain degree of precision (second order in this paper), while the evolution in normal form is already known, being an amplitude-dependent rotation, whose operator R is defined by the tunes (Q x,y ) and the invariants (2I x,y ) only, all measurable quantities, as shown later. In normal forms, the circle surface π|ζ| 2 is the new (nonlinear) invariant, see lower right portrait of Fig. 22. The nonlinearity is also transferred in the frequency, which exhibits a dependence on the amplitude |ζ| = √ 2I (amplitude-dependent tune). The system in these coordinates is equivalent to an anharmonic oscillator and the motion is a rotation whose frequency depends on the initial conditions. As the Courant-Snyder matrix contains all the information regarding the linear lattice, the RDTs of F carry its nonlinear content.
The equation establishing the change of coordinates in normal form of the above scheme may be written in terms of the Lie operators Following the same procedure of Ref. [22], all operators may be decomposed in first-and second-order terms as follows Since the Hamiltonian in normal forms must be phase independent (only h jjll coefficients are nonzero), its first-order term must contain the detuning part of the Courant-Snyder Hamiltonian, which corresponds in turn to its average over the phases, i.e.
Detuning terms are those in Eq. (A6) having j = k and l = m (the octupolar-like h 2200 , h 1111 and h 0022 ), since only when these two conditions are met, the corresponding phase is zero (h j x,+ h j x,− h l y,+ h j y,− = |h x | 2j |h y | 2l , phase independent). In normal forms, hence, only detuning terms are kept, while those phase-dependent are absorbed by the generating function F : This is the reason why RDTs will always be phase-dependent. In general, at each order, it is always possible in the Courant-Snyder Hamiltonian to decompose a phase-independent term <H (1,2) > φ from a phase-dependent remainderH ‡ , which is equivalent tõ After substituting the first-and second-order decomposition of Eqs. (A11) and (A13), the following relations hold Up to the second order the above equation reduces tõ By separating first-and second-order terms we obtaiñ First-order RDTs By substituting Eqs. (A16) and (A17) in Eq. (A23) the normal form transformation up to the first order reads Recalling that both F andH (1) are polynomial functions (see Eqs. (A9) and (A6)), and the definition of R given in Eq. (A15), the above relation must hold for any index set j, k, l, m, i.e.
(A26) The explicit dependence of the RDTs on s is due to the presence of the phase advances between the location where f jklm is either evaluated or measured (s) and the one of the magnet w: RDTs measured at different places will contain hence different phase advances, making f jklm to vary. Formulas in Table III are derived from Eqs. (A26) and (A7). Equation (A26) shows a fundamental feature of the first-order RDTS: they depend linearly on h w,jklm and hence on the magnet strengths K w,n−1 and J w,n−1 , through Eq. (A7). By measuring sextupole RDTs, for instance, it is possible to infer a sextupole error model and to correct undesired deviation from the ideal setting. This is done by first rewriting Eq. (A26) as linear system where f norm. sext is a vector containing the sextupolar RDTs evaluated or measured at N f observation points along the ring, K 2 is a vector with the strengths of the N k normal sextupoles, and B N k is a N f × N k response matrix which depends on the C-S parameters only (betatron functions and phases at the sextupoles, betatron phases at the observation points, and the tunes). Ideal sextupoles would induce a given RDT vector, If sextupolar RDTs are measurable, a difference vector may be defined as ∆ f = f mod norm. sext − f meas norm. sext and the above system may be rewritten and pseudo-inverted, via single-value decomposition (SVD) for instance, to infer sextupole errors If corrector sextupoles are available, a second system may be defined as where K cor 2 contains the strengths of the N c corrector magnets and B Nc is the same matrix of Eq. (A27), whose dimensions are N f × N c and whose C-S parameters correspond to the corrector sextupoles in place of the main magnets. K cor 2 may be then evaluated from the difference between the measured and expected RDT vector (∆ f ) after pseudo-inverting Eq. (A30), providing the strengths of the corrector sextupoles to be set in order to minimize the deviation from the ideal non-linear lattice model. The system may be extended in order to include in the RDT vector the linear chromaticity (which is also linear in the sextupole strengths).
To complete the normal form approach, explicit formulas for the change of coordinates are missing. They are readily derived from h(s, N ) = e :F (s) : ζ(s, N ) .  Table IV of Ref. [7] is derived.
In conclusion, up to the first order, Eq. (A26) is the formula to evaluate the RDTs from the lattice parameters, while Eqs. (A36) and (A37) may be used to compute (or measure) them from the FFT of turn-by-turn position data, either simulated via tracking or measured by BPMs. Both approaches provide the same equivalent RDTs. In the following part it will be shown how this equivalence is no longer true when second-order terms are to be taken into account.
Second-order RDTs The evaluation up to the second order of the RDTs passes through Eq. (A24) (from the lattice) and the Poisson bracket of Eq. (A33) (from turn-by-turn data). Equation (A24) may be rewritten as By inserting Eq. (A25) into the Poisson brackets, the following relations apply providing The average over the phases of Eq. (A41) reads It is worthwhile recalling that, according to Eq. (A26), F (1) is phase-dependent, while H (2) , by definition, must be phase-independent, i.e. H (2) =< H (2) > φ . Hence where the later relation results from the fact that H (1) is phase-independent, conversely toH (1) ‡ : the resulting Poisson bracket is then necessarily phase-dependent, hence with zero average. Equation (A42) thus reads Substituting the above expression in Eq. (A41), the latter is equivalent to According to Eq. (A17) where [, ] ‡ denotes the phase-dependent part of the Poisson bracket. Equation (A42) then reads providing the general equation to evaluate the secondorder contribution to the RDTs (from the lattice) The situation is less desperate than it could appear. H (1) is the first-order Hamiltonian in normal forms that contains first-order detuning terms only (phase independent). These may be generated firstly by normal quadrupole errors δK 1 , through the Hamiltonian terms w h w,1100 = w β x,w δK 1,w and w h w,0011 = w β y,w δK 1,w . Nevertheless, assuming that the machine is tuned to the desired ideal tune, those sums are equal to zero. The next nonzero first-order detuning terms may then be excited by octupoles (through the Hamiltonian terms w h w,2200 = w β 2 x,w K 2,w and the like), which are assumed to be a negligible source of detuning compared to sextupoles, which act only in the second-order Hamiltonian H (2) of Eq. (A46). Under thse assumptions the first-order Hamiltonian in the complex Courant-Snyder coordinates will be always phase-dependent, i.e. H (1) ‡ ≡H (1) . The same is true for second-order RDTs: only phase-dependent terms of [H (1) ‡ ,H The assumption of having no detuning term in the firstorder Hamiltonian (H (1) = 0) shall not be confused with the unnecessary assumption of having zero linear detuning, that may come from sextupolar terms in the secondorder Hamiltonian (H (2) = 0). If first-order octupolar terms may not be neglected, the more general Eq. (A48) shall be used. The first step in making Eq. (A49) more explicit is the evaluation ofH (2) , whose phase-independent terms will contribute to the detuning with amplitude of H (2) , through Eq. (A46), while those phase-dependent will de-fine the second-order RDTs via Eq. (A49).H (2) results from the CBH theorem and, according to Eq. (A13), where the dependence on s is kept explicit to prevent incorrect simplification. Equation (A6) provides the explicit expressions for bothH u (s) andH u (s) w in the exponential term. Such a dependence disappears only when p − q = −(j − k) and r − t = −(l − m), i.e. whenever j + p = q + k and l + r = m + t: a condition, however, that generates detuning terms, since h j+p−1 The Poisson bracket may be then split as follows The example is completed by writing the analytic expression for f 0030 up to the second order  Table XI lists for each RDT (up to the sextupole terms) the Hamiltonian coefficients h jklm and the corresponding magnetic element contributing to the second order f (2) jklm , as derived from Eqs. (A55) and (A61). The result is manifold: to the second order, (i) skew quadrupoles (coupling) induce focusing errors; (ii) focusing errors modify coupling and sextupole RDTs; (iii) coupling and normal sextupoles induce skew sextupole RDTs. Similar list for the second-order octupolar RDTs may be computed, but are not reported here for sake of space.
The last missing step is to include second-order terms in the change of coordinates of Eqs. (A31) and (A33). In analogy with the previous apporach, the function F is split in its first-an second-order parts h(s, N ) = e :F : ζ = ζ + [F (1) where the second Poisson bracket was reduced, as any term proportional to [F (2) , F (1) ] or [F (2) , F (2) ] goes into the third-order remainder. F (1) and F (2) may be evaluated from Eqs. (A25) and (A49). Hence the only quantity to be evaluated is the double Poisson bracket [F (1) , [F (1) , ζ ]]. The inner bracket has been already evaluated in Eq. (A36) (horizontal plane) and Eq. (A37) (vertical plane), yielding The double Poisson bracket then reads pqrt [ζ j x,+ ζ k x,− ζ l y,+ ζ m y,− , ζ p−1 x,+ ζ q x,− ζ r y,+ ζ t y,− ] , RDTs of Refs. [4][5][6][7] may be evaluated either via analytical formulas or from turn-by-turn BPM data. More precisely, BPM data need first to be normalized by the beta function (Courant-Snyder coordinates) and then to be composed in order to obtain the complex turn-by-turn variable h r (N ) =r(N )−ip r (N ), where r stands for either x or y and N is the turn number. The harmonic analysis of h r (N ), via the Fast Fourier Transform (FFT), allows the direct measurement of the RDTs. As discussed in Ref. [24] the reconstruction of the momentump r from the positions at two consecutive BPMs is reliable as long as the region between the two monitors is free of nonlinearities (such as sextupole magnets). This condition is almost never met in electron storage rings like the one at the ESRF, where there is always one sextupole between two BPMs within each cell. A way out was found in Ref. [24] to combine the signal over three consecutive BPMs. The resulting variable is no longer affected by errors in the momentum reconstruction and its harmonic analysis may be used to measure local resonance terms.
The method was successfully applied to the CERN Super Proton Synchrotron [7], as well as to the Relativistic Heavy Ion Collider [24]. On the other hand, the applicability of the 3-BPM signal is hampered whenever the phase advance between the monitors is close to either zero or π, which is unfortunately the case of many BPMs in the ESRF storage ring. Moreover, both 2-BPM and 3-BPM signals require a perfect synchronization among the BPMs (i.e. triggering on the same turn and on the same position along the bunch train).
Another aspect limiting the applicability of the multi-BPM signals in electron machine is represented by radiation damping. Ideally, the greater the number of turns with exploitable data (i.e. before decoherence smooths out the signal to zero), the higher the spectral resolution and hence the quality of the RDT measurement. At the ESRF a special sextupole setting was found to provide low amplitude-dependent detuning and linear chromaticity in both planes, so to minimize decoherence. However, the damping time being of about 2500 turns, the signal is sufficiently depressed to compromise the whole measurement already after 1024 turns (see Fig. 23). It has been observed that the spectral background noise increases with the number of turns used to perform the FFT of the turn-by-turn signal (see upper plots of Fig. 24): An effect which is believed to be related to radiation damping. Moreover, when analyzing the complex signal h x constructed between two consecutive BPMs the background noise is enhanced (see bottom plot of Fig. 24). The sextupolar spectral lines being intrinsically of limited height, it is of capital interest to keep the spectral background noise as low as possible, so to enhance the signal-to-noise ratio. For this reason, even if 2048 turns may be stored by each BPM, only 256 or 512 are routinely used at the ESRF in order to carry out the harmonic analysis, a trade off between enhancement of spectral resolution and minimization background noise.
A new approach has been then developed to measure (a different kind of) RDTs from single-BPM data, r(N ) = r(N )/ √ β r , in order to avoid the noise enhancement whenever data from two or three BPMs are used. By using single-BPM data the issue of synchronization between the monitors is no longer of concern, the harmonic analysis at each BPM being independent of the data acquired by the others.
The bottom plot of Fig. 24 shows a typical horizontal spectrum of h x with the excited spectral lines: Besides the principal tune line generated by the main quadrupoles, quadrupole errors (beta-beat) excite a line at the frequency 1 − Q x , H h (−1, 0), while betatron coupling is visible from the presence of a secondary line at the frequency corresponding to the vertical tune, H h (0, 1), and its reciprocal, H h (−1, 0). The main sextupoles (chromatic and harmonic) generate several lines, among which H h (±2, 0) and H h (0, ±2). Skew sextupole lines appear also at the position Q x −Q y , H h (1, −1), and 1−Q x −Q y , H h (−1, −1): their origin will be discussed later. Other lines generated by 2-nd order sextupolar terms are more visible in the spectrum ofx (center plot of Fig. 24).
The harmonic analysis of the real signalr produces a spectrum that is mirrored around 0.5 (in tune units). By looking at Table IV of Ref. [7] and Fig. 24 it is clear that secondary spectral lines of the complex signal h r and excited by either coupling or sextupoles, become indistinguishable. For instance, the two sextupolar horizontal spectral lines H h (2, 0), located at the frequency 2Q x , and H h (−2, 0), located at 1 − 2Q x , are excited by the two different RDTs, f 1200 and f 3000 , respectively. The latter are distinguishable and measurable from the FFT of the complex signal h x , while the mirroring around 0.5 prevents such distinction if the FFT is performed on the real signalx. An example may help understanding this merging. A complex signal h x contains two harmonics in the following combination The first term would correspond ideally at the spectral line H h (2, 0), while the second to H h (−2, 0). The FFT of h x (N ) would yield two spectral lines located at 2Q x and 1 − 2Q x , respectively, with measurable amplitudes (A + and A − ) and phases (ψ and θ). The real part of h x (N ), corresponding to the single-BPM turn-by-turn datax, readsx The omitted term represents the complex conjugate of the first (i.e. its mirrored copy) and contains no additional information. The FFT ofx(N ) would still generate two spectral lines H(±2, 0), which are however complex conjugates. This implies that the only (complex) observable left is A + e iψ + A − e −iθ , while the four quantities A ± , ψ and θ are no longer measurable. Back to the RDT context, the consequence of analyzing the single-BPM signal instead of h r is that only linear combinations of RDTs are directly measurable. It will be shown that this is still sufficient to infer lattice errors and provide a correction scheme. Generally speaking, each line in the spectrum ofx(N ) is the superposition of two lines in the spectrum of h x (N ), according to H(n x , n y ) without suffix denotes a line in spectrum of the real signalx(N ). H h (n x , n y ) refers to a generic line in the spectrum of the complex signal h x (n). Identical relations hold for the vertical spectrum.
Appendix C: Quadrupole errors and tune-line amplitude In Table I ( There is no mirroring around 0.5, but the background noise is higher than in the simple FFT ofx (center plot) and some spectral lines are no longer visible. For a complete (up to the first order) classification of all spectral lines, see Table IV of Ref. [7].
while for skew sextupoles (more complex) second-order ORDTs g jklm are invoked. The latter are also used in Table VIII for normal octupoles. In this section motivations and conditions for such a choice are provided. It will be shown how this is related to the removal of RDTs generated by focusing errors when using the modulated beta functions (i.e. computed from a lattice including quadrupole errors) rather than those of the ideal lattice.
Parenthetically, a novel procedure for using single-BPM turn-by-turn data to measure the beta functions is described, which is complementary to the traditional approach based on the direct measurement of the phase advance between two consecutive BPMs [25]. The latter is independent on calibration errors, but requires a perfect synchronization among the BPMs. The proposed scheme, on the contrary, necessitates well calibrated monitors but does not need any synchronization, as for the nonlinear analysis of Table I. In the Appendix of Ref. [26] the complete Lie series of Eq. (A64) was computed in presence of betatron coupling, i.e. with the normal form transformation F defined exclusively by coupling RDTs, namely Recursive expressions for the Poisson brackets at any order were derived leading to the following expression for the turn-by-turn evolution of the complex Courant-Snyder coordinates According to Eq. (B1) the tune lines of the real Courant-Snyder coordinates read where c.c. stands for complex conjugate. Note that in presence of pure coupling H h (−1, 0) = V h (0, −1) = 0. The same algebra may be applied to another extreme case with normal quadrupole errors only, i.e. with the normal form transformation F defined exclusively by focusing error RDTs The result is where q 2000 = arg {f 2000 } and q 0020 = arg {f 0020 } , (C10) f 0020 = W w δK w,1 β w y e 2i∆φw,y with β x,y and ∆φ x,y are the the C-S parameters of the ideal lattice (i.e. without focusing errors δK w,1 ). Conversely to coupling, pure quadrupole errors excite directly the two lines H h (−1, 0) and V h (0, −1). Applying again Eq. (B1) the tune lines of the real Courant-Snyder coordinates read × 2I x e i(2πN Qx+ψx,0) + c.c. , (C13) × 2I y e i(2πN Qy+ψy,0) + c.c. , (C14) In the more general case with both quadrupole and coupling errors similar results may be derived. However, Eqs. (C5)-(C6) and (C13)-(C14) already reveal an intrinsic feature of linear lattice errors: The amplitude of the tune lines H(1, 0) and V (0, 1) are modified by the RDTs. The implication of that is twofold. First, it becomes impossible to use single-BPM turn-by-turn data to disentangle and measure coupling and beta-beat RDTs, because the tune lines used to extract them from the secondary lines in Refs. [5][6][7] depend on the RDTs too. For the same reason, measurement of sextupolar combined RDTs of Table II will be corrupted. A way out from this inconvenient situation is represented by measuring (and correcting) lattice errors before carrying out the turn-by-turn analysis with an independent technique, such as the orbit response matrix (ORM) and LOCO analysis of Ref. [27]. In Ref. [28] the procedure to evaluate first-order focusing and coupling RDTs from ORM measurement is described in detail. It can be hence assumed that f 2000 , f 0020 , f 1001 , and f 1010 be known prior to the turn-by-turn analysis. At the ESRF, with (peak) beta-beating usually corrected up to ±5% and betatron coupling so to have an emittance ratio lower than 1‰, typical values of P, |f 2000 | and |f 0020 | are lower than 10 −2 , see Fig. 25. Hence the perturbation introduced by coupling to the tune-line amplitudes of Eqs. (C5) and (C6) is negligible, 1 − cosh (2P) < 10 −4 . The same is true only partially for quadrupole errors: while 1 − cosh (4|f 2000 |) ≃ 1 − cosh (4|f 0020 |) < 10 −4 , the residual modulation introduced by the hyperbolic sines in Eqs. (C13) and (C14) may not be ignored, remaining of the level of percents. If such a modulation is not removed, it will be propagated as an error in the nonlinear error model.
The task of making the tune-line amplitudes constant along the ring is actually much easier than it may appear. Comparison between the coupling RDT factor P (green) and the focusing error RDTs f2000 (red), f0020 (blue) inferred from ORM measurement at the ESRF electron storage ring after correction (peak beta-beating of about ±5% and an emittance ration lower than 1‰). All three quantities are of the same order of magnitude, though well below 10 −2 level.
In the ideal lattice, the Courant-Snyder coordinatex = x/ √ β x would provide a a tune-line amplitude It is straightforward to prove that by scaling the beta function by a factor c, β x1 = cβ x , the tune-line amplitude scales as Hence, it is enough to replace the ideal beta function β x with to retrieve a RDT-independent tune line, |H(1, 0)| = √ 2I x /2. Equation (C18) provides an analytical expression for the horizontal beta-beating introduced by quadrupole errors: The same algebra applied to the vertical plane leads to ∆β y β y = 2 sinh (4|f 0020 |) sinh (4|f 0020 |) (C20) + cosh (4|f 0020 |) sin q 0020 . In Fig.26 Fig.26 are inferred from the harmonic analysis of single-particle tracking data, after isolating the H h (−1, 0) and V h (0, −1) of Eqs. (C8) and (C9). The agreement is remarkable. In practice then, the perturbations introduced by the focusing error RDTs f 2000 and f 0020 of Eqs. (C11) and (C12) may be absorbed by replacing the ideal C-S parameters β x,y and ∆φ x,y with the modulated ones β x1,y1 and ∆φ x1,y1 . By doing so, the new Courant-Snyder coordinates will no longer show quadrupole errors, and the beta-beat RDTs vanish, i.e.
Physically this corresponds to the fact that not including focusing errors in the computation of the C-S parameters results in mismatched functions and a phase space topology (ellipses) dependent on the longitudinal position along the ring (through the s-dependent betabeating RDTs f 2000 and f 0020 ). When, instead, the C-S parameters used to compute the C-S coordinates properly account for all normal quadrupole forces, the corresponding phase space topology becomes invariant along the ring (and circular).
Even though focusing errors and coupling may be efficiently measured and corrected from ORM measurement, the inferred model results usually from a best fit procedure which converges towards the measured matrix up to a certain degree of precision. Provided that coupling is well corrected (e.g. cosh (2P) = 1 up to a sufficient level), the same single-BPM turn-by-turn data may be used to validate and possibly to further correct the beta functions. The starting point are focusing RDTs that, despite the use of C-S parameters obtained from the error model, may still be nonzero because of residual fit errors, i.e. 0 = f 2000 (β x , ∆φ x ), f 0020 (β x , ∆φ x ) ≪ 1. It is then reasonable to assume that cosh (4|f 2000 |) ≃ cosh (4|f 0020 |) = 1 up to a sufficient level of tolerance. Equation (C16) then simplifies to The above expression contains a constant term, √ 2I x /2, and an oscillating one proportional to the residual focusing RDT, |f 2000 | sin q 2000 . If the number of oscillations along the ring is sufficiently large and the number of BPM enough to cover uniformly the path, by averaging the tune-line amplitudes among all BPMs, the oscillating term cancels out and the invariant may be retrieved: where N is the number of available BPMs (not necessarily synchronized over the same turns and/or bunches) and |H(1, 0)| n are the tune-line amplitudes measured at the different monitors. More intriguingly, the same single-BPM turn-by-turn data may be post-processed to extract the true beta function at its location. Once the average tune-line amplitude is computed, < |H(1, 0)| > (< |V (0, 1)| >), at each BPM the beta function may be scaled by a factor c = [ |H(1, 0)| n / < |H(1, 0)| >] 2 (c = [ |V (0, 1)| n / < |V (0, 1)| >] 2 ) as done for Eq. (C18). The result is then straightforward: where β x,n denotes the initial horizontal beta function obtained from the lattice error model created, for instance, from the ORM measurement and fit, while β x1,n are those corrected by the harmonic turn-by-turn analysis.
In Fig. 27 the results from a numerical test carried out from single-particle tracking with the same focusing errors and coupling of Fig. 25  FIG. 27. (Color) Top: Evolution of the tune-line amplitudes along the SERF storage ring obtained from single-particle tracking with the ideal lattice (black curve), with lattice errors included in the tracking but not in the beta functions (red), and with the beta functions corrected after minimizing the spread between the tune-line amplitudes among the BPMs (green). Bottom: Comparison between the expected beta-beating as computed by MADX (magenta curve) and the once inferred from the minimization of the spread among the tune-line amplitudes (black stars). Note how the tuneline amplitude pattern (red curve, upper plot) matches that of the beta-beating (bottom plot).
from the ratio between the tune-line amplitude at the BPM and the mean value. The resulting beta-beating is compared with the one computed by MADX confirming the excellent agreement, while the spread between the tune-line amplitude evaluated at the 224 BPMs with the new beta functions drops dramatically. Note how the tune-line amplitude pattern (red curve in the upper plot) matches that of the beta-beating (bottom plot).
The use of the C-S parameters that already include focusing errors in evaluating the first-order RDTs of Table III not only will correctly account for the modulation introduced by the beta functions β x,y , but has a tremendous impact in simplifying the second-order anal-ysis of coupling and normal sextupole RDTs of Tables XII and XIII, respectively: The first-order beta-beat RDTs being all zero (as well as the corresponding Hamiltonian coefficients), second-order ORDTs g jklm are equivalent to the first-order RDTs f (1) jklm . For this reason the in Table I the latter are used in the entries corresponding to skew quadrupoles and normal sextupoles and no betabeat RDT is reported in the tune lines. Second-order ORDTs g jklm are instead used for the skew sextupole-like entries because they are generated by nonzero coupling and normal sextupole RDTs.
Focusing errors hence, if not included in the lattice model, modulate the tune-line amplitudes and thus the beta functions. The modulation is independent on the initial conditions (action and phase). Another, more complex, amplitude-dependent modulation is introduced at the second order by normal sextupoles, requiring a careful preliminary analysis in order to make it negligible. In the example of Eq. (A74), when computing the secondorder contribution to the spectral line V h (0, −2), proportional to ζ 2 y,+ , the sets of indexes jklm and pqrt were selected by solving the following systems for abcd = 0020: The vertical tune line V h (0, 1) (identical considerations apply to the horizontal one) receives contributions from all terms proportional to ζ y,− : These may come from those selected by abcd = 0001, but also from abcd = 1101, which is proportional to |ζ x | 2 ζ y,− , as well as from abcd = 0012, which scales with |ζ y | 2 ζ y,− . Only coupling and focusing errors may contribute to abcd = 0001, whereas normal sextupoles excite the terms introduced by abcd = 1101 and abcd = 0012 (skew sextupoles RDTs also contribute, but are here neglected, as they are assumed to be generated by tilted normal sextupoles and hence to be a small fraction of the normal sextupole RDTs). By solving the two systems of Eq. (C28) with these two later conditions, and repeating the same algebra for the horizontal tune line, it can be shown that where T Hx,Hy and T V x,V y vary along the ring and are quadratic functions of the first-order normal sextupoles RDTs (f (1) 3000 , f (1) 1002 , and the like). Similar expressions apply also for the lines H h (−1, 0), proportional to ζ x,+ , and V h (0, −1), proportional to ζ y,+ . The tune lines of the real Courant-Snyder signalsx andỹ are modulated too, since H(1, 0) = (H h (1, 0) + H h (−1, 0))/2 and V (0, 1) = (V h (0, 1) + V h (0, −1))/2. Sextupoles therefore modify to the second order (i.e. quadratically in their RDTs and hence in their strengths) the tune-line amplitudes, which are no longer equivalent to 2I x,y /2 (first two rows of Table I). Equations (C29) and (C30) reveal also the nonlinear coupling introduced by sextupoles which makes the tune-line amplitude in one plane dependent on the action |ζ| of the other. If not negligible, this nonlinear modulation may corrupt (or prevent) the evaluation of the invariants (2I x,y ) from the tune-line amplitudes and hence the overall analysis discussed here, which is based on the formulas of Table II. Given a certain sextupole setting, T Hx,Hy and T V x,V y are fixed. It is then of interest to estimate the largest beam oscillation amplitude that keeps the modulation below a tolerable level. To this end, preliminary singleparticle tracking simulations at different initial conditions x 0 and y 0 (i.e. amplitudes) may be carried out. By storing the particle positions at all BPMs and performing the FFT of the Courant-Snyder coordinatesx andỹ, the tune-line amplitudes may be plotted along the ring and their modulation evaluated against x 0 and y 0 . In Fig. 28 an example with betatron oscillations of x 0 = 10 mm and y 0 = 2.2 mm (large values by ESRF standards) is shown. Focusing errors are included in the model when computing the beta functions and the residual modulation of about 3% is generated exclusively by sextupole RDTs. Results from a more complete scan of the ESRF storage ring are reported in Table XVI. They suggest to limit the transverse oscillation to x 0 ≃ 3.5 mm and y 0 ≃ 1 mm, corresponding to √ 2I x ≃ 2I y ≃ 3.1 × 10 −4 m 1/2 with relative variation of about 0.2%, well within the measurement statistical fluctuations of about 1%. Larger oscillations would induce a beneficial larger spectral resolution (higher ratio between sextupolar secondary lines TABLE XVI. Dependence of tune-line amplitudes mean value and rms modulation against initial conditions evaluated from single-particle tracking and FFT of the particle position recorded at the 224 BPMs if the ESRF storage ring. The sextupole setting is the same used in the experiments and the focusing errors are included in the lattice model when computing the β functions used to normalize x and y. (x0, y0) (|H(1, 0)|, |V (0, 1)|) (|H(1, 0)|, |V (0, 1)|) rel. mean value rms modul. modul. (mm) m 1/2 m 1/2 and background noise), but also a larger modulation of the tune-line amplitudes, which is detrimental for the correct evaluation of the invariants 2I x,y , hampering in turn the correct measurements of sextupolar RDTs. As reported in Ref. [4], the spectral line H h (−1, 0) of the complex C-S signalsx − ip x receives a contribution from the normal octupole term x 4 via two ORDTs, g 3100 and g 2011 . It can be shown that H h (−1, 0) = 3g 3100 (2I x ) 3/2 + 4g 2011 (2I x ) 1/2 (2I y ) × (−2i)e −i(2πQxN +ψx0) . (C31) This implies that, on top of the focusing errors not included in the model and second-order normal sextupole terms, the tune line H(1, 0) of the real C-S signalx receives a contribution from octupolar terms, since H(1, 0) = 1/2[H h (1, 0) + H h (−1, 0)]. Three problems arise at large excitation amplitude and or with large octupolar components in the lattice: (i) The tune phase is affected by octupolar terms and the linear lattice modelling discussed in Sec. IV B is corrupted; (ii) It is no longer possible to extract any linear combination of g 3100 and g 2011 , because of the different dependence on the action of the two terms, ∝ (2I x ) 3/2 and ∝ (2I x ) 1/2 (2I y ) respectively; (iii) The tune line amplitude is no longer equal to (2I x ) 1/2 and the computation of the other CRDTs from Tables II and IX are affected by an intrinsic error. Equivalent considerations apply for the vertical tune line, affected by the y 4 octupolar terms, g 0013 and g 1102 .
In conclusion, the turn-by-turn analysis of the nonlinear lattice model may be carried out and the formulas of Tables I and II applied provided that: (i) an independent measurement of linear lattice errors, and hence of coupling and beta-beat RDTs, is performed prior the harmonic analysis; (ii) focusing errors are included when computing the C-S parameters to be used when evaluating the first-order RDTs of Table III and when normalizing the measured turn-by-turn data before performing the FFT,x = x/ √ β x andỹ = y/ β y ; If a residual important modulation of the tune-line amplitudes along the ring is observed, the BPM beta functions may be further corrected by requiring that each tune-line amplitude be equal to the mean value (among all BPMs); (iii) the transverse beam excitation is conveniently chosen as a trade off between maximizing the spectral signal-tonoise ratio and minimizing the tune-line amplitude modulation induced by sextupoles and octupoles. This will result in tune lines having the same amplitude along the ring (|H(1, 0)| ≃ √ 2I x /2 and |V (0, 1)| ≃ 2I y /2), in zero beta-beat RDTs, and hence in the possibility of using first-order RDTs for the analysis of normal sextupole errors.
Appendix D: Combined RDTs from single-BPM turn-by-turn data In this Appendix formulas for the single-BPM combined RDTs (CRDTs) of Tables I and VIII are derived from the results of Appendix B. As discussed in Appendix C it is assumed that quadrupole errors are included in the computation of the C-S parameters, i.e. that the modulated beta functions are used in evaluatingx = x/ √ β x andỹ = y/ β y , and that transverse oscillations are sufficiently small to neglect the interference of sextupole and octupole RDTs on the tune lines and to avoid amplitude-dependent detuning: This will ensure that the two sums in Eqs. (A72) and (A73) do not contain the secondary lines H h (±1, 0) and V h (0, ±1). Results for the skew quadrupole CRDTs are presented for completeness, even though they are not considered suitable for a refined evaluation of betatron coupling (as mentioned in Appendix C). Equations (A72) and (A73) may be rewritten as where the corresponding sextupolar CRDT is defined as F N S3 = 3f  It is worthwhile noticing that the choice has been made here to select those lines laying within 0 and 0.5 in tune units, starting from betatron tunes of the ESRF storage ring, whose fractional parts are Q x = 0.44 and Q y = 0.39: H(−2, 0) appears at 1 − 2Q x = 0.12, H(0, −2) at 1 − 2Q y = 0.22, V (−1, −1) at 1 − Q x − Q y = 0.17 and V (1, −1) at Q x − Q y = 0.05. This choice is however arbitrary. Their complex conjugates may be used as well, V (−1, 1) instead of V (1, −1) for instance, on condition to modify accordingly the computation of the CRDT phase.