<figure><img src="image_1.png" /></figure>

HAL
open science

# Alignment of the Alpha Magnetic Spectrometer (AMS) in space

Qi Yan, Vitaly Choutko

► To cite this version:

Qi Yan, Vitaly Choutko. Alignment of the Alpha Magnetic Spectrometer (AMS) in space. European Physical Journal C: Particles and Fields, 2023, 83 (3), pp.245. 10.1140/epjc/s10052-023-11395-0. hal-04132262

HAL Id: hal-04132262

https://hal.science/hal-04132262

Submitted on 18 Jun 2023

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
<figure><img src="image_3.png" /></figure>

# Alignment of the Alpha Magnetic Spectrometer (AMS) in space

Qi Yan<sup>a,b</sup>, Vitaly Choutko

Massachusetts Institute of Technology (MIT), Cambridge, MA 02139, USA

Received: 25 November 2022 / Accepted: 11 March 2023

© The Author(s) 2023

**Abstract** The Alpha Magnetic Spectrometer (AMS) is a precision particle physics detector operating at an altitude of ~410 km aboard the International Space Station. The AMS silicon tracker, together with the permanent magnet, measures the rigidity (momentum/charge) of cosmic rays in the range from ~0.5 GV to several TV. In order to have accurate rigidity measurements, the positions of more than 2000 tracker modules have to be determined at the micron level by an alignment procedure. The tracker was first aligned using the 400 GeV/c proton test beam at CERN and then re-aligned using cosmic-ray events after being launched into space. A unique method to align the permanent magnetic spectrometer for a space experiment is presented. The developed underlying mathematical algorithm is discussed in detail.

## Contents

1 Introduction

2 AMS detector and the silicon tracker

3 Coordinate systems and composite alignment parameters

3.1 Coordinate transformation and alignment parameters

3.2 Coordinate measurement residual and its derivatives with respect to the alignment parameters

4 Constraints of the composite alignment parameters

4.1 Constraints of sensors in a ladder

4.2 Constraints of ladders in a layer

4.3 Constraints of layers in the tracker

4.4 Constraints of stretching and shear deformations

4.4.1 Stretching

4.4.2 Shearing

5 Global track alignment

6 Alignment based on the 400 GeV/c proton test beam

6.1 Setup of the test beam

6.2 Alignment procedure

6.2.1 Presigmas in the alignment

6.2.2 Fixed parameters in the alignment

6.3 Alignment results

6.4 Mechanical stability study with the 180° runs

7 Dynamic alignment of the external tracker layers in space

7.1 Thermal environment and data collection on orbit

7.2 Alignment procedure

7.2.1 Dynamic alignment in a short-time window

7.2.2 Alignment smoothing for long time period

7.3 Alignment results

8 Static alignment of the tracker in space

8.1 Global track alignment with curvature constraints

8.2 Alignment data sample

8.3 Alignment procedure

8.3.1 Alignment validation with Monte Carlo

8.3.2 Alignment optimization for the flight data

8.3.3 Refinement with the curvature alignment

8.3.4 Determination of the total absolute rigidity scale

8.4 Alignment results

8.4.1 Displacements of the tracker modules during launch

8.4.2 Stability of the tracker modules in space

8.4.3 Alignment precision

9 Conclusion

Appendix A: Coordinate transformation from the local sensor frame to the global tracker frame

Appendix B: $\chi^2$ minimization and alignment matrix in the global alignment

References

## 1 Introduction

The Alpha Magnetic Spectrometer (AMS), operating aboard the International Space Station (ISS) since May 2011, is a unique large acceptance magnetic spectrometer in space. It

<footnote><sup>a</sup>e-mail: qyan@cern.ch (corresponding author)</footnote>
aims to measure energy spectra of cosmic-ray charged particles, nuclei, antiparticles, antinuclei, and gamma-rays in the GeV–TeV region to understand Dark Matter, antimatter, and the origin of cosmic rays, as well as to explore new physics phenomena. The AMS silicon tracker detector, together with the permanent magnet, determines the rigidity (momentum/charge) of charged cosmic rays by multiple measurements of the coordinates along the particle trajectory. High performance of the tracker is crucial for the AMS mission and requires a sophisticated alignment to accurately determine the positions of the detector modules.

In August 2010, before AMS was launched, the complete detector was tested with a 400 GeV/c proton beam at the CERN Super Proton Synchrotron (SPS). This data allows the precise alignment of the tracker with micron accuracy using the procedure described in this paper, which aligns all the detector modules from different mechanical hierarchy levels in one step. The strong accelerations and vibrations during launch, followed by the rapid outgassing of the support structure in vacuum, together with continuous temperature variations in space all change the positions of the tracker modules. The tracker is continuously re-aligned with cosmic-ray events to correct the resulting displacements. The unprecedented challenge in the alignment of the magnetic spectrometer in space is that the detector has to be aligned by using cosmic-ray events with unknown rigidities in the presence of the magnetic field. In this paper, we report a unique mathematical approach which allows to overcome these difficulties and align the tracker to micron precision.

## 2 AMS detector and the silicon tracker

As shown in Fig. 1, the AMS detector consists of a permanent magnet and an array of particle detectors to measure the velocity $\beta = v/c$, absolute charge $Q$, energy $E$, and rigidity $R$ of the passing particles. Within the magnet bore and above and below the magnet are a total of 9 precision silicon tracker layers, L1 to L9. The tracker accurately measures $R$ and $Q$ of the particles. Above and below the magnet bore are the Upper and Lower Time of Flight (TOF) counters [1]. The TOF provides a charged particle trigger to AMS and determines $\beta$ and $Q$ of the incoming particles. The Transition Radiation Detector (TRD) [2], located above the Upper Time of Flight counters, identifies electrons and positrons. The Ring Imaging Cherenkov detector (RICH) [3], below the Lower Time of Flight counters, measures $\beta$ and $Q$ of passing particles. The Electromagnetic Calorimeter (ECAL) [4], at the bottom of AMS, measures $E$ of electromagnetic particles and separates protons from electrons and positrons. The Anti-Coincidence Counters (ACC) [5], surrounding the inner tracker inside the magnet bore, reject cosmic rays entering AMS from the side. The magnet [6] is made of 64 sectors

<figure><img src="image_4.png" /><figcaption>Fig. 1 (Right) Schematic view of a cosmic-ray fluorine nuclei event of 26 GV rigidity measured by AMS, with the signals in the TRD, TOF, silicon tracker, RICH, and ECAL. Also shown are the permanent magnet and ACC. (Left) Layout of the tracker showing the upper external layer (L1), the inner tracker (L2–L8), and the lower external layer (L9) as well as their support planes</figcaption></figure>

of high-grade Nd-Fe-B assembled in a cylindrical shell. The central field of the magnet is 1.4 kGauss. In 2010, the field was measured in 120 000 locations to an accuracy of better than 2 Gauss. Comparison with the measurements performed with the same magnet in 1997 shows that the field did not change within 1%. On orbit, the magnet temperature varies from –3 to +20 °C. The field strength is corrected with a measured temperature dependence of –0.09%/°C [7].

The AMS tracker comprises 2284 double-sided silicon micro-strip sensors each with a surface area of $41.360 \times 72.045$ (active area of $39.832 \times 70.565$) mm² and thickness of 0.300 mm, assembled in 192 mechanical and electrical units called ladders [8]. Each ladder contains 9 to 15 sensors, see Fig. 2a. The total active area is $6.42 \text{ m}^2$. Both sides of a sensor are implanted with metallic strips running in orthogonal directions, providing a two-dimensional measurement of the particle position. For the side with $p$-doped strips ($p$-side), the implantation (readout) strip pitch is 27.5 (110) µm. The opposite side ($n$-side) with $n$-strips has an implantation (readout) pitch of 104 (208) µm. The $p$-side ($n$-side) strips provide the measurement of the particle bending (non-bending) coordinate $y(x)$. Combining the information from all signal strips in a sensor, the coordinate resolution in $y$ is ~10 µm for $Q = 1$ and ~5 µm for $Q = 6$ particles [9]. Sensors within a ladder are daisy-chained together through wire bonds on the $p$-side and are connected by a metalized Upilex film on the $n$-side which is then glued to a ladder reinforcement frame with layers of foam and carbon fiber (see Fig. 2a).
<figure><img src="image_5.png" /></figure>

<figure><img src="image_6.png" /><figcaption>**Fig. 2** The AMS silicon tracker ladder: **a** the main components of the ladder and **b** two assembled ladders</figcaption></figure>

From 16 to 26 ladders are mounted onto one side of a support plane to form a layer. As seen in Fig. 1, the tracker has 9 layers supported by 6 rigid planes. Each plane is made of an aluminum honeycomb interior and carbon fiber skins. The first layer (L1) is on plane 1 at the top of the detector, the second (L2) is on plane 2 just above the magnet, six (L3 to L8) are on 2 sides of planes 3, 4, and 5 within the bore of the magnet, and the last (L9) is on plane 6 just above the ECAL. The maximum lever arm from L1 to L9 is about 3 m. L2 to L8 constitute the inner tracker.

The planes of the inner tracker are firmly held by a cylindrical carbon fiber structure which has near zero coefficient of thermal expansion and excellent mechanical strength [8]. The material thickness of a plane, including 2 layers of ladders, represents ~ 1% of a radiation length ($X_0$). External plane 1 carrying L1 is bolted to another support sandwich plane (plane 1 NS) fastened to the top cover of the TRD. External plane 6 carrying L9 is attached to the ECAL fixation blocks [6]. The deformation of the support structures of the TRD (M-Structure) [10] and ECAL (Unique Support Structure) [11] due to gravity change or temperature variation (more than ±10 °C in space) induce sizable displacements of L1 and L9 with respect to the position of the inner tracker.

<figure><img src="image_7.png" /><figcaption>**Fig. 3** The components and coordinate systems of **a** a sensor, **b** a ladder, **c** a layer, and **d** the inner tracker. The inner tracker coordinate system is also the global coordinate system</figcaption></figure>

The material thickness between L1 and L2, mostly the TRD and Upper TOF, is ~ 0.3 $X_0$, and that between L8 and L9, mostly the Lower TOF and RICH, is ~ 0.2 $X_0$ [12].

### 3 Coordinate systems and composite alignment parameters

The AMS tracker modules (sensors, ladders, and layers) are assembled in a hierarchical support structure – sensors in ladders, ladders on layers, and layers on planes into the tracker. Each module is positioned with respect to the next support structure by 6 degrees of freedom: 3 translations and 3 rotation angles. Figure 3a–c illustrates the local coordinate systems of a sensor, a ladder, and a layer where the geometric center of each module is defined as its origin point ($\vec{o}_s$, $\vec{o}_L$, or $\vec{o}_P$). Taking the sensor coordinate system as an example, as shown in Fig. 3a, the $u_s$-axis and the $v_s$-axis are defined along the coordinates measured by the strips of the n-side and the p-side respectively and the $w_s$-axis is normal to the sensor plane. Figure 3d shows the global coordinate system of the tracker where the geometric center of the inner tracker layers (L2–L8) is defined as its origin point ($\vec{o}_g$ or $\vec{o}$), the x ($u_g$)-axis is along the coordinates measured by n-side strips parallel to the main component of the magnetic field, the z ($w_g$)-axis is pointing vertically perpendicular to the tracker layers, and the y ($v_g$)-axis completes to a right-handed orthogonal coordinate system.

In composite alignment, all detector modules from different hierarchy levels are aligned simultaneously. This approach was previously used in the CMS experiment [13]. In this section and Sect. 4, we will introduce mathematical formulae for composite alignment. Specifically, Sect. 4
will address the implementation of constraints in composite alignment using our original numerical grid method.

## 3.1 Coordinate transformation and alignment parameters

The coordinates of the detector hit measured in the local sensor frame $\vec{q} = (u_s, v_s, w_s)^T$ can be transformed subsequently to the coordinates in the next reference frame, namely, in the ladder frame ($\vec{r}_L$), in the layer frame ($\vec{r}_P$), and in the global tracker frame ($\vec{r}_g$), as:

$$ \vec{r}_L = \mathbf{R}_s^T \Delta \mathbf{R}_s (\vec{q} + \Delta \vec{q}_s) + \vec{r}_{0s} \quad (1) $$

$$ \vec{r}_P = \mathbf{R}_L^T \Delta \mathbf{R}_L (\vec{r}_L + \Delta \vec{q}_L) + \vec{r}_{0L} \quad (2) $$

$$ \vec{r}_g = \mathbf{R}_P^T \Delta \mathbf{R}_P (\vec{r}_P + \Delta \vec{q}_P) + \vec{r}_{0P} \quad (3) $$

where $\vec{q} + \Delta \vec{q}_s$, $\vec{r}_L + \Delta \vec{q}_L$, and $\vec{r}_P + \Delta \vec{q}_P$ are the hit coordinates in the frames of the sensor, ladder, and layer respectively including small corrections on their individual position shifts of $\Delta \vec{q}_s$, $\Delta \vec{q}_L$, and $\Delta \vec{q}_P$; $\mathbf{R}_s^T$, $\mathbf{R}_L^T$, and $\mathbf{R}_P^T$ are the nominal rotation matrices from the sensor into the ladder, from the ladder into the layer, and from the layer into the tracker respectively and $\Delta \mathbf{R}_s$, $\Delta \mathbf{R}_L$, and $\Delta \mathbf{R}_P$ are their small individual corrections; and $\vec{r}_{0s}$, $\vec{r}_{0L}$, and $\vec{r}_{0P}$ are the nominal positions of the sensor, ladder, and layer origin points in the next frame of the ladder, layer, and tracker respectively. The corrections of each module displacement by an offset $\Delta \vec{q}_i = (\Delta u, \Delta v, \Delta w)^T$ and a rotation $\Delta \mathbf{R}_i = \Delta \mathbf{R}_i^\gamma \Delta \mathbf{R}_i^\beta \Delta \mathbf{R}_i^\alpha$ have to be determined from the alignment procedure, where $\Delta \mathbf{R}_i^\gamma$, $\Delta \mathbf{R}_i^\beta$, and $\Delta \mathbf{R}_i^\alpha$ are the decomposed rotation matrices defined by angles of rotation $\alpha, \beta$, and $\gamma$ around the u-axis, the new v-axis, and the new w-axis (Fig. 3):

$$ \Delta \mathbf{R}_i^\alpha = \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos \alpha & \sin \alpha \\ 0 & -\sin \alpha & \cos \alpha \end{pmatrix} \quad \Delta \mathbf{R}_i^\beta = \begin{pmatrix} \cos \beta & 0 & -\sin \beta \\ 0 & 1 & 0 \\ \sin \beta & 0 & \cos \beta \end{pmatrix} $$

$$ \Delta \mathbf{R}_i^\gamma = \begin{pmatrix} \cos \gamma & \sin \gamma & 0 \\ -\sin \gamma & \cos \gamma & 0 \\ 0 & 0 & 1 \end{pmatrix}. \quad (4) $$

In the small-angle approximation, the correction matrix for rotation becomes:

$$ \Delta \mathbf{R}_i = \Delta \mathbf{R}_i^\gamma \Delta \mathbf{R}_i^\beta \Delta \mathbf{R}_i^\alpha = \begin{pmatrix} 1 & \gamma & -\beta \\ -\gamma & 1 & \alpha \\ \beta & -\alpha & 1 \end{pmatrix}. \quad (5) $$

The transformation of a hit coordinate from the local sensor frame, $\vec{q}$, to the global tracker frame, $\vec{r}_g$, is given by:

$$ \vec{r}_g \approx \mathbf{R}^T (\vec{q} + \Delta \vec{q}) + \vec{r}_0 \quad (6) $$

where $\Delta \vec{q}$ is the total equivalent displacement correction in the local sensor frame including alignment parameters for all composite detector structures of the sensor, ladder, and layer, $\mathbf{R}^T$ is the nominal rotation matrix from the sensor into the global tracker frame, and $\vec{r}_0$ is the nominal position of the sensor origin point in the global tracker frame. The definitions of $\Delta \vec{q}$, $\mathbf{R}^T$, and $\vec{r}_0$ and the detailed calculation can be found in Appendix A.

## 3.2 Coordinate measurement residual and its derivatives with respect to the alignment parameters

The coordinate measurement (hit) residual $\vec{\epsilon}$ is defined as the spatial difference between the predicted position of the track $\vec{q}_p$ and the measured position of the detector hit $\vec{q}$ in the sensor plane (local sensor frame), as:

$$ \vec{\epsilon} = \vec{q}_p - \vec{q}. \quad (7) $$

The predicted position of the track in the sensor plane, $\vec{q}_p$, is only sensitive to the sensor displacement, $\Delta \vec{q}$, along the $w_s$-axis (Fig. 3a). Such displacement will introduce a change of the track intersection position $\Delta \vec{q}_p$ as:

$$ \Delta \vec{q}_p = \mathbf{P}_p \Delta \vec{q} \quad (8) $$

where

$$ \mathbf{P}_p = \begin{pmatrix} 0 & 0 & \frac{du_s^p}{dw_s^p} \\ 0 & 0 & \frac{dv_s^p}{dw_s^p} \\ 0 & 0 & 1 \end{pmatrix}. \quad (9) $$

The quantities $du_s^p/dw_s^p$ and $dv_s^p/dw_s^p$ are the track projected directions in the sensor $u_s w_s$-plane and $v_s w_s$-plane respectively. Hence, the total correction to the residual for the detector module displacements is:

$$ \Delta \vec{\epsilon} = \Delta \vec{q}_p - \Delta \vec{q} = \mathbf{P} \Delta \vec{q} \quad (10) $$

where

$$ \mathbf{P} = \mathbf{P}_p - \mathbf{E} = \begin{pmatrix} -1 & 0 & \frac{du_s^p}{dw_s^p} \\ 0 & -1 & \frac{dv_s^p}{dw_s^p} \\ 0 & 0 & 0 \end{pmatrix} \quad (11) $$

and $\mathbf{E}$ is the unit matrix.

From Eqs. (A.3) and (10), all the partial derivatives of the residual with respect to the alignment parameters can be calculated. Some examples are listed as follows:

$$ \frac{\partial \vec{\epsilon}}{\partial u_s} = \mathbf{P} \vec{\epsilon}_1 $$

$$ \frac{\partial \vec{\epsilon}}{\partial u_L} = \mathbf{P} \mathbf{R}_s \vec{\epsilon}_1 $$
$$
\begin{align}
\frac{\partial \vec{\epsilon}}{\partial u_P} &= \mathbf{PR}_s \mathbf{R}_L \vec{e}_1 \nonumber \\
\frac{\partial \vec{\epsilon}}{\partial \alpha_s} &= \mathbf{P} \frac{\partial \Delta \mathbf{R}_s}{\partial \alpha_s} \vec{q} \nonumber \\
\frac{\partial \vec{\epsilon}}{\partial \alpha_L} &= \mathbf{PR}_s \frac{\partial \Delta \mathbf{R}_L}{\partial \alpha_L} (\mathbf{R}_s^\top \vec{q} + \vec{r}_{0s}) = \mathbf{PR}_s \frac{\partial \Delta \mathbf{R}_L}{\partial \alpha_L} \hat{\mathbf{r}}_L \nonumber \\
\frac{\partial \vec{\epsilon}}{\partial \alpha_P} &= \mathbf{PR}_s \mathbf{R}_L \frac{\partial \Delta \mathbf{R}_P}{\partial \alpha_P} [\mathbf{R}_L^\top (\mathbf{R}_s^\top \vec{q} + \vec{r}_{0s}) + \vec{r}_{0L}] \nonumber \\
&= \mathbf{PR}_s \mathbf{R}_L \frac{\partial \Delta \mathbf{R}_P}{\partial \alpha_P} \hat{\mathbf{r}}_P \tag{12}
\end{align}
$$

where $\vec{e}_1=(1, 0, 0)^\top$ is the unit vector of the u-axis, and $\hat{\mathbf{r}}_L=(\hat{u}_L, \hat{v}_L, \hat{w}_L)^\top=\mathbf{R}_s^\top \vec{q} + \vec{r}_{0s}$ and $\hat{\mathbf{r}}_P=(\hat{u}_P, \hat{v}_P, \hat{w}_P)^\top=\mathbf{R}_L^\top (\mathbf{R}_s^\top \vec{q} + \vec{r}_{0s}) + \vec{r}_{0L}$ are the hit coordinates in the frames of the ladder and layer respectively without displacement. Substituting the rotation (Eq. (5)) derivatives, the partial derivatives of the residual with respect to the alignment parameters of the sensor ($\partial \vec{\epsilon}/\partial \vec{p}_s$), ladder ($\partial \vec{\epsilon}/\partial \vec{p}_L$), and layer ($\partial \vec{\epsilon}/\partial \vec{p}_P$) are obtained as:

$$
\begin{align}
\frac{\partial \vec{\epsilon}}{\partial \vec{p}_s} &= \left( \frac{\partial \vec{\epsilon}}{\partial u_s}, \frac{\partial \vec{\epsilon}}{\partial v_s}, \frac{\partial \vec{\epsilon}}{\partial w_s}, \frac{\partial \vec{\epsilon}}{\partial \alpha_s}, \frac{\partial \vec{\epsilon}}{\partial \beta_s}, \frac{\partial \vec{\epsilon}}{\partial \gamma_s} \right) = \mathbf{P} \frac{\partial \vec{q}}{\partial \vec{p}_s} \nonumber \\
&= \mathbf{P} \begin{pmatrix} 1 & 0 & 0 & 0 & -w_s & 0 \\ 0 & 1 & 0 & w_s & 0 & -u_s \\ 0 & 0 & 1 & -v_s & u_s & 0 \end{pmatrix} \tag{13}
\end{align}
$$

$$
\begin{align}
\frac{\partial \vec{\epsilon}}{\partial \vec{p}_L} &= \left( \frac{\partial \vec{\epsilon}}{\partial u_L}, \frac{\partial \vec{\epsilon}}{\partial v_L}, \frac{\partial \vec{\epsilon}}{\partial w_L}, \frac{\partial \vec{\epsilon}}{\partial \alpha_L}, \frac{\partial \vec{\epsilon}}{\partial \beta_L}, \frac{\partial \vec{\epsilon}}{\partial \gamma_L} \right) = \mathbf{P} \frac{\partial \vec{q}}{\partial \vec{p}_L} \nonumber \\
&= \mathbf{PR}_s \begin{pmatrix} 1 & 0 & 0 & 0 & -\hat{w}_L & \hat{v}_L \\ 0 & 1 & 0 & \hat{w}_L & 0 & -\hat{u}_L \\ 0 & 0 & 1 & -\hat{v}_L & \hat{u}_L & 0 \end{pmatrix} \tag{14}
\end{align}
$$

$$
\begin{align}
\frac{\partial \vec{\epsilon}}{\partial \vec{p}_P} &= \left( \frac{\partial \vec{\epsilon}}{\partial u_P}, \frac{\partial \vec{\epsilon}}{\partial v_P}, \frac{\partial \vec{\epsilon}}{\partial w_P}, \frac{\partial \vec{\epsilon}}{\partial \alpha_P}, \frac{\partial \vec{\epsilon}}{\partial \beta_P}, \frac{\partial \vec{\epsilon}}{\partial \gamma_P} \right) = \mathbf{P} \frac{\partial \vec{q}}{\partial \vec{p}_P} \nonumber \\
&= \mathbf{PR}_s \mathbf{R}_L \begin{pmatrix} 1 & 0 & 0 & 0 & -\hat{w}_P & \hat{v}_P \\ 0 & 1 & 0 & \hat{w}_P & 0 & -\hat{u}_P \\ 0 & 0 & 1 & -\hat{v}_P & \hat{u}_P & 0 \end{pmatrix}. \tag{15}
\end{align}
$$

The alignment parameters of the sensor, ladder, and layer are $\Delta \vec{p}_s = (\Delta u_s, \Delta v_s, \Delta w_s, \alpha_s, \beta_s, \gamma_s)^\top$, $\Delta \vec{p}_L = (\Delta u_L, \Delta v_L, \Delta w_L, \alpha_L, \beta_L, \gamma_L)^\top$, and $\Delta \vec{p}_P = (\Delta u_P, \Delta v_P, \Delta w_P, \alpha_P, \beta_P, \gamma_P)^\top$ correspondingly.

## 4 Constraints of the composite alignment parameters

For a composite detector which consists of several subcomponents, those modules on the same support structure are likely to have highly correlated displacements. Applying the alignment directly on a single level of the hierarchy such as the sensors ignores the mechanical correlations and distorts the detector structure. In the composite alignment, the alignment parameters in each level are defined relative to the next support structure as shown in Eqs. (1)–(3) and all the

<figure><img src="image_8.png" /><figcaption>Fig. 4 Schematics of a ladder and b a layer divided into fine uniform grids</figcaption></figure>

alignment parameters for all the detector modules (sensors, ladders, and layers) are aligned simultaneously. In this way, all correlations are considered and the alignment accuracy is optimized.

If all composite modules are aligned at the same time without constraints, there will be no unique solution. For example, all the sensors in a ladder can move in one direction and the ladder can move in the opposite direction, which results in no movement of any sensors. To avoid this, 6 degrees of freedom must be constrained for every group of subcomponents on the same support structure. The expressions of all the constraints are derived by our developed grid method described in the following Sects. 4.1–4.3.

In addition, the stretching and shear deformations of the detector as subsets of the linear coordinate transformation will need specific constraints, as they are not sensed by the track alignment procedure. In Sect. 4.4, we present our study to deal with this issue.

### 4.1 Constraints of sensors in a ladder

Each sensor in a ladder can move individually. To investigate the displacements of the sensors with respect to the ladder, a ladder is divided into fine uniform grids spanning over all its sensors, as illustrated in Fig. 4a. A lattice point $\vec{m}^i$ represents a movement in the $i$-th grid position induced by the displacement of the sensor. The movement of the ladder $\Delta \vec{q}$ as a result of the displacements of all its sensors is estimated
from all the lattices via $\chi^2$-minimization:

$$ \chi^2 = \sum_i |\vec{m}^i - \Delta\vec{q}|^2. \qquad (16) $$

The derivatives of the minimized $\chi^2$ with respect to the ladder movement parameters $\Delta\vec{p}_L$ are zero:

$$ \frac{\partial \chi^2}{\partial \vec{p}_L} = \sum_i 2 \left( \frac{\partial \vec{q}}{\partial \vec{p}_L} \right)_i^\mathrm{T} (\vec{m}^i - \Delta \vec{q}) = \vec{0}. \qquad (17) $$

The displacements of sensors in a ladder are required to result in zero overall ladder displacement as $\Delta\vec{q}(\Delta u_L^s, \Delta v_L^s, \Delta w_L^s, \alpha_L^s, \beta_L^s, \gamma_L^s) = \vec{0}$. Substituting $\Delta\vec{q} = \vec{0}$ and $\vec{m}^i = (\partial\vec{q}/\partial\vec{p}_s)_i \Delta\vec{p}_s^i$ (the first order approximation) into Eq. (17), 6 constraints on the alignment parameters of sensors in a ladder are obtained by summing up all the lattice points, as:

$$ \sum_i \left( \frac{\partial \vec{q}}{\partial \vec{p}_L} \right)_i^\mathrm{T} \left( \frac{\partial \vec{q}}{\partial \vec{p}_s} \right)_i \Delta \vec{p}_s^i = \vec{0} \qquad (18) $$

where

$$ \left(\frac{\partial \vec{q}}{\partial \vec{p}_L}\right)_i^\mathrm{T} = \left(\frac{\partial \vec{q}}{\partial u_L}, \frac{\partial \vec{q}}{\partial v_L}, \frac{\partial \vec{q}}{\partial w_L}, \frac{\partial \vec{q}}{\partial \alpha_L}, \frac{\partial \vec{q}}{\partial \beta_L}, \frac{\partial \vec{q}}{\partial \gamma_L}\right)_i^\mathrm{T} \\ = \begin{pmatrix} 1 & 0 & 0 & 0 & -\hat{w}_L^i & \hat{v}_L^i \\ 0 & 1 & 0 & \hat{w}_L^i & 0 & -\hat{u}_L^i \\ 0 & 0 & 1 & -\hat{v}_L^i & \hat{u}_L^i & 0 \end{pmatrix}^\mathrm{T} \mathbf{R}_s^i \qquad (19) $$

is transposed from Eq. (14),

$$ \left(\frac{\partial \vec{q}}{\partial \vec{p}_s}\right)_i = \begin{pmatrix} 1 & 0 & 0 & 0 & -w_s^i = 0 & v_s^i \\ 0 & 1 & 0 & w_s^i = 0 & 0 & -u_s^i \\ 0 & 0 & 1 & -v_s^i & u_s^i & 0 \end{pmatrix} \qquad (20) $$

is from Eq. (13), and

$$ \Delta \vec{p}_s^i = (\Delta u_s^i, \Delta v_s^i, \Delta w_s^i, \alpha_s^i, \beta_s^i, \gamma_s^i)^\mathrm{T}. \qquad (21) $$

## 4.2 Constraints of ladders in a layer

Similarly, to study the displacements of the ladders with respect to the layer, a layer is divided into fine uniform grids as illustrated in Fig. 4b. A lattice point $\vec{m}^i = (\partial\vec{q}/\partial\vec{p}_L)_i \Delta\vec{p}_L^i$ represents a movement in the $i$-th grid position induced by the displacement of the ladder. Using the same method, 6 constraints on the alignment parameters of ladders in a layer are derived as:

$$ \sum_i \left( \frac{\partial \vec{q}}{\partial \vec{p}_P} \right)_i^\mathrm{T} \left( \frac{\partial \vec{q}}{\partial \vec{p}_L} \right)_i \Delta \vec{p}_L^i = \vec{0} \qquad (22) $$

where

$$ \left(\frac{\partial \vec{q}}{\partial \vec{p}_P}\right)_i^\mathrm{T} = \left(\frac{\partial \vec{q}}{\partial u_P}, \frac{\partial \vec{q}}{\partial v_P}, \frac{\partial \vec{q}}{\partial w_P}, \frac{\partial \vec{q}}{\partial \alpha_P}, \frac{\partial \vec{q}}{\partial \beta_P}, \frac{\partial \vec{q}}{\partial \gamma_P}\right)_i^\mathrm{T} $$

$$ = \begin{pmatrix} 1 & 0 & 0 & 0 & -\hat{w}_P^i & \hat{v}_P^i \\ 0 & 1 & 0 & \hat{w}_P^i & 0 & -\hat{u}_P^i \\ 0 & 0 & 1 & -\hat{v}_P^i & \hat{u}_P^i & 0 \end{pmatrix}^\mathrm{T} \mathbf{R}_L^i \mathbf{R}_s^i \qquad (23) $$

is transposed from Eq. (15),

$$ \left(\frac{\partial \vec{q}}{\partial \vec{p}_L}\right)_i = \mathbf{R}_s^i \begin{pmatrix} 1 & 0 & 0 & 0 & -\hat{w}_L^i & \hat{v}_L^i \\ 0 & 1 & 0 & \hat{w}_L^i & 0 & -\hat{u}_L^i \\ 0 & 0 & 1 & -\hat{v}_L^i & \hat{u}_L^i & 0 \end{pmatrix} \qquad (24) $$

is from Eq. (14), and

$$ \Delta \vec{p}_L^i = (\Delta u_L^i, \Delta v_L^i, \Delta w_L^i, \alpha_L^i, \beta_L^i, \gamma_L^i)^\mathrm{T}. \qquad (25) $$

## 4.3 Constraints of layers in the tracker

The composite structure of layers in the tracker also has to be constrained to factor out the translations and rotations of the whole detector and to establish the basic position and orientation of AMS. Considering mechanical and thermal stability, only the layers from the inner tracker (L2–L8), whose planes are firmly held by the carbon fiber cylinder, are used in the constraints. All the inner tracker layers are divided into fine grids of equal size with each (i-th) lattice point representing the layer displacement at that position, see Fig. 4b. By requiring the overall inner tracker to have neither translations nor rotations as $\Delta\vec{p}_g = (\Delta x, \Delta y, \Delta z, \alpha, \beta, \gamma)^\mathrm{T} = \vec{0}$, the constraints on the alignment parameters of the inner tracker layers are obtained as:

$$ \sum_i \left( \frac{\partial \vec{q}}{\partial \vec{p}_g} \right)_i^\mathrm{T} \left( \frac{\partial \vec{q}}{\partial \vec{p}_P} \right)_i \Delta \vec{p}_P^i = \vec{0} \qquad (26) $$

where

$$ \left(\frac{\partial \vec{q}}{\partial \vec{p}_g}\right)_i^\mathrm{T} = \begin{pmatrix} 1 & 0 & 0 & 0 & -\hat{z}_i^i & \hat{y}_i^i \\ 0 & 1 & 0 & \hat{z}_i^i & 0 & -\hat{x}_i^i \\ 0 & 0 & 1 & -\hat{y}_i^i & \hat{x}_i^i & 0 \end{pmatrix}^\mathrm{T} \mathbf{R}_P^i \mathbf{R}_L^i \mathbf{R}_s^i \qquad (27) $$

$\hat{z}_g^i = (\hat{x}_i^i, \hat{y}_i^i, \hat{z}_i^i)^\mathrm{T}$ is the $i$-th lattice point position in the global tracker frame without displacement,

$$ \left(\frac{\partial \vec{q}}{\partial \vec{p}_P}\right)_i = \mathbf{R}_s^i \mathbf{R}_L^i \begin{pmatrix} 1 & 0 & 0 & 0 & -\hat{w}_P^i & \hat{v}_P^i \\ 0 & 1 & 0 & \hat{w}_P^i & 0 & -\hat{u}_P^i \\ 0 & 0 & 1 & -\hat{v}_P^i & \hat{u}_P^i & 0 \end{pmatrix} \qquad (28) $$

is from Eq. (15), and

$$ \Delta \vec{p}_P^i = (\Delta u_P^i, \Delta v_P^i, \Delta w_P^i, \alpha_P^i, \beta_P^i, \gamma_P^i)^\mathrm{T}. \qquad (29) $$

The grid density for calculation of Eqs. (18), (22), or Eq. (26) is sufficiently large so that its contribution to the uncertainty of each constraint is negligible.

## 4.4 Constraints of stretching and shear deformations

The first alignment of the AMS tracker is based on the 400 GeV/c proton test beam, where the characteristics of
<figure><img src="image_9.png" /><figcaption>(c) Shear deformed inner tracker</figcaption></figure>

<figure><img src="image_10.png" /><figcaption>(b) Shearing</figcaption></figure>

<figure><img src="image_11.png" /><figcaption>**Fig. 5** Schematics of the inner tracker deformations: **a** stretching, **b** shearing, and **c** shearing section view</figcaption></figure>

tracks with given momenta in the magnetic field is equivalent to straight tracks. Any linear coordinate transformation will conserve the linearity of a straight track and hence not be sensed by the track alignment procedure. Conversely, without specific constraints, an unstable system of the alignment due to $\chi^2$ invariance could introduce this kind of transformation, manifested as an extra detector displacement or deformation. A general linear transformation from a vector $\vec{r} = (x, y, z)^T$ to a new vector $\vec{r}' = (x', y', z')^T$ can be expressed by the matrix equation:

$$ \vec{r}' = D\vec{r} + \vec{d} \qquad (30) $$

where $D$ is a $3 \times 3$ matrix, called a transformation matrix, and $\vec{d} = (d_1, d_2, d_3)^T$ is a vector representing a translation. Clearly, in a linear transformation, there are a total of 12 free parameters (3 in $\vec{d}$ and 9 in $D$), which can be categorized to describe the following decomposed transformations:

(i) 3 translations represented by 3 elements in $\vec{d}$

(ii) 3 rotations whose matrix forms are shown in Eq. (4)

(iii) 3 stretchings with each leading to an expansion or shrinking of the object along the corresponding axis. As an example, Fig. 5a shows the shrinking along the z-axis

(iv) 3 shearings with each deforming the object shape on the corresponding projection plane as the one in Fig. 5b shows the shearing on the yz-plane.

The outcome of (i) translations and (ii) rotations is a rigid-body displacement without changing the object shape or size. The 3 translations and 3 rotations of the inner tracker $\Delta\vec{p}_g = (\Delta x, \Delta y, \Delta z, \alpha, \beta, \gamma)^T$ have already been constrained to be zero as previously discussed in Sect. 4.3. Next, we will focus on (iii) stretchings and (iv) shearings.

### 4.4.1 Stretching

The matrix of stretching $D_t$ is diagonal:

$$ D_t = \begin{pmatrix} \lambda_1 & 0 & 0 \\ 0 & \lambda_2 & 0 \\ 0 & 0 & \lambda_3 \end{pmatrix} \qquad (31) $$

where $\lambda_1, \lambda_2$, and $\lambda_3$ are the extension-contraction coefficients along the x-, y-, and z-axes, respectively.

Stretching deformations are connected to the detector structure. As shown in Fig. 3, the silicon sensors through the ladder structure are tiled in the xy-plane to form all layers. The stretching deformation in the xy-plane is constrained to some extent by the exactly known size of the sensors. During exposure to the proton test beam or to cosmic rays in space, the incoming particles always enter the detector in various directions and positions. The distance between the neighboring sensors or ladders is well determined by many tracks, which are crossing them and the sensors from other layers in front and behind. Therefore, during alignment, the extension-contraction coefficients $\lambda_1$ and $\lambda_2$ are naturally constrained by the intrinsic size of the sensors either themselves or the ones in front/behind and no external constraints are needed.

The extension-contraction coefficient along the z-axis, $\lambda_3$, has no any sensor structure restriction (Fig. 5a) and has to be defined. According to Eq. (31), the stretching length along the z-axis, $\Delta z$, is described as:

$$ \Delta z = (\lambda_3 - 1)z = kz \qquad (32) $$

where no stretching deformation is $k \equiv (\lambda_3 - 1) = 0$. We can use the same grid method as in the previous section to derive the corresponding constraint on the alignment parameters. As seen in Fig. 4b, the i-th lattice point of the inner tracker $m^i = \Delta z_i$ represents the z position shift induced by the displacement of the layer at that position. The stretching parameter $k$ is estimated from all the lattices via $\chi^2$-minimization, as:

$$ \chi^2 = \sum_i (m^i - kz^i)^2 \qquad (33) $$

where the derivative of $\chi^2$ with respect to $k$ is zero:

$$ \frac{\partial \chi^2}{\partial k} = \sum_i 2z^i(m^i - kz^i) = 0. \qquad (34) $$

The constraint of $k = 0$ leads to:

$$ \sum_i z^i m^i = \sum_i z^i \Delta z^i = 0 \qquad (35) $$

$\Delta z^i$ in $\Delta\vec{p}_g^i = (\Delta x^i, \Delta y^i, \Delta z^i, \alpha^i, \beta, \gamma)^T$ can be replaced by the layer alignment parameters of $\Delta\vec{p}_p^i = (\Delta u_p^i, \Delta v_p^i,$
$\Delta w_p^i, \alpha_p^i, \beta_p^i, \gamma_p^i)^T$ as:

$$ \Delta \vec{p}_g^i = \left( \frac{\partial \vec{q}}{\partial \vec{p}_g} \right)_i^T \left( \frac{\partial \vec{q}}{\partial \vec{p}_P} \right)_i \Delta \vec{p}_P^i \quad (36) $$

where $(\partial \vec{q}/\partial \vec{p}_g)_i^T$ is from Eq. (27) and $(\partial \vec{q}/\partial \vec{p}_P)_i$ is from Eq. (28). For the AMS inner tracker structure, the constraint of Eq. (35) can be simplified as:

$$ \sum_{l=2}^{8} \mathbf{R}_{P}^{\mathrm{T}l}(3, 3) \Delta w_{P}^{l} z^{l} A^{l} = 0 \quad (37) $$

where $\mathbf{R}_P^{\mathrm{T}l}(3, 3)$ is the $(3, 3)$ entry of the $l$-th layer rotation matrix, $\Delta w_P^l$ is the $l$-th layer alignment parameter on the translation along the $w_P$-axis, and $z^l$ and $A^l$ are the $l$-th layer $z$ position and surface area respectively.

### 4.4.2 Shearing

Three individual matrices of pure shearing $\mathbf{D}_h^{\kappa 1}$, $\mathbf{D}_h^{\kappa 2}$, and $\mathbf{D}_h^{\kappa 3}$ are given by:

$$ \begin{aligned} \mathbf{D}_h^{\kappa 1} &= \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & \kappa_1/2 \\ 0 & \kappa_1/2 & 1 \end{pmatrix} & \mathbf{D}_h^{\kappa 2} &= \begin{pmatrix} 1 & 0 & \kappa_2/2 \\ 0 & 1 & 0 \\ \kappa_2/2 & 0 & 1 \end{pmatrix} \\ \mathbf{D}_h^{\kappa 3} &= \begin{pmatrix} 1 & \kappa_3/2 & 0 \\ \kappa_3/2 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} & & \end{aligned} \quad (38) $$

where $\kappa_1, \kappa_2$, and $\kappa_3$ are the shear strains on the $yz$, $xz$, and $xy$-planes, respectively. As seen, the pure shear matrices are symmetric in contrast with rotation matrices which are anti-symmetric as shown in Eq. (4).

Using small angle and shear strain approximation, the product of matrices of shearing $\mathbf{D}_h^{\kappa 1}$ and rotation $\Delta \mathbf{R}^{\alpha}$ is:

$$ \mathbf{D}_h^{\kappa 1} \Delta \mathbf{R}^{\alpha} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & \kappa_1/2 + \alpha \\ 0 & \kappa_1/2 - \alpha & 1 \end{pmatrix}. \quad (39) $$

When $\alpha = \kappa_1/2$, $\mathbf{D}_h^{\kappa 1} \Delta \mathbf{R}^{\alpha}$ becomes a simple shearing [14] along the $y$-axis on the $yz$-plane as illustrated in Fig. 5c. In the presence of both shearing and rotation in the $yz$-plane, the change of the object position along the $y$-axis, $\Delta y$, obtained from Eq. (39) is:

$$ \Delta y = (\kappa_1/2 + \alpha)z = k_1 z \quad (40) $$

where the requirement of the object to have neither rotation $\alpha = 0$ nor shear deformation $\kappa_1 = 0$, defines $k_1 = 0$. Repeating $\chi^2$ minimization to Eq. (40) together with the constraint $k_1 = 0$ leads to:

$$ \sum_i z^i \Delta y^i = 0 \quad (41) $$

where $\Delta y^i$ can be replaced by the layer alignment parameters as shown in Eq. (36). For the AMS inner tracker structure, the corresponding constraint is simplified to be:

$$ \sum_{l=2}^{8} \mathbf{R}_{P}^{\mathrm{T}l}(2, 2) \Delta v_{P}^{l} z^{l} A^{l} = 0 \quad (42) $$

where $\mathbf{R}_P^{\mathrm{T}l}(2, 2)$ is the $(2, 2)$ entry of the $l$-th layer rotation matrix, $\Delta v_P^l$ is the $l$-th layer alignment parameter on the translation along the $v_P$-axis, and $z^l$ and $A^l$ are the $l$-th layer $z$ position and surface area respectively. From Eq. (39), we can also study the change of the object position along the $z$-axis instead of the $y$-axis to derive another constraint on the $yz$-plane as:

$$ \Delta z = (\kappa_1/2 - \alpha)y = k_1'y. \quad (43) $$

Nevertheless, given a rotation constraint on $\alpha$, the constraints on $k_1'$ of Eq. (43) and $k_1$ of Eq. (40) are not independent as $k_1' = k_1 - 2\alpha$, which means the $k_1'$ constraint is just a linear combination of the $k_1$ constraint and the $\alpha$ constraint. To restrict both rotation and shearing on the $yz$-plane, a pair of constraints on any of $(\alpha, k_1)$, $(\alpha, k_1')$, or $(k_1, k_1')$ are sufficient and they are equivalent to each other.

For the $xz$-plane, which is similar to the $yz$-plane (Fig. 3), the requirement of the object to have neither rotation $\beta = 0$ nor shearing $\kappa_2 = 0$, leads to:

$$ \sum_i z^i \Delta x^i = 0 \quad (44) $$

where $\Delta x^i$ can be replaced by the layer alignment parameters as shown in Eq. (36). For the AMS inner tracker structure, the corresponding constraint can be simplified as:

$$ \sum_{l=2}^{8} \mathbf{R}_{P}^{\mathrm{T}l}(1, 1) \Delta u_{P}^{l} z^{l} A^{l} = 0 \quad (45) $$

where $\mathbf{R}_P^{\mathrm{T}l}(1, 1)$ is the $(1, 1)$ entry of the $l$-th layer rotation matrix and $\Delta u_P^l$ is the $l$-th layer alignment parameter on the translation along the $u_P$-axis.

The detector structure of the $xy$-plane, where the sensors are tiled, is completely different from the $yz$- and $xz$-planes. The essence of shear deformation is a symmetric strain tensor that results in a change in angle. So, the shearing on the $xy$-plane to a sensor will shear the sensor surface and break the orthogonal system of the strips on the opposite sides, which is mechanically not allowed. In this sense, the pure shearing on a $xy$-plane or a layer, which leads to a homogeneous deformation of all detector microscopic components, is practically non-existent. Another kind of pseudo-shearing of a layer with only shifting the positions of its ladders along the $x$-axis ($u_P$-axis in Fig. 4b) without deforming the ladders' shape, is also constrained by the intrinsic structure of
the sensors in the track alignment procedure, where the relative position between neighboring ladders in a layer is well defined by many tracks crossing them and the sensors from other layers in front and behind. Accordingly, similar to $\lambda_1$ and $\lambda_2$ in the stretching deformation, the shearing strain $\kappa_3$ also does not need external constraint.

In this section, we have studied the 12 degrees of freedom in the linear transformation with each of them corresponding to a kind of detector displacement or deformation. They were all constrained:

(a) 3 translations and 3 rotations by Eq. (26),

(b) 2 stretchings and 1 shearing by the intrinsic size and shape of the sensors during track alignment,

(c) 1 stretching by Eq. (35) or Eq. (37),

(d) 2 shearings, one by Eq. (41) or Eq. (42) and the other by Eq. (44) or Eq. (45).

## 5 Global track alignment

The global alignment method was first introduced in Ref. [15]. It is widely used in HEP and other fields [16–18]. In addition to this method, there are also other alignment methods, such as the one presented in Ref. [19].

In magnetic field, each track trajectory is characterized by a number of parameters (5 for a helix without multiple-scattering) which has to be determined from the track fitting procedure. Besides the position measurements, multiple scattering due to Coulomb interaction of the particle with the detector materials also impacts the accurate determination of the track. Taking into account the scattering angles being extra measurement quantities, for a given track $i$, the track parameters $\Delta \vec{q}_i$ are determined via $\chi^2$ minimization [20]:

$$ \chi_i^2 = \sum_{j=1}^{n_{\text{meas}}} \vec{\epsilon}_j(\vec{q}_i)^{\text{T}} \mathbf{V}_j^{-1} \vec{\epsilon}_j(\vec{q}_i) + \sum_{j=2}^{n_{\text{scat}}-1} \vec{\beta}_j(\vec{q}_i)^{\text{T}} \mathbf{W}_j^{-1} \vec{\beta}_j(\vec{q}_i) \quad (46) $$

where $\vec{\epsilon}_j$ is the $j$-th hit residual with the position measurement covariance matrix $\mathbf{V}_j$, and $\vec{\beta}_j$ is the $j$-th scattering angle with the covariance matrix $\mathbf{W}_j$ [21,22].

In the AMS global alignment, the global detector alignment parameters, $\Delta \vec{p}$, and the local track parameters, $\Delta \vec{q}$, of all tracks are determined simultaneously through a vast $\chi^2$ minimization, taking account of both residual measurements and multiple-scattering effects:

$$ \chi^2(\vec{q}, \vec{p}) = \sum_{i=1}^{N_{\text{track}}} \left[ \sum_{j=1}^{n_{\text{meas}}} \vec{\epsilon}_{ij}(\vec{q}_i, \vec{p})^{\text{T}} \mathbf{V}_{ij}^{-1} \vec{\epsilon}_{ij}(\vec{q}_i, \vec{p}) \right] $$

$$ + \sum_{j=2}^{n_{\text{scat}}-1} \vec{\beta}_{ij}(\vec{q}_i)^{\text{T}} \mathbf{W}_{ij}^{-1} \vec{\beta}_{ij}(\vec{q}_i) \right]. \quad (47) $$

Setting the partial derivatives of the $\chi^2$ of Eq. (47) with respect to each global parameter and each local track parameter equal to zero leads to the matrix equation:

$$ \begin{pmatrix} \sum_i \mathbf{C}^i \mathbf{G}^1 \dots \mathbf{G}^j \dots \mathbf{G}^N \\ (\mathbf{G}^1)^{\text{T}} \Gamma^1 \dots \mathbf{0} \dots \mathbf{0} \\ \vdots \\ (\mathbf{G}^j)^{\text{T}} \mathbf{0} \dots \Gamma^j \dots \mathbf{0} \\ \vdots \\ (\mathbf{G}^N)^{\text{T}} \mathbf{0} \dots \mathbf{0} \dots \Gamma^N \end{pmatrix} \begin{pmatrix} \Delta \vec{p} \\ \Delta \vec{q}_1 \\ \vdots \\ \Delta \vec{q}_j \\ \vdots \\ \Delta \vec{q}_N \end{pmatrix} = \begin{pmatrix} \sum_i \vec{d}^i \\ \vec{b}^1 \\ \vdots \\ \vec{b}^j \\ \vdots \\ \vec{b}^N \end{pmatrix} \quad (48) $$

see Appendix B for the definitions of matrices $\mathbf{C}$, $\mathbf{G}$, $\Gamma$ and vectors $\vec{d}$, $\vec{b}$ as well as the detailed calculation. The solution requires the inversion of the matrix of dimension $(n_g + N \cdot n_l)^2$, where $n_g$ is the number of global alignment parameters (up to ~ 15,000 for the AMS tracker), $N$ is the number of tracks used for the alignment (e.g. ~ 10⁹ tracks for the alignment with cosmic rays collected in flight), and $n_l$ is the number of local parameters per track (e.g. up to 27 for the General Broken Lines algorithm [20] with 13 equivalent thin scatterers representing the AMS materials). The dimension of the inversion matrix for solving the global alignment parameters can be reduced to $n_g^2$ by partitioning [23]. The constraints discussed in Sect. 4 are added into the matrix via Lagrange multipliers. The matrix inversion is handled by the Pede program [24]. A presigma, which can be interpreted as an initial detector mounting precision, can be assigned to the diagonal matrix element of each alignment parameter to optimize the matrix solution in the program.

In principle, the matrix inversion for solving the global alignment parameters only needs to be performed once and no iterations are required. However due to potential inaccuracies in the solution of the large linear system and due to a required outlier (large residual events) treatment, a few internal iterations for the matrix inversion may be necessary. For the “Inversion” solution method in the Pede, 3 internal iterations are more than enough. The presigmas are always defined with respect to the previous iteration, hence alignment corrections significantly larger than the presigmas can still occur after iterations. In this sense, the presigmas are considered not to bias the result if enough iterations are performed but will impact the choice of the preferred solution among all possible candidates with similar $\chi^2$, which will be discussed in more detail in the next section.

Recently, the version of the Pede written in Fortran has been implemented to be compatible with multi-threading [25]. But it is still deficient in dealing with massive local parameters of billions of tracks ($N \cdot n_l \sim 10^9 \times 20$) and a sizable number of global parameters ($n_g \sim 15,000$). This version of
Pede is extended by the AMS collaboration to become fully parallelized using the OpenMP platform [26], which allows much faster I/O and computational processing. In particular, the most restricted I/O part is improved by replacement with the parallelized ROOT [27] I/I. Using CERN 64-CPU machines and the EOS storage system [28], it takes ~30h to process the matrix inversion for 1 billion tracks with 3 internal iterations.

## 6 Alignment based on the 400 GeV/c proton test beam

Each module of the AMS tracker has its own initial mechanical mounting precision varying from a few microns to thousands of microns: the assembly accuracy for a sensor in the ladder is ~6 µm, the mounting accuracy for a ladder on the layer is ~70 µm, the installation accuracy for an inner tracker layer is ~40 µm along x and y and ~200 µm along z while for an external layer it is ~1000 µm for x, y, and z. A summary of the initial mounting precision can be found in Table 1a. The test-beam track alignment aims to reduce the module misalignment from all these sources down to a micron level for the rigidity measurement.

### 6.1 Setup of the test beam

During the beam test, AMS was installed on a rotation stand which allows the detector to be exposed to particles from different positions and directions. To minimize the potential deformation of the tracker planes as well as the contraction of the support structures due to gravity, the nominal attitude of the AMS illustrated in Fig. 6 was pointing to be the z-axis against the beam direction, the x-axis to the nadir (down), and the y-axis parallel to the Earth (horizontal), hence the positions of the tracker modules along the y-axis, i.e. the particle bending direction, was the least deformed.

The track alignment is performed based on the primary 400 GeV/c proton beam, where the positions and orientations of the detector were adjusted 886 times to collect events in the full acceptance of the tracker as illustrated in Fig. 6. The beam spot size, defined as the spot radius to include 68% of events at each position, was rather narrow at ~3.5 mm. With ~10⁴ events per position, the total collected number of events for the alignment was ~10⁷.

Besides the normal data collection, AMS also collected a special dataset of the 400 GeV/c proton beam, in which the whole detector was rotated around the y-axis by 180° to examine the mechanical stability of the tracker, as illustrated in Fig. 7. There were 60 assigned beam positions for this configuration and the total number of the collected events was ~10⁶. This data is only used for the alignment verification purpose instead of being directly used in the test-beam alignment.

<table><caption>**Table 1** a The initial mechanical mounting precision of the tracker modules and b the presigmas of the alignment parameters used in the test-beam alignment. The presigmas labeled “-” indicate the parameters that cannot be precisely determined by the alignment due to the limited beam directions per sensor and therefore are fixed to 0. The presigmas labeled “†” are significantly increased to approach the preferred solution</caption><thead><tr><th rowspan="2">Precision</th><th colspan="3">Translation (µm)</th><th colspan="3">Rotation (mrad)</th></tr><tr><th>Δu</th><th>Δv</th><th>Δw</th><th>α</th><th>β</th><th>γ</th></tr></thead><tbody><tr><td colspan="7">(a) Initial mechanical mounting precision</td></tr><tr><td>L1/L9</td><td>1000</td><td>1000</td><td>1500</td><td>0.1</td><td>0.1</td><td>0.5</td></tr><tr><td>L2-L8</td><td>50</td><td>30</td><td>200</td><td>0.06</td><td>0.06</td><td>0.05</td></tr><tr><td>Ladder</td><td>70</td><td>100</td><td>40</td><td>0.3</td><td>0.3</td><td>0.2</td></tr><tr><td>Sensor</td><td>6</td><td>6</td><td>6</td><td>0.1</td><td>0.1</td><td>0.1</td></tr><tr><td colspan="7">(b) Presigmas used in the test-beam alignment</td></tr><tr><td>L1/L9</td><td>5000†</td><td>5000†</td><td>5000†</td><td>10†</td><td>10†</td><td>10†</td></tr><tr><td>L2-L8</td><td>200†</td><td>200†</td><td>200</td><td>0.25†</td><td>0.25†</td><td>0.2†</td></tr><tr><td>Ladder</td><td>100</td><td>100</td><td>50</td><td>0.3</td><td>0.3</td><td>0.2</td></tr><tr><td>Sensor</td><td>6</td><td>6</td><td>-</td><td>-</td><td>-</td><td>0.1</td></tr></tbody></table>

<figure><img src="image_12.png" /><figcaption>**Fig. 6** Schematics of the nominal attitude of the AMS in the beam test: the z-axis of the AMS against the beam direction, the x-axis to the nadir, and the y-axis (pointing out of the page) parallel to the Earth. The densely packed lines represent the 886 directions of the primary 400 GeV/c proton test beam passing through AMS</figcaption></figure>

### 6.2 Alignment procedure

In the test-beam alignment, all the composite tracker modules are aligned simultaneously using the global composite alignment approach as discussed in Sects. 3, 4, and 5. The General Broken Lines (GBL) algorithm with fixed curvature ($1/R = 1/400 \text{ GV}^{-1}$) track fitting is imposed to derive the residuals $\vec{e}_{ij}(\vec{q}_i^0, \vec{p}^0)$, the partial derivatives with respect to the local track parameters of the residuals $\partial \vec{e}_{ij}/\partial \vec{q}_i$ and the scattering angles $\partial \vec{\beta}_{ij}/\partial \vec{q}_i$, for Eq. (48), see also Eqs. (B.8), (B.10), (B.13) and (B.14). The 400 GeV/c proton Monte Carlo sample produced by Geant4 [29] is used for the alignment optimization.
<figure><img src="image_13.png" /><figcaption>**Fig. 7** Schematics of the detector deformations due to gravity for a nominal AMS and for b 180° rotated AMS in the beam test</figcaption></figure>

### 6.2.1 Presigmas in the alignment

The external layers, L1 and L9, have much worse mounting accuracy than the inner tracker (L2–L8). At the small scale, the assembly accuracy of the sensors-in-ladders or ladders-on-layers for L1 and L9 are similar to that of the inner tracker. It means that the positions of the external layers in the sensor or ladder level can be treated equally as the inner tracker in the alignment and help to reduce the overall bias. But this can only be achieved by the composite alignment, where all the modules are defined relative to the next support structures and all the modules from the inner tracker and external layers are aligned together taking into account all the correlations. In the composite alignment, the presigmas of the layer alignment parameters for L1 and L9 are set to be more than 20 times larger than the inner tracker (see Table 1b), while the presigmas of the sensor/ladder alignment parameters are assigned to be the same for every layer, so that the preferred alignment solution tends to correct the displacements of the whole external layers with reference to the position of the inner tracker.

On the other hand, under similar conditions or $\chi^2$, the solutions with displacements of the larger modules are preferred to the solutions with displacements of the smaller components. Presigmas of the alignment parameters can be properly adjusted to favor displacements of the larger modules. As seen in Table 1, the presigmas of the layer alignment parameters labeled “†” are significantly increased compared with the layer mounting precision to strengthen the preference of the corrections on the layers rather than on the ladders.

### 6.2.2 Fixed parameters in the alignment

With a total of 886 beam spots distributed over ~ 250 sensors per layer, the average number of beam spots per sensor is ~ 3. Due to the limited beam positions and directions, ~ 75% of the sensors with the crucial sensor parameters of $\Delta u_s$, $\Delta v_s$, and $\gamma_s$ can be aligned: for a sensor with a small number of passing events, < 2000, $\Delta u_s$, $\Delta v_s$, and $\gamma_s$ are fixed to 0; for a sensor with the passing beam spots close together, such as $\sigma(u_s) < 10$ mm and $\sigma(v_s) < 12$ mm, $\gamma_s$ cannot be precisely

<table><caption>**Table 2** The number of ladders (a) and sensors (b) with fixed parameters in the test-beam alignment. Note that the AMS tracker has 192 ladders and 2284 sensors</caption><thead><tr><th>Δu<sub>L</sub></th><th>Δv<sub>L</sub></th><th>Δw<sub>L</sub></th><th>α<sub>L</sub></th><th>β<sub>L</sub></th><th>γ<sub>L</sub></th></tr></thead><tbody><tr><td colspan="6">(a) Number of fixed ladder alignment parameters</td></tr><tr><td>2</td><td>1</td><td>1</td><td>39</td><td>2</td><td>1</td></tr><tr><td>Δu<sub>s</sub></td><td>Δv<sub>s</sub></td><td>Δw<sub>s</sub></td><td>α<sub>s</sub></td><td>β<sub>s</sub></td><td>γ<sub>s</sub></td></tr><tr><td colspan="6">(b) Number of fixed sensor alignment parameters</td></tr><tr><td>734</td><td>572</td><td>2284</td><td>2284</td><td>2284</td><td>1276</td></tr></tbody></table>

determined and is fixed to 0, where $\sigma$ represents the standard deviation.

One ladder in L3 is completely inactive and its alignment parameters are fixed as $\Delta u_L = \Delta v_L = \Delta w_L = \alpha_L = \beta_L = \gamma_L = 0$. Another ladder in L4 is inactive on the n-side and its $\Delta u_L$ is fixed to 0. For a ladder with the passing beams at small inclination angles and small position spanning along the $v_L$-axis, both $\sigma(du_L^p/dw_L^p \cdot v_L) < 2.2$ mm and $\sigma(du_L^p/dw_L^p \cdot v_L) < 2.2$ mm, $\alpha_L$ cannot be precisely obtained from the alignment and is fixed to 0, where $du_L^p/dw_L^p$ and $du_L^p/dw_L^p$ are the beam projected directions in the ladder $u_L w_L$-plane and $v_L w_L$-plane respectively (see Fig. 3b). Similarly, for a ladder with the passing beams of small inclination angles and small position spanning along the $u_L$-axis, both $\sigma(du_L^p/dw_L^p \cdot u_L) < 7$ mm and $\sigma(du_L^p/dw_L^p \cdot u_L) < 7$ mm, $\beta_L$ is fixed to 0.

Table 2 summarizes the number of ladders and sensors with fixed alignment parameters. As seen, 39 ladders – out of a total 192 ladders – have the alignment parameter $\alpha_L$ fixed. From Eq. (14), we can derive that the $\alpha_L$ equivalent alignment corrections on the ladder hit position are $du_L^p/dw_L^p \cdot v_L \cdot \alpha_L$ and $du_L^p/dw_L^p \cdot v_L \cdot \alpha_L$ for the $u_L$- and $v_L$-projections respectively. Assuming the particle incident angle $du_L^p/dw_L^p$ (or $du_L^p/dw_L^p$) = 0.3, for the hit with the largest $v_L$ = 35 mm at the ladder edge, a typical mounting precision of $\sigma(\alpha_L) = 0.3$ mrad (see Table 1a) or a fixed $\alpha_L = 0$ will introduce a misalignment of 3.15 µm, which is a small inaccuracy. This is also the case for sensor alignment parameters of $\Delta w_s$, $\alpha_s$, and $\beta_s$ fixing them in the alignment
<figure><img src="image_14.png" /><figcaption>**Fig. 8** The distributions of the alignment parameters of layers (top row), ladders (middle row), and sensors (bottom row) obtained from the test-beam alignment. The fixed alignment parameters are not included</figcaption></figure>

will not result in a sizable misalignment. Owing to a good sensor assembly precision of $\sigma(\gamma_s) = 0.1$ mrad, a fixed $\gamma_s = 0$ for part of sensors will also give a small misalignment of up to $|v_s\gamma_s| = 3.5$ µm ($v_L = 35$ mm) and $|u_s\gamma_s| = 1.9$ µm ($u_L = 19$ mm) for the $u_L$- and $v_L$-projections respectively.

## 6.3 Alignment results

The alignment parameters obtained from the test-beam alignment are shown in Fig. 8. As seen, the external layers, L1 and L9, have much larger layer-biases both in translations and rotations compared with the layers of the inner tracker. Other than that, no significant large outliers on the alignment parameters occur. Figure 9 shows the residual distributions of the 9 layers in the sensor $v_s$ direction before and after the test-beam alignment. A large improvement of the residual distributions is obvious. Figure 10 shows the residual biases of all sensors before and after the alignment. As seen, there is no bias in each sensor after the alignment. Even taking into account the limited beam positions and directions, the overall misalignment in the $v_s$ direction for the rigidity measurement is 1–2 µm.

## 6.4 Mechanical stability study with the 180° runs

The test-beam alignment is done based on the nominal data where the AMS z-axis is against the beam direction and the x-axis is to the nadir as illustrated in Fig. 7a. The obtained alignment corrections are then applied to the data collected

with the whole detector rotated around the y-axis by 180° where now the z-axis is along the beam direction and the x-axis is pointing to the zenith as illustrated in Fig. 7b. After rotation, as seen in Fig. 11a, there is a significant bias of each sensor in the sensor $u_s$ direction (along or opposite to the x-axis), while the residual bias of each sensor in the sensor $v_s$ direction (along or opposite to the y-axis) is tiny as shown in Fig. 11b. This clearly indicates the displacement induced by gravity whose direction is parallel to the x-axis.

Compared with the inner tracker support structure, a carbon fiber cylinder, the support structures of the external layers, the TRD M-Structure and the Unique Support Structure, are made from aluminum, which is much less stiff. The resulting detector deformations due to gravity before and after the detector rotation are illustrated in Fig. 7a, b respectively. As seen, when the direction of gravity was switched from along to opposite to the AMS x-axis, the most prominent changes of the external layer positions in the tracker frame are expected to be the layer translation along the x-axis (e.g. from $\Delta u_P^{L1} > 0$ to $\Delta u_P^{L1} < 0$ for L1) and the layer rotation around the y-axis (e.g. from $\beta_P^{L9} < 0$ to $\beta_P^{L9} > 0$ for L9).

To justify this reasoning, an additional alignment to correct the displacements of the external layers is performed to the 180° runs, where all the alignment parameters on the sensors and ladders as well as the layers of the inner tracker are fixed to be the same as the nominal runs except the layer alignment parameters of L1 and L9 which are left free. The obtained relative changes (180° with respect to the nominal) of the layer alignment parameters of L1 and L9 are shown
<figure><img src="image_15.png" /><figcaption>**Fig. 9** The residual distributions of the individual layers in the sensor $v_s$ direction before (dashed histograms) and after (solid histograms) the test-beam alignment</figcaption></figure>

<figure><img src="image_16.png" /><figcaption>**Fig. 10** The residual biases of the individual sensors in a the $u_s$ direction and b the $v_s$ direction before (open squares) and after (full circles) the test-beam alignment. A circle or square represents the residual bias of each sensor. The circles or squares of a common group are the sensors from the same half of a tracker layer. The sensor ID is defined as $(\text{sensor} + 20 \times \text{ladder} + 400 \times \text{layer}) \times \text{half}$, where *sensor* is the sensor number [1...15], *ladder* is the ladder number [1...13], *layer* is the layer number [0...8], and *half* is -1 for the ladders located on the negative half ($u_{0L} < 0$) and +1 on the positive half ($u_{0L} > 0$) of a layer</figcaption></figure>

<figure><img src="image_17.png" /><figcaption>**Fig. 11** The residual biases in a the $u_s$ and b the $v_s$ directions of the individual sensors of the 180° test-beam runs using the alignment corrections from the nominal runs but before (open squares) and after (full circles) the additional alignment on the external layers</figcaption></figure>

in Table 3. As seen, when reversing the gravity load in the x-direction, the largest translation displacements are along the x-axis, -200 µm and -580 µm for L1 and L9 respectively, and the largest rotation displacements are around the y-axis, 0.297 mrad and 1.253 mrad for L1 and L9 respectively. The translation displacement along the y-axis, which is the most critical direction, namely the particle bending direction, is the smallest, -1 µm and -2 µm for L1 and L9

respectively. Most strikingly, with the alignment only on the external layers, all the major structures of the sensor residual biases disappear and the remaining deviations are within 2 µm as shown in Fig. 7. This demonstrates that the major outcome of the tracker deformation due to gravity in the beam test is the rigid-body displacement of the external layers.

With the 180° runs, the alignment has been verified, the inner tracker support structure has been proved to be rigid, and significant movements induced by gravity of the external layers as rigid bodies have been observed.
<table><caption>**Table 3** The displacements of L1 and L9 introduced by 180° detector rotation obtained from the test-beam alignment</caption><thead><tr><th rowspan="2">Displacement</th><th colspan="3">Translation (μm)</th><th colspan="3">Rotation (mrad)</th></tr><tr><th>Δu<sub>P</sub></th><th>Δv<sub>P</sub></th><th>Δw<sub>P</sub></th><th>α<sub>P</sub></th><th>β<sub>P</sub></th><th>γ<sub>P</sub></th></tr></thead><tbody><tr><td>L1</td><td>-200</td><td>-1</td><td>-42</td><td>-0.016</td><td>0.297</td><td>0.002</td></tr><tr><td>L9</td><td>-580</td><td>-2</td><td>96</td><td>0.038</td><td>1.253</td><td>-0.007</td></tr></tbody></table>

## 7 Dynamic alignment of the external tracker layers in space

After AMS was launched into space, we found that the positions of ladders and sensors were permanently changed up to tens of microns compared to their positions on the ground. In addition, the continuous temperature variations on orbit, through the thermal deformation of the support structures, cause the periodic movements of the whole external layers at hundreds of microns per half-obit (~46 min). The first kind of displacement is corrected by the static alignment with billions of cosmic-ray events, which will be discussed in Sect. 8. The second kind of displacement is corrected by the dynamic alignment with instantaneously collected cosmic-ray events and will be reported in this section. Prior to the static alignment, the dynamic alignment should be applied to remove large periodic movements of the external layers and decrease the inaccuracy of the external tracker layers to the same level as that of the inner tracker.

### 7.1 Thermal environment and data collection on orbit

The ISS orbits the Earth every 93 min with an orbital inclination of 52°. The thermal environment of AMS on the ISS has both short-term and long-term variations. The regular short-term variation is the periodic temperature cycle that follows orbital day and night transition. The long-term variation is mainly due to the change of the angle between the ISS orbital plane and the direction to the Sun, or solar beta angle, which has a precession period of 60 days and can reach up to ±75°. Other thermal variables such as the positions of the ISS radiators and solar arrays, ISS attitude changes for visiting vehicles and reboosts, and shading of AMS by adjacent payloads can also have a big influence on the temperature changes at different time scales, from minutes to months.

The sensor positions with respect to the carbon fiber reinforced ladders should not change over time, as carbon fiber has near zero coefficient of thermal expansion. Likewise, the positions of ladders on the carbon fiber skinned planes is stable. The positions of the inner tracker layers should also not change as their planes are firmly embedded in the carbon fiber cylinder. However, the variation of the temperature and gradients across the aluminum mechanical structures (mainly the TRD M-Structure and the Unique Support Structure)

lead to continuous periodic movements of the external layers, which are corrected by the dynamic alignment using the concurrently collected cosmic-ray events, mainly protons and helium.

In flight, the AMS event trigger rates vary from 200 Hz near the equator to ~2000 Hz near the Earth's magnetic poles. The average event acquisition rate is ~700 Hz. The events from each quarter of the ISS orbit (from near the pole to the equator or vice versa), about 23 min, are arranged in sequence as one run. Detector hardware calibrations are done between runs and last up to two minutes.

### 7.2 Alignment procedure

In the dynamic alignment, only the rigid-body movements of the external layers are considered. In this case, there are a total of 12 alignment parameters, 6 for L1 of $(\Delta u_P^{L1}, \Delta v_P^{L1}, \Delta w_P^{L1}, \alpha_P^{L1}, \beta_P^{L1}, \gamma_P^{L1})^T$ and 6 for L9 of $(\Delta u_P^{L9}, \Delta v_P^{L9}, \Delta w_P^{L9}, \alpha_P^{L9}, \beta_P^{L9}, \gamma_P^{L9})^T$. For a short time interval with a finite number of cosmic-ray events which are mostly at low rigidities [7,30], the main constraint on the alignment precision of an external layer comes from the multiple scattering due to the materials of between L1 and L2, ~0.3 $X_0$, or between L8 and L9, ~0.2 $X_0$ (see Fig. 1). As an example, for a particle with 10 GV rigidity, the average scattering angle between L1 and L2 is ~0.7 mrad, which corresponds to ~700 µm smearing on the L1 position using the 1 m extrapolation from the inner tracker. Since multiple scattering and the resulting position smearing decreases linearly with increasing rigidity [21], the efficient usage of cosmic-ray events and particularly those at high rigidities is critical for the precision of the dynamic alignment.

#### 7.2.1 Dynamic alignment in a short-time window

The developed global alignment approach as discussed in Sects. 3 and 5 is applied for the dynamic alignment. The GBL algorithm with free curvature (inverse rigidity, $1/R$) track fitting is used to derive the residuals $\vec{\epsilon}_{ij}(\vec{q}_i^0, \vec{p}^0)$, the partial derivatives with respect to the local track parameters of the residuals $\partial\vec{\epsilon}_{ij}/\partial\vec{q}_i$ and the scattering angles $\partial\vec{\beta}_{ij}/\partial\vec{q}_i$, for Eq. (48), see also Eqs. (B.8), (B.10), (B.13) and (B.14). The event sample used for the dynamic alignment is required to have a reconstructed track and hits on the external layers. The crucial ingredient for the dynamic alignment accuracy, the covariance matrix of the scattering angle, $W_{ij} \propto 1/R_i^2$ in Eq. (47), can be calculated iteratively event by event using the measured rigidity with the following alignment procedures:

(i) Initialize $W_{ij}(R_i)$ event by event using the rigidity measured from the inner tracker.

(ii) Determine the alignment parameters of L1 and L9 by minimization of Eq. (47).
<figure><img src="image_18.png" /><figcaption>Fig. 12 Misalignments of L1 (a, b) and L9 (c, d) before (dashed histograms) and after (solid histograms) the dynamic alignment derived from the MC simulation. For every 100,000 simulated events passing through either L1 or L9, the positions of the external layers in the MC are randomly displaced, which is then followed by a dynamic alignment. One entry of misalignment in each histogram corresponds to one set of displacements of the external layers. With the alignment, the misalignments projected to x (a, c) and y (b, d) coordinates are reduced from more than a thousand microns down to 2.8 µm for L1 and 3.8 µm for L9</figcaption></figure>

(iii) Recalculate $W_{ij}(R_i)$ event by event by replacing the rigidity with the new one measured from both the inner tracker and external layers including the latest alignment corrections from step (ii).

(iv) Repeat steps (ii) (iii) until all the alignment parameters converge.

An isotropic cosmic-ray Monte Carlo (MC) sample produced by Geant4 [7,29,30] is used for validation of the alignment. For every 100,000 events, the positions of the external layers in the MC are randomly displaced, which is then followed by a dynamic alignment. Figure 12 shows the misalignments of L1 and L9 before and after the alignment derived directly from the MC. As seen, with the alignment, the misalignments are reduced from more than a thousand microns down to a few microns.

For the flight data, this alignment is performed in time-slices of $\Delta t \approx 90$ s. The set of alignment parameters obtained in each time-slice have significant statistical errors, which are further reduced by combining the alignment results from the nearby time-slices via a custom developed smoothing procedure described in the next section.

### 7.2.2 Alignment smoothing for long time period

After the short-time dynamic alignment, for a given time period of $N\Delta t$, $N$ sets of alignment parameters are smoothed as functions of time to describe the differential movements of the external layers. To fully exploit the alignment informa-

<figure><img src="image_19.png" /><figcaption>Fig. 13 Illustration of the spline smoothing for describing the variation of the dynamic alignment parameter $\Delta u_p^L$ over time. The entire time block is divided into several smaller overlapping time segments, where the alignment data (points) in each segment are smoothed by a spline function (curve) as indicated. The distribution of knots of the spline is indicated by the vertical lines including those knots shared with the neighboring splines (dashed vertical lines)</figcaption></figure>

tion, the time period for each smoothing should be as long as possible, but that introduces too many fitting parameters to solve. Instead, in our approach, the entire 10 years is divided into small overlapping time segments of a few hours, where the alignment data in each time segment are smoothed by a spline function [31], as illustrated in Fig. 13:

1. Each spline function has up to 40 knots (indicated as vertical lines in Fig. 13) which are distributed over time with an equal number of data points per knot.

2. The neighboring segments overlap (share) 6 knots of the alignment data (Fig. 13 dashed vertical lines' region).

3. If there is a data gap (more than 1 h), the new segment will restart once the next alignment data appears.

To achieve the minimal alignment error, the assignment of the knots is critical: the more alignment-data points per knot, the smaller the statistical error but the larger the systematic error; while the fewer data points per knot, the smaller the systematic error but the larger the statistical error.

In the short-time dynamic alignment, the error of each alignment parameter for each time slice ($\Delta t$), $\sigma_t$, is estimated from error propagation, which has a small bias depending on (a) the track fitting model along with the assessment of errors on the multiple scattering and coordinate resolution and (b) the intrinsic correlation among the alignment parameters. A correction factor $k$, which scales the alignment parameter error to the true one as $k\sigma_t$, can be derived from the alignment data over a long time period ($N_0\Delta t$) by bootstrapping:

$$k = \sqrt{\frac{\chi_0^2}{n_0}} = \sqrt{\frac{\chi_0^2}{N_0 - m_0}} \quad (49)$$

where $\chi_0^2$, $m_0$, and $n_0 = N_0 - m_0$ are the fitting chi-square, number of knots, and degrees of freedom, for the spline fitting to $N_0$ data points with a sufficient number of knots to reach a negligible systematic error. In view of the observed rate of
<figure><img src="image_20.png" /><figcaption>**Fig. 14** The total errors of the dynamic alignment parameters as functions of number of data points per knot, calculated over 10 years from Eq. (50). The error bars in each plot represent the standard deviations of the alignment errors arising from the time dependence</figcaption></figure>

the external-layer movement, every 2 data points or 180 s per knot ($m_0 = N_0/2$) is enough to derive $k$.

For a spline fit to N data points with a given number of data points per knot, the total alignment error after smoothing is the sum in quadrature of the statistical and systematic errors:

$$ \sigma_{tot} = \sqrt{\sigma_{stat}^2 + \sigma_{sys}^2} = \sqrt{k^2 \sigma_{fit}^2 + \left(\frac{\chi^2}{n} - k^2\right) \sigma_t^2} \quad (50) $$

where $\sigma_{fit}$, $\chi^2$, and $n$ are the fitting error, chi-square, and degrees of freedom respectively, $\sigma_{stat} = k\sigma_{fit}$ is the statistical error which decreases as increasing data points per knot, and $\sigma_{sys} = \sigma_t\sqrt{\chi^2/n - k^2}$ is the systematic error which increases as increasing data points per knot.

The smoothing of the external layer movement is optimized by assigning the knots with the minimal total error of Eq. (50) for every alignment parameter.

## 7.3 Alignment results

The total errors of the individual alignment parameters as functions of number of data points per knot calculated over 10 years from Eq. (50) are shown in Fig. 14. Accordingly, the time intervals between adjacent knots for the spline smoothings with the minimal alignment errors are summarized in Table 4a. As seen, compared with rotations, translations need more dense knots to trace their variations, indicating that the movements of the external layers in terms of translations are more rapid than in terms of rotations.

Typical variations of the individual alignment parameters over a day together with the smoothings are shown in Fig. 15. The orbital period of ~93 min can be clearly seen. As shown in the figure, the movement of L1 (L9) in terms of translation is ~200 µm, ~100 µm, and ~200 µm (~100 µm, ~20 µm, and ~200 µm) per half orbit in the x-, y-, and z-directions (strictly the $u_{P-}$, $v_{P-}$, and $w_{P-}$-directions) respectively and of rotation is ~0.2 mrad, ~0.2 mrad, and ~0.03 mrad (~0.2 mrad, ~0.1 mrad, and ~0.05 mrad) per half orbit around the x-, y-, and z-axes (strictly the $u_{P-}$, $v_{P-}$,

<table><caption>**Table 4** (a) The time intervals between adjacent knots used for the spline smoothings of the individual alignment parameters that provide (b) the best dynamic alignment precision</caption><thead><tr><th>Parameter</th><th>Δu<sub>P</sub></th><th>Δv<sub>P</sub></th><th>Δw<sub>P</sub></th><th>α<sub>P</sub></th><th>β<sub>P</sub></th><th>γ<sub>P</sub></th></tr></thead><tbody><tr><td colspan="7">(a) The time intervals between adjacent knots (s)</td></tr><tr><td>L1</td><td>450</td><td>540</td><td>990</td><td>1800</td><td>1800</td><td>1800</td></tr><tr><td>L9</td><td>540</td><td>720</td><td>900</td><td>1800</td><td>1800</td><td>1800</td></tr><tr><th>Parameter</th><th colspan="3">Translation (μm)</th><th colspan="3">Rotation (mrad)</th></tr><tr><td></td><th>Δu<sub>P</sub></th><th>Δv<sub>P</sub></th><th>Δw<sub>P</sub></th><th>α<sub>P</sub></th><th>β<sub>P</sub></th><th>γ<sub>P</sub></th></tr><tr><td colspan="7">(b) External layer dynamic alignment precision</td></tr><tr><td>L1</td><td>7.4</td><td>6.8</td><td>25.6</td><td>0.098</td><td>0.078</td><td>0.015</td></tr><tr><td>L9</td><td>7.2</td><td>7.6</td><td>29.1</td><td>0.164</td><td>0.115</td><td>0.023</td></tr></tbody></table>

and $w_{P-}$-axes) respectively. In addition to the orbital movements, the external layers also display the long-term movements with a cycle of about 2 months – the period of the solar beta angle. Figures 16 and 17 show the variations of the individual alignment parameters of L1 and L9 respectively, over 10 years from May 20, 2011 to May 20, 2021, where each data point represents the alignment parameter averaged over a day. As seen, the long-term movements of L1 (L9) translations are up to ~1000 µm, ~200 µm, and ~300 µm (~300 µm, ~100 µm, and ~700 µm) per month in the x-, y-, and z-directions respectively and the rotations can reach ~0.2 mrad, ~0.6 mrad, and ~0.02 mrad (~0.4 mrad, ~0.5 mrad, and ~0.03 mrad) per month around the x-, y-, and z-axes respectively.

The final achieved alignment precision for all the alignment parameters derived from Fig. 14 is summarized in Table 4b. As seen, for example, with the dynamic alignment, the translational movement in the y-direction ($\Delta v_P$) is aligned to a precision of 6.8 µm for L1 and 7.6 µm for L9. To evaluate the total residual misalignments of the external layers in the particle bending direction which is connected to the rigidity resolution, the rigidity measured using the upper span of the tracker, namely from L1 to L8 ($R_{18}$), are com-
<figure><img src="image_21.png" /><figcaption>Fig. 15 The variations of the dynamic alignment parameters of L1 (left column) and L9 (right column) over 24 h on Dec. 17, 2015</figcaption></figure>

pared to the rigidity measured using the lower span, namely from L2 to L9 (R29), for a helium sample with the full-span rigidity (measured from L1 to L9) R19 > 570 GV. Figure 18 shows the Gaussian sigma of the 1/R18 − 1/R29 distribution derived from the flight data (full circle) and its fit to the prediction from the MC simulation (line). As seen, with the dynamic alignment, the total residual misalignments (alignment errors) on the rigidity measurement are estimated to be 7.1 µ m for L1 and 7.9 µ m for L9.

8 Static alignment of the tracker in space

Before launch, AMS has been aligned based on the primary 400 GeV/c proton test beam as discussed in Sect. 6. However, the strong accelerations and vibrations during launch, followed by the rapid outgassing of the support structure in vacuum permanently changed the positions of all the tracker modules. Therefore, the entire tracker has to be aligned again with cosmic-ray events to correct the resulting displacements. The most challenging part of this alignment is the unknown curvatures (1 /R ) of the incoming particles in the presence of the magnetic field. A track alignment approach similar to the test-beam alignment but with free curvature

track fitting (see Eq. (47)) is not enough for such an alignment as the curvatures of the tracks can be biased by any value without changing the alignment χ $^{2}$. The development of a new mathematical description is required for such an alignment.

8.1 Global track alignment with curvature constraints

For the alignment with a magnetic field and with particles whose rigidities are unknown, a new term, ρ 2 $_{i}$( ⃗ p ) /Z$_{i}$ , is introduced in the global alignment χ 2 to constrain the curvature change:

$$
\chi^2(\vec{q}, \vec{p}) = \sum_{i=1}^{N_{\text{track}}} \left[ \sum_{j=1}^{n_{\text{meas}}} \vec{\epsilon}_{ij}(\vec{q}_i, \vec{p})^{\text{T}} \mathbf{V}_{ij}^{-1} \vec{\epsilon}_{ij}(\vec{q}_i, \vec{p}) \right. \\
\left. \qquad + \sum_{j=2}^{n_{\text{scat}}-1} \vec{\beta}_{ij}(\vec{q}_i)^{\text{T}} \mathbf{W}_{ij}^{-1} \vec{\beta}_{ij}(\vec{q}_i) + \frac{\rho_i^2(\vec{p})}{Z_i} \right] \quad (51)
$$

where ρ$_{i}$ ( ⃗ p ) = ρ$_{i}$ ( ⃗ p $^{0}$) + ∑ g ′ ∂ρ$_{i}$ ∂p$_{g}$ ′ Δ p$_{g}$ ′ is the curvature bias (Δ R − $^{1}$) for the i -th track, that depends on the global alignment parameters Δ ⃗ p , and is equal to ρ$_{i}$ ( ⃗ p $^{0}$) before the alignment, namely Δ ⃗ p = ⃗ 0 ; and Z$_{i}$ is its variance. Z → 0 will
<figure><img src="image_22.png" /><figcaption>Fig. 16 The variations of the dynamic alignment parameters of L1 over 10 years from May 20, 2011 to May 20, 2021. Note the change in behavior starting from the end of 2015, which is due to the installation of a thermal blanket on the port (−x) side of AMS on Oct 28, 2015 (indicated by the vertical dashed line)</figcaption></figure>

impose no change of the curvature measurement before and after the alignment. Conversely, $Z \to \infty$ means no curvature constraints in the alignment, making Eq. (51) the same as Eq. (47). In the absence of a curvature reference, the measured curvature of a track is supposed to have no bias before the alignment, as $\rho_i(\vec{p}^0) = 0$, with an uncertainty represented by the variance (squared error) $Z_i$.

Setting the partial derivative of the $\chi^2$ of Eq. (51) with respect to each global parameter $\Delta p_g$ equal to zero, we can derive a matrix equation similar to Eq. (B.7), as:

$$ \sum_{i=1}^{N_{\text{track}}} \vec{d}^i = \left( \sum_{i=1}^{N_{\text{track}}} \mathbf{C}^i \right) \Delta \vec{p} + \sum_{i=1}^{N_{\text{track}}} \mathbf{G}^i \Delta \vec{q}_i \quad (52) $$

where $\vec{d}^i$ is a vector whose g-th element is given by:

$$ d_g^i = - \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial p_g} \right)^{\text{T}} \mathbf{V}_{ij}^{-1} \vec{\epsilon}_{ij} (\vec{q}_i^0, \vec{p}^0) - \frac{\partial \rho_i}{\partial p_g} Z_i^{-1} \rho_i (\vec{p}^0) \quad (53) $$

$C^i$ is a matrix whose $(g, g')$ entry is given by:

$$ C_{gg'}^{ij} = \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial p_g} \right)^{\text{T}} \mathbf{V}_{ij}^{-1} \frac{\partial \vec{\epsilon}_{ij}}{\partial p_{g'}} + \frac{\partial \rho_i}{\partial p_g} Z_i^{-1} \frac{\partial \rho_i}{\partial p_{g'}} \quad (54) $$

and $\mathbf{G}^i$ is the matrix whose entry has been defined in Eq. (B.10).

Setting the partial derivative of the $\chi^2$ of Eq. (51) with respect to each local track parameter of each track equal to zero, we obtain the same matrix equation as Eq. (B.12).

Combining Eqs. (B.12) and (52), all the global alignment parameters, $\Delta \vec{p}$, and all the local track parameters, $\Delta \vec{q}$, can be solved simultaneously as in Eq. (48) with the replacement of $\vec{d}^i \to \vec{d}^i$ and $\mathbf{C}^i \to \mathbf{C}^i$.

The partial derivatives of the curvature change with respect to the global alignment parameters, $\partial \rho_i / \partial \vec{p}$, present in both $\vec{d}^i$ of Eq. (53) and $\mathbf{C}^i$ of Eq. (54), are needed for the alignment. For the i-th track, the alignment corrections $\Delta \vec{p}$ will change the (j-th) hit residual by:

$$ \vec{\epsilon}_{ij}^0 = \sum_{g'} \frac{\partial \vec{\epsilon}_{ij}}{\partial p_{g'}} \Delta p_{g'} \quad (55) $$
<figure><img src="image_23.png" /><figcaption>Fig. 17 The variations of the dynamic alignment parameters of L9 over 10 years from May 20, 2011 to May 20, 2021. Note the change in behavior starting from the end of 2015, which is due to the installation of a thermal blanket on the port (−x) side of AMS on Oct 28, 2015 (indicated by the vertical dashed line)</figcaption></figure>

<figure><img src="image_24.png" /><figcaption>Fig. 18 The standard deviation of the difference in the inverse rigidities measured using the upper span (L1–L8) and using the lower span (L2–L9) of the tracker, σ (1/R$_{18}$ − 1/R$_{29}$), for cosmic-ray helium data with the alignment corrections (full circle) and for the Monte Carlo prediction based on the alignment errors of L1 and L9 (line) in the rigidity range R$_{19}$ > 570 GV. As seen, the data point best matches the Monte Carlo prediction at the alignment errors of 7.1 µ m and 7.9 µ m for L1 and L9 respectively</figcaption></figure>

A track fitting is performed on ̂ ε$_{i}$ 0 from all the hits to derive the local track parameters, Δ ̂ q$_{i}$ , which represent the alignment corrections on the i -th track trajectory. Minimization of the fitting ̂ χ 2 leads to the partial derivative with respect to each local track parameter, ̂ q$_{il}$ , equal to zero:

$$
\begin{align}
0 &= \frac{\partial \tilde{\chi}^2}{\partial \tilde{q}_{il}} \approx 2 \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \tilde{\varepsilon}_{ij}}{\partial \tilde{q}_{il}} \right)^{\text{T}} \left( \tilde{\varepsilon}_{ij}^{0} + \sum_{l'} \frac{\partial \tilde{\varepsilon}_{ij}}{\partial \tilde{q}_{il'}} \Delta \tilde{q}_{il'} \right) \nonumber \\
&= 2 \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \tilde{\varepsilon}_{ij}}{\partial \tilde{q}_{il}} \right)^{\text{T}} \left( \sum_{g'} \frac{\partial \tilde{\varepsilon}_{ij}}{\partial p_{g'}} \Delta p_{g'} + \sum_{l'} \frac{\partial \tilde{\varepsilon}_{ij}}{\partial \tilde{q}_{il'}} \Delta \tilde{q}_{il'} \right). \tag{56}
\end{align}
$$

Equation (56) can be simplified in matrix form as:

$$
\bar{0} = (\tilde{G}^i)^T \Delta \vec{p} + \tilde{\Gamma}^i \Delta \tilde{q}_i \quad (57)
$$

where ˜ G i is a matrix whose ( g , l $^{′}$) entry is given by:

$$
\tilde{G}_{gl'}^i = \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \tilde{\varepsilon}_{ij}}{\partial p_g} \right)^{\text{T}} \frac{\partial \tilde{\varepsilon}_{ij}}{\partial \tilde{q}_{il'}} \quad (58)
$$
and $\tilde{\Gamma}^i$ is a matrix whose $(l, l')$ entry is given by:

$$ \tilde{\Gamma}_{ll'}^i = \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \tilde{\varepsilon}_{ij}}{\partial \tilde{q}_{il}} \right)^{\text{T}} \frac{\partial \tilde{\varepsilon}_{ij}}{\partial \tilde{q}_{il'}}. \qquad (59) $$

The partial derivatives of the residual with respect to the local track parameters, $\partial \tilde{\varepsilon}_{ij} / \partial \tilde{q}_i$, for Eqs. (58) and (59), are derived from the track fitting algorithm (e.g. the GBL algorithm) without multiple scattering. Hence, the local track parameters, $\Delta \tilde{q}_i$, which represent the i-th track trajectory change by the alignment, are obtained from Eq. (57) as:

$$ \Delta \tilde{q}_i = [-(\tilde{\Gamma}^i)^{-1}(\tilde{G}^i)^{\text{T}}] \Delta \vec{p} = \tilde{H}^i \Delta \vec{p} \qquad (60) $$

where $\Delta \tilde{q}_i = (\Delta \rho_i = \Delta \tilde{R}_i^{-1}, \Delta \tilde{q}_{i2}, \Delta \tilde{q}_{i3}, \Delta \tilde{q}_{i4}, \Delta \tilde{q}_{i5})^{\text{T}}$ has only 5 parameters, much fewer than $\Delta \tilde{q}_i$ with multiple scattering appearing in Eqs. (B.12) and (52), and the matrix $\tilde{H}^i$ is given by $\tilde{H}^i = -(\tilde{\Gamma}^i)^{-1}(\tilde{G}^i)^{\text{T}}$. As $\Delta \rho_i = \Delta \tilde{q}_{i1}$ in Eq. (60), the partial derivative of the curvature change with respect to the g-th global alignment parameter, $\partial \rho_i / \partial p_g$, is the $(1, g)$ entry of $\tilde{H}^i$:

$$ \frac{\partial \rho_i}{\partial p_g} = \tilde{H}^i(1, g). \qquad (61) $$

The variance of $\rho_i$, namely $Z_i$, present in both $\tilde{d}^i$ of Eq. (53) and $C^i$ of Eq. (54), is also needed for the alignment. As inferred from Eq. (60), $Z_i$ can be interpreted as the error propagation from a given covariance matrix of $\Delta \vec{p}$ denoted by $\tilde{V}^{\Delta \vec{p}}$, as:

$$ Z_i = [\tilde{H}^i \tilde{V}^{\Delta \vec{p}} (\tilde{H}^i)^{\text{T}}] (1, 1). \qquad (62) $$

Each layer alignment translation parameter can be assigned an error, $\tilde{\sigma}$, for the calculation of $\tilde{V}^{\Delta \vec{p}}$ as $\tilde{V}^{\Delta \vec{p}} = \tilde{V}(\tilde{\sigma})$ and propagated to $Z_i(\tilde{\sigma})$ as:

$$ Z_i(\tilde{\sigma}) = [\tilde{H}^i \tilde{V}(\tilde{\sigma}) (\tilde{H}^i)^{\text{T}}] (1, 1). \qquad (63) $$

Note that $Z_i$ is set via $\tilde{\sigma}$ rather than itself merely for the sake of understanding: for instance, $Z_i(\tilde{\sigma})$ with $\tilde{\sigma} = 10 \ \mu\text{m}$ is equal to the curvature variance (squared error) arising from a position uncertainty of 10 $\mu\text{m}$ on each tracker layer. The assignment of $\tilde{\sigma}$ passing to $Z_i(\tilde{\sigma})$ should be optimized to attain the best alignment precision as discussed below in Sect. 8.3.

## 8.2 Alignment data sample

Most of the collected cosmic-ray events are at low rigidities, below 10 GV [7,30]. To achieve micron level alignment accuracy for each sensor, the alignment will require billions of cosmic-ray events to overcome the multiple scattering arising from the detector materials, especially the large amounts between the external layers and inner tracker ($\sim 0.3 \ X_0$ between L1 and L2 and $\sim 0.2 \ X_0$ between L8 and L9).

Multiple scattering decreases linearly with increasing rigidity [21]. By selecting the latitude and longitude where the minimal geomagnetic cutoff [32,33] in the AMS field of view is greater than 7.6 GV, the number of events at rigidities below 10 GV is reduced to 5%; while $\sim 40\%$ of the high rigidity ($> 30$ GV) events are kept for the alignment.

In the static alignment data sample, there are 1.6 billion cosmic-ray events, which corresponds to the full AMS dataset from May 2011 to January 2015 (over 3.5 years period). The track information from all those events is filled into one matrix to solve all the alignment parameters in one step (see Sects. 5 and 8.1). Owing to the massive amount of data used, the statistical error in the alignment is negligible.

## 8.3 Alignment procedure

After the previous dynamic alignment, the external tracker layers have been aligned with respect to the inner tracker. Next, the modules from the external layers and inner tracker can be aligned together to reduce the overall misalignment. In particular, the positions of the external layers in the ladder or sensor level can help to improve the alignment precision of the inner tracker.

The developed global alignment approach as discussed in Sects. 3, 4, and 8.1 is applied for the static alignment. The GBL algorithm with multiple scattering and with free curvature $(1/R)$ track fitting is used to derive the residuals $\tilde{\varepsilon}_{ij}(\tilde{q}_i^0, \vec{p}^0)$, the partial derivatives with respect to the local track parameters of the residuals $\partial \tilde{\varepsilon}_{ij} / \partial \tilde{q}_i$ and the scattering angles $\partial \tilde{\beta}_{ij} / \partial \tilde{q}_i$, for Eqs. (B.10), (B.13), (B.14) and (53). The GBL algorithm without multiple scattering and with free curvature track fitting is used to derive the partial derivatives of the residuals with respect to the local track parameters $\partial \tilde{\varepsilon}_{ij} / \partial \tilde{q}_i$ for Eqs. (58) and (59).

### 8.3.1 Alignment validation with Monte Carlo

An isotropic cosmic-ray Monte Carlo sample produced by Geant4 [7,29,30] is used to validate the static alignment. All the tracker modules in the MC are randomly displaced by Gaussian sampling using the displacement parameters similar to the flight data. The static alignment (see Eq. (51)) accuracy is optimized by varying the curvature constraint, namely $\tilde{\sigma}$, which defines the curvature variance $Z_i(\tilde{\sigma})$ for the alignment as shown in Eq. (63).

Figure 19 shows the distributions of the proton full-span rigidity resolution $(\delta R_{19}^{-1})$ at 1.5 TV for no module displacement (dashed histogram), displaced modules before alignment (solid histogram), and displaced modules after alignment with $\tilde{\sigma} = 200 \ \mu\text{m}$ (full circle histogram). As seen, the developed alignment procedure is capable of restoring most of the smeared rigidity resolution. Note that the small shift in the mean of the measured rigidity will be precisely cor-
<figure><img src="image_25.png" /><figcaption>**Fig. 19** The distributions of the proton full-span rigidity resolution ($\delta R_{19}^{-1}$) at 1.5 TV for the MC samples with no tracker module displacement (dashed histogram), displaced modules before alignment (solid histogram), and displaced modules after alignment using $\tilde{\sigma} = 200$ µm (full circle histogram)</figcaption></figure>

rected by using the rigidity-scale determination procedure in Sect. 8.3.4. Figure 20 shows the proton rigidity resolutions of (a) the inner tracker ($R_{28}$), (b) L1 and the inner tracker ($R_{18}$), and (c) the full-span tracker ($R_{19}$) as functions of the curvature constraint $\tilde{\sigma}$ (full circles and dot-dashed curves). As seen, in the alignment, the optimal values of $\tilde{\sigma}$ that derive the best rigidity resolutions, are ~ 150 µm for $R_{28}$, ~ 200 µm for $R_{18}$, and ~ 280 µm for $R_{19}$. It is clear that the curvature constraint $\tilde{\sigma}$ should be neither too tight as that will force no track curvature change before and after alignment, nor too loose as that will result in arbitrary change of the curvature in the alignment. Compared with a typical tracker intrinsic position resolution of ~ 10 µm, $Z_i(\tilde{\sigma})$ with $\tilde{\sigma} \sim 200$ µm is a rather loose variance, which is equal to a curvature variance transformed from a position uncertainty of ~ 200 µm on each tracker layer.

### 8.3.2 Alignment optimization for the flight data

As shown in the MC study (Sect. 8.3.1), the alignment precision is sensitive to the curvature variance, $Z_i(\tilde{\sigma})$, used in Eq. (51), which also needs to be derived from the flight data. The primary goal for the alignment is to improve the track curvature ($1/R$) measurement precision, i.e. to reduce the curvature bias. Residuals cannot be used for the study of the curvature misalignment as the curvature bias cannot be seen from the residuals. However, the curvature bias or rigidity bias is very sensitive to the cosmic-ray flux measurement – or, more precisely, the rigidity dependence of the cosmic-ray flux measured at high rigidities [7,30,34]. This feature can be exploited to probe the curvature misalignment.

As cosmic rays are isotropic, for an ideal tracker without misalignment, the cosmic-ray fluxes measured with a similar

<figure><img src="image_26.png" /><figcaption>**Fig. 20** The proton rigidity resolutions $\sigma(1/R)$ of a the inner tracker ($R = R_{28}$), b L1 and the inner tracker ($R = R_{18}$), and c the full-span tracker ($R = R_{19}$) at 1.5 TV as functions of the curvature constraint $\tilde{\sigma}$, obtained from the alignment on the MC with the tracker modules displaced (full circles and dot-dashed curves). The rigidity resolutions for no module displacement (dashed lines) and displaced modules before alignment (solid lines) are also shown</figcaption></figure>

pattern in layers but different detector-module combinations, such as different ladder combinations (see one ladder combination illustrated in Fig. 21a), are expected to be the same. Therefore, as a result of the differential curvature bias, the deviation of the fluxes or the rigidity dependencies of the event rates (the number of the collected events per second) obtained from different ladder combinations, is used as an estimator of the tracker misalignment.

To display the relative rigidity dependence, the cosmic-ray event rates measured from the i-th ladder combination are divided by the event rates measured with the total tracker, denoted by $n_i/n$. Then the obtained $n_i/n$ is normalized by its acceptance fraction $A_i/A$, as:

$$ \frac{\hat{n}_i}{\hat{n}} = \frac{n_i/n}{A_i/A} = \frac{n_i/n}{\kappa_i/\kappa} \qquad (64) $$

where $\kappa_i$ is the total number of events for the i-th ladder combination, which sums up all the passing events above 30 GV – the rigidity region that has no influence from the geomagnetic field [35]; and $\kappa_i/\kappa$ is the ratio of the total events between
<figure><img src="image_27.png" /><figcaption>Fig. 21 a Schematic of a ladder combination of the inner tracker and b the slope fits (lines) to the normalized event ratios ($\hat{n}_i/\hat{n}$) of 4 different ladder combinations with each specified by a set of symbols (up triangles, squares, circles, or down triangles). The different rigidity dependences of the ratios, or the deviation among the slopes, induced by the different curvature biases, are clearly seen</figcaption></figure>

the i-th ladder combination and the full tracker, which is used to calculate the acceptance fraction as $A_i/A = \mathfrak{N}_i/\mathfrak{N}$.

For the i-th ladder combination, the normalized event ratio, $\hat{n}_i/\hat{n}$, is fitted over the high rigidity range 90–1000 GV to derive the event-ratio slope $k_i$, with:

$$ \frac{\hat{n}_i}{\hat{n}} = k_i \log(R) + b_i \qquad (65) $$

where the slope $k_i$ and the intercept $b_i$ are the two fitting parameters.

As an illustration, Fig. 21b shows the slope fits to the normalized event ratios of 4 different ladder combinations. A clear deviation among the event-ratio slopes of different ladder combinations is seen. For each track pattern of L2–L8, L1–L8, or L1–L9, the standard deviation of the event-ratio slopes from the 1000 most populated ladder combinations (i.e. with the largest number of passing events) is used as a gauge to evaluate the misalignment.

Figure 22 shows the standard deviations of the event-ratio slopes, $\sigma(k)$, as functions of the alignment used $\tilde{\sigma}$ for the ladder combinations of (a) the inner tracker ($R_{28}$), (b) L1 and the inner tracker ($R_{18}$), and (c) the full-span tracker ($R_{19}$). As seen, the optimal values of $\tilde{\sigma}$ for the flight data that have the minimal curvature misalignment, are 80–150 µm for $R_{28}$, 150–200 µm for $R_{18}$, and ~ 280 µm for $R_{19}$, which are consistent with the previous estimation from the MC (Sect. 8.3.1). Taking all the track patterns (L2–L8, L1–L8, and L1–L9) into account, the curvature constraint of $\tilde{\sigma} = 200$ µm is chosen for the static alignment. As shown in the figure, after the static alignment, the quality of the rigidity measurement or the rigidity resolution has been significantly improved. There is also no misalignment of the residuals after this step. However, a small remaining misalignment of the curvature still exists and is further reduced by the 2nd static alignment performed afterwards using the curvature alignment approach introduced below.

<figure><img src="image_28.png" /><figcaption>Fig. 22 The standard deviations of the cosmic-ray event-ratio slopes (flux rigidity dependences), $\sigma(k)$, as functions of the curvature constraint $\tilde{\sigma}$ for the ladder combinations of a the inner tracker ($R_{28}$), b L1 and the inner tracker ($R_{18}$), and c the full-span tracker ($R_{19}$), obtained from the static alignment on the flight data (full circles and dot-dashed curves). The deviations of the slopes before the static alignment (solid lines) and the statistical limits due to the slope uncertainties arising from the limited number of cosmic-ray events at high rigidity (dashed lines) are also shown</figcaption></figure>

### 8.3.3 Refinement with the curvature alignment

In the 2nd static alignment, the alignment corrections obtained from the 1st static alignment are applied. Different from the 1st static alignment, which was using zero mean for the curvature constraint as $\rho_i(\vec{p}) = \rho_i(\vec{p}^0) + \sum_{g'} \frac{\partial \rho_i}{\partial p_{g'}} \Delta p_{g'}$ with $\rho_i(\vec{p}^0) = 0$ in Eq. (51), the 2nd static alignment, namely the curvature alignment, uses the curvature bias $\rho_i(\vec{p}^0)$ estimated from the data to further improve the result. The method to obtain $\rho_i(\vec{p}^0)$ is based on the isotropic property of cosmic-ray fluxes, i.e. the same rigidity dependence of the cosmic-ray event rates measured with the different detector-module combinations.

In the j-th rigidity bin $[R_j, R_{j+1}]$, the event rate, $n_j = N_j/T$ (the number of the events per second), measured from the total tracker which has a small curvature misalignment of $\rho$, can be described by:
$$n_j(\rho) = \int_{R_j}^{R_{j+1}} \frac{dR}{R^2} \int_0^\infty \Phi(R_0) A(R_0) M \times \left(R_0, \frac{1}{R} - \frac{1}{R_0} + \rho\right) dR_0 \quad (66)$$

where $1/R + \rho$ and $1/R$ are the measured inverse rigidities with and without the curvature bias respectively, $R_0$ is the true rigidity before detector resolution smearing, $\Phi(R_0)$ is the cosmic-ray flux, $A(R_0)$ is the acceptance of the tracker, and $M(R_0, 1/R - 1/R_0 + \rho)$ is the probability density function of the tracker rigidity resolution for a given true rigidity $R_0$ expressed as a function of $1/R - 1/R_0 + \rho$. The total tracker is assumed to have no curvature bias as $\rho = 0$. With $A$ and $M$ parameterized from the MC simulation, the parameterization of $\Phi$ is obtained from the fit to the event rates measured with the total tracker.

In the j-th rigidity bin, the ratio of the event rate of the i-th detector-module combination, $n_{ij}$, to the total event rate, $n_j$, is:

$$\frac{n_{ij}}{n_j} = \frac{f_i n_j (\rho = \rho_i)}{n_j (\rho = 0)} = \frac{f_i \int_{R_j}^{R_{j+1}} \frac{dR}{R^2} \int_0^\infty \Phi(R_0) A(R_0) M(R_0, \frac{1}{R} - \frac{1}{R_0} + \rho_i) dR_0}{\int_{R_j}^{R_{j+1}} \frac{dR}{R^2} \int_0^\infty \Phi(R_0) A(R_0) M(R_0, \frac{1}{R} - \frac{1}{R_0}) dR_0} \quad (67)$$

where $\rho_i$ is the curvature bias of the i-th detector-module combination, $f_i = A_i/A$ is the constant acceptance ratio of the i-th detector-module combination to the total tracker, and $n_{ij} = A_i/A \cdot n_j(\rho = \rho_i) = f_i n_j(\rho = \rho_i)$. From the fit of Eq. (67) to the event-rate ratio at high rigidity bins (90–1000 GV as in Fig. 21b), the curvature bias $\rho_i$ is obtained.

After the 1st static alignment, 2500 ladder combinations of the inner tracker (86% of the total sample), 4000 ladder combinations of L1 and the inner tracker (88% of the total sample), and 2000 ladder combinations of the full-span tracker (77% of the total sample) are estimated for their remaining curvature biases, which are used as the curvature reference $\rho_i(\bar{p}^0)$ in Eq. (51) for the 2nd static alignment.

To illustrate the full (1st and 2nd) static alignment improvement, Fig. 23 shows the curvature biases of the 1000 most populated ladder combinations (~60% of the total sample) for each track pattern (L2–L8, L1–L8, or L1–L9) before the static alignment (open squares) and after the full static alignment (full circles), which are derived from Eq. (67). Figure 24 summarizes the curvature misalignments, defined as the standard deviations of curvature biases of the 1000 ladder combinations, $\sigma(\rho)$, for the individual track patterns, together with the statistical limits (dashed line) due to the uncertainties arising from the limited number of cosmic-ray events at high rigidities in the curvature bias determination. As seen, with the static alignment approach, the misalign-

<figure><img src="image_29.png" /><figcaption>Fig. 23 The curvature biases of the 1000 most populated ladder combinations for the individual track patterns of a L2–L8 ($R_{28}$), b L1–L8 ($R_{18}$), and c L1–L9 ($R_{19}$) before the static alignment (open squares) and after the full static alignment (full circles)</figcaption></figure>

<figure><img src="image_30.png" /><figcaption>Fig. 24 The curvature misalignments, defined as the standard deviations of curvature biases of the 1000 most populated ladder combinations, $\sigma(\rho)$, for the track patterns of the inner tracker ($R_{28}$), L1 and the inner tracker ($R_{18}$), and the full-span tracker ($R_{19}$) before (open squares) and after (full circles) the static alignment. The statistical limits (dashed line) due to the uncertainties arising from the limited number of cosmic-ray events at high rigidities in the curvature bias determination are also shown</figcaption></figure>

ment of the tracker has been greatly reduced for all the track patterns.

### 8.3.4 Determination of the total absolute rigidity scale

After the previous 2 rounds of static alignment, the tracker becomes homogeneous, i.e. the relative curvature bias from module combination to module combination has vanished. However, the whole tracker can have an overall curvature bias, or a shift in the total absolute rigidity scale, which behaves as a coherent shift in the positions of the tracker layers. To determine the total absolute rigidity scale in space, a method using cosmic-ray electrons ($e^-$) and positrons ($e^+$) events to calibrate the detector has been developed.
<figure><img src="image_31.png" /><figcaption>**Fig. 25** The distributions of the alignment parameters of layers (top row, **a–f**), ladders (middle row, **g–l**), and sensors (bottom row, **m–n–o**) obtained from the static alignment of all the tracker modules in space. The layer alignment parameters of L1 and L9 are not included in the plots (**a–f**) as they are dynamically aligned using the position of the inner tracker for the reference</figcaption></figure>

Similar method to estimate the curvature bias was used in the CMS experiment [36]. The basic idea is to use the property that the deflection curves of the track trajectories in the magnetic field are mirrored between a charged particle and its anti-particle with the same energy. When a coherent shift in the tracker layers occurs, the measured absolute inverse rigidity, $|1/R|$, will be shifted by a positive (negative) and by a negative (positive) value for $e^-$ and $e^+$ respectively. The rigidity scale shift therefore can be evaluated by comparing the $|1/R|$ distributions between $e^-$ and $e^+$ events with the same energy measured in the AMS electromagnetic calorimeter detector. To make full use of the collected cosmic-ray $e^+$ and $e^-$ events with different energies, an unbinned likelihood method was developed. The detailed description of the method is presented in Ref. [34].

Using this approach, the total rigidity scale is established with an accuracy of $\pm 1/34 \text{ TV}^{-1}$ based on 10 years of AMS data, limited mostly by the available positron statistics. The estimated small correction for the total curvature bias is converted into position offsets of the individual tracker layers [34], adding to the layer alignment parameters.

## 8.4 Alignment results

The results of the static alignment are classified into several aspects shown in the following sections.

### 8.4.1 Displacements of the tracker modules during launch

After the static alignment, we obtain the changes between the positions of the tracker modules in space and those on the ground, which are expressed as the alignment parameters shown in Fig. 25.

As seen in Fig. 25a–f, the translations of the inner tracker layers are ~ 1 µm, ~ 1 µm, and ~ 32 µm along the $u_p$-, $v_p$-, and $w_p$-axes (x-, y-, and z-axes) respectively and the rotations are ~ 0.015 mrad, ~ 0.04 mrad, and ~ 0.004 mrad around the $u_p$-, $v_p$-, and $w_p$-axes respectively. The translation of ~ 32 µm along the $w_p$-axis (z-axis) can be explained by the outgassing of the support structure, i.e. the foam in the ladder reinforcement frame (see Fig. 2a), which happened very rapidly under vacuum. This is confirmed by the fact that the odd and even layers of the inner tracker are shifted in opposite z-direction (see Fig. 25c), since their ladders are mounted oppositely. Apart from that, the support structure of the inner tracker planes (the carbon fiber cylinder), exhibits excellent mechanical stability, holding the layers of the inner tracker in place at the micron level through the launch.

As seen in Fig. 25g–l, the translations of the ladders are ~ 13 µm, ~ 11 µm, and ~ 13 µm along the $u_L$-, $v_L$-, and $w_L$-axes respectively and the rotations are ~ 0.4 mrad, ~ 0.1 mrad, and ~ 0.03 mrad around the $u_L$-, $v_L$-, and $w_L$-axes respectively. The sizable changes of the ladder positions are the major sources of the tracker misalignment in space.

As seen in Fig. 25m–o, the translations of the sensors are ~ 16 µm and ~ 5 µm along the $u_s$- and $v_s$-axes respectively
<figure><img src="image_32.png" /><figcaption>**Fig. 26** The residual biases of the individual sensors of the inner tracker in **a** the $u_s$ direction and **b** the $v_s$ direction before (open squares) and after (full circles) the static alignment for a selected cosmic-ray proton sample with rigidity $R > 30$ GV based on 10 years of AMS data. A circle or square represents a residual bias of each sensor. The circles or squares of a common group are the sensors from the same half of a tracker layer</figcaption></figure>

and the rotation is ~ 0.1 mrad around the $w_s$-axis, which are also not small changes. In particular, the largest translation of ~ 16 µm along the $u_s$-axis reveals a systematic change of the ladder structure after the launch, that is an increased distance between the adjacent sensors in a ladder. The reason might also be related to the deformation of the foam in the ladder reinforcement frame.

Figure 26 shows the residual biases of the individual sensors of the inner tracker in the sensor $u_s$- and $v_s$-directions before and after the static alignment for a selected cosmic-ray proton sample with rigidity $R > 30$ GV based on 10 years of AMS data. Obvious displacements of the tracker modules induced by the launch (before the static alignment) are seen. After the alignment, there is no bias in the residual of each sensor.

### 8.4.2 Stability of the tracker modules in space

We have also examined the position stability of the inner tracker sensors in space through their residuals over time. During the 10 year period, in the microgravity environment, the changes of the sensor positions are found to be very small.

In order to increase the sensitivity of detecting the tracker movement in space, a similar approach as in Sect. 8.3.3 is applied to estimate the time dependent rigidity-scale shift of the total tracker, by using that the cosmic-ray flux at high rigidities is constant in time. The curvature biases, or the rigidity-scale shifts, are measured in 40 time periods of 3 months each by fitting the measured event-rate ratios of those periods to the total over 10 years ($n_{i=1-40}/n$) with a function similar to Eq. (67).

Figure 27 shows the rigidity-scale shifts as a function of time over 10 years obtained from the event rates of cosmic-

<figure><img src="image_33.png" /><figcaption>**Fig. 27** The rigidity-scale shifts as a function of time over 10 years obtained from the event rates of cosmic-ray protons (open symbols) and helium (full symbols) measured using the inner tracker ($R_{28}$, circles), L1 and the inner tracker ($R_{18}$, squares), and the full-span tracker ($R_{19}$, triangles). The solid curve shows the fit with a logistic function</figcaption></figure>

ray protons (open symbols) and helium (full symbols) measured using the inner tracker ($R_{28}$, circles), L1 and the inner tracker ($R_{18}$, squares), and the full-span tracker ($R_{19}$, triangles). As seen, the slow shift of the rigidity scale, or the long-term movement of the inner tracker, is evident before 2015 and progressively decreasing to near zero around 2016. The amplitude of this movement is fairly small, as the maximum rigidity-scale change of ~ 0.18 TV⁻¹ shown in the figure is equivalent to a displacement of an inner tracker layer of < 1 µm [34]. It is also shown in the figure that the shift of the rigidity measured with the external layers ($R_{18}$ or $R_{19}$) perfectly follows the shift of the rigidity measured with only the inner tracker ($R_{28}$), proving the high stability and reliability of the L1 and L9 dynamic-alignment procedure.

The small correction for the time dependent rigidity-scale shift is converted into position offsets of the individual tracker layers [34], adding to the layer alignment parameters.

### 8.4.3 Alignment precision

After the static alignment, the misalignment in the residual, or incoherent misalignment, is negligible (under a micron as seen in Fig. 26) compared with the intrinsic tracker coordinate resolution. Figure 28 shows the Gaussian sigma of the $v_s$ residual, that is the $v_s$ coordinate difference between the measurement from a sensor of L5 and the prediction from the track fit using the other layers, as functions of the incident particle direction in the sensor $v_s w_s$-plane, $dv_s^p/dw_s^p$, for cosmic-ray helium (triangles) and carbon (full circles) nuclei with rigidities $R > 50$ GV. Owing to the precise alignment together with the advanced position finding algorithm [9], the average $v_s$ or $w_s$ coordinate resolutions are 6.5 (7.5) µm for helium and 5.1 (5.8) µm for carbon in the full-span (L1 and inner) tracker geometry. The detailed performance of the
<figure><img src="image_34.png" /><figcaption>**Fig. 28** The standard deviation ($\sigma$) of the $v_s$ residual (the $v_s$ coordinate difference between the measurement from a sensor of L5 and the prediction from the track fit using the other layers), as functions of the incident particle direction $d\mathbf{v}_s^\perp/d\mathbf{w}_s^\perp$ for cosmic-ray helium (triangles) and carbon (full circles) nuclei with rigidities $R > 50$ GV. The vertical dashed lines indicate the angular boundary of the full-span tracker geometrical acceptance, which includes 95% of the events. The vertical dot-dashed lines indicate the same boundary but of the L1-inner tracker acceptance. The intrinsic tracker spatial resolution is predominant in the residual $\sigma$. The average $v_s$ coordinate resolutions are 6.5 (7.5) $\mu$m for helium and 5.1 (5.8) $\mu$m for carbon in the full-span (L1 and inner) tracker geometry</figcaption></figure>

AMS tracker coordinate resolutions for all charged particles up to $Q = 26$ can be found in Ref. [9].

Another source of the misalignment in the static alignment is the misalignment of the curvature, or coherent misalignment, which is not visible in the residual and is more crucial. The curvature misalignment can be split into two parts: (a) the overall curvature bias that will shift the mean of the measured rigidity and (b) the differential curvature bias that will degrade the rigidity resolution.

The overall curvature bias, or the rigidity scale shift of the total tracker, has been corrected to an accuracy of $\pm 1/34$ TV$^{-1}$ by using cosmic-ray electrons and positrons events with the procedure discussed in Sect. 8.3.4.

The differential curvature biases for the different combinations of the tracker modules can smear the tracker resolution as shown in the MC study (see Fig. 19). With the unique alignment approach, most of the smeared rigidity resolution is recovered. By using the isotropic property of cosmic-ray flux, direct assessment of the misalignment is performed on the data. As shown in Fig. 24, after the alignment, the standard deviations of the differential curvature biases among different ladder combinations, are better than 0.18 TV$^{-1}$, 0.125 TV$^{-1}$, and 0.11 TV$^{-1}$ for the rigidities measured using the inner tracker ($R_{28}$), L1 and inner tracker ($R_{18}$), and full-span tracker ($R_{19}$) respectively, which are the misalignments equivalent to additional smearings of the measured position of each layer by less than 0.7 $\mu$m, 1.2 $\mu$m, and 2.7 $\mu$m for $R_{28}$, $R_{18}$, and $R_{19}$ respectively. This estimation is based on

<figure><img src="image_35.png" /><figcaption>**Fig. 29** The rigidity resolutions, $\sigma(1/R)$, of L1-inner ($R = R_{18}$) and full-span ($R = R_{19}$) track patterns as functions of the true rigidity for carbon nuclei obtained from MC simulation. The corresponding maximal detectable rigidities, $R^M$, with $R^M\sigma(1/R^M) \equiv 1$, are $R_{18}^M = 1.6$ TV and $R_{19}^M = 3.6$ TV</figcaption></figure>

different ladder combinations and does not include the contribution from the misalignment of the sensors, which cannot be accurately determined from the different sensor combinations due to the limited number of cosmic-ray events per sensor combination at high rigidities. Considering that the sensor position change during launch is small, $\sim 5 \mu$m, in the bending direction, based on the MC simulation, we assign an error of $\sim 2 \mu$m to the sensor misalignment. So, combining in quadrature, the total differential curvature misalignments equivalent to the position errors of each layer are 2.1 $\mu$m, 2.3 $\mu$m, and 3.3 $\mu$m for $R_{28}$, $R_{18}$, and $R_{19}$ respectively, which are smaller than both the intrinsic spatial resolution (e.g. 5.1 $\mu$m for carbon nuclei in the full-span geometry) and the alignment errors of the external layers in the dynamic alignment (7.1 $\mu$m for L1 and 7.9 $\mu$m for L9).

## 9 Conclusion

Precise alignment of the silicon tracker is invaluable for the success of the AMS mission. We have presented a series of new methods to align the large permanent magnetic spectrometer for the space experiment, starting from the alignment with the test beam data on the ground through the alignment with the cosmic-ray events in space, with an ultimate precision of a few microns achieved under harsh conditions. This allows AMS to accurately measure cosmic rays up to the multi-TV region. As an example, Fig. 29 shows the rigidity resolutions of L1-inner track pattern, $\sigma(1/R_{18})$, and of full-span track pattern, $\sigma(1/R_{19})$, as functions of the true rigidity for carbon nuclei after the full alignment procedure. The maximal detectable rigidities, $R^M$, with $R^M\sigma(1/R^M) \equiv 1$, are $R_{18}^M = 1.6$ TV and $R_{19}^M = 3.6$ TV, correspondingly.
The developments of the new mathematical alignment algorithms, such as the alignment for the composite detector structure, the alignment for the dynamic system, and the alignment in the presence of the magnetic field, are useful for various HEP experiments equipped with the tracking detectors and particularly valuable for the future spaceborne magnetic spectrometers.

**Acknowledgements** We acknowledge the continuous support from MIT and its School of Science. We are grateful for the support of the U.S. Department of Energy (DOE), Office of Science (DE-SC-0011848). We thank the strong support from CERN IT department. We thank Dr. Michael Capell for his diligent proofreading of the manuscript.

**Data Availability Statement** This manuscript has no associated data or the data will not be deposited. [Authors' comment: This study is based on data of the AMS collaboration and is not publicly available according to the collaboration policy.].

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.

Funded by SCOAP³. SCOAP³ supports the goals of the International Year of Basic Sciences for Sustainable Development.

## Appendix A: Coordinate transformation from the local sensor frame to the global tracker frame

Substituting Eq. (1) into Eq. (2) gives:

$$ \begin{aligned} \vec{r}_P &= \mathbf{R}_L^\mathrm{T} \Delta \mathbf{R}_L [\mathbf{R}_s^\mathrm{T} \Delta \mathbf{R}_s (\vec{q} + \Delta \vec{q}_s) + \vec{r}_{0s} + \Delta \vec{q}_L] + \vec{r}_{0L} \\ &\approx \mathbf{R}_L^\mathrm{T} \mathbf{R}_s^\mathrm{T} [(\mathbf{R}_s \Delta \mathbf{R}_L \mathbf{R}_s^\mathrm{T}) \Delta \mathbf{R}_s \vec{q} + \Delta \vec{q}_s + \mathbf{R}_s \Delta \mathbf{R}_L \vec{r}_{0s} \\ &\quad + \mathbf{R}_s \Delta \vec{q}_L] + \vec{r}_{0L}. \end{aligned} \quad (A.1) $$

Subsequently, substituting Eq. (A.1) into Eq. (3) gives:

$$ \begin{aligned} \vec{r}_g \approx & \mathbf{R}_P^\mathrm{T} \mathbf{R}_L^\mathrm{T} \mathbf{R}_s^\mathrm{T} [(\mathbf{R}_s \mathbf{R}_L \Delta \mathbf{R}_P \mathbf{R}_L^\mathrm{T} \mathbf{R}_s^\mathrm{T}) (\mathbf{R}_s \Delta \mathbf{R}_L \mathbf{R}_s^\mathrm{T}) \Delta \mathbf{R}_s \vec{q} \\ & + \Delta \vec{q}_s + (\mathbf{R}_s \mathbf{R}_L \Delta \mathbf{R}_P \mathbf{R}_L^\mathrm{T} \mathbf{R}_s^\mathrm{T}) \mathbf{R}_s \Delta \mathbf{R}_L \vec{r}_{0s} + \mathbf{R}_s \Delta \vec{q}_L \\ & + \mathbf{R}_s \mathbf{R}_L \Delta \mathbf{R}_P \vec{r}_{0L} + \mathbf{R}_s \mathbf{R}_L \Delta \vec{q}_P] + \vec{r}_{0P}. \end{aligned} \quad (A.2) $$

The above equation can be simplified to:

$$ \vec{r}_g \approx \mathbf{R}^\mathrm{T} (\vec{q} + \Delta \vec{q}) + \vec{r}_0 $$

where

$$ \begin{aligned} \Delta \vec{q} = & [(\mathbf{R}_s \mathbf{R}_L \Delta \mathbf{R}_P \mathbf{R}_L^\mathrm{T} \mathbf{R}_s^\mathrm{T}) (\mathbf{R}_s \Delta \mathbf{R}_L \mathbf{R}_s^\mathrm{T}) \Delta \mathbf{R}_s - \mathbf{E}] \vec{q} \\ & + \Delta \vec{q}_s + [(\mathbf{R}_s \mathbf{R}_L \Delta \mathbf{R}_P \mathbf{R}_L^\mathrm{T} \mathbf{R}_s^\mathrm{T}) \mathbf{R}_s \Delta \mathbf{R}_L - \mathbf{R}_s] \vec{r}_{0s} \\ & + \mathbf{R}_s \Delta \vec{q}_L + \mathbf{R}_s \mathbf{R}_L (\Delta \mathbf{R}_P - \mathbf{E}) \vec{r}_{0L} + \mathbf{R}_s \mathbf{R}_L \Delta \vec{q}_P \end{aligned} \quad (A.3) $$

$$ \mathbf{R}^\mathrm{T} = \mathbf{R}_P^\mathrm{T} \mathbf{R}_L^\mathrm{T} \mathbf{R}_s^\mathrm{T} \quad (A.4) $$

$$ \vec{r}_0 = \mathbf{R}_P^\mathrm{T} \mathbf{R}_L^\mathrm{T} \vec{r}_{0s} + \mathbf{R}_P^\mathrm{T} \vec{r}_{0L} + \vec{r}_{0P}. \quad (A.5) $$

## Appendix B: $\chi^2$ minimization and alignment matrix in the global alignment

Minimization of the $\chi^2$ of Eq. (47) leads to the partial derivative with respect to each (g-th) global parameter $\Delta p_g$ being zero:

$$ \begin{aligned} \frac{\partial \chi^2}{\partial p_g} &= 2 \sum_{i=1}^{N_{\mathrm{track}}} \sum_{j=1}^{n_{\mathrm{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial p_g} \right)^{\mathrm{T}} \mathbf{V}_{ij}^{-1} \vec{\epsilon}_{ij} = 0 \\ &\approx 2 \sum_{i=1}^{N_{\mathrm{track}}} \sum_{j=1}^{n_{\mathrm{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial p_g} \right)^{\mathrm{T}} \mathbf{V}_{ij}^{-1} \left[ \vec{\epsilon}_{ij} (\vec{q}_i^0, \vec{p}^0) \right. \\ &\qquad \left. + \sum_{l'} \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il'}} \Delta q_{il'} + \sum_{g'} \frac{\partial \vec{\epsilon}_{ij}}{\partial p_{g'}} \Delta p_{g'} \right] \end{aligned} \quad (B.6) $$

where $\vec{\epsilon}_{ij} \approx \vec{\epsilon}_{ij}(\vec{q}_i^0, \vec{p}^0) + \sum_{l'} \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il'}} \Delta q_{il'} + \sum_{g'} \frac{\partial \vec{\epsilon}_{ij}}{\partial p_{g'}} \Delta p_{g'}$ depends both on the local track parameters $\Delta \vec{q}_i$ and the global alignment parameters $\Delta \vec{p}$, and $\vec{\beta}_{ij} \approx \sum_{l'} \frac{\partial \vec{\beta}_{ij}}{\partial q_{il'}} \Delta q_{il'}$ as the intrinsic track property only depends on the local track parameters $\Delta \vec{q}_i$. Equation (B.6) can be further simplified in matrix form as:

$$ \sum_{i=1}^{N_{\mathrm{track}}} \vec{d}^i = \left( \sum_{i=1}^{N_{\mathrm{track}}} \mathbf{C}^i \right) \Delta \vec{p} + \sum_{i=1}^{N_{\mathrm{track}}} \mathbf{G}^i \Delta \vec{q}_i \quad (B.7) $$

where $\vec{d}^i$ is a vector whose g-th element is given by:

$$ d_g^i = - \sum_{j=1}^{n_{\mathrm{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial p_g} \right)^{\mathrm{T}} \mathbf{V}_{ij}^{-1} \vec{\epsilon}_{ij} (\vec{q}_i^0, \vec{p}^0) \quad (B.8) $$

$\mathbf{C}^i$ is a matrix whose $(g, g')$ entry is given by:

$$ C_{gg'}^i = \sum_{j=1}^{n_{\mathrm{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial p_g} \right)^{\mathrm{T}} \mathbf{V}_{ij}^{-1} \frac{\partial \vec{\epsilon}_{ij}}{\partial p_{g'}} \quad (B.9) $$

and $\mathbf{G}^i$ is a matrix whose $(g, l')$ entry is given by:

$$ G_{gl'}^i = \sum_{j=1}^{n_{\mathrm{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial p_g} \right)^{\mathrm{T}} \mathbf{V}_{ij}^{-1} \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il'}} \quad (B.10) $$
The partial derivatives of the residual with respect to the global alignment parameters, $\partial \vec{\epsilon}_{ij}/\partial \vec{p}$, are from Eqs. (13)–(15) and with respect to the local track parameters, $\partial \vec{\epsilon}_{ij}/\partial \vec{q}_i$, are derived from the track fitting algorithm. In this paper, the track fitting was done with the custom software implementation of the General Broken Lines algorithm [20].

Minimization of the $\chi^2$ of Eq. (47) leads the partial derivative with respect to each (l-th) local track parameter of each (i-th) track, $\Delta q_{il}$, to equal zero:

$$ 
\begin{aligned}
\frac{\partial \chi^2}{\partial q_{il}} &= 2 \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il}} \right)^{\text{T}} \mathbf{V}_{ij}^{-1} \vec{\epsilon}_{ij} + 2 \sum_{j=2}^{n_{\text{scat}}-1} \left( \frac{\partial \vec{\beta}_{ij}}{\partial q_{il}} \right)^{\text{T}} \mathbf{W}_{ij}^{-1} \vec{\beta}_{ij} = 0 \\
&\approx 2 \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il}} \right)^{\text{T}} \mathbf{V}_{ij}^{-1} \left[ \vec{\epsilon}_{ij}(\vec{q}_i^0, \vec{p}^0) + \sum_{l'} \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il'}} \Delta q_{il'} \right. \\
&\qquad \left. + \sum_{g'} \frac{\partial \vec{\epsilon}_{ij}}{\partial p_{g'}} \Delta p_{g'} \right] + 2 \sum_{j=2}^{n_{\text{scat}}-1} \left( \frac{\partial \vec{\beta}_{ij}}{\partial q_{il}} \right)^{\text{T}} \mathbf{W}_{ij}^{-1} \sum_{l'} \frac{\partial \vec{\beta}_{ij}}{\partial q_{il'}} \Delta q_{il'}.
\end{aligned}
\quad (\text{B.11})
$$

Equation (B.11) can be simplified in matrix form as:

$$ \vec{b}^i = (\mathbf{G}^i)^{\text{T}} \Delta \vec{p} + \Gamma^i \Delta \vec{q}_i \quad (\text{B.12}) $$

where $\vec{b}^i$ is a vector whose l-th element is given by:

$$ b_l^i = - \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il}} \right)^{\text{T}} \mathbf{V}_{ij}^{-1} \vec{\epsilon}_{ij} (\vec{q}_i^0, \vec{p}^0) \quad (\text{B.13}) $$

$(\mathbf{G}^i)^{\text{T}}$ is the transpose of the matrix $\mathbf{G}^i$ which is defined in Eq. (B.10), and $\Gamma^i$ is a matrix whose $(l, l')$ entry is given by:

$$ \Gamma_{ll'}^i = \sum_{j=1}^{n_{\text{meas}}} \left( \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il}} \right)^{\text{T}} \mathbf{V}_{ij}^{-1} \frac{\partial \vec{\epsilon}_{ij}}{\partial q_{il'}} + \sum_{j=2}^{n_{\text{scat}}-1} \left( \frac{\partial \vec{\beta}_{ij}}{\partial q_{il}} \right)^{\text{T}} \mathbf{W}_{ij}^{-1} \frac{\partial \vec{\beta}_{ij}}{\partial q_{il'}} \quad (\text{B.14}) $$

The partial derivatives of the scattering angle with respect to the local track parameters, $\partial \vec{\beta}_{ij}/\partial \vec{q}_i$, are derived from the track fitting algorithm.

Combining Eqs. (B.7) and (B.12), all the global alignment parameters, $\Delta \vec{p}$, and all the local track parameters, $\Delta \vec{q}$, can be solved simultaneously from following matrix equation:

$$ \begin{pmatrix} \sum_i \mathbf{C}^i \mathbf{G}^1 & \dots & \mathbf{G}^j & \dots & \mathbf{G}^N \\ (\mathbf{G}^1)^{\text{T}} & \Gamma^1 & \dots & \mathbf{0} & \dots & \mathbf{0} \\ \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ (\mathbf{G}^j)^{\text{T}} & \mathbf{0} & \dots & \Gamma^j & \dots & \mathbf{0} \\ \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\ (\mathbf{G}^N)^{\text{T}} & \mathbf{0} & \dots & \mathbf{0} & \dots & \Gamma^N \end{pmatrix} \begin{pmatrix} \Delta \vec{p} \\ \Delta \vec{q}_1 \\ \vdots \\ \Delta \vec{q}_j \\ \vdots \\ \Delta \vec{q}_N \end{pmatrix} = \begin{pmatrix} \sum_i \vec{d}^i \\ \vec{b}^1 \\ \vdots \\ \vec{b}^j \\ \vdots \\ \vec{b}^N \end{pmatrix} $$

## References

1. V. Bindi et al., Nucl. Instrum. Methods Phys. Res. Sect. A **743**, 22 (2014). https://doi.org/10.1016/j.nima.2014.01.002

2. T. Kirn et al., Nucl. Instrum. Methods Phys. Res. Sect. A **706**, 43 (2013). https://doi.org/10.1016/j.nima.2012.05.010

3. M. Aguilar et al., Nucl. Instrum. Methods Phys. Res. Sect. A **614**, 237 (2010). https://doi.org/10.1016/j.nima.2009.12.027

4. C. Adloff et al., Nucl. Instrum. Methods Phys. Res. Sect. A **714**, 147 (2013). https://doi.org/10.1016/j.nima.2013.02.020

5. P. von Doetinchem et al., Nucl. Phys. B Proc. Suppl. **197**, 15 (2009). https://doi.org/10.1016/j.nuclphysbps.2009.10.025

6. K. Luebelsmeyer et al., Nucl. Instrum. Methods Phys. Res. Sect. A **654**(1), 639 (2011). https://doi.org/10.1016/j.nima.2011.06.051

7. M. Aguilar et al., Phys. Rev. Lett. **114**(17), 171103 (2015). https://doi.org/10.1103/PhysRevLett.114.171103

8. W. Burger et al., Nucl. Instrum. Methods Phys. Res. Sect. A **512**(3), 517 (2003). https://doi.org/10.1016/S0168-9002(03)01866-7

9. G. Ambrosi, V. Choutko, C. Delgado, A. Oliva, Q. Yan, Y. Li, Nucl. Instrum. Methods Phys. Res. Sect. A **869**, 29 (2017). https://doi.org/10.1016/j.nima.2017.07.014

10. T. Siedenburg et al., Nucl. Phys. B Proc. Suppl. **113**(1-3), 154 (2002). https://doi.org/10.1016/S0920-5632(02)01835-2

11. S. Borsini et al., SAE Technical Paper pp. 01-3023 (2007). https://doi.org/10.4271/2007-01-3023

12. Q. Yan, V. Choutko, A. Oliva, M. Paniccia, Nucl. Phys. A **996**, 121712 (2020). https://doi.org/10.1016/j.nuclphysa.2020.121712

13. M. Stoye, Calibration and alignment of the CMS silicon tracking detector. Ph.D. thesis, U. Hamburg, Germany (2007). https://cds.cern.ch/record/1047047

14. C. Thiel, J. Voss, R.J. Martin, P. Neff, Int. J. Non-Linear Mech. **112**, 57 (2019). https://doi.org/10.1016/j.ijnonlinmec.2018.10.002

15. V. Blobel, Nucl. Instrum. Methods Phys. Res. Sect. A **566**(1), 5 (2006). https://doi.org/10.1016/j.nima.2006.05.157

16. G. Flucke, P. Schleper, G. Steinbrück, M. Stoye, J. Instrum. **3**(09), P09002 (2008). https://doi.org/10.1088/1748-0221/3/09/P09002

17. S. Viret, C. Parkes, M. Gersabeck, Nucl. Instrum. Methods Phys. Res. Sect. A **596**(2), 157 (2008). https://doi.org/10.1016/j.nima.2008.07.153

18. ALICE Collaboration, J. Instrum. **5**(03), P03003 (2010). https://doi.org/10.1088/1748-0221/5/03/P03003

19. ATLAS Collaboration, Eur. Phys. J. C **80**, 1194 (2020). https://doi.org/10.1140/epjc/s10052-020-08700-6

20. V. Blobel, C. Kleinwort, F. Meier, Comput. Phys. Commun. **182**(9), 1760 (2011). https://doi.org/10.1016/j.cpc.2011.03.017

21. G.R. Lynch, O.I. Dahl, Nucl. Instrum. Methods Phys. Res. Sect. B **58**(1), 6 (1991). https://doi.org/10.1016/0168-583X(91)95671-Y

22. C. Kleinwort, Nucl. Instrum. Methods Phys. Res. Sect. A **673**, 107 (2012). https://doi.org/10.1016/j.nima.2012.01.024

23. V. Blobel, C. Kleinwort (2002). arXiv preprint. arXiv:hep-ex/0208021

24. V. Blobel, Institut für Experimentalphysik, Universität Hamburg (2007). https://www.desy.de/~sschmitt/blobel/Mptwo.pdf

25. DESY gitlab. Millepede-II. https://gitlab.desy.de/claus.kleinwort/millepede-ii.git

26. D. Leonardo, R. Menon, Comput. Sci. Eng. **5**(1), 46 (1998). https://doi.org/10.1109/99.660313

27. R. Brun, F. Rademaker, Nucl. Instrum. Methods Phys. Res. Sect. A **389**(1-2), 81 (1997). https://doi.org/10.1016/S0168-9002(97)00048-X

28. A.J. Peters, E.A. Sindrilaru, G. Adde, J. Phys.: Conf. Ser. **664**, 042042 (2015). https://doi.org/10.1088/1742-6596/664/4/042042

29. S. Agostinelli et al., Nucl. Instrum. Methods Phys. Res. Sect. A **506**(3), 250 (2003). https://doi.org/10.1016/S0168-9002(03)01368-8

30. M. Aguilar et al., Phys. Rev. Lett. **115**(21), 211101 (2015). https://doi.org/10.1103/PhysRevLett.115.211101

31. C.H. Reinsch, Numerische Mathematik **10**(3), 177 (1967). https://doi.org/10.1007/BF02162161
32. D.F. Smart, M.A. Shea, Adv. Space Res. 36(10), 2012 (2005).
https://doi.org/10.1016/j.asr.2004.09.015

33. E. Thébault et al., Earth Planets Space 67(1), 1 (2015). https://doi.org/10.1186/s40623-015-0228-9

34. J. Berdugo, V. Choutko, C. Delgado, Q. Yan, Nucl. Instrum. Methods Phys. Res. Sect. A 869, 10 (2017). https://doi.org/10.1016/j.nima.2017.07.012

35. M. Aguilar et al., Phys. Rep. 894, 1 (2021). https://doi.org/10.1016/j.physrep.2020.09.003

36. CMS Collaboration, J. Instrum. 9(06), P06009 (2014). https://doi.org/10.1088/1748-0221/9/06/P06009