GRAAL: A novel package to reconstruct data of triple-GEM detectors

Micro-Pattern Gas Detectors (MPGDs) are the new frontier among the gas tracking systems. Among them, the triple Gas Electron Multiplier (triple-GEM) detectors are widely used. In particular, cylindrical triple-GEM (CGEM) detectors can be used as inner tracking devices in high energy physics experiments. In this contribution, a new offline software called GRAAL (Gem Reconstruction And Analysis Library) is presented: digitization, reconstruction, alignment algorithms and analysis of the data collected with APV-25 and TIGER ASICs are reported. An innovative cluster reconstruction method based on charge centroid, micro-TPC and their merge is discussed, and the detector performance evaluated experimentally for both planar triple-GEM and CGEM prototypes.


Introduction
GRAAL 1 is a code developed to face the need for fast and consistent analysis of the studied gas detectors in a long testbeam campaign. The software is a C++ object-oriented code that exploits the ROOT [1] libraries for Input/Output, fitting and plotting. The code is hosted in Gitlab at the following link: https://github.com/Hilldar/GRAAL.git.

Code workflow
The aim of the code, named GRAAL, is to provide an automatic analysis of the triple-GEM detector and the used setup in each of the different tested conditions, taking into account a large variability of the input parameters with dedicated algorithms for each conditions. The code is divided in two parts.
The first part of the code extracts the information needed by the reconstruction, i.e. charge of the collected signal and its arrival time; it merges these with the geometry information to associate a spatial coordinate to each firing strip, then it measures the position of the charged particle interacting with the detector. There the objects hit and cluster are created and saved in collection for the further analysis.
The second part of the code combines the position of each detector to reconstruct the ionizing particle path. This allows to measure the residual distribution on each detector with respect to the track, then in the third part the performance: e.g. total charge, number of readout fired channels, spatial resolution, time resolution, efficiency, etc. These information are stored in the class detector. A block diagram shows the code flow in Fig. 1.
The setup used minimizes the systematic contributions to the spatial resolution with at least two detectors under test and an external tracking system. The two test detectors have to be as close as possible. An example of the setup is shown in Fig. 1. Each part of the code produces at the end distributions to monitor the goodness of the reconstruction. These distributions are used to determine selection criteria in the analysis in order to remove any dependency on the different triple-GEM conditions.

Detector and testbeam setup
The Gas Electron Multiplier (GEM) technology [2] has been invented in 1997 by F. Sauli to amplify the primary ionization signal from charged particles interacting with a gas medium. The GEM is composed by a thin copper-coated kapton foil with holes of 50 µm diameter on its surface. A voltage difference of a few hundreds of Volts between the two GEM faces generates an intense electric field in the GEM hole. Electrons entering in the hole are accelerated and they gain enough kinetic energy to ionize the gas. To optimize the collection of the primary electrons inside the GEM hole and the readout of the signal, the GEM foil is placed within an anode and a cathode. The used anode is segmented in strips and it is readout by APV-25 or TIGER electronics [3,4]. Multiple amplification stages allow to generate a signal of about 100 fC, keeping the number of discharges small [5]. The full design of a triple-GEM comprises a cathode, three GEM foils and an anode. The volume between the cathode and the first GEM is labelled drift gap. The innovations of the triple-GEM detector consist in a performing spatial resolution with high gain and low discharge probability.
Several testbeam experiments have been performed at CERN and MAMI [6] facilities to characterize the technology and its performance in different conditions: inclined tracks, magnetic field, cylindrical detector surface. The reconstruction of the detector signal and the full event in the tested setup, then its analysis, has been performed with a dedicated software package. The code is used to reconstruct the data in each detector, then the ionizing particle path through the entire setup. This information is used to evaluate the performance of each detector and to align it with respect to the other parts of the used setup.

Hit digitization
Each time a particle interacts with a triple-GEM, an electron avalanche is generated and collected on the readout plane. The induced charge is split between several strips and collected by the electronics. Two readout types have been used in the testbeam experiments, with different techniques to measure charge and time: APV-25 [3] and the TIGER [4]. The APV-25 is a commercial chip that samples the charge each 25 ns for 27 times after the trigger signal. The TIGER performs analogue measurement of charge and time together with a fully digital output. The electronics is one of the contributions to the detector performance studied by GRAAL: it contributes to the sensitivity of the detector, charge and time resolution together with the electronic noise. The input data format depends on the electronics. Generally, a ROOT file is generated for each run and a collection of hits is generated for each ionizing particle. The raw hit contains the information on the charge, the time, the ID of the electronic channel and the ID of the chip.
While TIGER can provide charge and time measurements for each channel, labelled as hit, the signal recorded by APV-25 needs to be converted to the measurements of interest: the charge is given by the largest bin among the sampled values, Q hit = Q max , and the time  is extracted from a fit of Fermi-Dirac (FD) function on the rising edge. This fit requires a pre-analysis of the setup to determine the noise contribution to the collected charge (offset) and the time delay of the detector with respect to the trigger system (shift). An example is shown in Fig. 2, while the function is shown in Eq. 1, where Q 0 is the offset given by the noise, Q max is the highest value of the collected charge, t FD is the time in the middle of the rising edge and this is labelled as t hit and σ FD is the width of the rise up. The fit is performed by TMinuit ROOT class.

Time reference
The time measured by the electronics is the time interval between the trigger start signal and the induction of the current on the strips by the electron motion. The average time needed by each electron to drift from the first GEM to the anode is assumed to be the same. The spread in the time distribution is due to the different initial positions of the primary electrons. A fit with a double FD function on the time distribution shown in Fig. 2 extracts two parameters: the rising edge time, related to the time needed by the closest electron to the anode to drift from the first GEM; the falling edge time, related to the primary electron generated closest to the cathode. Every time measurement of the hits has to be related to the rising edge time measured by the time distribution to apply the reconstruction algorithm based on the time as described in Sec. 3: where t 0 is the time reference described in Fig. 2. Different configuration settings, e.g. channel threshold, electronics chip, electric field used, etc, may affect the time distribution by few nanoseconds therefore a time reference is measured in each detector for each configuration.

Hit clusterization
Contiguous hits are considered together to create a cluster. The cluster contains all the charge coming from the signal and it is used to perform a precise spatial measurement. Starting from the position of each hit, x hit 2 , the cluster uses the charge and time information to apply two reconstruction methods: the charge centroid (CC) and the µTPC. The CC uses the charge collected by each hit to weight its position and compute a weighted average, while the µTPC uses the time information t hit and it associates to each strip a bi-dimensional point (x hit ,z hit ) 3 . The distance z hit is the distance travelled by the electron avalanche in the drift gap and it is measured as: z hit = t hit · v dri f t , where v dri f t is the electron drift velocity in the drift gap calculated with simulation [7]. Several µTPC points are used together to reconstruct the particle path in the drift gap by a linear fit. In Eq. 3 the formulas to obtain the position by the two reconstruction methods are described: where a and b are the parameters of the fitting line and gap is the drift gap thickness.

Merging procedure
The two algorithms, CC and µTPC, reach the best performance in different beam configurations. Without magnetic field the CC is efficient if the incident track is orthogonal to the detector surface, while the µTPC gives the best results for inclined tracks. If the magnetic field is present then the CC is used in the focusing configuration 4 and the µTPC in the defocusing configuration. The best performance of the two algorithms are reached under different conditions, thus a stable spatial resolution can be achieved by merging the results of results of both the methods. 2 the position is defined with respect to the middle of the strip and orthogonal to the strip length 3 The z direction is parallel to the electron drift direction, while x and y are orthogonal 4 incident angle coincident with the Lorentz angle of the electron drift A merging procedure has been developed to average properly the positions with the Eq. 4. The weights of this average have been extracted with a data-driven study and two different methods: a first one using the cluster size information because the CC is more efficient for small cluster size; a second one that uses the incident angle information from the tracking system.
where w cc is the weight associated to the CC and ∆ cc is the constant shift between CC and µTPC.

Tracking system
Once the clusterization is completed, the positions from the trackers are used to perform a linear fit and measure the ionizing particle path through the entire setup. This information, together with the setup geometry, is used to estimate the interaction point of the track on each detector plane under test: x expected . The position measured by the test detector, x detector , is compared with x expected and the residual is measured as shown in Eq. 5.
The residual distribution ∆x trackers is fitted with a Gaussian function and its mean value is used in the alignment procedure. The sigma of the Gaussian is related to the spatial resolution of the test detector but it contains the contribution of the tracking system. To remove easily the contribution of the trackers the residual distribution of the two test detectors, ∆x 1,2 , is used. See Eq. 6. ∆x 1,2 = x detector,1 − x detector,2 The procedure to extract the spatial resolution will be explained in Sect. 6.

Alignment procedure for planar detector
The readout provides the bi-dimensional measurement of the passage of the particle in the setup, used in the reconstruction algorithms. It is however necessary to feed the code with the description of the geometry to properly compute the points of the interaction of the particle on the detector planes, e.g. the position of the detectors along the beam, their rotation angle, their height with respect to the floor, etc. The detector readout provides a bi-dimensional reconstruction of the setup, the full information is given by its geometry implementation in the code, e.g. the position along the beam line. The mechanical tolerance of the setup and possible errors in the measurements have to be taken into account: the position reconstructed in the code and the real one might be different and this mismatch must be removed by software. Sometime within the same testbeam experiment, the setup may change, then an automatic alignment algorithm is needed to reconstruct a large data sample with different correction values.
The alignment procedure implemented in GRAAL is applied to trackers and test detectors, one by one, until the error on the alignment is smaller than the tolerance. There are three different kinds of effect that have to be considered: shift, rotation and tilt, world reference w.r.t. the setup reference. Fig 3 shows an example of variables used in the alignment and the effects of the alignment on them.
The shift are evaluated in the one-dimension space from the mean value of the ∆x trackers : a translation of the detector is applied in order to have a mean value around zero. This procedure is applied both for x and y coordinates.
The tilts of the detector are evaluated by bi-dimensional plots: if a correlation of the ∆x trackers distribution and the y detector is present, then the parameters of the linear fit are used to rotate the detector in the XY plane.
The last step of alignment takes care of the beam direction and constrain the setup to a unique reference frame: the first detector on the beam line is centered in (0,0,0) and the beam direction reconstructed by the tracking system is shifted to the real beam direction, e.g. orthogonal beam as shown in Fig. 3, through a rotation of the full setup of the same angle. Figure 3: Plot used in the automatic alignment procedure for one view of one detector in the setup. On the top part the distributions are shown the distribution 1D and 2D before the alignment, on the bottom after the alignment. On the left side is shown the distribution of ∆x trackers related to the shift alignment, in the middle the distribution of ∆x trackers :y detector used to removed the XY rotation, on the right the reconstructed angle of the ionizing track with respect to the tracking system. After the alignment the ∆x trackers has to be centered in zero and it must not depend on the y detector . Similar plot are produced for the Y coordinate too.

Alignment procedure for a cylindrical detector
An innovation introduced by triple-GEM technology is the chance to construct a detector with a non-planar geometry. An example is the cylindrical-GEM (CGEM) detector that will be used as inner tracker in the BESIII experiment [8]. A testbeam experiment with this kind of detector has been performed and the data have been reconstructed with GRAAL. In order to align the CGEM to the trackers, different variables have been considered. The cylindrical surface provides two different set of measurement: XY coordinate in the reference system of the trackers, φV 5 in its reference frame. These allow to measure the alignment of the cylinder axis and the rotation needed by the cylinder in the φ direction. Similarly to the shift correction described in Sec. 4.1, the residual distribution of the X coordinate and the one of the Y coordinate are used to measure the shift of the cylinder axis, while the residual distribution of the φ coordinate returns information of the cylinder rotation around its axis.

Detector analysis
The detector performance is measured after the alignment using events with a good tracking reconstruction: events in which all trackers are fired, and with a residual position within 5σ of the residual distribution. This selection allows to reject the events with multiple scattering or other bad configurations. The spatial resolution of the test detector is measured using the ∆x 1,2 distribution: a Gaussian fit is used to extract the sigma of the distribution σ residual , then the spatial resolution of the system given by the two test detectors σ detector . If the two are identical detectors with the same configuration and performance then it is possible to extract the spatial resolution from Eq. 7.
This removes easily the systematic contribution to the spatial resolution. If ∆x trackers would be used, then σ 2 residual = σ 2 detector + σ 2 trackers and the contribution of the tracking system would be more complicated to evaluate since σ trackers is difficult to evaluate with the needed precision.
The number of events with a good reconstruction N epsilon is defined as the number of events within 5σ in ∆x 1,2 distribution. This number, compared to the total number of events with a good track reconstructed by the tracking system, D , allows to measure the efficiency of the two test detectors. As assumed in the σ detector calculation, if the two detectors have the same configurations then the efficiency is measured as described in Eq. 8.
The clusters belonging to this selection can be used later to characterize the signal reconstruction of the test detector, i.e. cluster charge and cluster size.

Conclusion
The testbeam data with triple-GEM, and more generally with MPGD technologies, can be reconstructed and the performance can be extracted in general testbeam experiments sharing certain conditions on the tracking system and the test detectors. The algorithm allows to have an efficient and automatic analysis as a function of several configurations: electromagnetic field applied, gas mixture fluxed, misalignment or changes of the detector positions, detector geometry and electronic settings. The results extracted with GRAAL have been published in several articles with triple-GEM detectors and other MPGD [9][10][11].