{'fraction_non_alphanumeric': 0.026448109412711182, 'fraction_numerical': 0.010458567980691875, 'mean_word_length': 4.788707799767171, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Characterization of a Maximum Likelihood Gamma-Ray Reconstruction Algorithm for VERITAS

We characterize the improved angular and energy resolution of a new likelihood gamma-ray reconstruction for VERITAS. The algorithm uses the average photoelectrons stored in templates that are based on simulations of large numbers of showers as a function of 5 gamma-ray parameters: energy, zenith angle, core location (x,y), and depth of first interaction in the atmosphere. Comparing the template predictions of the average photoelectrons in each pixel to observed photoelectrons allows us to calculate the likelihood. By maximizing the likelihood, we find the optimal gamma-ray parameters. The maximum likelihood reconstruction improves on the standard VERITAS analysis which relies on: 1. the weighted average of the axis of elongation in the images to determine the gamma-ray direction and 2. look-up tables that relate the observed energy deposition of Cherenkov photons to the true gamma-ray energy. Not only is the maximum likelihood method more accurate, but it is also not biased by missing pixel information due to the edge of the camera or pixel cleaning. The drawback is that it takes more CPU time (80 ms/event).


Introduction
Imaging Air Cherenkov Telescopes (IACTs) have been using weighted averages of air-shower images to successfully reconstruct gamma-rays for over twenty years. Hillas parameters [1] are formed from the moments of the shower-image formed by Cherenkov light from air-showers. The direction of these moments is traditionally averaged to find the air-shower direction, and look-up tables are typically used to relate the amount of the detected light to the incident γ-ray energy [2]. As processor speed and memory increase, maximum likelihood fitting methods have become a viable option. LeBohec and de Naurois have demonstrated the improved resolution and sensitivity of maximum likelihood methods using shower-image templates for IACTs [3,4] and the H.E.S.S. collaboration has created the ImPACT algorithm based on the method [5]. Here we report on our implementation of the shower-image template maximum likelihood γ-ray reconstruction method (ITM) in a VERITAS standard analysis package (VEGAS_v2.5.6) [6]. The primary advantage of maximum likelihood methods is that they are not biased by missing information such as images that extend beyond the edge of the camera or pixels removed because of bright starlight.
Our method interpolates between shower-image templates based on six gamma-ray parameters: energy, zenith angle, azimuthal angle, core location (x,y), and depth of first interaction in the atmosphere. The templates were created by Vincent [7] for VERITAS using CORSIKA simulations of gamma-ray air showers . Each template contains the average number of photoelectrons that are expected to be detected by a VERITAS PMT based on the incident energy, zenith angle, core location, as well as the depth of first interaction in the atmosphere. The reconstruction code rotates the template pixels to the camera coordinates for a specific azimuth and wobble. It then calculates the likelihood by comparing the template prediction to the observed number of photoelectrons in Observed VERITAS Event Template Prediction Figure 1: Images from each of the four VERITAS telescopes. (left) Real candidate γ-ray event, (right) Image-template prediction. each pixel. By maximizing the likelihood, we find the optimal γ-ray parameters. Example camera images are shown in Fig. 1. Here, a low-energy γ-ray candidate event is shown on the left and the template prediction is shown on the right. The reconstructed energy for this event is about 150 GeV, close to the energy threshold for VERITAS. Missing pixels are shown in black. The group of four pixels in the NW portion of each camera are coincident with the image of a bright star. To reduce damaging anode currents in the photomultiplier tube, the HV in these pixels was lowered during the observation. It is not unusual for the missing pixels to affect the γ-ray reconstruction.
To make fitting methods robust and fast, we consider four practicalities of the implementation. First, maximum likelihood methods require that the likelihood produces a reliable gradient so that they move successfully to the optimal solution. For IACTs, the requirement is that the seed parameters produce a pool of expected Cherenkov light that overlaps with the observed shower image. Most of the camera is dark, and the gradient is not valid if the seed predicts light only where the pixels contain pedestal noise. We therefore seed the new algorithm with gamma-ray parameters from the standard moment analysis which are generally close to the optimal parameters. The second practical consideration is time. The average time to reconstruct and event is 80 ms. We use the mean-scaled width and length of the shower to select only the likely gamma-rays for reconstruction. These cuts, which primarily remove cosmic ray showers, are independent of the reconstructed parameters and do not bias the reconstructed events. The third practical consideration is the relationship between the template predictions and the observed signals. An overall energy calibration factor was developed to account for the detector effects, including seasonal differences in the atmosphere, mirror reflectivity and electronic response, among other considerations. Finally, Earth's magnetic field also affects the energy scale, especially for lower-energy showers, which show a separation of electrons and positrons as the shower develops due to the Lorentz force. As shown in Fig. 2, by the time they reach the ground, Cherenkov photons radiated by electrons are separated from those radiated by positrons, changing the density and angular distribution of the photons entering the IACTs. Because the strength of the force depends on the angle between the incident γ-ray and the local magnetic field, we apply a calibration correction for the energy that depends on both the incident zenith and azimuthal angles.

Angular and Energy resolution
The simulated angular resolution is shown in Fig. 3. The 68% containment radius depends on the γ-ray energy and zenith angle. The standard moment analysis is shown for comparison. The new algorithm localizes γ-rays 25% to 30% better. Angular selection cuts, θ , were optimized for the detection of a 1% Crab flux using VERITAS data. For a medium to hard spectrum, with a power-law index less than 3, the optimal cut on angular separation between the reconstructed γ-ray direction and the direction to the source is θ < 0.071 • . For soft spectra, with a power-law index greater than 3, the optimal cut is θ < 0.1 • . The sensitivity of the new medium to hard analysis is 35% better than the moment analysis and the soft analysis is 30% better. The simulated energy resolution is shown in Fig. 4 for a variety of zenith angles. At the lowest energies, the simulated trigger bias is evident. At energies above a few TeV, some pixels are likely to switch to their low-gain mode to avoid saturating. The templates have not yet been tested for pixels in the low-gain mode with N pe > 300, so at present the new algorithm removes these pixels from the reconstruction. The energy can still be reconstructed with minimal bias using the remaining pixels in the image. The energy range of the new algorithm extends from 140 GeV to 30 TeV. The trigger bias is currently folded into the systematic uncertainty, but we have plans to implement an unfolding algorithm for the spectral reconstruction code in the future.

Crab Observations
We analyzed 3.75 hours of observations taken between 2013 and 2016 to show how the algorithm with soft cuts performs on real data. Significance maps are shown in Fig. 5. The source is well localized and the angular spread of γ-ray candidates is in good agreement with the simulations. The significance scale was adjusted on the right-hand map to show that background fluctuations are distributed as expected. Three stars are in the field and there is no evidence of bias in these nuisance regions. This is confirmed by the significance distribution shown in Fig. 6. Notice that the backgrounds, even those within the circles denoting stars follow a Gaussian function. The analysis of the Crab spectrum shows good agreement with the standard algorithm.

Sensitivity
The optimal angular cuts are more stringent now that the angular resolution is improved. The tighter angular cuts result in higher sensitivity primarily due to reduced background from a smaller on-source region. The smaller nuisance regions near stars also provide more area to measure the backgrounds accurately. Fig. 7 shows the time it takes to detect a source for various fluxes. For simplicity, the flux is given in Crab Units (CU) defined to be the integral flux of the Crab Nebula above 180 GeV. The medium spectrum used here is scaled using Crab observations (spectral index of 2.48) [10] and the soft spectrum is scaled using PKS 1424+240 observations (spectral index of 3.8, energy threshold 140 GeV) [11]. With the image-template method, dim sources with an intensity of 1% CU can be detected more than 40% quicker. These improvements have come entirely through the application of more sophisticated software and are comparable to the improvements achieved by the camera upgrade in 2012 [9].

Conclusions
The new image-template method provides a significant improvement to the science reach of VERITAS. The sensitivity is improved by 25% for dim soft-spectrum sources and 35% for dim medium-to hard-spectrum sources. The background nuisance regions around stars are substantially reduced making analysis far simpler. The improved energy resolution is expected to reduce uncertainties in spectral parameters. Furthermore, the algorithm is also practical to run, requiring only about 2.5 times more disk space at the earliest stages and about 30% more processing time.