Beam Based Alignment of Interaction Region Magnets

In conventional beam based alignment (BBA) procedures, the relative alignment of a quadrupole to a nearby beam position monitor is determined by finding a beam position in the quadrupole at which the closed orbit does not change when the quadrupole field is varied. The final focus magnets of the interaction regions (IR) of circular colliders often have some specialized properties that make it difficult to perform conventional beam based alignment procedures. At the HERA interaction points, for example, these properties are: (a) The quadrupoles are quite strong and long. Therefore a thin lens approximation is quite imprecise. (b) The effects of angular magnet offsets become significant. (c) The possibilities to steer the beam are limited as long as the alignment is not within specifications. (d) The beam orbit has design offsets and design angles with respect to the axis of the low-beta quadrupoles. (e) Often quadrupoles do not have a beam position monitor in their vicinity. Here we present a beam based alignment procedure that determines the relative offset of the closed orbit from a quadrupole center without requiring large orbit changes or monitors next to the quadrupole. Taking into account the alignment angle allows us to reduce the sensitivity to optical errors by one to two orders of magnitude. We also show how the BBA measurements of all IR quadrupoles can be used to determine the global position of the magnets. The sensitivity to errors of this method is evaluated and its applicability to HERA is shown.


Introduction
The new HERA interaction regions are designed to achieve a maximum possible luminosity by strongly focusing the proton beam. This results in β-function values at the interaction point (IP) which are in the range of the bunch length. This new design includes superconducting combined function magnets inside the colliding beam

INTRODUCTION
detectors H1 and ZEUS which focus the 27.5GeV lepton beam in the vertical plane and bend the beam away from the 920GeV proton beam. This allows to place the low β magnet for the protons as close as 11m to the IP. The synchrotron radiation produced by the beam separation has to be absorbed far away from the IP. Therefore the vacuum chambers downstream of the IP have a keyhole shape to allow the synchrotron radiation fan to propagate through the low-beta quadrupoles. These have a 28mm gap between the coils. The aperture of the flat part of the downstream vacuum chambers is only 18mm. This is critical because of the height of the synchrotron radiation that is generated in the upstream low-beta quadrupoles. Due to the large vertical divergence of the beam in these quadrupoles, the synchrotron radiation fan will only fit inside the keyhole shape if the quadrupoles in the lowbeta region are aligned to a precision of better than 0.5mm. By optical surveying, a precision of about 0.3mm can be achieved under optimum conditions which are not given in the interaction region (IR) with shielding walls and a large detector in between the two halves of the straight section. Beam-based alignment was proposed to verify specifications that cannot be verified to a satisfactory precision by the survey procedure. A precision of magnet alignment of 0.1mm appears to be desirable. The magnets of the HERA IR are movable via remote control and can be adjusted in an iterative way without access to the magnets.
Beam-based alignment is a technique of deriving the position of a quadrupole magnet from the analysis of difference orbits that are generated by the variation of the strength of this quadrupole. If the central orbit of the beam is not in the center of the quadrupole, the beam experiences a dipole field that changes the orbit. Beam-position monitors detect the changes of the orbit around the ring. The offset of the beam with respect to the quadrupole axis is then determined by analysis of the difference orbit. The result may be used to calibrate the offsets of nearby beam position monitors or to mechanically re-align the quadrupole magnets.
This technique has been invented to optimize the performance of the SLC [1,2,3,4]. It has also been successfully applied to calibrate the beam position monitors in the HERA electron ring, where it was the basis for an orbit steering algorithm of minimizing the residual vertical kicks which yielded a record electron spin polarization [5,6,7]. Future accelerators such as NLC will depend heavily on extensive beam-based steering algorithms [8,9].
The application of beam-based alignment techniques to adjust the magnet positions in the new HERA interaction region however encountered a number of difficulties and problems. The analysis and the solutions of these problems can be helpful for future application of beam-based alignment, especially in interaction regions.
The difficulties we encountered have to do with circumstances that might be considered typical for an interaction region: (a) The quadrupoles are quite strong and long. Therefore the thin lens approximation is quite imprecise. (b) The effects of angular magnet offsets become significant. (c) The possibilities to steer the beam are limited as long as the alignment is not within specifications. (d) The beam orbit has design offsets and design angles with respect to the axis of the low-beta quadrupoles. (e) Often quadrupoles do not have a beam position monitor in their vicinity. Under these circumstances the results are very sensitive to errors and it turned out to be very difficult to achieve the desired precision of the beam-based alignment of 0.1mm. Moreover, since the beam cannot be centered in all the magnets simultaneously, a global analysis of the magnet positions becomes necessary which uses the results of the beam-based alignment measurements in all the IR quadrupoles.

The HERA Interaction Regions
In the following we describe the HERA Interaction region to the extent relevant for synchrotron radiation background and beam-based alignment of the low-beta quadrupoles.
The proton and lepton beams collide head on in the interaction point. The two beams are separated by combined function magnets, which start on both sides at 2m from the IP. Because of the strong synchrotron radiation power of together approximately 30kW generated in these magnets, the layout is not symmetric. On the left side from which the lepton beam enters, there is a 3.2m long relatively low field superconducting magnet (GO) of 90mm full aperture which deflects the leptons by 3mrad and focuses them in the vertical plane as the first lens of a low-beta triplet. On the right side of the IP, these functions are provided by a combination of a short (1.3m length) but large full aperture (120mm) superconducting combined function magnet (GG) and a normal conducting conventional quadrupole (GI) with a length of 1.88m. These innermost magnets are complemented by a horizontally focusing quadrupole of type GI and a vertically focusing magnet (GJ) of 1.88m length on both sides of the IP. The double-doublet structure for focusing the protons starts at 11.2m on each side of the IP with a half quadrupole with septum plate. Table  2.1 shows the main parameters of the HERA IR quadrupoles and the location of the positron design orbit relative to the quadrupole axis in the center of each IR magnet. For electron/proton collisions the values are slightly different. Due to spin matching requirements it has not been possible to use exactly these design parameters for the quadrupoles, and in the routinely used optics files the computed path for injection and for luminosity operation differ by up to 0.5mm in some quadrupoles.

Closed Orbit Changes due to a Quadrupole Change
As described before, beam-based alignment is the analysis of difference orbits that are excited by a change in the strength of a quadrupole as illustrated in figure 3.1.
The difference orbit is related to the offset and the angle of the beam orbit with respect to the quadrupole axis. Therefore, we will derive the relationship between magnet alignment, closed orbit, strength variations and the difference orbit. Following standard text-book procedure, the closed orbit is written in linear approximation as (3.1) x + (s) Figure 3.1: The orbit position relative to the axis of a quadrupole can be deduced from the closed orbit change which is created by a change in the quadrupole's field strenght.
In this expression, x(s) is the vector with closed orbit x and it's derivative x ′ at some longitudinal position s along the design trajectory, which is chosen as reference x(s) = 0. T s,0 is the transport matrix from the position s = 0 to position s. With the total circumference of the design curve L the revolution matrix at s is M s = T s+L,s and I is the unity matrix. With the focusing strength k, the curvature κ of the design trajectory in the dipole fields and ∆κ from dipole field errors and correction coils, the vector d s,s 0 describes the closed orbit distortions along the ring according to the inhomogeneous equation of motion We assume that the quadrupole to be aligned, the test quadrupole, is the first element in the lattice. For generality the quadrupole can also have a dipole field component. This is important for HERA, since the magnets GG and GO are quadrupole magnets with an additional vertical dipole field. For the beam-based alignment procedure only the quadrupole strength k is changed, not the dipole field strength.
Since the quadrupole magnet has a straight axis, the motion through these fields is not correctly described with the map of a combined function magnet, where the quadrupole field is evaluated around a curved trajectory. In the coordinate system which is aligned along the quadrupoles straight axis, the equation of particle motion through the magnetic field B y is given by Charge and momentum are denoted by q and p. The transport map G( x) which transports the phase space vector x 0 from the beginning of the quadrupole to x e at its end is given by When the alignment of the magnet with respect to the design trajectory at its entrance is described by a shift to z 0 and a slope z ′ 0 , and similarly z e describes the alignment of the end of the magnet, then the particle transport is described by (3.5) The closed orbit at the end of the quadrupole is given by the periodicity condition  After the quadrupole strength has been changed to k + ∆k we denote changed quantities by a superscript +, and the closed orbit is similarly given by We are looking for a relation between the distance of the closed orbit from the quadrupole's center ∆ x = x − z and the closed orbit change δ x = x + − x. For this purpose we use equation (3.6) to eliminate T L,e x e + d L,e − z 0 in equation (3.7) and obtain x + e = δ x e + ∆ x e + z e (3.8) This equation can now be solved to express δ x in terms of ∆ x, This expression can already be used to determine the magnet alignment ∆ x e at its end. However, when neglecting second orders in ∆k, the expression become simplest when the alignment ∆ x m in the middle of the magnet is computed. For this we introduce the matrix g and vector d which are G and D in equation (3.4) for half the quadrupole length. A useful matrix will be which reduces the effect of ∆k to the center of the quadrupole. In the following we will use the abbreviations For a defocusing quadrupole (k < 0) sin changes to sinh due to the imaginary unit in √ −k, With the revolution matrix M m = gT L,e g for the middle of the test magnet equation (3.9) leads to Relating ∆ x e to the center of the magnet leads to ∆ x e = g∆ x m + d and similarly D = g d + d. To leading order in ∆k the difference orbit around the ring δ x(s) = T s,m g −1 δ x e is then given by (3.14) This shows that for a quadrupole with an additional dipole field, the closed orbit distortion δ x is not created by the distance x− z between closed orbit and quadrupole axis, but by the distance between the closed orbit and an axis that is shifted by f from the quadrupole axis, with To simplify the notation, we will now use ∆ x m = x m − z m − f for the closed orbit with respect to the modified axis of the quadrupole. The shift of the alignment axis by f amounts to −401µm for the GO magnet and to −132µm for the GG magnet.
Since T s,m (I − M m ) −1 is the closed orbit generator, the difference orbit δ x(s) is created by an effective kick in the center of the test magnet. However, there is not only an angle kick θ m like in the thin lens model of a quadrupole, but there is also a position kick ∆ m so that the difference orbit which is created by the change of the test quadrupole has two terms, Contributions from angular offsets become important if sin(l √ k) l √ k is significantly smaller than unity, which is the case for the HERA low-beta quadrupoles as shown in table 4.3. The well-known formulas The contribution δx θ is the conventional closed orbit for a correction coil at the center of the test magnet, where φ = φ m . The contribution δx ∆ can be compensated by a correction coil at when φ(s) is not between φ m and φ α . For φ α we take the branch where the atan function is in [− π 2 , π 2 ]. A closed orbit correction program with correctors at these two phases will readily determin θ m and ∆ m γm βα sign(α m ) as proposed corrector kicks. These lead immidiately to ∆x m and ∆x ′ m with equation (3.19) and (3.20).

Kick Compensation Method
Quadrupole errors around the machine might lead to a misinterpretation of the quadrupole offsets to be evaluated. We therefore propose to create a closed bump by changing the strength of the test quadrupole by appropriately exciting two corrector coils as shown in figure 3.2.
The orbit position relative to the axis of a quadrupole can be deduced from the angles required to close a bump which is exited by changing the quadrupole's field strength.
The difference orbit is thus a closed bump, which starts with δx = 0, δx ′ = 0 at the test quadrupole. The amplitude and slope δ x(s) within this bump is derived from with the original closed orbit x 0 and the quadrupole offset and angle alignment z 0 at the beginning of the test quadrupole. We again refer to the alignment in the quadrupole's center by The difference orbit vanishes after the second correction coil so that vanishes with x 2 = 0 and x ′ 2 = 0. Here the deviation of the closed orbit from the modified quadrupole center ∆ x m = x m − z m − f has been used again. The closed orbit inside the quadrupole is then To simplify notations, we again use The total transformation between the compensating kicks Θ = (Θ 1 , Θ 2 ) and the test quadrupole offset vector is then Where the effective center shift f is given in equation (3.15) and appears whenever the quadrupole field which is changed for beam based alignment is superimposed by a dipole field. Similarly the corrector angles can be determined from the quadrupole alignment by the inverse equation, These formulas are accurate up to leading order in ∆k. The program MAD was used to simulate the closed orbit and the kick compensation version of beam-based alignment for the HERA IR magnets. The inaccuracy of the reconstructed closed orbit deviation due to the neglected higher orders in ∆k was shown for all the IR magnets to be better than 1.3% for ∆k/k ≤ 5%. And it was shown that only second order terms in ∆k/k contribute noticeably to this small error.
For the quadrupoles QR16L, QR14L, GOL and GOR the error of the linearization is shown in figure 3.3. The deviation between the alignment x m − z m and the first order result (x m − z m ) 1 of formula (3.30) is plotted against ∆k/k on a logarithmic scale. The simulations were performed for the displayed range of ∆k/k. For even smaller ∆k/k numerical inaccuracies dominate the compution. The error increases linearly, which shows that only next to leading order effects contribute noticeably to the errors and that these are small.
The nature of this transformation becomes more transparent if the two kicks θ = (θ 1 , θ 2 ) are replaced by two fictive kicks θ f which occur at a betatron phase difference of exactly π and −atan(1/α m ) from the test quadrupole respectively and are normalized to the β-function. We again take the branch where the atan function is in [− π 2 , π 2 ]. With φ 1m → π and φ 2m → −atan(1/α m ) this leads to for GGR log 10 ( ∆k k ) for the accuracy of the angular reconstruction (upper curves).
The fictive angles θ f = (θ f 1 , θ f 2 ) are now clearly related to the alignment. The kick θ f 1 corrects the oscillation from the magnet offset so that θ f 1 = − √ β m θ m with equation (3.19). The kick and θ f 2 corrects the oscillation due to the angle of the closed orbit relative to the magnet axis and θ f 2 = √ γ m ∆ m due to equation (3.20).
The relation between the real and the fictive angles turns out to be

Influence of Measurement Errors and Imperfections
In the following, we will consider the errors in case of the compensating kick method.

Error of Thin Lens Treatment
Let us first consider the error that is made by treating the test quadrupole as a thin lens. The effective kick in the quadrupole of equation ( The error has two components, a scaling error of σ − = 1 − σ + which is shown in the 2nd column of table 4.3, and an absolute error of −f σ + which is 452µm for the GOL and 132µm for the GGR magnet. For a HERA IR quadrupole GO the scaling error amounts to 11%. Given the systematic horizontal offset of −5.5mm in this magnet and an additional closed orbit deviation of up to 5mm, the absolute error due to thin lens analysis could be in the order of 1mm. Also for the magnet GI in the HERA IR a thin lens evaluation could lead to an error of up to 1mm since the scaling error amounts to 6% and the offset could be 10mm design offset plus a closed orbit deviation of 5mm. The error in case of a standard lattice quadrupole with k ≈ 0.1m −2 and l = 1m however is rather small. Even with an orbit offset of 5mm, the measurement error for such an element with zero design offset is only 50µm.
The influence of the angle error in the quadrupole alignment is completely ignored in the thin lens model. To estimate the relative importance of the oscillation excited by the angle alignment, we investigate the Courant-Snyder invariant ǫ ∆x ′ of the part of the difference orbit which is due to the angle error and ǫ ∆x which is the part due Name For the HERA IR magnets the 3rd column of table 4.3 shows this ratio of oscillation amplitudes. For the long, superconducting GO magnets in the HERA IRs the oscillation amplitude ǫ ∆x ′ is 29% of the oscillation amplitude due to the quadrupole shift. The quadrupole's angle and the corresponding error from neglecting it are therefore quite significant. Thus even if the contribution of angular alignment is considered small, one should take into account only that component of the difference orbit which has the proper phase relation to the test magnet in order to avoid large errors. This is especially important, if there is a large value of α m in the center of the test quadrupole.

Influence of Optical Errors
Beam optics distortions between the compensating kicks in a beam-based alignment measurement and the test quadrupole lead to misinterpretation of the difference orbit and a corresponding error of the evaluation. Given optical errors δ β = (δβ m , δβ 1 , δβ 2 ), δα m and δ φ = (φ 1m , φ 2m ), the change ∆k in the test quadrupole requires correction kicks θ to close the bumps which are obtained by inserting the perturbed optical functions in to equation (3.31). The inferred orbit in the quadrupole is however obtained by equation (3.30) with the unperturbed optical functions and is therefore erroneous. This erroneous result of the beam-based alignment procedure Table 4.4: Errors of the beam-based alignment procedure for the HERA IR quadrupoles at injection due to a phase error of δφ = 0.01 · 2π within the closed bump of the kick compensation method.
Name is here referred to as ∆ x err . We refer to the matrix in equation (3.31) as A( β, α m , φ).

The matrix in equation (3.30) is
For simplicity let us now assume a phase error, so that the α and β functions do not change and we assume δφ = δφ 1,m = δφ 2,m which means that no optics error occurs between the corrector magnets. Here we will neglect all nonlinear terms in δφ by replacing cos(δφ) by 1 and sin(δφ) by δφ. With the equations (3.31) and (3.30) the result can be expressed in the following way The term in the position error which is proportional to ∆x m is thus simply given by With a phase deviation ∆φ = 0.01 · 2π this error is 24% for the GO quadrupole. For the same phase deviation, table 4.4 shows all these errors for the HERA IR magnets. The error in the position measurement that is introduced by the angle alignment is a few percent. However, the term that generates the error in the angle determination is shown to be huge in the third column of table 4.4. This will prevent a precise measurement of the angular alignment. The here studied case of a pure phase error is somewhat artificial. When the other optical functions are also perturbed, then the evaluation becomes rather elaborate and the errors depend strongly on the location of the optical element that courses them. We now assume that there is one thin lens quadrupole error with focal strength δk l at position q in between the test magnet and the two correction coils. The kicks θ in the correction coils are then related to the alignment by equation (3.29), The erroneously determined alignment ∆ x err does not take the optical error into account, We therefore obtain the relation The error is a linear combination of the deviation ∆x m from the magnet center and the deviation of the slope, and similarly for the error of the angular alignment determination. The exact value of the terms in the matrix that relates ∆ x err and ∆ x depend on the optical parameters, especially on the phase advance between the error and the test quadrupole. When one inserts as a worst case scenario for each of the matrix elements the phase φ qm where it has the maximum absolute value, one obtains These values are shown for the HERA IR in table 4.4 when a thin lens quadrupole error with tune change 1 4π δk l β q = 0.01 is assumed. Table 4.6 shows which relative quadrupole errors in the IR lead to such a tune shift.
For specific quadrupole errors in the HERA interaction region, the sensitivity of this beam based alignment procedure was also evaluated. Table 4.7 shows the error of the constructed beam offset in the GJ8L, GI7L, and GOL magnet which occurs when the field strength in one of the other quadrupoles on the left side of the IP has an error which leads to a tune shift of 0.01. We only show the most relevant term of the error, ∂ ∆x (∆x err − ∆x).

Reduction of Sensitivity to Errors
One source of errors is an imperfect determination of the compensation kicks θ 1 and θ 2 . Since the determination of ∆x ′ m is very prone to errors, as can be seen in the tables 4.4 and 4.5, it is not worth trying to determine the angle alignment. But we will assume that the angle alignment ∆x ′ m = x ′ m − z ′ m is approximately correct and we will therefore require our compensation to lead to the design value z ′ 0 m of the angular alignment. While the angles Θ are measured, we assume that the correct angles to close the bump would have been Θ − ∆ Θ. Since the errors ∆ Θ are not known, we introduce an estimate ∆ Θ * of the erroneous angle such that equation (3.30) leads to an estimated alignment of m . This condition should be satisfied for a set ∆ Θ * of angles which is as small as possible, i.e. |∆ Θ * | 2 should be minimal. We can use Lagrange multipliers to minimize, These equations lead to ∆ Θ * = a 2 ( a 2 · Θ+z ′ 0 m )/| a 2 | 2 . With a 1 = (A −1 11 , A −1 12 ) equation (3.30) determins the alignment to ∆x m = a 1 · Θ. When the above estimate ∆ Θ * is used, the estimated alignment is given by When the determination of the angles Θ has an error with standard deviation σ Θ , then the errors in the determination of ∆x m and ∆x ′ m have the standard deviations When the equation (4.49) is used, the standard deviation of ∆x * m is always smaller, Especially for large α m his spread of results in ∆x * m is drastically smaller than the spread in equation (4.52). If the angular alignment of the orbit relative to the magnet is not the design value −z ′ 0 m , then ∆x * m contains a systematic error since ∆Θ = 0 does not lead to the correct alignment ∆x m = a 1 · Θ but with a 2 · Θ = ∆x ′ m it leads to This systematic deviation of ∆x * 0 m = ∆x * m (∆ Θ = 0) from ∆x 0 m = ∆x m (∆ Θ = 0) is shown in tabel 4.8 for an angular deviation x ′ m of 1mrad. Figure 4.4 shows that a spherical error distribution for Θ 1 and Θ 2 leads to an elliptical distribution for ∆x m and ∆x ′ m . The large spread in ∆x m is reduced by the estimation of ∆ Θ * as shown in the figure. This, however, introduces the systematic error x * 0 m − x 0 m which is also shown. Now we will show that this procedure also reduces the sensitivity to optical errors. In the tables 4.4, 4.5 and 4.7 is has been seen that the most important error of the alignment determination is due to the term ∂ ∆x ∆x err − 1. This is mostly due to the fact that the Twiss parameter α m that contributes to this term can be relatively large. We will now show that the here proposed method of error reduction makes this term independent of α for all types of optical errors. For an alignment ∆x m , the angles Θ that close the bump are given by Θ The most disturbing error contribution ∂ ∆x ∆x err m − 1 is then given by Since det(A −1 ) as well as | a 2 | 2 do not depend on α m , the error contribution no longer depends on α m , no matter which optical perturbation occurs. Equation (4.38) and table 4.4 show the error terms introduced by an optical error that only changes the betatron phase. When the error reduction method is used, the error of the alignment determination can be computed from equation (4.57) to be Also the term ∂ ∆x ∆x err m − 1 depends on the Twiss parameters at the corrector coils. For φ 1m = π/2 and φ 2m = π we obtain The error becomes completely independent of ∆x m and the already small error due to ∆x ′ m in equation (4.38) is reduced by 1 + α 2 m . For the phase advances which are realized in the HERA IR between the test magnet and two horizontal correction coils at 101m and 75m left of the IP, the error terms are shown in table 4.9. The error has been reduced to less than 1% for all magnets, whereas it was up to 36% without error reduction.
The maximum error terms that can occur due to a focusing error somewhere in the bump depend also on the phase advances when the error reduction method is used. For φ 1m = π/2 and φ 2m = π one obtains (4.61) Both terms are always smaller than the maximum errors in equation (4.44) without error reduction. Especially the first error term is significantly smaller as can be seen in table 4.9 where these maximum errors are plotted for the IR of HERA. In table 4.10 the error for one of the IR magnets is shown which occurs when another IR magnet causes the focusing error. With error reduction also these errors are significantly smaller than those in table 4.7. We conclude the error considerations by realizing that there are no chances to determine the angular alignment of the quadrupoles with the desired precision of ∆x ′ m ≃ 100µrad. The large sensitivity to optical errors and to corrector settings of the estimated quadrupole offset can be reduced drastically by one to two orders of magnitude.

Combining BBA Data of all IR Magnets
Since it is not possible to steer the beams to the middle of all quadrupoles for a misaligned interaction region, the measurement of the position and angle of the beam with respect to a single quadrupole magnet does not give enough information to determine the global alignment of this magnet. All the quadrupole offsets and angles with respect to the beam have to be determined, and the beam orbit has to be consistently modeled, thereby fixing the absolute magnet positions. In order to achieve that, the following procedure has been established: the beam offsets with respect to all the quadrupoles in the IR are measured for two or more different quadrupole settings in the IR. Then a model of the IR that has the initial orbit values at the entrance of the IR and the magnet positions as free parameters is fitted to the set of measurements. An additional constraint in the fit is that the magnet position deviations from their nominal values should be minimal in order to connect to the machine coordinate system avoiding a global, unrealistic offset.
In order to perform this task, we need an explicit formula for the beam orbit as a function of alignments and initial conditions. To arrive at such a formula we write the transformation of the beam orbit from the center of a quadrupole to the center of its neighbor quadrupole as x n = g n D n,n−1 [g n−1 ( x n−1 − z n−1 ) + d n−1 + t n−1 z n−1 ] + d n,n−1 − t −1 n z n + d n + z n . The 4 × 4 matrix D n,n−1 is the transport matrix from the end of the n-1st test magnet to the entrance of the nth test magnet. On this distance the closed orbit distortions d n,n−1 due to corrector coils or field errors are being accumulated. The matrix t n describes a drift with half the length of the nth magnet. It is used to obtain the alignment at the end of a magnet as t n−1 z n−1 or at the beginning of a magnet as t −1 n z n . In the following it will use the 4 × 4 matrix T n,n−1 = g n D n,n−1 g n−1 . The matrix T n,n−1 transforms from center to center between two neighbored quadrupoles. The vector x n describes the orbit and z n is the vector of magnet alignments, both taken in the center of the magnet, g n transforms through half the quadrupole with index n. This equation can be simplified by using 5 × 5 matrixes, where the fifth column is used to describe the closed orbit distortions. The orbit vector then has five components, (x, x ′ , y, y ′ , 1), the alignment vectors z n have 0 in their 5th component. The closed orbit deviations d are then all absorbed in the 5th columns so that, after combining the terms, the recursive orbit formula reads This recursive formula leads to the explicit expression Using P n,0 = −T n,0 (I − g −1 0 t 0 ) , (5.64) P n,j = T n,j (g −1 j t j − g j t −1 j ) for 0 < j < n , (5.65) We finally obtain for the orbit in each of the N test magnets the desired form On the left side appears the expression which is obtained as the result of the measurement, the right hand side contains the parameters to be fitted, the magnet offsets and angles and the initial orbit coordinates. Since there are more parameters than measured values, this expression can only be solved by fitting at least two different measurements with different quadrupole settings (index m, thus different matrices T From the previous paragraph, it is clear that the angular alignment cannot be determined with satisfactory precision. Since the angles of the magnets with respect to the beam need to be taken into account for the fit, the design angles of the magnet are used. Therefore we can only make use of the position part of the vector equation (5.67). This introduces certain errors into the alignment reconstruction that are analyzed in the next section.
We now define a new relationship between the measured values of x n − z n , the magnet offsets z 0 , z 1 . . . z N and the initial orbit values x 0 , x ′ 0 . For this we define new vectors. The first one includes several sets (m ∈ {1 . . . M}) of relative position measurements (x m − z m ) (m) in all the IR magnets, as well as the design position z 0 The second vector contains the parameters to be determined In cases when the inverse cannot be computed due to a bad condition of the matrix, a singular value decomposition (SVD) can be helpful.

Error in Magnet Offset Determination by Ignoring the Magnet Angle Offsets
The quadrupole magnet's angular alignment produces a contribution to the closed orbit that is to be reconstructed. Since we are not able to measure the angular alignment, it is not contained in our model. Therefore, the missing angular offset in the model is compensated by an additional false offset in neighboring magnets. The magnitude of this error is estimated in the following. The effect of the magnet angle on the beam trajectory is described in equation (5.63) for a one of the orbit planes by two dimensional sub-matrices, (5.86) Table 5.11 shows what error an angular alignment error of HERA's IR quadrupoles can have on the estimated position of the two neighboring IR magnets. Even for an angular alignment error of 1mrad, the errors in the reconstructed position is always below 150µm.

Error Propagation in the Fitting Procedure
The magnet positions as the result of a fit of the measurements can be written as We now introduce sets of random errors of the input variables labeled by α z n + ∆z α n = N j=1 (B nj + ∆B α n,j )(y j + ∆y α j ) . (∆B α n,j · y j + B n,j · ∆y α j ) .

(5.89)
We now calculate the expectation value of ∆z n by squaring the expression and by subsequently averaging over the error set α. We assume that for random errors the following correlations hold: < ∆B α n,j ∆B α nk > α = ∆B 2 rms δ j,k and < ∆y α j ∆y α k > α = y 2 rms δ j,k . With this we finally obtain ∆z n,rms = j y 2 j · ∆B 2 rms + j B 2 n,j · ∆y 2 rms . (5.90) The first sum has typically values of 1 to 3 when evaluated for the HERA IR. Thus an error of a single measurement ∆(x j − z j ) = 0.1mm propagates, yielding approximately an error of 0.3mm in the reconstructed magnet position. However, these are only first observations for the case of HERA where the here presented version of beam-based alignment is currently being heavily used in the commissioning process. This particular application and experiences with this method will thus be reported in a separate paper after the successful commissioning of the HERA luminosity upgrade.

Conclusion
We have introduced a beam based alignment method for a general class of combined function magnets that can be encountered in collider interaction regions. While this method can in principal determine alignment angles, we have shown that these angles would be very prone to measurement errors. We have therefore introduced a procedure to use the angular alignment to strongly improve the accuracy of the position determination by one to two orders of magnitude. Furthermore a procedure has been presented to determine global magnet positions after the closed orbit deviation from the quadrupole axis has been measured throughout the interaction region.