Software compensation in particle flow reconstruction

The particle flow approach to calorimetry benefits from highly granular calorimeters and sophisticated software algorithms in order to reconstruct and identify individual particles in complex event topologies. The high spatial granularity, together with analogue energy information, can be further exploited in software compensation. In this approach, the local energy density is used to discriminate electromagnetic and purely hadronic sub-showers within hadron showers in the detector to improve the energy resolution for single particles by correcting for the intrinsic non-compensation of the calorimeter system. This improvement in the single particle energy resolution also results in a better overall jet energy resolution by improving the energy measurement of identified neutral hadrons and improvements in the pattern recognition stage by a more accurate matching of calorimeter energies to tracker measurements. This paper describes the software compensation technique and its implementation in particle flow reconstruction with the Pandora Particle Flow Algorithm (PandoraPFA). The impact of software compensation on the choice of optimal transverse granularity for the analogue hadronic calorimeter option of the International Large Detector (ILD) concept is also discussed.


Introduction
Particle flow event reconstruction [1][2][3] is one of the main drivers for the design of detector concepts at future energyfrontier e + e − colliders. In combination with highly granular calorimeter systems, this technique enables the precise reconstruction of multi-jet final states, which are of high relevance to TeV-scale physics. A particular goal of the detector designs for future linear colliders is the capability to separate W and Z bosons in hadronic decays. A separation of 2.3-2.6 σ is a e-mail: huong.lan.tran@desy.de achievable with a jet energy resolution of 3-4 % over a wide range of jet energies [3]. Such resolutions cannot be achieved with the traditional calorimetric approach where all the jet components are exclusively measured in the electromagnetic and hadronic calorimeters (ECAL/HCAL).
Particle flow algorithms make optimal use of all measurements of particles within a jet in the different subsystems of the experiment. For charged hadrons, which on average carry 60% of the total energy, the most precise measurement is typically obtained in the tracker. Photons, accounting on average for 30% of the total jet energy, and neutral hadrons with an average of around 10% are only measured in the calorimeters. The optimal combination of all energy measurements has thus the potential to significantly reduce the impact of the intrinsically limited hadronic energy resolution of calorimeter systems in collider detectors.

Detector systems designed for particle flow
A key ingredient for the success of particle flow reconstruction is the capability to correctly match reconstructed tracks with calorimeter clusters to avoid missing or double counting energy. Detector designs optimised for particle flow thus feature highly granular calorimeters, a tracker providing good momentum resolution with low material budget and a high magnetic field. The tracker and the calorimeters are located inside the magnet coil to avoid extended uninstrumented regions which would deteriorate the capability to associate different energy depositions of the same particle.
All detector concepts proposed for possible future linear colliders such as ILC or CLIC are based on the particle flow approach. They differ somewhat in overall size and magnetic field, and in the choice of the tracking system technology, but the proposed calorimeter systems are very similar. One example of a detector concept which fulfils this requirement is the International Large Detector (ILD) [4] for the International Linear Collider [5]. It uses a hybrid tracking system consisting of a large-volume gaseous Time Projection Chamber (TPC) tracking detector surrounded by silicon tracking layers and inner silicon strip and pixel detectors which together provide an excellent momentum resolution.
The electromagnetic and hadronic calorimeters in ILD as considered here have high longitudinal and transverse segmentation and are based on the silicon-tungsten ECAL [6] and on the scintillator-steel analogue HCAL [7] developed in the CALICE collaboration. The ECAL is composed of 30 layers with tungsten absorber and 5 × 5 mm 2 silicon cells. The tungsten absorber is ideal for the ECAL: it has a short radiation length and a small Molière radius which leads to compact electromagnetic showers, while featuring a large ratio of λ I /X 0 , which allows the ECAL to be almost "transparent" to hadrons. The first 20 ECAL layers have 2.1 mm thick tungsten absorber plates while the last 10 layers have 4.2 mm thick tungsten absorber plates. In total, the ECAL corresponds to 23 radiation lengths (X 0 ) and 0.8 nuclear interaction lengths (λ I ). For the HCAL the absorber material is stainless steel with a thickness of 20 mm per layer. The active elements consist of 3 mm thick 3 × 3 cm 2 plastic scintillator tiles directly read out with embedded Silicon Photomultipliers (SiPMs). The HCAL has a 48 layers, with a total thickness of 6λ I . In addition to the technology choices outlined above, also scintillator/SiPM active elements and semi-digital RPCbased detectors are considered for the ECAL and the HCAL, respectively. These options are not included in the present study.

Detector optimisation with PandoraPFA
Together with the detector design, the reconstruction software also plays a central role. The Pandora Particle Flow Algorithm (PandoraPFA) is the most widely used algorithm for detector benchmark and performance studies for future linear colliders. PandoraPFA was first introduced in 2009 [3] and since then has been continuously maintained and improved. The tool provides a sophisticated pattern recognition for individual particle identification while remaining independent of the detector implementation [8]. Individual particles are reconstructed as so-called Particle Flow Objects (PFOs), combining the information obtained from different sub-detectors. The two-shower separation in the calorimeters, a key performance driver of the algorithm, has been studied both in simulations and on CALICE data [9], finding good agreement with little dependence on the precise shower physics model and giving confidence in the simulation studies used to develop and evaluate the algorithm in a collider detector setting.
PandoraPFA has been used to optimise the ILD detector design. For the optimisation of the calorimeters, the jet energy resolution is taken as the main parameter. Figure 1 shows  , obtained with the Pan-doraPFA algorithm for the ILD detector concept. The intrinsic energy resolution is obtained by using the information of which particle is responsible for a given energy deposition in the calorimeter from Geant4 in the pattern recognition, ensuring correct matching of particle tracks and calorimeter clusters. The confusion term is the contribution to the resolution originating from mistakes in the assignment of energy depositions to reconstructed particles, defined as the quadrature difference between the total and the intrinsic energy resolutions the jet energy resolution obtained for di-jet events with jets originating from light quarks (u, d, s) in the barrel region (|cosθ | < 0.7) of the ILD detector. In this analysis, cell energy truncation is used in the reconstruction as discussed in more detail in Sect. 3.3.1. For the 50-250 GeV energy range, the jet energy resolution is below 4%. The contributions of different effects to the total jet energy resolution are also studied to identify the main performance drivers. The intrinsic particle energy resolution is determined using perfect pattern recognition algorithms. These algorithms use the information of the location of energy depositions belonging to a given particle available in Geant4 to provide a correct assignment of calorimeter energy deposits to PFOs. In this procedure, the matching of calorimeter cells with energy depositions to clusters and tracks is "cheated". Each calorimeter cell is assigned to the MC particle which is responsible for the largest fraction of the energy in that cell. Given the high granularity of the calorimeters, the possible ambiguity in this assignment has negligible effects on the overall energy assignment. The detector response itself is not altered with respect to the regular reconstruction, taking into account realistic detector effects as discussed in Sect. 2.1. This effectively removes the influence of imperfect pattern recognition and energy assignment, thus leaving only the intrinsic energy resolution of the detector as a source of uncertainty.
The confusion term, which is defined as the quadrature difference between the total and intrinsic energy resolution, represents the contribution of mistakes made in the reconstruction of the PFOs. The confusion term receives contributions both from calorimeter energy lost in the reconstruction and from double-counting of energy. A typical example for the former is the case where calorimeter hits belonging to a photon are not properly resolved from a cluster belonging to a track and therefore the photon energy is not accounted for. Double-counting of energy can occur if a part of a charged hadron shower is mis-identified as a separate cluster. In this case this cluster's energy is counted twice in the jet energy reconstruction. For jet energies below 100 GeV, the intrinsic calorimetric energy resolution is the main driver, whereas for higher energy jets starting from 100 GeV the confusion term starts to be dominant.

The software compensation concept
Even though the particle flow reconstruction approach reduces the influence of the calorimeter energy resolution on the overall jet reconstruction performance, resolution still plays an important role. It directly influences the contribution of the neutral hadron energy measurement on the jet energy, and is also relevant in the matching of calorimeter clusters to reconstructed tracks. Optimising the hadronic energy resolution of the calorimeter system is thus also highly relevant in detectors designed for particle flow.
In most experiments, the calorimeters are non-compensating, which means that the detector response for electromagnetic showers is typically higher than for hadronic showers (e/h > 1). The non-compensation arises from the complexity of the hadronic showers, which consist of an electromagnetic and a hadronic component. The electromagnetic component originates primarily from the production of π 0 and η particles in hadronic showers, which instantly decay into photon pairs, resulting in electromagnetic cascades in the detector. The hadronic component contains unaccessible processes, such as nuclear target recoil in which the generated energy usually does not reach the active medium, binding energy losses from nuclear breakup or late neutron capture which happens with substantial delay, beyond the integration time of the detector electronics. These undetectable processes lead to a response that fluctuates strongly from event to event and is on average lower than that of electromagnetic showers, where in principle the full energy is detectable. Since the electromagnetic fraction strongly fluctuates from event to event, the difference in response for the two components results in a degradation of the energy resolution. In addition, the average electromagnetic fraction increases with the energy of the incoming particle, which results in a non-linear calorimeter response [10].
Compensating calorimeters (e/h ≈ 1) can thus improve the energy reconstruction and the resolution for hadrons. Compensation can be reached with specific detector designs using heavy metal absorbers and hydrogenous active elements in a specific ratio [11]. These requirements however impose strong constraints on the geometry and uniformity of the calorimeter system. On the other hand, a compensation of the detector response is also achievable for intrinsically non-compensating calorimeters using signal weighting techniques, here referred to as software compensation. These techniques exploit the fact that the electromagnetic components tend to have a higher energy density compared to purely hadronic components, since their evolution is characterised by the radiation length, which is substantially shorter than the nuclear interaction lengths in typical calorimeter materials. The local signal amplitude in segmented calorimeters can thus be used to improve the energy resolution through a reduction of shower-to-shower fluctuations in visible energy based on appropriate weighting of the signals of individual readout channels. This was first demonstrated in the ironscintillator calorimeter of CDHS [12], was used in collider experiments such as H1 [13] and ATLAS [14], and successfully applied to the highly granular CALICE analogue hadron calorimeter [15].
In this paper, we discuss the technical aspects of the implementation of software compensation in PandoraPFA, following the so-called local software compensation technique used in CALICE, followed by a study of the performance of this technique for jet energy reconstruction in ILD detector concept, and an investigation of the impact of the transverse granularity of the hadron calorimeter on the jet energy resolution.

Implementation of software compensation in the particle flow reconstruction
The technical framework used to study software compensation in the ILD detector concept can be sub-divided into three discrete areas, connected to different aspects of the problem, as discussed below. The first is the simulation and reconstruction of the events used in the study, the second is the implementation and the calibration of the software compensation on the calorimeter cell level, and the third one is the integration of the technique into the PandoraPFA particle flow algorithm.

Simulation and reconstruction framework
The present study is performed using Monte Carlo samples of single hadrons for calibration and jets to test the performance of the algorithm. The simulations use the default settings of ILC physics simulations. Jet fragmentation and hadronisation are based on the PYTHIA [16] generator tuned to the fragmentation data from the OPAL experiment [17]. The generated physics events were simulated in the Mokka framework [18] using Geant4 [19] version 9.6 and a realistic model of the ILD detector concept outlined in Sect. 1.1 (ILD_o1_v06). For the simulation of particle showers in the detector material, the QGSP_BERT [20] physics list of Geant4 was used. The detector simulation includes a number of instrumentation effects such as the dead regions around the silicon detector pads in the ECAL, gaps between modules in the ECAL and HCAL and an implementation of Birk's law [21] to model saturation effects in the scintillator response in the HCAL as well as smearing of the HCAL cell energies to account for photon statistics and detector noise, amplitude cuts for noise rejection in the reconstruction and timing cuts to realistically model the finite integration time of the readout electronics. For the reconstruction of the events, the full digitisation and reconstruction chain in the Marlin framework [22] of ILCSoft version v01-17-07, combined with PandoraPFA version v02-09-00 is used. The simulation and reconstruction correspond to the standard ILD software and include detailed modelling of detector effects, validated with test beam data. Only some effects corresponding to specific design choices of ILD have been removed, e.g. some services or dead areas due to guard rings, to preserve the generic nature of the results. It was verified that these effects do not alter the resolutions by more than 5% relative.

Implementation and calibration of software compensation weights
The present study is based on the local software compensation technique developed for the highly granular calorimeters of CALICE, as described in [15]. This technique uses cell-by-cell weights in the calorimeter, with the weights a function of the local energy density ρ. Here, ρ is defined as the hit energy in GeV divided by the cell volume in units of 1000 cm 3 , taking the volume of the scintillator and the absorber and other passive materials into account. In this definition, a standard HCAL calorimeter cell has a volume of 23.85 cm 3 . The volume normalisation in principle allows for treating cells with different sizes. In the study here, the HCAL has uniform granularity, so this does not affect the performance. A typical distribution of the hit energy density is shown in Fig. 2. On this scale, a minimum-ionising particle corresponds to approximately 1 GeV/1000 cm 3 , with the first bin extending to 2 MIPs per cell. If a hit has higher energy density, it is more likely to originate from to the electromagnetic component of the shower. Conversely, a hit with lower energy density is more likely to be of purely hadronic origin. In order to reach compensation (ratio e/h close to 1), the response to different hits with different energy densities is re-weighted, with hits with a higher density receiving a smaller weight than those with lower energy density. The energy of calorimeter clusters are computed as: where ω(ρ) gives the weight of a hit as a function of its energy density ρ. This weight function are expressed by the sum of an exponential function and a constant to enforce a monotonically falling behaviour with energy density [15], where the parameters p 1 , p 2 and p 3 depend on the energy of the particle to take overall changes of the shower structure and density profiles with particle energy into account. Here, p 2 is negative while the other two parameters are positive, resulting in lower weights for higher hit energies. To extract this weight function, the energy density is divided into 10 bins as illustrated by the differently shaded areas in Fig. 2. The sum of hit energies of each bin is then weighted by ω(ρ), with ρ being the centre of the bin, meaning that each hit within a given density bin is weighted with the same weight. As discussed in [15], the choice of the number of bins is a compromise between high granularity of the weights and stability of the algorithm. In the CALICE study, the bin border were chosen such that each bin contributes approximately the same to the total energy of typical events. Since the present study is performed for a wide variety of cell sizes, the bin borders were re-optimized to obtain stable convergence of the training procedure for all cell sizes considered. In general, the performance of the algorithm does not depend strongly on the exact choice of the bin borders or on the number of bins.
By design, the exponential parametrisation of the dependence of the weight on local energy density provides a good description of the expected weight behaviour: it gives larger weights for low density hits, which are likely to be of hadronic origin, and smaller weights for high density hits, which are more likely generated in the electromagnetic component. Since the electromagnetic fraction and the overall particle density in a hadronic shower changes with the energy of the incoming hadron, it is expected that the weights change with particle energy as well. The parameters p 1 , p 2 and p 3 therefore have to take this dependence into account. Following [15], the parameters are expressed as functions of the unweighted energy sum E sum of the cluster. The functional forms used to model the energy dependence is determined in a phenomenological approach, based on the observed energy dependence of the weight parameters, where p i0 , p i1 and p i2 are numerical constants used to model parameter p i . In the present study, the software compensation is applied to all particle showers in the main calorimeter system of ILD (barrel and endcap), however, only energy deposits in the HCAL are re-weighted. Additional work needs to be done to include the ECAL, but since the energy deposition from hadronic showers is primarily in the HCAL, the application of software compensation within this region is sufficient to realise the majority of the potential performance gain, while at the same time keeping the complexity of the calibration and application of the technique rather low. Energy deposits outside the HCAL do contribute to the raw cluster energy that determines the weights to be applied, and are counted in the final energy estimate with unit weight.
The software compensation weights are determined by the minimisation of a χ 2 -like function in a dedicated calibration procedure. The energy dependence of the weights is obtained by carrying out the minimisation of this function using calibration events with single neutral hadrons simulated for a range of energies, as discussed below. In this process, equal statistics of each energy point are required to avoid biases towards particular energies. An equal weight of the different simulated energies in the overall χ 2 is ensured by normalising the deviation of the reconstructed from the true energy by the approximate single particle stochastic resolution term of 50% √ E hadron GeV for a CALICE -style analogue hadron calorimeter [15].
For this calibration, a sample of single neutral hadron (neutron and K 0 L ) events with energies ranging from 10 to 95 GeV is used. The hadrons originate from the interaction point and only events with one cluster fully contained in ECAL and HCAL are selected. This ensures that the weight calibration is not biased by events that have clusters not matching the expected original energy. The fraction of events rejected by this requirement is approximately 30%, primarily due to events with small shower fragments not correctly associated to the main PFO. Figure 3 shows the derived weight values based on Eq. 3 as a function of the hit energy density for different hadron energies. Note that Eqs. 4-6 are used here to extrapolate the energy dependence of the weights beyond the range of the calibration points to lower energy, resulting in sensible values also at 1 GeV. This is an important property for the overall stability of the algorithm when applying to jets with particles with a wide range of energies.
The mean energy of neutral hadrons entering the calorimeter system ranges from 5.6 to 16 GeV for light-quark jets with an energy from 45.5 to 250 GeV, with a somewhat lower average energies for charged particles. At the same time, the energy distributions have a pronounced tail extending to high energies, up to the full jet energy. This underlines the importance of a robust performance at both low and high particle energies.

Implementation in PandoraPFA
PandoraPFA uses a multi-algorithm approach to calorimeter pattern recognition, with iterative steps building up the calorimeter clusters in combination with tracking information to arrive at the final PFOs. The energy of calorimeter clusters primarily enters at two stages in the process. The "reclustering" algorithm uses the matching of the calorimeter cluster energy estimation and the momentum of the associated track for charged particles to guide an iterative reclustering. It splits or merges calorimeter clusters with energies inconsistent with an associated track to try to achieve a better energy-momentum consistency. In the final building of the PFOs the cluster energy is used for neutral particles, and taken into account in combination with the track momentum for charged particles.
For the determination of the weights used by the software compensation algorithm, the uncorrected cluster energy is used. In principle, for the test of a given track cluster matching hypothesis, the measured momentum of the track could also be used in the choice of weights for the compensated energy estimate of the cluster. However, in a dense jet environment, with several tracks to be tested for the same cluster, this leads to additional complications and combinatorial overhead. Since studies on test beam data have shown that very little gain is to be expected for a scintillator-based analogue calorimeter when using the true rather than the measured cluster energy [15], this has not been implemented.
The software compensation procedure outlined in the preceding subsection is implemented in the PandoraPFA particle flow algorithm making use of the features provided by the Pandora software development kit (SDK) [8], which provides a flexible environment for developing and running pattern recognition algorithms as part of the particle flow reconstruction. In the present study, the software compensation is implemented as a user-defined "plugin" cluster energy estimator. For a set of input calorimeter hits, grouped into a cluster, the plug-in provides an estimate of the energy, making use of software compensation. The pattern recognition algorithms can access this information by requesting the corrected hadronic energy for a cluster.
In the present study, we consider three different cases for the cluster energy reconstruction: 1. The default energy estimation without the use of SC as a reference; 2. the application of the SC-based cluster energy correction in the final PFO construction stage only; 3. the full use of software compensation throughout the reconstruction, allowing the clustering algorithms within PandoraPFA to access improved energy estimators to inform pattern recognition decisions.

Software compensation performance
In this section, the effect of the software compensation technique on the energy reconstruction of single particles and hadronic jets is discussed. As in other PandoraPFA-related studies, the energy resolution of jets, used as a performance metric, is defined as RMS 90 /Mean 90 . RMS 90 and Mean 90 are the standard deviation and the mean of the reconstructed energy distribution over the smallest range of total reconstructed energy which contains 90% of all events. For the single particle energy resolution, the RMS and Mean values are quoted from a gaussian fit on this 90% integral range. This is done to make the single particle resolutions directly comparable to the energy resolution of the CALICE AHCAL [15], which is determined from gaussian fits to the reconstructed energy.
All plots in the following show the comparison of three different reconstruction schemes: the standard reconstruction without energy corrections based on SC, SC applied only to neutral hadrons after pattern recognition and with SC also used at the stage of pattern recognition in particle flow.

Single particle energy resolution
The software compensation weights are applied first to single particle samples of K 0 L and neutrons from 10 to 95 GeV. The reconstructed energy is computed using the energy sum of all PFOs in the event. As discussed in Sect. 2.2, approximately 30% of the single particle events are reconstructed with more than one PFO. In the majority of these cases, only small cluster fragments are not correctly associated to the leading PFO. To study the energy reconstruction free from issues of pattern recognition, all reconstructed PFOs in the event are considered here. Decays of K 0 L in the detector volume are not explicitly excluded, but the contribution of such processes is negligible.
When applying SC, the distribution of the energy sum becomes more gaussian and narrows considerably, as shown in Fig. 4. The fluctuations in the reconstructed energy are considerably reduced since events with a high electromagnetic content and a correspondingly higher visible energy are down-weighted, while those dominated by purely hadronic activity are reconstructed with higher average weights. When applying SC additionally at the reclustering step no significant change in the improvement is seen. This is expected, since for neutral hadrons there is no reconstructed track pointing to the calorimeter cluster, which could be used to guide the pattern recognition. Subtle differences between the two methods arise due to threshold effects in the PFO creation, since the application of SC during the reclustering changes the hit energies before the final PFOs are created, while the application of SC to neutral hadrons only changes the energy estimates for neutral hadrons after the pattern recognition is completed. Figure 5 shows the mean reconstructed energy of single particles as a function of energy. Software compensation improves the linearity of the energy response of the detector considerably, with deviations below 4% over the full energy range considered.
The energy resolution of single particles is clearly improved over the whole range of energy from 10 to 95 GeV, as demonstrated in Fig. 6. The relative improvement ranges from ∼13 to ∼26%. This result is compatible with the observations made by the CALICE collaboration when applying the software compensation technique to charged pion test beam data with an energy from 10 to 80 GeV [15].

Jet energy resolution
The performance of software compensation in jet energy reconstruction is studied in simulated di-jet events e + e − → (Z /γ ) * → qq considering only decays to light quarks (i.e. q = u, d, s). The two jets are produced back-to-back with equal energy. The total energy of the two-jets system E jj is reconstructed and the jet energy resolution is obtained by multiplying the relative total energy resolution by √ 2. Note that this procedure ignores effects of jet finding on the jet energy reconstruction and resolution.
Four different centre-of-mass energies are considered: √ s = 91, 200, 360 and 500 GeV. A cut on the polar angle of the generated quarks (|cosθ q |, |cosθq | < 0.7) is applied to select jets predominantly in the barrel region of the detector, de-emphasising the barrel-endcap transition region.   Figure 7 shows the normalised distributions of the reconstructed energy sum per event for two different jet energies, 45 and 250 GeV. When applying SC, the distributions narrows slightly, and the high energy tail is reduced, following the general trend observed also for single neutral particles. As expected, the effect of SC is less pronounced in the case of jets.
In Fig. 8, the jet energy resolution obtained for all three scenarios of the reconstruction, without energy correction, when applying SC for neutral clusters at the PFO level only and when applying SC also at the reclustering step for all clusters, is compared. The intrinsic energy resolution and the confusion term, derived from "cheated" reconstruction using perfect pattern recognition as discussed in Sect. 1.2 are also included in the figure. The application of SC only for neutral hadrons after the reclustering step only improves the intrinsic energy resolution without impact on the confusion term and thus mostly affects the lower part of the jet energy range. However, the application of SC in the reclustering step gives a substantial improvement of both contributions to the jet energy resolution, thus also affecting the high energy region and highlighting the two effects of a full integration of SC into the particle flow algorithm: -The improvement of the individual cluster energy measurement provides more powerful cluster-track compatibility constraints and therefore leads to confusion mitigation. This cannot be achieved with SC applied only at the PFO level. -The total energy distribution of a jet event is the sum of all single particle energies. The improved single particle resolution and a more gaussian energy distribution results in an intrinsically better jet energy resolution.

Alternative implementations of energy correction
In the following, two alternative implementations of the energy correction in PandoraPFA are discussed. The first is the "standard" correction mechanism, which uses a truncation of the cell energy. The second uses the software compensation technique discussed above, making use of a different parametrisation of the hit energy weights, inspired by the semi-digital energy reconstruction developed for highly granular calorimeters with gas detector readout developed within the CALICE collaboration [23].

Cell energy truncation
As discussed in Sect. 2.3, the earliest point where one can apply SC in particle flow is at the reclustering step. However, if the total cluster energy is not used to determine cell weights, an energy correction can already be applied at the hit level by simply reducing the response of the calorimeter to the hits that are likely to belong to electromagnetic subshowers. For that, a simple cut on the cell energy is applied, limiting the response of individual cells. This technique is referred to as cell energy truncation, and has been used as the default energy correction in PandoraPFA in the ILD detector concept.
The advantage of the method over the more sophisticated software compensation lies in its simplicity. Nevertheless, the determination of the optimal cell energy truncation value is not trivial. The overall calibration also needs to be reoptimised once truncation is applied, as it reduces the total reconstructed energy. In PandoraPFA, the cell energy truncation method is applied in combination with a simple treatment of hadron showers with very high electromagnetic fraction ("hot hadrons"): the energy of hadrons with a low number of hits and very high energy density is scaled down. The hot hadron treatment is in fact a simple form of compensation. With this combined method the jet energy resolution is improved significantly compared to the case without energy correction, as demonstrated in Fig. 9. However, the level of improvement is smaller than for full SC at the reclustering step.

Software compensation weights inspired by semi-digital energy reconstruction
In a semi-digital hadron calorimeter, each cell provides only a 2-bit energy information corresponding to three hit energy thresholds, rather than the 12-bit "analogue" energy information available in the calorimeter considered here. To recover response linearity and energy resolution also at higher energies, the reconstructed energy is given by the sum of the hits above each of the three thresholds, each weighted with a parameter depending on the total number of hits in the shower. This dependence is parametrised by a second-order polynomial [23], and determined by a minimisation procedure identical to the one used here, described by Eq. 7.
In order to establish a general formalism covering both analogue and semi-digital reconstruction, as a first step the analogue software compensation has been implemented in a scheme in which the total energy dependence of the weights is parameterised in each hit energy density bin independently. This approach removes the enforced exponential dependence of the weights as a function of hit energy density. This monotonically falling weight towards higher energy densities is motivated by the higher density and higher detector response of electromagnetic sub-showers. Encoding this in the software compensation weights however does not necessarily result in the best possible performance. In this alternative scheme, the reconstructed energy is given by where the energy dependence of α is parameterised as a second order polynomial with 3 free parameters per bin to be optimised. This becomes semi-digital reconstruction, i.e. counting of hits in each of the bins, by replacing α by α/E i in a second step, thus canceling the hit energy dependence, and expressing E as a function of the total number of hits. The difference between software compensation and semi-digital reconstruction then reduces to a smaller number of bins and a forced effective 1/E hit dependence of the weight within each bin instead of weights being bin-wise constant. This implementation of the SC formalism thus prepares Pandora for the optimisation for calorimeters with semi-digital read-out. In order to verify the equivalence of the formalism for analogue software compensation, the binning in hit energy density was kept unchanged, and the weight parameters (here the parameters of the second-order polynomial for each bin) are determined by using Eq. 7. Figure 10 shows the jet energy resolution obtained with SC fully applied in the reconstruction for both the standard and the semi-digital-inspired weight parametrisation. The performance of both cases is comparable for the range of energy considered, showing that the benefits of software compensation do not depend strongly on the details of the implementation of the hit weights.

The influence of transverse granularity
For a particle flow calorimeter, the level of granularity has an important influence on the performance, since it determines the possibilities for pattern recognition. Also the software compensation technique discussed here benefits from high granularity. Therefore the inclusion of software compensation methods in the particle flow reconstruction could in principle affect the choice of the optimal cell size. The present study is the first one to take this into account.
The optimal granularity is an interplay of the physics performance and the complexity and cost of the detector. The latter has several components which are proportional to the detector's volume, the instrumented area and the number of channels. If the size and the number of layers of the detector are kept constant, the number of channels is the relevant quantity to be optimised. A smaller cell size may improve the jet energy resolution, but the corresponding larger number of cells results in an increased cost due to increased electronics requirements as well as a larger number of photon sensors in the case of scintillator-based calorimeters.
In this study, the dependence of the jet energy resolution obtained with PandoraPFA on the cell size of the HCAL is studied for quadratic cells ranging from a size of 1 × 1 cm 2 to 10 × 10 cm 2 , keeping all other parameters of the calorimeter constant. The study is performed with full application of software compensation and without any energy corrections as a comparison. When using software compensation, the weights to be used by the algorithm are determined separately for each cell size following the procedure described in Sect. 2.2. For consistency, the same binning in energy density as well as the same noise rejection thresholds on the cell level are used for all detector configurations. Figure 11 shows the resulting energy resolution as a function of cell size for the four different jet energies considered here. The application of software compensation leads to a significant improvement of the jet energy resolution for all cell sizes and all jet energies. The general trend of the evolution of the energy resolution with changing cell size is the same for reconstruction with and without the use of software compensation. The reduced improvement of the energy resolution with software compensation observed for the smallest cell sizes for lower jet energies is due to a non-optimal use of the lower energy density bins in these models. In combination with the noise rejection cut on cell level this results in a slight reduction of the performance of software compensation at lower jet energies, visible in particular for 45 GeV jets for the model with 1 × 1 cm 2 cells.
As mentioned above, the optimisation of the cell size of the detector has to find a balance between physics performance and and the number of readout channels, which is expected to influence the detector cost. To inform this choice, the results shown in Fig. 11 are shown as a function of the number of HCAL cells in the full ILD detector in Fig. 12. Note that the HCAL baseline design for ILD consists of about 8 millions cells with a size of 3 × 3 cm 2 . The figure illustrates that the HCAL baseline design represents a well-motivated choice, being located at the knee of the distribution. A larger cell size (corresponding a smaller number of cells) results in a noticeable degradation of the jet energy resolution, while a smaller cell size does not provide substantial improvement, albeit very significantly increasing the number of cells.
Beyond the change of the size of all cells in the calorimeter, an overall reduction of the channel count can also be achieved by using larger cells only in the rear part of the detector, where pattern recognition requirements may be less strict due to reduced occupancy. To investigate this scenario, a study has been performed that uses two different cell sizes, 3 × 3 cm 2 in the front part of the detector and 6 × 6 cm 2 in the rear part. Since the consistent implementation of software compensation in a detector with varying granularity goes beyond the scheme developed here, this study is performed with the  Here, 0 corresponds to 6×6 cm 2 throughout the full calorimeter, while 48 represents the scenario with 3 × 3 cm 2 granularity in the full system studied in the main part of this paper standard reconstruction without software compensation or any other form of energy correction. Figure 13 shows the jet energy resolution as a function of the number of highly granular layers in the front part of the hadron calorimeter for the standard reconstruction without software compensation for different jet energies. The impact of the depth at which the transition from a fine to a coarse HCAL occurs depends on the jet energy. While there is only a small impact for low energies, higher energies prefer a deeper location of the transition, with 250 GeV jets still improving when also implementing the higher granularity in the last 10 layers.

Conclusions
The software compensation technique developed for the CALICE analogue hadron calorimeter, making use of local energy density information within hadronic showers to substantially improve the energy resolution for single hadrons, has been integrated into particle flow event reconstruction based on the PandoraPFA algorithm. The performance of this algorithm is studied on simulated single particle and dijet events in the ILD detector concept for the International Linear Collider.
The results demonstrate that the application of software compensation in particle flow reconstruction in the HCAL substantially improves the detector performance, both due to the improvement of the energy measurement of neutral hadrons and an improved track-cluster matching due to more accurate calorimeter energy information. For single neutral hadrons, the improvement of the energy resolution is compatible to the result previously obtained within the CALICE collaboration using test beam data. For the jet energy resolution, in addition to the improvement of the intrinsic particle energy resolution, the application of software compensation also results in a reduction of the confusion term. The ILD goal of a jet energy resolution of better than 4% over the full relevant energy range is achieved, with a jet energy resolution of better than 3.5% obtained for energies higher than 45 GeV. The full software compensation outperforms less sophisticated energy correction techniques such as a truncation of very high energy depositions in single calorimeter cells. An alternative implementation of the SC compensation formalism, shown to provide identical performance for the analogue HCAL, prepares Pandora for the application to calorimeters with semi-digital read-out.
PandoraPFA with integrated software compensation has also been used to revisit the optimisation of the cell size of the scintillator/SiPM -based analogue HCAL of the ILD detector concepts. The results confirm that a size of 3 × 3 cm 2 is an optimal choice for the scintillator tiles considering performance and overall detector channel count. A channel count reduction can also be achieved by making only the rear part of the hadron calorimeter less granular. The point at which such a transition does not negatively impact the resolution depends on the jet energy, with the highest energies studied here favouring high granularity throughout the detector.
The results presented in this paper demonstrate that the application of local software compensation in the analogue hadron calorimeter has an important impact on particle flow reconstruction and improves energy resolution for single particles and jets. Following the present study, software compensation is used as the standard energy correction algorithm in PandoraPFA version v02-09-00 and later versions for physics studies of ILD.