## 2 Methods
### Analog to Photon-Counting Signal Gluing
#### 2.3.1 \(\chi^{2}\)-Based Gluing
The gain \(g\) and an additional possible offset \(O\) are then free fit parameters that minimize:  
\[\chi_{j,n}^{2}=\sum_{i=j}^{j+n}\frac{\left(\mathcal{R}_{i,\text{chi2}}- \mathcal{R}^{\prime}_{i,\text{chi2}}\right)^{2}}{s_{UL,L}^{2}(\mathcal{R}_{i, \text{chi2}})+s^{2}(\mathcal{R}^{\prime}_{i,\text{chi2}})-f_{s}^{2}/N_{sh} \cdot(A_{i,\text{obs}}-A_{b}+g\mathcal{R}_{b})/g}\quad, \tag{17}\]  
where \(j\) denotes the starting range index of a fit window and \(n\) is the window length. Note that the correlated part of both the AN and PC variances has been subtracted from the denominator of Equation (17) and \(s_{U}^{2}(\mathcal{R}_{i,\text{chi2}})\) is chosen when \(\mathcal{R}_{i,\text{chi2}}>\mathcal{R}^{\prime}_{i,\text{chi2}}\), otherwise \(s_{L}^{2}(\mathcal{R}_{i,\text{chi2}})\) is used. Since Equation (12) is only valid if \(\mathcal{R}_{i,\text{obs}}<1/\tau\), a minimum value for \(j\) is obtained immediately, apart from possibly excluded ranges affected by clouds. We chose as a starting condition \(\mathcal{R}_{i,\text{obs}}<1/(3\tau)\), to be on the safe side. At the same time, any saturated signal \(A_{i,\text{obs}}^{\text{sat}}\) must be removed from the gluing procedure. Note that by construction, the fit offset \(O\) should come out within a few standard deviations \(s_{A_{b}}\) of zero. We have restricted the minimizer to vary within \(\pm 10\,s_{A_{b}}\). Similarly, the PC efficiency \(\epsilon\) was previously fixed to 0.9 (see also the results from the next Section 2.3.2). The core idea is to find a range and location in the indices (a window) that provide a stable solution for the fit parameters \(g\) and \(O\), and a \(\chi^{2}/(n-2)\sim 1\). The algorithm then slides through the data samples in windows of width \(n\), until \(\mathcal{R}_{j+n,\text{obs}}<s_{\mathcal{R}_{b}}\). For each window, Equation (17) is minimized with respect to the parameters \(g,O\). We selected five test windows \(n\), logarithmically spaced between ranges \(\Delta r(n)=3000\) m and \(\Delta r(n)=30,000\) m. These values can be dynamically selected from a configuration file, though, for each channel separately. For each \(\Delta r\), the algorithm starts keeping track of how many valid points fall within each window. The algorithm then identifies the closest starting index \(j\) and iterates through the data while checking whether both the photon-counting and amplitude signals lie above their predefined minimum thresholds: \(\mathcal{R}_{i,\text{obs}}>\Delta\mathcal{R}_{b}\) and \(A_{i,\text{obs}}>4s_{A_{b}}\). If both conditions are met, the window is extended until the \(\Delta r\) has been reached. After finding all indices within a given window \(\Delta r\) that meet these criteria, they are stored as a series of valid intervals for each test window size. The algorithm parallelizes the processing of each \(\Delta r\) gluing window size, taking advantage of Python3's multiprocessing module, which allows it to spread the work over multiple CPU cores. The parallelization is achieved using the following steps:Identify the maximum range and prepare the data: the last index within the valid gluing range is stored; this sets the upper bound for processing. Then, the gluing window sizes are divided into batches of window sizes. Each batch contains one \(\Delta r\) value for sequential processing, with each batch running in parallel. 2. Create a pool of processes: the multiprocessing pool is initialized with the number of CPU cores available, allowing the algorithm to utilize all processing resources effectively. The batches are created as tuples of \(\Delta r\) values and the corresponding channel ID, then these are the input for each parallel process. 3. Parallel execution: the pool distributes the batches across the CPU cores, calling the batch process function for each batch. This function iterates over each \(\Delta r\) in the batch and executes the minimization of the \(\chi^{2}\), Equation (17). This setup allows each core to handle a different \(\Delta r\) in parallel, greatly speeding up the computation. 4.