Pulse-shape calculations and applications using the AGATAGeFEM software package

A software package for modeling segmented High-Purity Segmented Germanium detectors, AGATAGeFEM, is presented. The choices made for geometry implementation and the calculations of the electric and weighting fields are discussed. Models used for charge-carrier velocities are described. Numerical integration of the charge-carrier transport equation is explained. Impact of noise and crosstalk on the achieved position resolution in AGATA detectors are investigated. The results suggest that crosstalk as seen in the AGATA detectors is of minor importance for the position resolution. The sensitivity of the pulse shapes to the parameters in the pulse-shape calculations is determined, this as a function of position in the detectors. Finally, AGATAGeFEM has been used to produce pulse-shape data bases for pulse-shape analyses of experimental data. The results with the new data base indicate improvement with respect to those with the standard AGATA data base.


Introduction
In nuclear-structure physics, as in many other fields of research, the development of better instrumentation and the discoveries of new physics are closely linked. One of the most powerful techniques to study atomic nuclei is γ-ray spectroscopy, often combined with in-beam production of the species of interest. The development and construction of new advanced radioactive-beam and stable-beam facilities has prompted development and construction of a new generation of γ-ray spectrometers. The last before present generation of γ-ray spectrometers, such as EUROBALL [1] and GAMMASPHERE [2], have limitations in terms of efficiency, resolving power, and maximum count-rate capabilities. A way to improve the performance is to use fully digital electronics combined with highly segmented High-Purity Germanium detectors and perform so-called γ-ray tracking [3]. Two large projects have been developed and are presently in the construction phase. In Europe the Advanced GAmma-ray Tracking Array (AGATA) [4] and in the USA the Gamma-Ray Energy Tracking Array (GRETA) [5]. For a more complete discussion on γ-ray spectrometers and their development over time see, e.g., Eberth and Simpson [6]. A recent discussion on the current performance of AGATA can be found in Ljungvall et al. [7].
The main characteristic of γ-ray tracking spectrometers is the lack of Compton suppression shields. They have been replaced by γ-ray tracking: The track of the γ-ray through the array is reconstructed using interaction points given by pulse-shape analysis (PSA). The tracking allows an increase of the solid angle covered by germa-nium, with an increase in efficiency. The γ-ray tracking also gives a high peak-to-total. For this method to give high performance it is crucial that the PSA gives the interaction positions with high accuracy (i.e. less than 5 mm FWHM at 1 MeV). The accuracy of the PSA depends on how well the detector response is known, and to a lesser degree, the algorithm used for the PSA. Characterisation of the HPGe detectors, and associated electronics, are hence of great importance.
Extensive work has been done to model the response of the highly segmented germanium detectors used by AGATA and GRETA. Over the years several software packages have been developed within the AGATA collaboration to model the pulse shapes from segmented detectors [8,9,10,11,12]. At the same time extensive efforts have been made to provide these codes with accurate input in terms of impurity concentrations [13,14], crosstalk and electronics response [15,16,17], and charge-carrier mobility [18]. Within the AGATA community it is presently the ADL [11,12] package that is used to produce the data bases of pulse shapes needed for pulse-shape analysis. For work related to GRETA and GRETINA see [19,20] and references therein.
In this paper a software package written to model the segmented HPGe germanium detectors used in AGATA is described. The main intended use of this package is PSA development. It can however also be used for detector characterization or pulse-shape data bases production. A short introduction to pulse-shape calculations in semiconductor detectors is given in section 2. The AGATAGeFEM package together with models and assumptions made are described in section 3. An effort to characterize where in the detector volume the parameters entering in pulseshape calculations have the largest influence on the pulse shapes is presented in 4. How a poorly known crystal geometry might effect pulse-shape analysis is investigated in section 5. The use of the software package to benchmark the effect of crosstalk and noise on the two pulseshape algorithms Extensive Grid Search (EGS) and Singular Value Decomposition (SVD) is covered in section 6. To validate the pulse shapes calculated by the AGATAGe-FEM package pulse-shape data bases used for PSA have been calculated with it and used for PSA. Results using the AGATAGeFEM bases are compared to results produced with bases calculated with the ADL [11,12]. This is presented in section 7. Conclusions are given in section 8.

A short introduction to signal generation in semiconductor detectors
The signal (referred to as "pulse shapes" in this work) generation in all detectors based on the motion and collection of charge carriers is calculated using the Shockley-Ramo theorem [21,22]. The theorem states that the induced charge on an electrode due to moving charges is where W ( r e,h ) = −∇Φ W ( r e,h ) is the weighting field, N e,h the number of charge carriers for electrons and holes, respectively, and v e,h ( r e,h ) are the charge-carrier velocities. The charge carrier velocities are functions of the electric field E( r). The electric field is calculated from the electric potential as E( r) = −∇Φ( r).
The calculation of pulse shapes for a semiconductor detector begins with solving the two partial differential equations (PDE) and known as the Poisson and Laplace equations, respectively. Together with appropriate boundary conditions they describe the electric (Poisson) and weighting (Laplace) potentials. In equation 2, ρ( r) is the free charge distribution in the detector and Ge the dielectric constant for germanium. Boundary conditions for the electric potential are the applied detector bias or 0 V on the conducting surfaces. For surfaces requiring passivation the boundary condition should include charges and possible leakage currents. As these are unknown the approximation of natural boundary conditions is used in this work. The weighting potential Φ W ( r) is calculated by setting the potential on the electrode of interest to 1 and to 0 on all other conducting surfaces.
One of the major difficulties when integrating equation 1 is to find the correct function for the charge-carrier velocities v e,h ( r e,h ). The physics and the models used in this work is discussed in section 2.1.
To produce realistic pulse shapes for a detector the effects of the limited bandwidth of the electronics have to be included. The effect of the bandwidth can in principle be measured for a system using a pulse generator. However, the approximation using an analytical function seems sufficient and is more practical. The crosstalk between different segments has to be modeled. Typically the difference is made between so-called linear and differential crosstalks. The former has mainly the capacitive coupling of the electrodes as origin whereas the later has its origin in the front-end electronics. The linear crosstalk can not be avoided, whereas the differential crosstalk can be reduced using careful engineering. The AGATAGeFEM package models both types of crosstalk.

Charge-carrier motion in High-Purity Germanium detectors
For all pulse-shape calculations the models used to describe the charge-carrier mobilities are of crucial importance. A commonly used function [23] to describe the charge-carrier velocity is v( r) = µ E( r) where E 0 , β, µ n , and µ are experimentally adjusted parameters. This parameterization is valid when the electric field is parallel to one of the symmetry axes of the Germanium crystal (<100>, <110>, or <111>). The chargecarrier velocity is only parallel to the electric field when the electric field is parallel to a symmetry axes. For germanium crystals cooled down to liquid nitrogen temperatures (≈ −175 • Celsius) several models have been developed for the electron mobilities. For AGATAGeFEM the model of Nathan [24] is used. It treats the anisotropy of the electron drift velocity observed in germanium with high accuracy with the formalism described in Mihailescu et al. [25]. For the hole mobility B. Bruyneel et al. [18] have developed a model based on the so-called "streaming motion" concept. The holes are accelerated to a threshold energy, they emit an optical phonon losing most of their energy, are re-accelerated in the applied electric field to the threshold energy, and so on. In this work a different approach has been used. Here it is assumed that the variation in carrier velocity as a function of the electric field can be described by the fraction of holes populating the light-hole band and the heavy-hole band and a field dependent relaxation time. The anisotropy is given by the effective masses the second derivative of the energy of the hole bands. Despite the much higher the much higher energy of the light-hole band as compared to the heavy-hole band the model reproduces experimental data for hole drift velocities [26]. For the holes the surfaces of equal energy in the conduction bands are not ellipsoids, which means that the reciprocal effective mass tensor will depend on the direction of the wavevector k. Here the assumption is made that the wavevector is parallel to the applied electric field. The hole energy functions read [27] where the positive (negative) sign is for the light (heavy)hole band. Using equation to calculate the reciprocal effective mass tensor, we have the factor T (E) in the latter equation corresponds to t in the former and is considered an electric-field dependent relaxation time. F (E) is the fraction of the holes moving in the heavy-hole band and is also field dependent. As in the case of electrons, equation 4 can now be used to calculate the hole drift velocities in the <100> and <111> directions. Using these velocities T (E) and F (E) are obtained at the electric-field strength in question. A big difference for holes as compared to electrons is that the reciprocal effective mass tensor changes with the direction of the electric field. In figure 1 the anisotropy of charge carrier transport is illustrated. Without anisotropy the top row would show perfect spheres in one color and the second and third rows would show zero velocities. The deficiency of the model can be noted from the v h ϕ shown in the bottom right corner. There should be no anisotropy in any of the <100>, <110>, or <111> directions as these are symmetry axes in germanium. This is different for the electrons shown in the left column.
Neither the drift model for electrons nor for holes takes into account the effects of crystal temperature or impurity concentrations on the charge-carrier drift velocities although these effects modify the drift velocities [28]. The effect of varying the hole-drift velocity was studied within the GRETINA [20] and AGATA collaborations [29]. In these works it is concluded that the position resolution is not limited by the hole mobility models. When the hole mobility is varied within reasonable limits it is difficult to separate the effects from those coming from the frontend electronics. Numerical values used in this work for the mobility parameters are presented in table 2.

The AGATAGeFEM software package
Several software packages have been developed to calculate pulse shapes from the High-Purity Germanium detec-  [9,9,17] and ADL [11,18,12]. Although differing in details they all have in common the use of finite difference PDEs solvers for the electric field and the weighting potentials in the detector. However, the complex shapes of the AGATA crystals are not well reproduced using a finite difference scheme with rectangular grids. This is a problem that can be circumvented using finite element methods (FEM). Another strong point of FEM is that the solution is an approximation of a function describing the electric field and not the electric field at certain points. This removes the need to interpolate between grid points as the solution is defined on the entire volume of the detector. It is beyond the scope of the present work to describe FEM and the reader is referred to [31] and references therein. The AGATAGeFEM package written in C++, uses high-quality open-source FEM software to calculate the electric and weighting potentials of AGATA type germanium detectors. For the charge-carrier transport the ordinary differential equation solvers of the Gnu Scientific Library [32] are used. The geometry is described to machine precision for charge transport and mesh generation. Earlier versions of the program used mainly the FEM library dealii [33,34]. This is a very flexible code that allows an iterative refinement of the FEM mesh in a very simple way. However, the mesh cell geometry is limited to quadrilaterals and hexahedra. From the point of view of solving the partial differential equations this is a good choice. However, in AGATAGeFEM the solutions of the Poisson and Laplace equations are not projected down to a regular grid when used in the charge carrier-transport process. This is also the case for calculations of the induced signals via the Shockley-Ramo theorem. The idea Behind is that the mesh refinement procedure tells where a high granularity is needed and all projection to a regular grid deteriorates this information. The problem is then to find the correct cell in an irregular mesh. The curved boundaries of hexahedra cells make these calculations complicated. As a result the first version of AGATAGeFEM was capable of calculating about 2-3 pulse shapes/s. Sufficient to calculate a basis for PSA it is far from enough for using AGATAGeFEM in the fitting of parameters in the pulseshape calculations or to use it in a complete Monte Carlo simulation chain. The FEM part of the program was therefore changed to the libmesh library [35]. It uses tetrahedra with each side defined by three points, speeding up finding the correct mesh cell. The AGATAGeFEM is further more restrained to the use of only linear bases functions in the solution. This way the calculations are a factor of almost 100 faster while reproducing while reproducing the results using dealii.
AGATAGeFEM is fully parallelized with threads and the MPI interface. This applies to the field calculations and the pulse-shape calculations. Parallelism is also used while fitting the pulse-shape calculations parameters. To minimize the χ 2 Minuit and Minuit2 [36] are employed. AGATAGeFEM further has interfaces allowing calculating and displaying fields and pulses from the ROOT [37] interpreter interface. This inside the chosen detector geometry if wanted. It has further a very simple server client mechanism allowing other programs to ask the server to calculate pulse shapes for it.
The AGATAGeFEM package also contains miscellaneous codes for applying pre-amplifier response crosstalk re-sample pulse shapes compare pulse shapes calculate pulse shapes from the output of the AGATA geant4 MC [38] create data bases for PSA.

Geometry
The AGATA crystals are 90 mm long and have an diameter of 80 mm. They were produced in four different shapes. A symmetric hexagonal shape for three prototypes and three different non-symmetric hexagonal shapes for use in the AGATA [4]. For the generation of the FEM mesh OpenCASCADE models of the detectors are generated. For the charge transportation the detector geometries are implemented in C++ as the union of a cylinder and six planes or using the CSG geometry of geant4 [39]. The hole corresponding to the central contact has several parameters allowing it shape and orientation to be varied. These are the radius of the hole, the radius at the bottom of the hole joining the side of the bore hole with the bottom of it, and translation and rotation of the axes of the hole. The two different geometrical models of the detectors are equivalent. Examples of the geometries are shown in figure  2.
Top row, three views of an "A" type AGATA crystal. Bottom left shows a symmetric crystal. Bottom right, a "C" type AGATA crystal with half the volume hidden to show the central contact.

Calculations of the electric fields and weighting fields
AGATAGeFEM uses a total of 40 fields for calculating the pulse shapes. Thirty seven of these are the weighting fields for the 36 segments and the central contact. Except for the central contact which is trivial, these are defined either using the limiting depth values and start and stop angles of a segment or using the intersection between the detector surface and four planes. The segments do not have to cover the entire surface of the detector. This is intended for modeling the gaps between the segment contacts on the outer surface [40]. Presently no implementation of suitable boundary conditions for the electric field exists in AGATAGeFEM limiting the value of this option.
When solving the charge transport equations, AGATAGe-FEM uses three fields to calculate the electric field. The first one is the solution to the Poisson equation with 0 V on the surface of the detector and V bias V on the central contact, and the nominal impurity concentration. The choice to include charge impurities here was made to maximize the benefits of mesh refinement. Representative values for the charge impurities are presented in table 3 in appendix A. The second field is the solution of the Poisson equation assuming 0 V on both the surface and the central contact but with an impurity contribution of 1 at the front of the detector that decreases linearly as a function of depth to the back of the detector where it is 0. The third and final field is like the second one but reversing the slope of the impurity concentration. The use of three fields allows varying the effective impurity concentration and its effect on the electric field in the detector without recalculating the electric field. Solving the Poisson equation when varying the impurity concentration is too computationally intensive to allow the fitting of detector parameters to experimental signals.
For solving the Laplace equation and the Poisson equation AGATAGeFEM uses the libmesh library [35], with the meshes generated with gmsh [41]. As a first step the Laplace or the Poisson equation is solved using a uniform mesh with an average cell size of 2 mm. This solution is then used to estimate the largest acceptable geometrical approximation of the mesh in order to ensure an error on the field of less than one per mil of the maximum value of the field. This step is then followed by repeated steps of refinement of the mesh based on an estimate of the local error of the solution [42] until the field is described by at least 2.5 * 10 5 degrees of freedom. A limit that gives a good approximation of the fields (see section 7). The final step for each of the 40 fields is to create look-up tables on a 2x2x2 mm 3 grid over the detector volume to allow fast access to the correct mesh cell when evaluating the fields.

Solving the charge transport equation
The detector pulses are calculated by first transporting the point representing electrons and the point representing holes from the point of the γ-ray interaction until they reach the boundary of the detector volume using The equations are solved separately for the holes and the electrons using an solver algorithm with an adaptive time step. AGATAGeFEM allows the user to choose between any of the possible algorithms provided by GSL, but the default choice it the embedded Runge-Kutta Prince-Dormand method [43]. The paths of the charge carriers are calculated with an adaptive time step and sampled at a chosen frequency, by default 100 MHz. As the charge carriers approach the boundary of the detector the sampling frequency is adapted to allow an accurate description of the pulse shape as a 10 ns time step typically gives a path that ends outside the detector.
In the next step the charge on electrode i is calculated using for all 37 signals.

Convolution of the signals with the transfer function of the electronics
The signals can be convoluted with the response of the electronics. This is not done when generating a basis for PSA. In this work the response of the electronics have been modeled by the function [8,9] shown in figure 3. A convolution (in time-domain) is made for all 37 calculated signals. A possible improvement is to use a function with a slower rise time for the central contact. However, the convolution is mainly used for PSA development where AGATAGeFEM is used both for generating the bases and the signals that are analyzed so the exact form of the function is of minor importance. The effect of both linear and differential crosstalk can be included in the transfer function. For in-depth discussion concerning crosstalk in segmented germanium detectors, see [15,44]. An example of the signals calculated with and without response function is given in figure 4. The effects of linear and derivative crosstalks are also shown.

Investigation of the sensitivity of signal shapes to detector parameters
To understand the influence of the different detector parameters on the shape of the signals the sensitivity of the pulse shapes to each parameter was calculated for a large number of points inside a detector of symmetric type. As The modulating effect of the response of the electronics is clearly seen (red shape). The effect of linear (green shape) and derivative (blue shape) crosstalk is also shown. the absolute value of the different parameters vary over many orders of magnitude normalized dimensionless parameters was used to estimate this sensitivity. The sensitivity was evaluated as the second derivative of a χ 2 at zero fractional variation of the parameter in question. It is extracted by fitting a second degree polynomial and is hence the curvature of the χ 2 function. The χ 2 is calculated using the original pulse shape and a pulse shape calculated using the changed parameter. In figure 5 the extraction of the sensitivity is shown for the hole mobility in the <111> direction.  In figure 6 is shown for how many positions in the detector the pulse shapes are most sensitive to each parameter. It can be seen that at most points it is the parameters that control the velocity of the charge carriers in the <100> direction that are dominating. It is not surprising as in the coaxial part of the detector the charge transport is never in a <111> direction. Worth noting is that the hole mobility parameters for the <111> direction have a large impact at more positions than the <111> direction parameters for the electrons. This can also be understood geometrically as the paths close to the <111> direction with an overlapping large weighting potential are dominated by hole transport occurring at the corners of the front face of the detector. Crystal orientation only dominates at one position, a consequence of the definition and its evaluation at zero change.
Crystal Number of points  Figure 7 shows the average sensitivity of the pulse shapes to a parameter at the positions dominated by the parameter. One can notice that the highest average sensitivity is found for the crystal orientation followed by the parameterization of the hole mobility in the <111> direction. It can be understood as these parameters are the most likely to change in which segment the charges are collected.
Avg. curvature of square sum In figure 8 the relative sensitivity as a function of position in the detector volume is shown for the µ <100> e parameter. It is homogeneous inside the volume although the projection on the XY plane shows that, apart from the volume effect, there is an increase in sensitivity close to the <100> directions. This is expected as the charge carrier velocity mainly depends on parameters for that crystal axes at these positions. For the holes the pattern is not reflecting the <111> direction in the crystal. This is not imposed by the model, unlike for the model of the electrons. When the electric field is parallel to a symmetry axis of the crystal the charge carriers move, by symmetry arguments, parallel to the field and the axis. This can also be seen in figure 1 where the ϕ component of the hole velocity is non zero in the xy-plane <100> directions. Imposing this symmetry on the hole velocity model is planned for future work, but as shown in section 7 this deficiency does not seem to degrade the results.
5 Impact of imperfectly known crystal geometry on PSA As the exact geometry (here considering contact thickness dead layers etc as a part of the geometry) is imperfectly known it is interesting to investigate its possible impact on the pulse shapes. A different geometry was used to generate the basis for PSA. The influence of an imperfect geometry has been investigated for three different cases, ranging from an extreme (unrealistic) case to a small error on the used front-face segmentation.
a, b, c, Fig. 9. The three different geometries used for investigating the impact of an imperfect geometry on the pulse-shape data bases. In picture a, the nominal geometry of a capsule type A is shown. In b the bore hole for the central contact has been displace 5 mm and with an angle of φ = .2 radians and θ = .1 radians, respectively. In figure c the bore hole has been enlarged with 3 mm, this as an (extreme) example of the lithium drifted central contact.  Using the nominal geometry of an A type crystal with a representative impurity concentration a pulse-shape basis for PSA with a grid size of 1x1x1 mm 3 and a sample rate of 100 MHz was first calculated. Using three differently modified geometries the same 1x1x1 mm 3 grid of points were used to calculate pulse shapes for each of those. The following geometry modifications were used: 1) An incorrect front-face segmentation. 2) A displaced and tilted borehole for the central contact. 3) An enlarged bore hole for the central contact. The nominal geometry and geometries 2 and 3 are shown in figure 9 whereas the difference in front segmentation is shown in figure 10. The pulse-shape basis of the nominal geometry was then used for PSA on the three different pulse-shape sets corresponding to each geometry variation and on itself as a reference. The used PSA is a simple extensive grid search with 5 keV Gaussian noise added and an interaction energy of 1 MeV. In figure  11 the χ 2 for the four different cases are shown. It can be seen that for none of the geometries it is possible to use the χ 2 distribution to make a statement on whether the geometry used to produce the basis is good or bad -all four distributions are reasonable. On it self Wrong segmentation Core R=8 mm Core not correct Fig. 11. Chi-square distributions for the four different cases of PSA using one exact and three inexact geometries. The χ 2 rest close to 1 even if the basis used is calculated for a geometry that does not coincide with the correct one.
The average error on the determined positions ( figure  12 shows this for the x coordinate) is the most important parameter evaluating the performance of a pulse-shape basis. The incorrect segmentation lines do not produce an error that is significant as compared to the experimentally determined value (σ~1.7 mm [45]). The two other geometries give an error in the determination of the actual position that is larger than the experimental result. A tentative conclusion is that the geometries of actual AGATA crystals are better known than the two rather extreme cases used for this test.
Looking at scatter plots of the determined interaction positions, see figure 13, no clustering effects are seen for the case where PSA is done on pulses belonging to the reference basis (i.e. on itself) nor with a small error on the front segmentation. However, when the basis is made with a geometry that deviates from the geometry of the detector, one of the effects is clustering of events. The origin of this clustering is that the rise times contain most of the information in the pulse shapes and all pulses with extreme rise times will be clustered towards the position in the basis with the closest rise time. The empty voids are a combination of this rise-time mismatch and the union of the central contacts of the nominal geometry and that of the two variations of the bore hole geometry.

Evaluation of the impact on pulse-shape analyses of crosstalk and noise
Using the AGATAGeFEM package the resolution for Extensive Grid Search (EGS) and the Singular Value Decomposition matrix inversion (SVD) [46] as a function of noise level and the inclusion of differential and linear crosstalk has been investigated. The amount of linear crosstalk used for this investigation is typical for AGATA crystals when mounted in AGATA triple cryostats [15,16] and is about one per mil. The differential crosstalk is assumed proportional to the linear crosstalk with the proportionality factor taken as the one used in the AGATA online PSA (a factor of 10).
Assuming that the physics of a segmented germanium detector is well known, the possibility to determine the coordinates of a γ-ray interaction in a large volume HPGe detector is limited by the knowledge of the response of the electronics and by the signal-to-noise ratio. These two aspects have been studied by performing PSA on a data set of pulse shapes calculated using the AGATAGeFEM with exactly the same parameters as the basis used by the PSA code. Each pulse shape in the data set was analysed using 6 different levels of noise and using EGS and SVD. This with or without linear and differential crosstalk for a total of 48 different combinations. Each pulse was analyzed 20 times with noise regenerated for each time. For both PSA methods linear and differential crosstalks were added to the analyzed pulses but not to the pulse-shape basis used for the PSA. The results are summarized in table 1. According to this work the crosstalks have a very limited influence on the resolution, both for the average reconstructed position and by not introducing systematic errors. In figures 14 and 15 two-dimensional projections of interaction positions as determined by the two different PSA algorithms are shown. Looking at figure 14 and 15 a striking difference shows up for large noises. The EGS tends to cluster points towards the segment boundaries whereas the SVD seems to move the points towards the barycenter of the segment.
Data from Söderström et al. [45] is presented together with the result from present work in figure 17. One notes that the EGS is better on simulated data than what has been experimentally measured for energies above about 50 keV. The Matrix inversion using SVD decomposition to increase the signal-to-noise ratio is better at very low interaction energies. It is of interest to try SVD on lowenergy experimental data.

Pulse-shape analysis on experimental data
One of the objectives of the AGATAGeFEM package is to produce pulse-shapes bases used for the PSA of experimental data. In the AGATA collaboration an adaptive  grid search algorithm is presently used [49]. The validation of bases calculated with AGATAGeFEM for the AGATA PSA is presented in this section. This step also validates the AGATAGeFEM package for use in the development of pulse-shape analyses by proving that the pulse shapes are realistic. Pulse-shape data bases have been calculated for 6 AGATA crystals. These crystals were previously used to estimate the achieved position resolution [50,7] employing bases calculated with ADL [11,12].
An important parameter when calculating the electric fields inside the in fully depleted detectors is the space charge. The space charges come from impurities in the Germanium crystals. For the AGATA crystals they have been measured by the community using techniques based on the capacity of the crystal [13,14] and are used as input here with numerical values presented in table 3 in appendix A. The parameters for the electron and hole mobility are taken from Ljungvall et al. [26]. They differ slightly from values used in ADL [11,12] and are presented in table 2 appendix A.
The addition of electronics transfer function and crosstalk to the pulse-shape data bases were performed by the standard AGATA PSA codes. For the crosstalk values mea- sured during each experiment for each crystal are used (for typical values see Bruyneel at al. [15,16]). The response function of the electronics is modeled as an exponential with a rise time of 35 ns, the default used for PSA in AGATA.
To optimize the calculated bases, the parameters controlling the direction of the <100> crystal axis, the assumed radius of the central contact, and scaling of the hole and electron velocities, were varied. The best results for the PSA was sought in this parameter space for each crystal. The orientation of crystal lattice was varied by rotating the lattice around the <100> crystal axis assumed parallel to the bore hole for the central contact. Rotations in steps of 5 degrees until 90 degrees were performed. For the bore hole, three different radii were used: 5 mm (nominal), 6 mm, and 7mm. The charge carrier velocities were scaled from 0.8 to 1.1 is steps of 0.1 of their nominal values. In figure 18 and 19 the variation of the pulse shapes over the used parameter space is illustrated. As can be seen in figure 18 the lattice orientation has a noticeable impact on the pulse shapes. The varied parameters with the largest impact are the 10 % step scaling of the chargecarrier velocities, clearly seen in figure 19. This is coherent with what was shown in section 4. Evaluation of the performance of the PSA was done using the peak width of the 1221 keV γ-ray transition in 90 Zr, as illustrated in figure 20. Doppler correction was performed using first interaction point as defined by the γ-ray tracking and the recoil velocity of the nucleus given by the VAMOS spectrometer (for details see Li et al. [50]). An automatic fit procedure was chosen to exclude biases for one or the other set of bases. The experimental data was processed, with the exception of choice of pulse-shape data bases, exactly as described in Ljungvall et al. [7]. For the detectors used in this work neutron-damage correction was not needed. Similar efforts to optimize the results of PSA using ADL have recently been published by Lewandowski et al. [29]. The reader is cushioned that due to strong correlations between different parameters entering in the calculation of pulse shapes and in the PSA it is difficult to compare individual parameters, especially as different figures of merits are used.
A first optimisation varying only the lattice orientation and the central contact hole radius was performed. Pulse-shape analyses were done using a total of 72 different bases for each crystal followed by γ-ray tracking. The resulting spectra were fitted by an automatic routine and the FWHM were extracted for each crystal and for the total spectrum. The results, for each crystal and for the sum Gridsearch 5keV rms noise Gridsearch 3keV rms noise Matrix inversion 5keV rms noise Matrix inversion 3keV rms noise γ-ray 246 keV γ-ray 770 keV γ-ray 1352 keV γ-ray 1826 keV γ-ray 2333 keV γ-ray 3905 keV Scan data GS Scan data MI Fig. 17. Position resolution as a function of γ-ray interaction energy for simulated data, for different γ-ray energies [45], and for data from the 3D-scanning of the S002 at Liverpool [47,48] using extensive grid search (GS) or SVD (MI).
of the crystals, are presented in figure 21. The minimum FWHM is achieved close to the nominal orientation for most of the crystals. However, the minimum of the sum is close to a lattice rotation of 30 • and with an assumed core radius of 6 mm. This seems to be driven by crystal A007. The nominal direction of the lattice is 45 • . In figure 21 the results obtained with the data bases calculated using ADL are also shown as a reference. A second minimisation was performed on a parameter space including the three different central contact radii, 5 different crystal lattice orientations and 16 different scalings of the charge carrier velocities. In figure 22 the variation of the FWHM for crystal A002 is shown for the three different central contact radii and as a function of the scale of the electron and hole velocities. For each data point a crystal lattice orientation of 45 • was chosen. As can be seen there is a correlation between the central contact radius and the best scale factor for the electron velocity. It is reasonable that it is the electron velocity that can be used to compensate for changes in the central contact radius as they are (mainly) responsible for the generation of the signal on the central contact. Furthermore, the change of the central contact radius generates the strongest change in the electric field in the regions where the largest contribution from the electrons to the signal is created. From this optimisation it is also clear that different parameters for the pulse-shape calculations are strongly correlated and that it is difficult, if not impossible, to determine individual parameters using only the width of a γ-ray peak (or any other single figure of merit).
From the second minimisation the bases that produce the smallest FWHM of the 1221 keV peak were chosen for each crystal. In figure 23 the lowest FWHM for each crystal is marked with a circle. It seems as if a slight increase of the hole mobilities, reflected by the scaling factor S h , improves the performance on average. With an exception of the C001 crystal. This is not a general statement about hole mobilities when modeling HPGe detectors but only applies to this work. As for the bore hole radius, 6 mm seems to be preferred with, again, C001 in disagreement. Possible reasons for the different behaviour of the C001 crystal will be discussed later in this section.
The most important parameter in the adaptive grid search PSA algorithm used within the AGATA collaboration [49] is the power used to calculate the figure of merit (FOM) for a pulse shape in the basis when compared to the experimental signal. A minimum is sought for the expression    which for p = 2 is the typical square sum FOM and i is the index of the samples points. Using the ADL bases it has been shown that an p of 0.3 give the best result [51] (for a recent in-depth discussion of the impact of the distance metric on PSA, see Lewandowski et al. [29]). A scan of p's were performed using the six selected AGATAGeFEM bases, and the resulting FWHM are presented in figure 24. sition resolution has been added (for details see Li et al. [50]) allowing to estimate the improvements made. Looking at the lower panel in figure 24 an improved position resolution of a few tens of millimeters is suggested, this by comparing the points using the ADL bases and the optimised AGATAGeFEM bases (at 0.3 on the x-axis). The corresponding γ-ray spectra are shown in figure 25. Visually the difference in FWHM of 0.35 keV for the peak 1221 keV peak is not obvious, and no manual fit has been performed to verify the difference. This in the spirit of minimizing biases when analysing the data. One can however state that the AGATAGeFEM produced bases per-  form as well as the ADL bases presently used for analysing AGATA data. An homogeneous γ-ray flux over the solid angle covered by one AGATA crystal is an excellent approximation, and as a consequence the γ-ray interaction points should be homogeneously distributed on planes parallel to front face of the detector (here the small effect coming from that strictly speaking we should refer to spherical surfaces is ignored). Looking at the projections of γ-ray interaction points onto the plane parallel to the front face is therefore an indicator of how well the PSA is performing. In the figures 26, 27, and 28 projections of γ-ray interaction points are shown for the six crystals and three different sets of bases, respectively. In all figures similar features can be seen. With the exception of crystal C001 the intensity of γ-ray interactions is clearly seen to be lower at segment boundaries. This is interpreted as coming from the oneinteraction per segment approximation used in the PSA and supported by the results of performing PSA on calculated signals as previously shown in figures 14 and 15. Based on the number of counts in the maximum bin the Metric exponetial p Fig. 24. Full Width at Half Maximum of the 1221 keV γ-ray peak in 90 Sr as a function of the exponential p in the metric used to compare entries in the pulse-shape bases with experimental pulse shapes. The test was performed with the bases selected to be the best according to the FWHM for each crystal. The best value of 0.3 is in accordance with earlier results. A range of 0.1-3 in steps of 0.1 was scanned but as the results grow worse as the metric increases beyond 0.3 results are only shown up to 1.5. Results from using the ADL bases and with AGATAGeFEM bases assuming a central contact radius of 6 mm and a crystal lattice rotation of 45 • are given as reference (shown as grey circles and blue rectangles, respectively). On the lower panel an approximate conversion to position resolution (FWHM) is given (see [50]). quality of the PSA improves when moving from ADL bases to optimized AGATAGeFEM bases for four out of six detectors. This is seen when comparing the scales in figure  26 and figure 28. However, the "hot spots" seen for crystal C001 remains pronounced for all bases. They are located at the corners of the front face and for depths in the crystal that is smaller than 4 mm (as determined using the ADL bases). To investigate these events closer an average of all traces belonging to the hot spot close to x~-30 mm, y~0 mm, z<4 mm was produced together with an average of events that gave x and y coordinates next to the hot spot (the two regions are marked in figure 26). On the events used for averaging the condition of a net-charge in only one segment was also enforced. In figure 29 the resulting averages are shown together with the pulse shapes from the ADL and optimized AGATAGeFEM bases coming from positions in the bases corresponding to the hot spot. As can be seen the average trace for events ending up at the hot spot does not reach its full value. This is most likely related to an incorrect determination of the start time for these events (in figure 29 the traces have been aligned for clarity). When trying to fit the time-misaligned traces the PSA algorithm always finds the same best position as the time alignment can be compensated by choosing an extreme rise time in the pulse-shape data basis. When comparing the traces from the ADL bases and the optimized AGATAGeFEM bases an explanation to why the C001 hot spots are "less hot" for the AGATAGeFEM bases is given. The start of the signal for the AGATAGeFEM bases is different allowing for more positions to reproduce the "false" rise time of the time-misaligned traces. It is however difficult to state if one basis is more realistic than the other as the "hot spot" is related to the preprocessing of the traces performed before the PSA or to the time-pickup made in Gamma-ray interaction points as determined with the ADL pulse-shape data base. For crystal C001 the regions used to create averaged traces when investigating the origins of "hot spots" are found inside the red circle and are marked in white for events belonging to the "hot spot" and in green for reference events, respectively (for details see text).
the digitizers of AGATA. This underlines the importance of preprocessing for successful PSA.

Conclusions
The C++ based software package AGATAGeFEM aiming at modeling segmented High-Purity Germanium detectors has been described. It allows the implementation of the detector geometry and segmentation schemes to within machine precision and uses Finite Element Methods to solve the Laplace and Poisson equations. The resulting fields are calculated using the basis functions and support points of the actual FEM grid, i.e. using function evaluation rather than interpolation. The charge-transport equations are solved using time adaptive Runge-Kutta methods from the GNU Scientific Library. To the induced charge signals linear and differential crosstalk is added together with the transfer function of the electronics. Convolution is made in the time domain. The model used in AGATAGeFEM for hole-charge carrier velocity has proven to give good results for PSA but still has room for improvements. In this work AGATAGeFEM has been used to investigate the impact of crosstalk and noise for the EGS PSA and for the SVD PSA. The result suggests that crosstalk at the level of what is found in AGATA has a small impact on the resolution of the PSA. Furthermore the influence of an imperfectly known crystal geometry has been investigated. It was found that a χ 2 figure-of-merit stating on how good the experimental signals could be fitted using the pulse-shape basis is not a good indicator for the precision of the geometry. In extreme cases the measured position resolution using in-beam methods can give indications. These results point to the importance to have well defined crystal geometries when modeling pulse shapes.
As a validation of the pulse-shapes calculated using AGATAGeFEM pulse-shape data bases for PSA on AGATA data have been produced and optimized. The resulting bases allow for analysing the data with results that are as good as the other state-of-the-art pulse-shape data bases, showing that the concepts and models used in AGATAGe-FEM are producing pulse shapes as realistic as the ADL presently used within the AGATA collaboration. It has also been shown that "hot spots" seen in the distribution "Hot spot" Next to "Hot spot" Basis AGATAGeFEM Basis ADL Fig. 29. Signals from the net-charge segment for one-segment events coming from the "hot spot" seen for crystal C001 (for the ADL bases, see figure 26).
of γ-ray interaction points from the AGATA PSA can be linked to problems in the data treatment prior to PSA, e.g. the time alignment of the traces.

Acknowledgement
The author would like to thank the AGATA collaboration and the GANIL technical staff. Gilbert Duchêne is thanked for providing the in-beam data set used to extract the position resolution of the pulse-shape analysis. A Parameters used for pulse-shape calculations