Time alignment of the front end electronics of the LHCb calorimeters

LHCb is the experiment at the Large Hadron Collider at CERN designed for performing studies of CP-symmetry violation and rare decays of B-hadrons. Its calorimeter system allows to trigger on photons and electrons by associating the information from a scintillating pad signing charged particle (SPD), a pre-shower tagging electromagnetic particles (PS), an electromagnetic calorimeter (ECAL) and a hadronic calorimeter (HCAL). We present the principles and procedures for the fine time-alignment throughout the commissioning and the first collision phases. We give a particular emphasis to the choices made in the electronic design of the calorimeters to deal with the signal shape and spill over. Also we summarise the achieved levels of synchronisation.


Introduction
The LHCb detector [1] is a single arm spectrometer mainly devoted to the study of CP violation and rare decays in B meson systems. Its calorimeter is divided in two, a Hadronic Calorimeter (HCAL) and an Electromagnetic Calorimeter which, in turn, splits into a Scintillator Pad Detector (SPD), a PreShower (PS) and the bulk of the Electromagnetic Calorimeter (ECAL) [2]. All four subdetectors work on the same principle: collect scintillation light produced by incoming particles, convert it to an electrical signal using photomultipliers and integrate it to obtain the energy measurement depending on the photo electron statistics. The detector technology and structure causes the light signal duration to exceed 25 ns, the period of the LHC clock. This can cause a spill over of part of the signal produced in a clock period to the following one. Each part of the calorimeter deals with this problem using a different approach but, for all of them, the choice of the initial time for the signal integration is capital to achieve the precision requirements in the energy measurement [1]. For this reason, the time alignment of the calorimeters, namely, the adjustment of the start of the integration time, has become one of the key issues in the commissioning of the detector and later on, of its maintenance.
-1 - Actually, the time alignment between the calorimeter data and the rest of the experiment requires two steps. The first one is to adjust the measurements made by all boards for a given collision to come out synchronously relative to each other and also relative to all other subdetectors. In this paper, we shall deal with the second step, the synchronisation of the front end electronics with respect to the incoming particle. For this, we shall first give a description of the LHCb calorimeter elements and their data acquisition electronics. We shall then discuss the signal shape and, based onto it, the time alignment principle. We then present how this technique was adapted to use cosmic rays to find a set of relative time alignment phases during the commissioning period. Finally, we show how those principles were applied with the first protons collisions in the LHC. We close the paper with a discussion on the achieved levels of synchronisation.

The LHCb calorimeters
The LHCb calorimeter system is conceived to play a main role in photon reconstruction, particle identification and in the trigger system. Four subsystems have been designed to fullfil these requirements (figure 1) sharing the same detection principle: tiles of organic scintillator with wavelength shifting fibers to extract the scintillation light and drive it to photomultipliers. We shall proceed to sketch each subsystem yet full details may be found in references [1,2].
Downstream from the interaction point, we find the Scintillator Pad Detector, a wall of 6016 scintillating pads of 1.5 cm thickness. Its goal is to tag charged from neutral particles for the L0 trigger by comparing the energy deposited on the tile to a threshold. The light generated by crossing particles is collected through wave length shifting (WLS) fibres and relayed by clear fibres to multi anode photomultipliers (MAPMT) of 64 channels. The integrated signal is compared to a -2 -

JINST 7 P08020
threshold adjusted in order to have a good efficiency on discriminating minimum ionising particles with sufficient backgroud rejection. The output is a single bit per channel. Following a 2.5 radiation length lead sheet, the pre-shower (PS) scintillating wall matches the SPD geometry to tags the start of electromagnetic showers. Combined with the SPD bit, the system provides electron and photon identification. Just like with the SPD, the light produced in the pad is shifted by WLS fibres and transported by clear fibers to 64 channel MAPMT. Actually, PS and SPD share the same type of photomultipliers, namely, Hamamatsu R5900-M64 with a bialkali photocathode. PS signals are integrated over a 25 ns time interval and then digitised with a 10 bit dynamic range.
The electromagnetic calorimeter is implemented using a shashlik technology constructed from a lead-scintillator sandwich read out by WLS fibers that transport the light to a single PMT per channel, a Hamamatsu R7899-20, installed in the back of the detector. Its segmentation projectively follows the SPD and PS geometry. The ECAL is 25 radiation lengths thick. Its Molière radius is 3.5 cm. The resolution was measured in test beam studies [1] in which the following value was obtained, where E is the particle energy. The last term represents the contribution of the electronics noise. This term depends upon the azimutal angle of the cell position with respect to the beam axis because the PMT gains are adjusted to correct the differences in particle trajectory lengths inside the calorimeter so the gain will be different from cell to cell.
The three electromagnetic elements of the calorimeter, SPD, PS and ECAL are divided in three zones, namely inner, middle and outer, in order to ensure better granularity in the areas with larger occupancies. ECAL cell sizes are 4.04, 6.06, 12.12 cm correspondingly.
The sampling structure of the hadronic calorimeter (HCAL) is made of iron and scintillating tiles parallel to the beam axis. As for ECAL, WLS fibers conduct the signal towards the same type of PMTs, Hamamatsu R7899-20, located in the back. The HCAL is segmented transversally in pads of 131.3 mm in the inner region and 262.6 mm in the outer region. The energy resolution follows [1]: where E is the deposited energy.
High Voltage (HV) is provided for the four susbsystems by full custom Cockroft-Walton voltage multipliers. PS and SPD share a common design for their 64 channel MAPMTs just as ECAL and HCAL do for their R7899-20. Besides, PS and SPD MAPMT bases are full custom ones, involving active elements to provide the last PMT dynodes with the necessary current to keep the response in the linear regime.
From the detector description, we observe a number of common features for ECAL and HCAL. For this reason, the data acquisition electronics has been designed to be the same for boths subsystems. In turn, PS and SPD electronics have also been designed to have large parts in common delivering the general scheme shown in figure 2. For all four subdetectors, signals are amplified, integrated and then digitised. The digital signals receive further treatment in FPGAs -3 - (pedestal subtraction in the XCAL 1 case and calibration and packing in the PS case) and are sent to the data acquisition and trigger systems.
XCAL signal processing is performed by the so called Front End Boards (FEB) hosting 32 data channels each delivering 12 bit precision values. FEB are located in crates on the top of the calorimeter platform (figure 1). Each crate is controlled by a central board called Calorimeter Read-Out Card (CROC) in charge of connecting the FEB to experiment control systems, both fast and slow. The CROC sends synchronously the LHCb 40 MHz clock to the FEB. For synchronisation purposes, programmable delays can be introduced into the clock at the level of the CROC: a coarse grain delay corresponding to an integer number of clock cycles and a fine grain one, in multiples of 104 ps. This clock is common to all FEB in the crate. Besides, each FEB can adjust the clock for each individual channel at the 0.1 ns level and define buffer memories to store the acquired data until all channels from the same bunch crossing (BX) are collected. The detail of the signal processing and the level at which those delays are introduced shall be described in the following section.
PS and SPD resort to processing the signal from the MAPMT in Very Front End boards (VFE) located close to the detector. Each VFE board is in charge of the 64 channels of a single MAPMT. The SPD bit decision is set on those VFE boards, while the PS VFE performs the analog processing. Data from VFE boards, PS and SPD, is then sent to PS FEB located in crates on the same racks as the XCAL ones. PS crates are also controlled by a CROC with the same synchronisation capabilities as the XCAL crate ones. Besides, SPD VFE boards are connected to the experiment control system by a set of Control Boards (CB) also located on those crates. The CB provides the system clock and the threshold levels to the SPD VFE. The PS VFE receive the system clock from their corresponding FEB by two different clock cables, one for every 32 channels. Both cables share the same clock delay, although differences in skew may result in 1 ns differences between them. The PS analog signal coming from the VFE is finally treated and digitised up to 10 bits and combined to the corresponding SPD bit to be sent through the trigger and data paths. Besides, CB and FEB can introduce delays with 1 ns steps into the clock signals feeding the VFE. This means that this clock defines the same start of the 25 ns integration time for the 64 channels of a given PMT.
This note describes the procedure for finding the values of the several delays available in the electronics to provide the best performance of the detector. As we shall see in the following section, signals extend over more than one clock period. For this reason, an essential feature in the LHCb data acquisition system is the possibility to record the signals from conscutive bunch crossings up to ±6 clock cycles around the trigger signal. Such working mode provides the so called Time Alignment Events (TAE).
We have sketched so far the process to acquire the signal produced by the incoming particles. Once the signal is digitised, it needs to be synchronised, first with all other signals acquired by the same FEB, and then, among FEB to produce the correct trigger signal agreeing with the stored data. The description of the trigger system and its synchronisation is beyond the scope of this paper, yet further details may be found in references [1,3,4].

Signal shape and time alignment principle
In order to meet the resolution specifications, the total energy measurement requires the integration of the signal. Even the SPD, due to its low photostatistics, shall integrate the signal before testing the MIP threshold. Therefore, the whole issue for the time aligment of the calorimeters consists, beyond the correct synchronisation of all channels so that all signals correspond to the same bunch crossing, in setting the correct integration time to obtain the desired accurate results.
The very first measurements already showed the signal shapes for all four subdetectors lasting about 50 to 60 ns, around twice the LHC clock period [2]. As an example, we show in figure 3 the signal recorded for an HCAL module at a testbeam. Such large spill over requires, beyond integration, further specific analog treatment.
We have adopted two main strategies to overcome the spill over problem. XCAL performs a clipping of the signal with a 5 ns delay to obtain a shape (10 ns FWHM) contained into one 25 ns period before its integration, while PS and SPD work on a dual channel basis, integrating alternatively on two subchannels and correcting then measurement by subtracting a fraction of the previous one. These strategies are different from the solutions adopted by other LHC detectors, such as ATLAS or CMS which sample the signal to perform a fully digital treatment afterwards [5,6]. In the following subsections, we shall proceed to study in further detail how these techniques are deployed.

Sources of time misalignment
Prior to going further in this study, we need to consider the fact that a fine synchronisation of the calorimeters has to take into account the tolerances and differences in a number of detector elements that may introduce inter-channel clock phase delays of several ns, enough to require considering each channel individually. We may group these into four main categories: optical fibers lenghts and structures, the time of flight of particles in the detector, the differences in the high voltage and cable lengths.
-5 - The optical fiber lengths affect differently XCAL from PS and SPD. Actually, all fibers in the XCAL detectors are of the same length with small enough tolerances, whereas in PS and SPD, the different cell sizes, groove characteristics and clear fiber lengths, introduce in fact differences among channels. More in detail, we may mention that, when a charged particle crosses a scintillator pad, photons are emitted with a decay time (τ=2.1 ns). Part of these photons are collected by the WLS fiber rolled inside the pad, introducing an additional decay time of around 9 ns [7]. Furthermore, as the fiber is rolled in 3.5 loops with a radius that depends on the scintillator size (17.5, 27, 54 mm for inner, middle and outer cells), the propagation time inside the scintillator and fiber can vary from 2.3 to 6.7 ns. The propagation speed inside the fiber is 5.8 ns/m. The length of the WLS fiber outside the pads is around 0.4-0.6 m. This implies an additional time of 2.3-3.5 ns. Afterwards, WLS fibers are coupled to clear fibers of lengths between 1.3-3.5 m, which are known but different for each VFE. With a propagation speed of 5.2 ns/m, the delays can vary from 6.7 to 18.2 ns.
From the detector structure point of view, we need also to consider the time of flight of particles in the detector. In the XCAL case, this time depends upon the angle between the particle trajectory and the beam axis which can be calculated for each channel. Differences are shown to be smaller than 2 ns. In the PS and SPD case, the detector thickness is small enough to make this effect negligible.
PMT are also a source of potential misalignment between channels. In effect, the signal transit time in the PMT depends on the value of the gain. In the case of XCAL, gain values may vary by a factor 10 while in the PS and SPD case, HV differences can get to 100 V. To estimate this delay, we may consider the motion of the photoelectrons from the photocathode to the anode to be driven by a constant electric field E. The field E is obtained from the high voltage V and the distance from the cathode to the anode, s, E = V /s. We shall assume that electrons are produced at basically speed zero, and the electron speed is non-relativistic. The acceleration of the electron is constant qV /m, being q the electron charge and m its mass. The time t to run over distance s is then Equation (3.1) still holds for the dynode structre by considering s to be an equivalent distance taking into account the voltage division structure. Again we would assume that electrons are extracted at zero speed and move non-relativistically. Finally, let us recall that the high voltage value is related to the gain G by an exponential relation Parameters α and β were measured and stored during the quality test checks and are known for every single PMT. For this reason, even an uniform gain setting may imply differences in the HV. This again translates into interchannel differences around 1 ns. Another potential source of misalignment between channels regards the clock distribution. In the case of XCAL front end boards, inside the crate, the clock is distributed on the backplane PCB by equal length strip lines, inducing less than 1 ns misalignment. In the PS and SPD case, the clock must be driven to the VFE boards. For the PS, all cables have the same length within a 5 cm tolerance but differences arise due to the twisting of the cable pairs. SPD cable lenghts are different for VFE laying on the top and the bottom of the detector. Laboratory measurements estimate a speed of 0.65 c so that we have an average of 46 ns difference for the travelling of the clock signal between VFE at top and bottom. Moreover, the twisting over the 30 m length of those cables combined to the signal speed, may account for differences of several ns.
In the case of PS and SPD, the signal processing is performed on the VFE boards, so no further effects have to be taken into account in the setting of the relative integration starting time. In the case of XCAL, however, the processing is made in the FEB so the signal cable also contributes to inter-channel time differences. The cable lengths tolerance between the PMT and the front-end cards is of 20 cm which tranlates into a potential 1 ns delay difference.
The study of the all these sources of time delay allows to make a theoretical prediction for an optimal setting of the clock phase, which may even take into account differences between channels coming from the PMT HV setting or the particle trajectory. Effects due to cable tolerances are, however, impossible to be considered, yet, moreover, this theoretical prediction may overlook some further effect. Anyhow, such a prediction shall be used to speed up the time alignment process by setting an initial educated guess, which avoids a systematic sweep over all possible values.

XCAL signal processing
As we have already mentioned, to avoid spill over, XCAL PMT pulses are shaped to remove the pulse tails in order to get signals fully contained in a 25 ns time interval and then integrated and digitised, using the electronic scheme in figure 4.
Pulses are sent to the FEB located in the rack above the calorimeters by a 10 to 15 meter coaxial cable. The first element in the FEB is the analog processing chip including a buffer and an integrator. In order to discharge the integrator the same pulse is subtracted after 25 ns, as sketched on the left side of figure 5.
-7 -  The results obtained for a 80 GeV hadron from simulation are shown on the right of figure 5. The spill over in the next 25 ns time interval is expected to be ∼ 3% with some fluctuations. This leakage has been tested in situ, measuring the collection from several 25 ns intervals, and gives for both ECAL and HCAL, a 4.2% of the signal in the next 25 ns interval and 1% at the preceding 25 ns interval. The impact is low in comparison to the intrinsic resolution of the calorimeters, as required.
Following the amplifier integrator, the pulse is digitized by a 12 bit-ADC. The signal is expected to be flat within 1% over ±2 ns around the maximum of the pulse. Since the different delays introduced may be an additional source of misalignment, the clock of each ADC can be adjusted at 1 ns precision by tuning a delay chip of 1 ns step with a range of 25 ns. In addition, pedestal variations due to electronics noise are corrected by subtracting the signal from the preceding time sample.

Time alignment principle
The result of the processing leaves a signal contained in the 25 ns of the clock period. The magnitude of the final output depends, of course, on the intial integration time, as shown in figure 6 where the expected fraction of energy for a given cell is plotted as a function the sampling time from Monte-Carlo data. Notice that the sampling of the integrated pulse can be changed in 1 ns units by the calorimeter electronics. The plot shows some plateau ( flat to < 1% ) for sampling time between ±3 ns second around the maximum.
If the system is well timed, we expect to see all the signal in the current bunch crossing and no contribution neither at the previous nor at the next one. It is however difficult to reach a good timing precision at the flat top since its variations are of the order of the signal fluctuations. Instead we shall benefit from the almost linear behaviour of the curve in figure 6 at the mid-height. From the initial timing, we shift the sampling time an amount dT 0 and we measure the amount of signal collected on one bunch crossing and the next one. We define a figure of merit which we call the asymmetry [8]: for two consecutive bunch crossings and for a given channel j, the asymmetry is set to be where E i j (current) is the energy collected on event i by channel j on the trigger bunch crossing while E i j (next) is the energy collected on event i by channel j on the bunch crossing following the trigger one. An equivalent quantity may be defined with respect to the previous bunch crossing. Remark the asymmetry is effectively defined on the average energy collected over a number of events. On figure 7 we see the asymmetry as a function of the sampling time displacement dT 0 defined for a generic channel j from Monte-Carlo data.
In effect, for a well timed system a displacement of around 12-13 ns should drive the asymmetry to zero with a linear behaviour nearby. On Monte-Carlo studies, in the region between 10 and 18 ns, is obtained when fitting the linear region. Naturally dT 0 sets the difference clock with respect to the correct sampling zero time. Around dT 0 = 12.5 ns a precision around 0.5 ns is expected to be achieved for each channel when 50 thousand events are registered over the whole calorimeter. The feasibility of such time alignment strategy is widely discussed in reference [8].
From this discussion, we infer the general procedure to set the correct sampling times for each cell of ECAL and HCAL. Once dT 0 is measured for all channels, the correct sampling time is set by subtracting it to the current time phase value.

Preshower signal and time alignment
As we have already mentionned, the signal of the preshower is integrated and buffered at the VFE level by a dual system of integrators alternatively charging and discharging, as depicted in figure 8. The analog signal is then sent through a pair of twisted cables, 27 meter long, to the FEB where the signal is digitized with a 10 bit ADC. A digital treatment is applied onto the converted signal consisting in pedestal subtraction, gain adjustment and spill over correction, called α correction. The latter relies on the measurement that about 15% of the signal collected during the 25 ns after a bunch crossing n arrives during the next 25 ns of BX n + 1. Finally the 10 bit data are coded into a 8 bit floating point format [2].
-10 - The VFE structure allows only to establish one single clock phase for one VFE, yet two clock cables arrive to the board, each one for a set of 32 channels. Although the phase should be the same, differences in the cable skew may account for delays smaller than 1 ns, as it was mentionned in the previous section. For this reason, we shall study the collected energy average over the 64 channels, depending on the start of the integration time. We obtain curve shapes which are similar to the XCAL ones, so the same strategy for the time alignment shall be adopted: displacing by an amount dT 0 PS the correctly timed system, we define the asymmetry R of a VFE board to be, where E(current) is the average signal on the VFE over a number of events in the triggered bunch crossing and E(next) the average signal in the consecutive bunch crossing. Simulated data were produced with the best knowledge of the signal shape, determined from lab and test beam data [7] in order to build up the asymmetry dependence upon the arrival time. Figure 9 displays the function as well as the fit of the linear part.
The linear behaviour of the asymmetry close to the zero value is fitted to be where dT 0 PS , expressed in ns, is the time displacement from the correctly timed system. The validity of the linear approximation definition is in the range [-19, 11] ns. This has been measured on data by varying the starting time of the integration by steps of 1 ns in TAE events. Actually, this fit holds, within the statistical error, for the three detector areas, inner, middle and outer. A similar procedure to the one applied to XCAL shall be used, namely, setting an initial timing estimated from a theoretical delay study, then a time displacement to study the asymmetry at a sensitive time position(see figure 9) and finally the estimation of dT 0 PS from the results. It is finally worth to remark that, despite the same delay applies to all channels in the same VFE board, the α correction allows to compensate interchannel misalignments, finally obtaining an individualised corrections for each single channel.

SPD signal and time aligment
The SPD VFE electronics, just as the PS one, integrates the PMT incoming signal using a dual integrator scheme and buffers the result to subtract a fraction of the previous bunch crossing signal. The result is compared to a programmable threshold and the resulting bit is sent to the PS FEB to be combined with the energy measurement of the PS. The electronics schematics for a single channel is shown in figure 10. The binary response of the SPD does not allow to compare the signal deposited in consecutive bunch crossings event per event. Instead, the information of the synchronization can be obtained by comparing occupancies -average number of hits per event -of two consecutive bunch crossings.
-12 - Figure 11. Asymmetries for an inner VFE as a function of dT 0 (left: current/next asymmetry; right: current/previous asymmetry). For 6k MC Minimum Bias events. This is done by means of an asymmetry, which is defined as: Asym (current/previous) = n(previous) − n(current) n(previous) + n(current) (3.6) where n(current) is the occupancy in the current bunch crossing and n(next) the occupancy in the previous one. Such asymmetries are computed per VFE. In a well aligned system Asym(current/previous) is expected to be −1. Besides having no signal at the previous bunch crossing, the criterion chosen for time alignment is having maximum efficiency at the current bunch crossing and little spill over at the following one.
A linear fit in the MC asymmetry for the SPD VFE, shows differences according to the detector area. For an inner VFE yields: Again, the strategy consists in setting pre-computed timing estimations, shifting the timing to be in the region with a linear behaviour of the asymmetry and, after collecting some data, establish the new correct timing. Further details can be found in reference [11].

Time alignment commissioning with cosmic rays
During the commissioning period, cosmic rays were used to perform consistency checks as well as an initial relative time alignment within the calorimeter subdetectors [8][9][10]. The flow of cosmic -13 -rays crossing the detector was estimated to be 0.9 Hz/m 2 under HCAL with an average energy of 50 GeV. First traces of cosmic rays were observed in December 2007, and were used extensively along 2008 and 2009 to test the detector performance.
Of course, to take full profit of cosmic rays measurement, special settings are required, in the detector as well as in the trigger system. For instance, cosmic events are asynchronous with the global LHC clock and therefore with the 40MHz LHCb clock. Also the detection involves trigger on a single Minimum Ionising particle. The calorimeter was working in standalone mode or eventually with the muon detectors and data were taken with ±3 consecutive bunches using the dedicated Time Alignement Event (TAE) format. Several million of events were recorded in successive campaigns in 2008 and 2009.
The cosmics data had mainly two uses regarding the time alignment of the detector. The first one was to set an internal time alignment for both ECAL and HCAL. The second one, to establish the relative time alignment of the SPD and the PS with respect to ECAL. This second purpose requires two conditions. The first one is that neither PS nor SPD should be included in the trigger for cosmics. The second one is that the cosmic ray trajectory has to be reconstructed in order to match properly the hit on the corresponding PS and SPD cells. We shall start this section explaining how the trigger and the trajectory reconstruction are performed and then the procedure for the interalignment of XCAL. Finally, we will show how PS and SPD are aligned in time with respect to ECAL.

Cosmic trigger and reconstruction
To perform the cosmic trigger, high voltage settings were adjusted to obtain uniform PMT gains, set to 2 · 10 5 for both ECAL and HCAL. With these settings, a minimum ionizing particle was expected to generate about 1000 photoelectrons for ECAL and 200 for HCAL. The trigger was established on the coincidence of an ECAL cluster (8 × 4 cells) with an HCAL cluster (2 × 2) both above a low threshold of 20 ADC counts. The observed rate was 10 Hz, in full agreement with the expected flow. As we have already said, PS and SPD were not used in the trigger and so were bias free in order to establish the relative time alignment with respect to ECAL and HCAL. Those results were used as initial setting for the first particle measurements.
Cosmic events were taken without magnetic field, so the trajectory was expected to be a straight line with a strong vertical component. By the detector structure, we would observe its projection onto the vertical plane. One part of this projection would correspond to the HCAL side and the other to the ECAL side.
We call φ the angle with respect to the vertical axis on the projection plane. For each subdetector, ECAL and HCAL, we call (x 0 , y 0 ) the coordinates of the highest energy cell, (x i , y i ), the coordinates of cell i, E i the signal collected by cell i in terms of ADC counts, and d i = (x i − x 0 ) 2 + (y i − y 0 ) 2 the distance from cell i to cell 0, we define, and CellSize i is the size of cell i. Our algorithm requires at least signal on 3 cells for HCAL and on 4 for ECAL. Once a first estimation of the angle is established, we spot outlier cells to eliminate them. We proceed then to -14 - evaluate the center of gravity of the signal (x XCAL , y XCAL ) and recompute angles with respect to this center of gravity. We have, while w i has the same definition above, but with respect, now to the center of gravity.
To test the consistency of the result, we also define a common ECAL-HCAL angle, Finally we define a variable χ 2 σ XCAL stands for the uncertainty in the calculation of φ XCAL while, σ is the uncertainty for φ . Traces are kept whenever χ 2 < 15. The φ determined for cosmic impacts in ECAL and HCAL is displayed on figure 12. The peak around π/2 corresponds to the case where the χ 2 value is larger than 15.
With the information of angle φ and the position of center of mass of the depositions in ECAL and HCAL we can reconstruct the cosmic ray trajectory and extrapolate it, in particular towards PS, SPD and the tracking system for time alignment purposes, yet the latter lays beyond the scope of this paper.

Timing determination for ECAL and HCAL
The clipping of the signal described in the previous sections ensures a duration within the 25 ns interval fitting so in two consecutive clock cycles. For all cells fired, we define the asymmetry r j -15 -2012 JINST 7 P08020 Figure 13. Distribution of the time dt of clusters in the ECAL and HCAL. as in equation (3.2). For this analysis we keep the cells for which the sum of ADC counts on 3 consecutive time interval exceed 100 (ECAL) and 20 (HCAL). From this, the average asymmetry is defined as where N is the numbers of cell in the cluster.
The expected distribution of the asymmetry over time would correspond to the Monte-Carlo simulation shown in figure 7. By using the linear approximation in the central value region |R| < 0.8, corresponding to delay values from 5 to 18 ns, we may extract a temptative average delay dt with respect to the LHCb clock, which is shown in figure 13. This figures have then to be corrected for the corresponding high voltage contribution. By subtracting the average delay, we set the relative aligment of all the cells in the cluster. By cumulating statistics, a given cell will form clusters with all its surrounding cells, and will get the relative alignment with its neighbourgs. The local alignment shall propagate to reach the full detector.
To check the quality of the alignment, we may look at the internal time alignment dispersion in ECAL and HCAL is estimated measuring for each selected event: for N selected events. Figure 14 shows the RMS distribution of the estimated time delays, corrected for the high voltage contribution for both ECAL and HCAL. Almost 50% of the cosmic events fulfill the timing selection for HCAL and ECAL. In terms of time alignment precision, the width of the distributions correspond respectively to 0.28 ns for ECAL and 0.58 ns for HCAL. This difference may be accounted on the larger length of the HCAL module.

Timing PS and SPD with cosmic events
As the cosmic trigger was based on the signal on ECAL and HCAL, PreShower and SPD may be synchronised relatively to ECAL. For this, we use the information on the reconstructed track described before and we require it to point towards the active cells in the PS and SPD. Regarding the PreShower, the statistics per channel is limited, at least for middle and inner regions, so cosmic candidates are summed up for each VFE board, in which the time difference between channels is expected to be small. By computing the corresponding asymmetry we derive from it the corresponding time corrections for each cell. Figure 15 shows for the outer region the time difference between ECAL and PreShower detectors. A relative inter-alignment at the level of 1 to 2 ns is achieved.
One channel in the figure 15 significantly departs from zero. It was actually tracked down to be due to an inconsistent value in the database of the measured length of the fibre bundle. This shows how cosmics data helped to give confidence in our understanding of the apparatus.
Similarly, by extrapolating the tracks to the SPD plane, we are able to set the asymetries, yet taking into account the need to average upon VFE boards over the largest possible number of events, as the SPD output is binary. The appropriate time corrections were applied onto each track, depending of the particle direction and its covered distance. Figure 16 shows the distribution of the relative misalignment of the SPD cells.
Larger error bars correspond to middle and inner cells which have less statistics.

Time alignement with LHC collisions
The first LHC proton-proton collisions at √ s =900 GeV were held in November 23rd, 2009. The SPD multiplicity (>2) was used as Minimum Bias trigger in coincidence with a HCAL candidate, with a rate of collisions of few Hz. Next, on March 30th, 2010, the first proton-proton collisions at √ s =7 TeV took place. Since these first LHC collisions, a systematic work on the timing has been carried on for each of the four sub-detectors. We first aimed at adjusting the timing of each individual cell or VFE board to find the optimal operation point. Subsequently, we have proceeded -17 -  to systematic periodic checks of the set values. The individual cells timing is done with dedicated runs where part of the detector is time-shifted so that the signals shared by consecutive LHC clock time intervals give a relative timing for each cell making an extensive use of the TAE mode of data acquisition.

Time alignment for ECAL and HCAL
On the first collisions, in order to adjust the timing for each channel, the following procedure was exercised.
For each cell, the expected delays from the photomultiplier and the cell position were computed. Regarding the PMT correction, it is related to the actual value of the HV, which covers a range up to a factor 10 in gain. The cell position delay comes from the azimutal angle with respect to the beam axis and corresponds to the longer flight trajectory of particles. These two corrections are shown in figure 17 for both ECAL and HCAL.
We proceeded next to determine the relative delay of each channel. For this, several minimum bias events runs were taken to determine the timing where the signal is equally shared by 2 consecutives LHC clock intervals of 25 ns. This process used the above mentionned corrections as starting point and was to determine a global shift from the correct timing of roughly 12.5 ns. With this assumption, timings were set to record data from four different points, approximately 10.5, 11.5, 12.5, 13.5 and 14.5 ns and compute the asymmetry of each channel. Actually we evaluated -19 - for HCAL. These values differ from Monte-Carlo studies by 20% , indicating that the theoretical signal shape is slightly different from data. As shown on figure 19, before the cell to cell adjustment, a good linearity is observed as well as a dispersion of repectively of 1.7% and 0.4% for ECAL and HCAL. These dependences of the measured asymmetry are used to calculate the corrections for the channel misalignement.
Results are coherent with cosmics observations: the channel to channel fluctuation was below 3 ns. The cell to cell adjustment is also plotted in figure 17, toghether with the precalculated contributions to the timing. We observe a dispersion of 1.7 ns for ECAL and 2.1 ns for HCAL.
Once the timing adjustment is achieved, several tests are made to control the time alignment quality.
• Data are taken with displaced timings to check the internal time alignment inside a crate or a FEB.
• Data are taken with and without magnetic field and displaced vertex to estimate the shift coming from the magnet bending.
-20 - Figure 19. Asymmetry as a function of the delayed timing in tenth of nanosecond unit. The distribution shows a good linearity in the ±2 ns interval.
• Data are taken to test the signal shape estimating the leakage in the adjacent time interval and the stability of the signal in the ±4 ns interval in order to determine the optimal timing setting corresponding to a stable signal: this enforces the calibration stability.
For instance, figure 20 shows the asymmetry distribution for all channels inside one of the ECAL crates. This plot is obtained by shifting the full crate by 12.5 ns from the computed correct timing. The asymmetry is determined with an average accuracy of 0.2 ns, the distribution shows a 1.8 ns width with a 0.5 ns shift, coherent with the timing shift. Figure 21 displays on the left the resulting timings for the different front-end board of a crate while on the right, we have the relative timing of all crates of both ECAL and HCAL, showing a dispersion below 0.5 ns .
Besides, data are taken regularly with half detector timing shifted by 12.5 ns to check the timing stability. Changes of a whole crate of 1 to 2 ns have been observed (figure 22) and monitored during data taking. The timing setting has to be sufficiently robust to face these changes.
Once the relative interalingment between cells has been established, the overall time settings have to be set back to have the largest part of the signal into the current bunch crossing. This is equivalent to moving the clock to an amount around 12-13 ns, but, due to the signal spill over, a fine tuning is required to obtain the best performance.
Two studies are conducted to determine the optimal timing operation point for ECAL and HCAL.
• Study the stability as a function of the time delay of the recorded electromagnetic energy triggered by a high energy deposition in the PS at fixed timing. A scan is done for ±4 ns in steps of 1 ns. In figure 23 (left) is displayed the ECAL inner part response from −2 ns to -21 -  +2 ns. In figure 23 (right) the mean response as a function of the timing scan is shown: a plateau of 4 ns is observed . The optimal point is set to +1 ns.
• In parallel the fraction of energy deposited in the central bunch crossing of 3 consecutive bunches is studied as a function of the tie delay setting. From these measurements, we define the quantity where current, prev and next refer to the reading of the FEB ADC counters on the triggered bunch crossing, the previous one and the next one, respectively.  cal channel is shown, while on figure 24 (right), the above quantity is plotted as a function of the time delay: the FC stays constant within 1% in the [−1, +2] ns interval. Again the conclusion is to set the optimal operation point to 1 ns .

Time alignment for PS and SPD
In order to time the PreShower channels, two dedicated runs were taken in time alignment mode. A soft pedestal correction using previous BX data was applied to actual signal. Besides, channels with large signals were cut off to reduce biases on asymmetry and charge shape distribution. We considered FEBs with more than one hit per channel, of which we found 83 of them. By taking t = 0 at the nominal settings previously estimated, we built the average asymmetry curve as well as the average charge shape as a function of the integration start time. The asymmetry slope distribution over valid FEB is shown in figure 25. The result, ∆ = −0.106 ± 0.006/ √ 82 ns −1 , is in good agreement with the Monte-Carlo value ∆ = −0.11 ns −1 . The shape of the cumulated charge over time proves to be slightly different depending on the pad size, as seen in figure 26. T 30 is defined to be the time for 30% signal and is taken as signal arrival time in the inner region. This allows to perform a correction according to the signal shape, to be added to the one coming from the time of flight. From this analysis, we concluded that the interalingment of FEBs within a crate was satisfactory within 1 ns.
For the timing scans of the SPD, the threshold was set at 0.5 MIP based on a coarse precalibration. A scan was done for each of the two detector sides separately. A total of 11 (12) steps were taken for the A (C) side respectively, separated by two or three ns, with 4 k events per step. Figure 27 shows two examples of occupancy curves and fitted asymmetries. One corresponds to a VFE of the outer region with low occupancy and the other one to a VFE of the middle region with high occupancy. Vertical lines correspond to the delays accomplishing the synchronization criterion mentioned above, which are obtained from the fit.
The corrections measured per VFE are in figure 28. Globally, the SPD was integrating about 3.7 ns late with respect to the arrival of the particles from the collisions. The standard deviation (rms) of delays was 1.1 ns and all VFE were mostly within ±2 ns. From the required modification of the delays, −3 ns (horizontal line drawn in figure 28) were corrected by adjusting the fine -24 -2012 JINST 7 P08020  delay of the CROC of all PS crates and the remaining delays modified in the SPD VFEs, with an estimated precision of half ns. Figure 29 shows the fraction of events with signal in Prev1 with respect the collisions bunch crossing, T0, per VFE. A clear improvement is achieved with a significant reduction of signal at the previous bunch crossing. The same fractions for Next1 are shown in figure 30. Note that spill-over is higher for VFEs of the outer region, as expected from the contribution of slow secondaries or decay products bent by the magnetic field and backsplash produced in the material of ECAL and HCAL.
For PS and SPD, a scan is made in order to fix the working point for which a 2% of the signal is seen in the previous BX id, which corresponds to obtaining the maximum part of the signal for the current BX id, as it was established in the preliminary studies on the detector [7]. In the case of the SPD this is naturally done by averaging over a large number of events to obtain a ratio.
As for ECAL and HCAL, periodic enforcements of this algorithm are performed to check the current values of the time alignment settings.
-26 -2012 JINST 7 P08020   designed to adjust the system clock up to 1 ns for every single channel. In order to devise the time alignment procedure one had to consider elements such as the shaping of the signal due to spill over. However, thanks to the LHCb DAQ system capability to store the data of several consecutive clock cycles around the trigger signal, we could measure the deposited energy over consecutive clock periods. Combining these elements, the asymmetry between these amounts of deposited energy was defined and parametrised as a function of the starting integration time. With this, the optimal integration time could be defined to the electronics precision.

Conclusions
The asymmetry method was successfully applied at commissioning time using data from cosmic rays to perform a relative time alignement and then was definitively applied using the first particles in the beam. Its performance meets the precision requirements and is currently used for the detector synchronisation with a 1 ns precision.
It should also be mentionned that the asymmetry method, originally devised for XCAL, could be adapted also for the PreShower, in which data channels come together in groups of 64 and also to the SPD which not only groups data channels but also has binary input.