{'fraction_non_alphanumeric': 0.0322011965266968, 'fraction_numerical': 0.016785131561673636, 'mean_word_length': 4.649713922441195, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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}}
Real-time Analysis and Selection Biases in the Supernova Legacy Survey

The Supernova Legacy Survey (SNLS) has produced a high-quality, homogeneous sample of Type Ia supernovae (SNe Ia) out to redshifts greater than z=1. In its first four years of full operation (to June 2007), the SNLS discovered more than 3000 transient candidates, 373 of which have been confirmed spectroscopically as SNe Ia. Use of these SNe Ia in precision cosmology critically depends on an analysis of the observational biases incurred in the SNLS survey due to the incomplete sampling of the underlying SN Ia population. This paper describes our real-time supernova detection and analysis procedures, and uses detailed Monte Carlo simulations to examine the effects of Malmquist bias and spectroscopic sampling. Such sampling effects are found to become apparent at z~0.6, with a significant shift in the average magnitude of the spectroscopically confirmed SN Ia sample towards brighter values for z>0.75. We describe our approach to correct for these selection biases in our three-year SNLS cosmological analysis (SNLS3), and present a breakdown of the systematic uncertainties involved.


Introduction
Type Ia supernovae (SNe Ia) have frequently demonstrated their value as standardizable candles out to redshifts of z 1.5. Studies of the expansion rate of the universe using SNe Ia have revealed the cosmic acceleration (Perlmutter et al. 1999;Riess et al. 1998), providing the most direct evidence for the presence of Dark Energy needed to drive the expansion of the universe. Subsequent searches have led to SN Ia discoveries over a wide range of redshifts (e.g., Astier et al. 2006;Miknaitis et al. 2007;Sako et al. 2008;Riess et al. 2007).
SNe Ia are relatively rare, transient objects lasting a few weeks in the rest-frame. They are most efficiently found through photometric monitoring of large areas of sky using a "rolling-search" technique to both find and follow SN events. Current examples include the ESSENCE survey (Miknaitis et al. 2007;Wood-Vasey et al. 2007), the SDSS-II SN Survey (Sako et al. 2008;Kessler et al. 2009), and the Supernova Legacy Survey (SNLS; Astier et al. 2006). The SNLS observed four 1-square-degree Deep Fields as part of Canada-France-Hawaii Telescope Legacy Survey (CFHT-LS) 1 . Multi-color light curves were obtained using the MegaCam imager on CFHT, with follow-up spectroscopy from the Gemini, VLT, and Keck telescopes. Owing in large part to its careful survey design and a substantial commitment of observing time from CFHT and the follow-up telescopes, the SNLS now offers a large, consistent, and well-defined set of SNe Ia measured out to z ∼ 1.
Real-time supernova searches require adequate light-curve sampling, a rapid output of photometry measurements, and a method to quickly prioritize candidate lists for followup studies (e.g., Sullivan et al. 2006a;Miknaitis et al. 2007;Sako et al. 2008). It is most advantageous to obtain spectroscopy near maximum SN brightness (e.g., see Howell et al. 2005). Since SNe Ia have typical rise times of ∼ 19 days (rest-frame B, Conley et al. 2006), and considering that observations are typically only taken during dark and grey time, in some cases only a couple of measurable epochs are available before peak. Data organization and the coordination of follow-up activities are therefore critical. In the SNLS, Canadian and French teams each ran independent detection pipelines, then amalgamated both candidate lists into a centralized database. Herein, we report exclusively on the Canadian real-time analysis pipeline.
As the extent and quality of SN Ia data sets improve, the relative impact of statistical uncertainties decreases and the management of systematic errors becomes the limiting factor (Kessler et al. 2009;Regnault et al. 2009;. One important source of systematic error in SN Ia studies arises from the incomplete sampling of the underlying SN Ia population: surveys tend to preferentially discover and follow brighter objects at higher redshifts, leading to Malmquist bias (Malmquist 1936) and other selection effects. Using detailed Monte Carlo simulations of artificial SNe Ia in all of the real-time detection images, we can determine the recovery efficiency and calculate the magnitude of the various sampling biases (see also . These can then either be directly applied to the data, or used to motivate fitting priors or corrections used when determining cosmological parameters (e.g., Kessler et al. 2009). This paper is organized as follows: An overview of the SNLS and a description of the Canadian SNLS real-time-analysis (RTA) pipeline and web database are given in §2. §3 presents the methods used in ranking candidates for spectroscopic follow-up observations. The Monte Carlo simulations used to calculate the SNLS detection efficiencies are described in §4 along with the recovery results. The effects of Malmquist bias and spectroscopic sampling are explored in §5, with a discussion of the systematic errors in the Malmquist bias in §6. The paper concludes with a summary in §7.

SNLS observations
The five-year Supernova Legacy Survey ran from [2003][2004][2005][2006][2007][2008] and was based on images obtained from the CFHT-LS Deep Synoptic Survey. The four Deep Field pointings were positioned to avoid extremely bright stars, minimize Milky Way extinction, and overlap with the fields of other multi-wavelength surveys to provide complementary data. The coordinates of the SNLS Deep Field centers are given in Table 1.
Observations were obtained in queue-scheduled mode at CFHT using the MegaCam wide-field imager (Boulade et al. 2003). MegaCam consists of 36 2048 × 4612 pixel 2 CCDs arranged in a 4 × 9 square mosaic. The CCDs have a resolution of ∼ 0.186 ′′ /pix and provide good sampling of the 0.7 ′′ median seeing at CFHT. A large (1.5 ′ ) dithering pattern was used to cover the 80 ′′ wide gaps between CCD rows in the MegaCam mosaic.
The SNLS employed a rolling-search observing strategy, with target fields imaged every 3 − 4 days in dark or grey time using multiple filters to provide optimal light-curve sampling and the opportunity for early SN discovery. This cadence translates to ∼ 2 − 3 days in the SN rest frame. Each MegaCam queue run lasted on average 16 − 17 nights centered around the new moon, typically providing 5 epochs (nights) of observation per field per lunation. An advantage of this scheme is that the same telescope is used to discover and follow-up all candidates, leading to considerable advantages in calibration.
The four filters used by SNLSg M r M i M z M -are similar (but not identical) to the filter system adopted by the Sloan Digital Sky Survey (Fukugita et al. 1996;Smith et al. 2002). Deep Field images were also obtained in u M , but these were not time-sequenced and thus were not used in the real-time analysis. A detailed description of the SNLS photometric calibration is provided in Regnault et al. (2009). Observations in the primary search filter (i M ) were alternated between "long" and "short" epochs in order to balance the requirements for adequate light-curve coverage with the need to conduct several deep searches within each queue run. Filter spacing and nightly exposure times for a typical queue run are provided in Table 2.
A major strength of the SNLS program is that it obtained better filter coverage and lightcurve cadence than had been achieved by previous high-z surveys. Other advantages included having a large quantity of dedicated telescope time with data acquisition coordinated through CFHT's Queued Service Observing mode. Furthermore, developing a careful strategy for the organization, analysis, and communication of SNLS data products was necessary to efficiently manage the continual acquisition of new target information. The process employed by the SNLS collaboration included linking remote search pipelines with a centralized database, and providing web-based applications as a simple user interface with communication and analysis functionalities. These are described in the next section.

Image processing
MegaCam images of the Deep Fields destined for SNLS analysis were pre-processed in real-time using the CFHT Elixir pipeline (Magnier & Cuillandre 2004). The Elixir pipeline performed bias subtraction and flat-fielding, as well as a basic fringe subtraction on the i M and z M images. Elixir-processed images were promptly made available to the SNLS team for further processing.
The real-time detection pipeline implemented by the Canadian SNLS team is outlined in the flowchart of Figure 1. Many of the processing steps were accomplished using IRAF 2 tasks. Due to time constraints and observatory requirements, the image processing was carried out remotely on SNLS computers at the CFHT headquarters in Waimea. Certain shortcuts were taken in the real-time pipeline as compared with the "final" photometry procedure used in the cosmological analysis (described in Guy et al. 2010). These were necessary since the SNLS RTA was operating under significant time pressures for discoveries and analysis.
Elixir-processed images were trimmed and reoriented, then bad pixel masks were created to flag and remove image artifacts and saturated stars. To account for optical distortions, astrometric solutions were fit to each CCD using combined catalogs from USNO-B and SDSS Fig. 1.-The Canadian RTA pipeline. The dotted box delineates the procedures that monitor incoming Elixir-processed images. The rest of the steps proceed on the pre-processed images as described in the text.
to align the images to the International Celestial Reference System (ICRS). The resulting fits had RMS residuals that were typically better than 0.06 ′′ (0.3 pixels) across the mosaic.
Photometric alignment of the RTA images was accomplished using aperture flux measurements of ∼ 20 000 − 40 000 "RTA secondary standards" selected over a wide range in brightness for all filters within each field. These secondaries were chosen from isolated objects exhibiting no significant changes in brightness over many epochs. Comparing the measured fluxes for the secondaries in a given epoch to their catalog values provided a multiplicative scaling factor used to flux calibrate each image. As such, all flux measurements over the duration of any SN light curve were consistently in the same reference system, removing variations in exposure time, airmass, and extinction. In the RTA, the images were calibrated to the AB photometric system (Oke & Gunn 1983); this differs from the method used in final photometry, which calibrated to the Landolt (1992) photometric system (Regnault et al. 2009).
Individual flux-scaled CCD images were adjusted for variations in effective pixel area using the IRAF MSCRED (mosaic data reduction) task MSCPIXAREA. Resampling and coaddition of the night's images were then done using the TERAPIX SWarp 3 program to form a median mosaic image and its accompanying weight-map for each field+filter combination.
The subtraction of a deep reference image from the science mosaic revealed the presence of SNe and other variable objects in the data. References for each field were constructed by selecting photometric images with excellent seeing ( 0.5 ′′ ) and good transparency. To avoid the presence of SN light in the reference images, only frames taken in years prior to the current observations were included in each stack 4 . These component images were flux scaled, WCS-aligned and co-added as described above to form the reference image. During the course of the survey, new RTA stacks were constructed at least once per season as more images became available to improve the depth of the reference mosaic.
Differences in image quality between the science and reference mosaics must be taken into account prior to image subtraction. A non-parametric point-spread function (PSF) matching routine was used to effectively degrade the seeing of the better quality imagetypically the reference -to match the seeing of the other image (see Fraser et al. 2008, Appendix A). A Moffat function was fit to a select set of a few thousand isolated, bright "PSF stars", culling those with poor-quality fits. A variable convolution kernel was computed for each star, matching the two PSFs. The reference image was then convolved with the kernel to produce a PSF-matched mosaic. Finally, the matched frame was subtracted from the science frame.
A sample "detection triplet" is presented in Figure 2 for a high-redshift SN candidate: SNLS-04D2ca at z = 0.835. It shows thumbnail images of corresponding regions in the science image for one epoch, the PSF-matched reference image, and the difference.
One drawback of the real-time analysis procedure is that, in the interest of processing speed, the method of co-adding the individual epoch images prior to the PSF-matching step meant that if the image quality changed significantly during a night's set of observations, the resulting difference image may have contained residuals from poor subtractions of host galaxies. Normally, such residuals were easy to identify and immediately cull from the output detection list, as described in the next section.

Supernova detection
Once the host galaxy light was removed via the subtraction of the reference image, potential supernova candidates appeared in the subtracted images as star-like objects with positive flux (see the right-hand panel of Figure 2). The subtracted images were searched using an algorithm that employed the TERAPIX SExtractor routine (Bertin & Arnouts 1996) to build a catalog of possible objects and apply a series of tunable culling procedures. Each preliminary catalog of detections was cleaned of objects with very low signal-to-noise or a significant fraction of bad pixels, as well as objects with irregular profiles or high secondorder moments. Adjustable image quality limits were available for additional culling on PSF-fit quality parameters and background sky measurements.
Residual features in the difference images could result from poorly subtracted galaxies or bright stars. These residuals commonly appeared as alternating bright and dark regions -the bright areas could sometimes survive the other culling procedures. To compensate for this, the detection code also compared the image statistics in defined regions immediately surrounding the candidate to help remove such false detections from the object list.
The resulting raw list of variable object candidates in each epoch was then used to produce a composite mosaic of detection triplets for visual review and a manual selection of candidates. The number of raw output detections depended on the parameter limits established for the cuts (e.g., the S/N cutoff). We generally opted to use liberal cuts and do a manual pre-selection of SN candidates from the resulting 200 raw detections. Of these, typically ∼ 10% remained as plausible SN candidates. Using the visual display of candidates, many of the remaining PSF-matching residuals, image artifacts, moving objects, and stellar cores that may have survived the previous culling steps could be removed.
Detections were primarily made using the i M (and to a lesser extent r M ) images in order to focus on the target redshift range of interest. Candidates that were too faint in i M were poorly-suited for SNLS follow-up spectroscopy and cosmological analysis. A detailed analysis of the detection incompleteness is presented later in §4.

Photometry
Supernova flux measurements were calculated using a PSF-fitting routine. The same sets of isolated stars used in PSF-matching step ( §2.2) were used to create a mean local PSF and residuals map for input to the fitting routine. The stellar model was then scaled to match each detection in the difference image, thus providing the flux of each source. In addition to the PSF photometry, aperture fluxes were also calculated using a range of static and seeing-dependent aperture sizes.
The output PSF-fit fluxes measured in each epoch were used to construct multi-color light curves for all of the variable-object candidates detected by SNLS. These light curves were then fit with SN Ia templates to assist in classification and to provide photometric redshift measurements; this process is described in §3.
A sample set of SN Ia light curves in g M r M i M is shown in Figure 3, demonstrating the typical observing cadence obtained by the SNLS.

The SNLS web database
Once the manual review and culling was complete for a given epoch, the preliminary detection list was loaded into the SNLS database in preparation for ranking and follow-up measurements. New SN candidates and photometry were made available to the community via the World Wide Web 5 , typically within 4 − 6 hours per field.
An observing request utility was used communicate the latest SNLS requirements to the CFHT queued service observers (QSOs). This tool kept the QSOs advised of the detailed priorities of the survey, reaching a level beyond what could normally be expressed in the Phase II application that was submitted at the start of each run. Often, observing condi-   tions, SN candidate status, and follow-up telescope availability called for some flexibility in field/filter observing priorities for SNLS.
Additional online tools facilitated the coordination of observing schedules and followup allocations so as to optimize the use of the available 8-10 m telescope time. A detection "forum" was used to collect comments and personalized rankings for candidates being considered for follow-up spectroscopy. Automated (but customizable) online finder charts simplified subsequent observations in both single-target and multi-object modes.
It is worth noting that the light curves of all candidates in the database were followed until they became too faint or were unequivocally rejected as a non-SNe. No candidates were thrown away, no matter how poor; all have been stored in the database for later studies.

Prioritization and spectroscopy
As with most supernova surveys, the SNLS was limited by the amount of time available for spectroscopic follow-up. Even with its maximum allocation of ∼ 140 hours of 8-10 m telescope time per semester, the SNLS was only able to follow a small fraction of all possible SN detections. Differentiating the SNe Ia from other variable sources using only a few early observations presented a significant challenge.

Candidate ranking
The success of any supernova survey relies on the careful selection of SN Ia candidates with enough time to optimally schedule spectroscopic follow-up close to peak magnitude. Light-curve fits and brightness cuts were the primary methods used to identify and rank SNLS targets for spectroscopy. The addition of photometric pre-selection dramatically improved the SNLS spectroscopic efficiency over comparable surveys, even at high redshift (Howell et al. 2005).
Probable SNe Ia could typically be identified from two or more epochs of real-time photometry with the supernova light-curve fitting technique described in detail in Sullivan et al. (2006a). The output light-curve fits are parameterized by redshift, stretch, peak brightness, and time of maximum light. Comparisons between photometric and spectroscopic redshifts for the SNLS SNe Ia are available in Sullivan et al. (2006a) and Perrett et al. (2010). Non-SNe Ia could be screened out based on their measured colors (g M − r M ) and rise times. All SN candidates were measured against several criteria to determine their suitability and prioritization for spectroscopic follow-up. Candidates with poor-quality SN Ia light-curve fits, or with fitted stretch values outside the range 0.7 ≤ s ≤ 1.3, were generally given the lowest ranking or were rejected entirely.
Observing near maximum light yields the brightest contrast between the SN and its host, and is the time when the spectral lines most clearly differ between supernova types. SNLS SNe Ia were normally discovered before peak, and the predicted phase from the fits allowed for optimal spectroscopic scheduling. Each candidate SN was required to have been detected at most seven days (rest frame) past its estimated peak date in order to qualify for timely spectroscopic observing. Objects discovered at the very start or end of an observing season were typically discarded if they would have no measurements either before or after peak. Enough of the candidate's light curve must be measured to provide adequate fits and prove useful for cosmology.
Limits were placed on the minimum observed brightness and fractional increase of each candidate compared with its host galaxy. Percent increase is defined as: where flux is measured in small (3-pixel radius) apertures in the science image (f sci ) and the reference (f ref ).
Due to the vagaries of weather and telescope scheduling, it is impossible to give a precise description of the selection process for sending candidates for spectroscopic followup. However, a good description of the average algorithm is as follows, with all observed magnitudes presented in the AB system: 1. Extremely bright SNe (i M < 22.9) always qualified for spectroscopic follow-up.
Candidates fainter than i M ∼ 24.4 were generally never observed spectroscopically.
The basic form of these limits was suggested by the experience of those selecting candidates for follow-up, and tuned by comparing the distributions of peak magnitude, color, and light-curve width of moderate redshift SNLS SNe (z < 0.6), where the survey should be essentially complete, to those of higher redshift SNe.
In practice, the selection process remained somewhat subjective. External factors also played a role in the ranking of candidates by SNLS members -e.g., the availability of follow-up telescope time, detailed scheduling limitations, long-term weather conditions, and the desired spread in redshifts needed for cosmological measurements.

Spectroscopy
Spectroscopic observations are necessary to verify candidate types and to obtain accurate redshift measurements for the SN and/or its host galaxy. SNLS spectra were obtained from 8-10 m class telescopes including Gemini 6 (Howell et al. 2005;Bronder et al. 2008), the Very Large Telescope (VLT) 7 (Balland et al. 2009), and Keck 8 (Ellis et al. 2008).
The redshift distribution of the spectroscopically-identified SNe Ia found by SNLS is shown in Figure 4. The spectroscopic sample is fairly complete out to z ∼ 0.6, at which point the numbers begin to drop off as the amount of exposure time required per candidate increases significantly. This effect on the incompleteness of the SNLS is examined later in §5.
Histograms showing the breakdown of the sample by type and spectroscopic redshift from the various telescopes are presented in Figure 5. Candidates labeled as "SN?" are those that have not been confirmed as SNe Ia or core-collapse SNe; this category may also include other types of variable objects that were not easily distinguished from supernovae. The non-SNe category mostly includes active galactic nuclei (AGNs) and other objects, most of which were observed prior to the implementation of the photometric fitting technique for follow-up ranking described in §3.1.
The median spectroscopic redshifts of the SNe Ia observed at the three observatories are Higher-redshift candidates were more frequently sent to Gemini because of the larger observing overheads, and because the nod-and-shuffle mode available at Gemini is useful for removing sky lines to obtain better spectra of high-z SNe. The Keck observations included several SN Ia programs with different science goals.

Candidate numbers
In its first four years of full operation (to July, 2007) 9 , the SNLS discovered > 3000 astrophysical transient events. Of these, 373 were spectroscopically identified as SNe Ia. This is the same SNLS sample used in the SN Ia rates analysis of Perrett et al. (2010). As expected, there is a strong correlation between the number of SN Ia detections and the total observing time in i M , as demonstrated in Figure 6. This figure contains four plots, one per field, each showing the running total of SNLS exposure time per filter (with i M in red) for comparison with the cumulative number of SNe Ia discovered (the shaded areas).
A summary by type for all SNLS transient detections (excluding moving objects and subtraction artifacts) is provided in Table 3. N refers to the number of objects of each type in the SNLS real-time database and N spec is the number of those with available spectroscopy. Trailing question marks "(?)" in the type label in Column 1 indicate that the number  includes both confirmed and probable identifications of that type. SNe Ia? are classified as "probable" because their spectra best match that of a Type Ia, but another type of supernova -typically a SN Ic -cannot be conclusively ruled out from the spectrum alone. SNe Ia? are equivalent to the SNe Ia * described in Howell et al. (2005) and Balland et al. (2009). New SN-like detections were given the default label "SN?" in the database until they could be identified via spectroscopy. (The one exception is a SN II-P SN, which could be identified from the obvious plateau in its light curve.) Three of the objects categorized as SN Ib/c(?) are actually confirmed SNe Ic: SNLS-03D4aa, SNLS-04D4jv, and SNLS-06D4dv (Balland et al. 2009).
We believe the bulk of the "Other SN" category to be real SN events that were not followed spectroscopically due to a lack of follow-up time. Many of these are very faint (in some cases below the spectroscopic limit) and likely high redshift; some had colors that were clearly incompatible with SNe Ia. Others will be SN Ia events in our redshift range. These candidates will be analyzed further to measure the volumetric SN Ia rate in Perrett et al. (2010). The "non-SN" category includes a large number of other astrophysical transient events, including AGN and variable stars, identified via their erratic light curves and central location in their "hosts".
We emphasize that the relative numbers of the different types of SNe in Table 3 are strongly affected by spectroscopic selection procedures. The total numbers are also influenced by factors such as losses due to poor winter weather conditions on Mauna Kea, as well as the slow ramp-up of observing during the pre-survey period. These observational effects are incorporated into the candidate recovery statistics that are measured in the next section.

SNLS Detection Efficiency
A thorough understanding of the recovery statistics in the RTA pipeline provides the basis for calculating sample selection biases. Detailed Monte Carlo simulations were carried out to measure the efficiency of SN Ia recovery from the SNLS real-time images. Although these simulations could have been performed concurrently with the real-time candidate searching (e.g., Dilday et al. 2008), in the SNLS we perform these simulations completely separately from the daily search activities. A description of the input test population is provided in §4.1, and the results of the simulations are outlined afterwards in §4.2.

SNe Ia input parameters
In all, 15 realizations of 10 000 artificial SNe each were performed individually for every Deep Field observing season up to the end of D3 in the summer of 2007. A "field-season" represents the period over a year during which a given field was visible: in this current sample, D3 was visible for five seasons (counting the pre-survey observing), while the rest of the fields were each visible for four. This yields a total of more than 2.5 × 10 6 artificial SNe tested in the simulations during 17 field-seasons.
To begin, a random redshift was selected for each input artificial SN from a uniform distribution over 0.1 ≤ z ≤ 1.2. The artificial SNe were then randomly assigned to hosts chosen from the SNLS field galaxy catalogs compiled from measurements of deep image stacks (see Sullivan et al. 2006b). The limiting magnitude of the reference stacks is i M ∼ 25.7 mag (AB), much fainter than the detection limit for any given epoch. Photometric redshifts for the field galaxies were calculated based on the PÉGASE.2 galaxy spectral evolution code (Le Borgne et al. 2004). A random host galaxy within z ± 0.02 of the selected redshift was picked in the appropriate Deep Field, weighted by a probability approximated by the two-component model for SN Ia rates (SNR): (Mannucci et al. 2005;Scannapieco & Bildsten 2005). A = 5.3 × 10 −14 SNe yr −1 M −1 ⊙ is the mass coefficient, and B = 3.9 × 10 −4 SNe yr −1 (M ⊙ yr −1 ) −1 is the coefficient of the starformation rate (SFR) term (adopted from Sullivan et al. 2006a). As a precaution against overcrowding, a field galaxy was not permitted to host more than one artificial SN during any given season.
The artificial SNe were assigned galactocentric positions drawn from a 2D Gaussian distribution about the host centroid 10 , verifying that each fell within the galaxy's detection ellipse returned by SExtractor. This produced a list of input coordinates for the input sample according to the astrometric solution of the reference stack.
The input objects were then randomly allocated stretch values drawn from a uniform distribution in the range 0.5 ≤ s ≤ 1.3. This wide range was adopted in order to over-sample the parameter space of interest, to include recovery statistics for potential sub-luminous SNe 10 The galaxy light in the stacks has already been convolved with the seeing (∼ 0.5 ′′ ), yet the SN positions are accurate to ∼ 0.1 ′′ . This will slightly underestimate the true central concentration of the input SN distribution. However, we find that the recovery fraction is quite flat with radius, as shown later in Figure 11. This is also in agreement with the conclusions of Howell et al. (2000), who demonstrate that selection bias at small host radii is not significant for CCD observations of high-z SNe Ia.
in the SNLS data (González-Gaitán et al. 2010). This population could later be resampled to investigate the observed distribution ( §4.2).
Each candidate was assigned a random peak date within the range min(MJD obs ) − 20 ≤ MJD peak ≤ max(MJD obs ) + 10, where MJD obs are the observed dates of all of the SNLS images obtained for the field and year being tested. The +10 −20 values are included to account for candidates that were detected while fading at the start or rising at the end of a field's observing period. Observational culls based on a required minimum number of observations before and after peak could be applied later as needed to test for selection bias.
The peak B magnitude appropriate for a Type Ia at each chosen redshift was calculated by incorporating the stretch-luminosity relationship and an absolute magnitude derived from cosmology fits assuming H 0 = 70. The adopted cosmological parameters are Ω m = 0.27, Ω λ = 0.73, and Ω k = 0. A random dispersion in the peak B-band magnitude (∆m B = ∆mag) was then applied after the stretch correction, drawing from a Gaussian distribution with an intrinsic scatter of σ int = 0.15. Again, a broad dispersion was adopted so that the output distribution could be resampled as needed.
A rest-frame spectrum was extracted from an SN Ia spectral template (Hsiao et al. 2007) and was scaled up or down to the appropriate B magnitude for each artificial object (with dispersion applied), thereby also affecting U and V . The output peak B magnitude was found by integrating over the Landolt filter functions. The U −B and B −V colors at peak were calculated using a bilinear model of the stretch-color relationship with a break at s = 0.8 (Garnavich et al. 2004), such that: This s − c relationship model was derived from fits of color as a function of stretch for the sample of low-z SNe Ia and the SNLS spectroscopic sample at z < 0.6 (González-Gaitán et al.

2010).
This procedure yields U and V rest magnitudes, and thus raw colors, for the artificial SNe. Gaussian noise with a dispersion of σ = 0.04 was added independently to U and V to adjust the colors, and the spectrum was "mangled" (i.e., color-corrected) to those values (see Hsiao et al. 2007).
The spectral energy distribution was next reddened to account for Milky Way extinction, E(B −V ) MW with R v,MW = 3.1, by randomly selecting from a one-sided (always positive) Gaussian distribution with σ = 0.015. Host extinction, E(B −V ) host , drawn from a uniform color distribution within the range −0.25 ≤ c ≤ 0.5, was also incorporated by assuming R v,host = β − 1.0, with β = 3.0 to match the SNLS spectroscopic sample at low redshift. Note that this does not precisely match our current understanding of the SN Ia color-color relationship (Guy et al. 2007;), which does not entirely match any measured dust law. However, this has a negligible effect on our estimates of Malmquist bias or SN rates as discussed later.
Finally, realistic SN Ia light curves were generated using a similar process as described above for calculating the peak magnitudes and colors. Randomly selected, isolated PSF stars in each object's CCD (brighter than the object to add) were used as the artificial SN models. Poisson noise was added to account for image gain. The stellar models were scaled and inserted with their appropriate phases, magnitudes, and positions into every pre-processed i M image obtained by SNLS. Due to the transient nature of SNe Ia, most of the input objects added to any particular image were fainter than the detection limit, and no overcrowding effects were observed in the trials. The images were then processed and analyzed using the same RTA procedure as described in §2.2. The output detection lists for each epoch were compared with the input records to calculate the recovery efficiencies as a function of several supernova parameters.
The strength of this straightforward yet rigorous approach is that it makes use of all of the actual images obtained by SNLS to measure recovery rates. This avoids the need to make assumptions about the detailed frequency and spacing of the observations, technical losses (e.g., missing CCDs), weather conditions, other observational effects, or to use simplified parameterizations to represent the recovery efficiencies.
Before calculating the recovery statistics, the input distribution of artificial SNe Ia is first resampled in z, s, c, and ∆mag. The goal is to represent the underlying population of (nonpeculiar) SNe before selection effects by adopting distributions of light-curve width, color, and σ int that match the observed distributions as a function of redshift in the selected sample. The low-redshift portion of the sample (z 0.6) is extremely useful for constraining these distributions, but note that we are making the assumption that the underlying demographics of the population do not change significantly more strongly than the A + B model of Eq. 2 suggests.
Rather than re-sample the input distributions, we instead simply weight the distributions to obtain the same effect while obtaining higher statistics in our measurement by not throwing out any objects. We weight the SN distribution to σ int = 0.11 mag based on the cosmological fits in Guy et al. (2010); . This differs from the value adopted therein because the simulated SNe used here do not include uncertainties in the input lightcurve model or other systematics which tend to increase the measurement uncertainties. We find that the underlying stretch distribution is well described by a two-component Gaussian distribution. A two-component Gaussian could not provide a good match to the observed color distribution and the evolution in the observed mean color with redshift due to selection effects. Instead, we have adopted the convolution of a exponential distribution and a Gaussian, similar in form to that of Jha et al. (2007).
The parameters of the stretch model are (mean, σ, peak value) 0.92, 0.11, 0.37 for the first Gaussian and 1.06, 0.08, 0.80 for the second. For the color model, the σ of the Gaussian is 0.04, the τ of the exponential distribution 0.155, and the mean value of the distribution 0.07. Note that we do not interpret the color distribution as arising from host-galaxy extinction, but simply use this model as a useful empirical parameterization. The resulting color and stretch distributions are compared with the actual 3rd-year cosmological sample in Figure 7, and the evolution of the mean parameters with redshift are shown in Figure 8.

Recovery results
The SN Ia recovery results are presented as a function of various parameters in Figures 9-11. These plots include the cumulative data for all realizations performed on the field-seasons up to the end of D3 observations in June 2007. In each of the top panels of the figures, the input (resampled) distributions are shown as the unfilled histograms and the recovered populations are shaded in the lightest grey. The recovery data naturally include the timing, spacing, and quality of the actual observations, as we had the opportunity to detect each supernova while it was visible on any night that SNLS obtained usable images.
The medium-grey histograms show the effects of incorporating a set of observational constraints on the artificial SNe that are recovered. These cuts are for the purpose of ensuring adequate light-curve coverage for fitting, as also described in Perrett et al. (2010). The observational requirements are established as: • ≥ 1 early (−15d to +2.5d) observation in each of i M and r M ; • ≥ 1 early (−15d to +5d) observation in g M ; • ≥ 1 observation near peak (−9d to +7d) in each of i M and r M ; • ≥ 1 late (+5d to +20d) observation in either i M or r M .
These dates are in effective rest-frame days, corrected for stretch and redshift: Similar cuts have been made in determining reliable efficiencies in other SN surveys (e.g., Dilday et al. 2008Dilday et al. , 2010. The lowest, dark filled histograms in each top panel of Figures 9-11 all represent the spectroscopically-viable population. In this case, the peak brightness and %inc limits are applied as described previously in §3 for follow-up suitability. In addition, the candidate must have been discovered prior to +7 days past peak (rest frame), and have at least one observation above background both before and after maximum light. Due to the limited availability of telescope time, not all of the suitable candidates would have actually been observed spectroscopically. Figure 9 shows the recovery fraction as a function of i M peak magnitude. The ability of the SNLS real-time pipeline to recover SNe Ia begins to drop off at magnitudes fainter than i M ∼ 23 mag, with a 50% recovery limit at i AB = 24.3 mag. This is measured in one individual night of observation; deeper limits can be achieved by combining multiple epochs of data in offline searches at the end of a run. The dip in the recovery fraction seen after the application of the observational cuts is likely due to the longer period over which the higher-stretch bright SNe Ia can be observed.
The redshift distribution for the recovered objects (Figure 10-left) is flat out to z ∼ 0.5 and falls off smoothly to a 50% incompleteness at z ∼ 1. The likelihood of recovering SNe Ia is very small at z 1.1 using this detection method. The small rise at low-z in the recovered fraction once the observational cuts are applied is due to time-dilation effects on the SN light curves (Eq. 4). Applying the observational constraints and spectroscopic cuts brings the 50% limit down to z ∼ 0.85, as shown by the dotted line in the lower-left panel of Figure 10.
These results appear to be consistent with similar simulations carried out for the lowerredshift SDSS-II SN Survey (Dilday et al. 2008). The SDSS search to z ∼ 0.4 with an efficiency of 0.5 (compared with z ∼ 1 for the SNLS, a factor of 2.5 larger), and report essentially 100% efficiency to z ∼ 0.2 (compared with z ∼ 0.5 in our simulations). The efficiencies in the SDSS are in good agreement with those from the SNLS, but multiplied by a factor 0.4 on the redshift axis.
The recovery fraction as a function of stretch (Figure 10-center) exhibits an overall rise for s > 0.8 which is primarily a color effect: on average, lower-stretch SNe are redder, fainter, and tend to have smaller recovery efficiencies. The dip at s = 0.8 is an artifact of the break in the stretch-color relationship of Eq. 3. As expected, the recovery rate shows a clear decrease towards redder colors (Figure 10-right).
The efficiency of SN Ia discovery depends not only on the brightness of the candidates, but also on the quality of the background subtraction in the real-time images. Furthermore, candidates with low %inc values (Eq. 1) compared with their hosts will generally not be considered suitable for spectroscopy. Figure 11 provides the distributions and recovery fractions as a function of ∆mag (left), galactocentric radius (center), and %inc (right). The ∆mag recovery shows a modest decrease towards increasing values due to the reduced chance of finding intrinsically fainter objects. The recovery fraction is constant for positions out to r ∼ 1.0 ′′ from the host center, beyond which radius the relative effects of any galaxy subtraction residuals will begin to diminish and the detection efficiency will increase. Note that these effects are averaged over hosts of various morphological types and brightnesses; the PSF convolution and subtraction of more highly structured galaxies can leave residuals in the difference images that can conceal detections. The %inc plots at the right of Figure 11 reveal that the fractional brightness over the host galaxy background can have a significant impact on detection recovery, although the effects of candidate brightness and color are also folded into this effect. The details of the host selection process in the artificial SN Ia simulations (Eq. 2) are found to have little effect on the recovery results.
Some of the recovery plots in Figures 10 and 11 can be difficult to interpret in view of the fact that they incorporate a broad and uniform distribution of redshifts from z = 0.1 − 1.2. To address this, Figure 12 provides the spectroscopic recovery fractions in four redshift bins as a function of ∆mag, c, host radius, and %inc. In each case, the incompleteness in the high-redshift bins is the most severe; this is due primarily to the brightness and %inc limits imposed on the spectroscopic sample.
The human review process is another element that must be considered in the detection recovery estimates; this is complicated by the fact that fake SNe were not shown to human reviewers during the RTA, as was done in some surveys (e.g., Dilday et al. 2008). In the RTA procedure, candidates were visually confirmed by an operator who could remove obviously erroneous detections prior to updating the SNLS database. Since any false detections that made it past the reviewer into the database could later be culled based on measurements of additional photometry and subsequent light-curve fits, the only remaining concern is the omission of good SN Ia candidates due to human error. Neill et al. (2006) performed a Monte Carlo simulation to test the SNLS human review process using single-epoch images having image quality (IQ) values of 0. ′′ 69 and 1. ′′ 09. Their results indicate that the Canadian RTA procedure yields a raw recovery percentage better than ∼ 95% brightward of the incompleteness limit. Given multiple chances of candidate discovery using several epochs of SNLS data, this success rate has been found to approach ∼ 100% over the duration of a typical, well-observed SNe Ia. Therefore, any additional contribution of the visual review process to candidate recovery is deemed to be insignificant.
A comparison of the input and measured photometry for the artificial SNe Ia in the simulations is shown in Figure 13. No significant systematic biases are found in the measured photometry using the RTA pipeline. In bright galaxies, Guy et al. (2010) have identified a ∼ 2% oversubtraction of host galaxy flux at the location of the SN when applying a similar method in the final photometry analysis; this bias is not apparent to within the precision of the RTA measurements.

Selection bias in the SNLS sample
The effects of systematic errors introduced by Malmquist bias and spectroscopic sample selection ( §3.1) are important considerations for supernova cosmology: they cause a redshift-dependent offset in the average relative distance moduli from which the cosmological parameters are determined. The distance moduli (µ B ) for a Type Ia SN can be calculated from: where m * B is the peak magnitude in the B band, s and c are stretch and color. The absolute magnitude, M, and the coefficients α and β are determined by minimizing the residuals on the Hubble Diagram ).
The artificial SNe Ia from §4.2 are used to calculate the mean offsets in ∆mag, stretch, and color as a function of increasing redshift. The mean properties of the observed spectroscopic sample can be compared with the underlying (unbiased) population to look for the effects of sampling biases. The unbiased population is represented by the input distributions that were re-weighted to match the underlying distribution as discussed in §4.1 (open histograms in the upper panels of Figures 9-11). This, of course, assumes that there is no significant evolution in the intrinsic properties of SNe Ia with redshift.
The observed spectroscopic sample consists of recovered objects that were deemed suitable for follow-up. We also assume that any SNLS candidates that were observed spectroscopically could be randomly selected from this latter sample; due to observing time constraints, not all suitable objects were queued for spectra. Furthermore, we do not include a component to address the spectroscopic identification efficiency. This would take into account the candidates that were observed spectroscopically, but which were unidentifiable or misclassified from their spectra. Such sample contamination issues are expected to be relatively minor for bias calculations, yet are exceedingly difficult to determine precisely (see discussions in Balland et al. 2009;.
The offset in the mean ∆mag for the observed sample as a function of redshift is presented in Figure 14, showing the combined effects of Malmquist bias and spectroscopic  sampling. The sampling effects start to become significant at z 0.75, but are apparent starting at z ∼ 0.6, shifting the mean ∆mag in the observed sample towards brighter values. Column 2 of Table 4 provides the numerical values of the average offsets in redshift bins for all fields combined. The mean magnitude corrections measured for the individual fields are all consistent and are listed in Table 5.
The offset in observed ∆mag with redshift depends strongly on the intrinsic dispersion of the actual sample. A comparison of the mean bias for different assumed values of σ int in the artificial population is given in Figure 15. The lower the dispersion in the ∆mag distribution, the smaller the effects of selection bias. This is due to a reduction in the relative contribution from intrinsically faint input objects near the detection limit.
The stretch and color trends with redshift were shown in Figure 8. The increasing offset towards larger stretch results from preferentially finding the brighter objects with broader light curves at high z (Column 3 in Table 4). Similarly, the mean color offsets (Column 4 in Table 4) are caused by a bias towards detecting brighter -and hence bluer -objects at z 0.8. These stretch and color offsets are not directly relevant to the cosmology: we already correct for first-order variations in s and c via the α and β parameters in Eq.5, and the second-order sampling biases that affect the average intrinsic luminosity of SNe Ia with redshift are already incorporated into the ∆mag corrections provided above.

Systematic Errors in the Malmquist Bias
There are many parameters in our estimate of the Malmquist bias, including: the assumed color-color law, the parameters of the spectroscopic selection model and its form, the values of σ int , α, β and M, and the measured underlying stretch and color distributions. In this section, we discuss the effects of these terms on the Malmquist bias.
As noted previously, the color-color relation used to warp our SN template to match the simulated colors does not match our current understanding of SN behavior. In order to determine the effects of this on our results, we re-weighted the simulations to reproduce the effects of using the SALT2 color law (Guy et al. 2007). The effects are quite small, less than 0.0003 mag at z = 1, so we have not applied this correction to the results.
The uncertainties in the luminosity distance model are 0.01 mag for σ int , 0.08 for α, 0.1 for β, and 0.025 for M 11 . We assign uncertainties of 0.1 mag to each of the magnitude limits a In each redshift bin, the difference, δ, between the mean ∆mag for the input SN population and the mean of the same parameter for the recovered SN sample is given. The errors quoted are the errors in the mean.
of our spectroscopic selection model, and 25% to each of the %inc components. In addition, we consider changing the form of the spectroscopic model to linearly interpolate between the %inc limits as a function of magnitude rather than abruptly changing from one limit to another. For the color and stretch models, we vary the parameters of the distributions until the χ 2 of the fit to the stretch and color evolution with redshift increases by one. The effects of each of these components are given in Table 6 in terms of the mean Malmquist bias of the 3rd-year SNLS cosmological sample (Guy et al. 2010) and the bias at z = 1. Since the mean and z = 1 values are 0.0065 and 0.0237 mag, respectively, the total systematic error is approximately 20%.

Summary
The SNLS real-time analysis has discovered thousands of supernova candidates during its first four years of full operation. The vast majority of these candidates remain unconfirmed by spectroscopy due to observing time limitations, although methods for photometric identification are improving. Nonetheless, this will remain a major limitation for the next generation of surveys that could discover an order of magnitude more SNe, yet may not have access to much more in the way of spectroscopic time (see Howell et al. 2009).
Supernova surveys all suffer from the effects of selection biases that must be carefully considered in any analysis (e.g., Kessler et al. 2009). Monte Carlo simulations of SNe Ia in the SNLS real-time pipeline show that the effects of Malmquist bias and spectroscopic sample selection begin to affect the distribution of intrinsic magnitudes observed at z 0.6. At z = 1, the offset in the mean ∆mag reaches ∼ −0.027 mag as the survey systematically observes the intrinsically brighter SNe. We find approximately 20% systematic errors in our estimate of the Malmquist bias based on the uncertainty in the input model to our simulations.
The SNLS has produced a supernova dataset of unprecedented size and quality out to z ∼ 1.1. This large, homogeneous sample of SNe Ia is ideal for cosmology , the analysis of SN Ia rates (Neill et al. 2006;Perrett et al. 2010;Ripoche et al. 2010), and studies of the SN environments (Graham et al. 2008;Carlberg et al. 2008;Sullivan et al. 2010). Other types of investigations can be made using the various samples of objects in the SNLS database: e.g., cosmology with SNe IIp (Nugent et al. 2006), core-collapse SN rates (Bazin et al. 2009), sub-luminous SNe Ia (González-Gaitán et al. 2010), analyses of unusual SNe (Howell et al. 2006;Schawinski et al. 2008), as well as optical variability about H 0 .    .-The upper panel shows the input (unfilled) and recovered (light grey) distributions in peak i M magnitude for the artificial SNe Ia used in the recovery tests. The effects of adding the observational and spectroscopic constraints are shown by medium and darkest grey histograms, respectively. The lower panels present the recovered fraction for the found sample (solid line) and with the observational and spectroscopic cuts (dashed and dotted lines, respectively). The 50% incompleteness limit for the real-time analysis lies at i AB = 24.3 mag (AB), represented by the vertical line in the lower diagram. The histograms in the upper panels show the input distributions (unfilled) and the recovered sample (light grey), along with the addition of the observational and spectroscopic cuts (medium and darkest grey histograms, respectively). The lower panels present the recovered fraction for the found sample (solid line) and with the observational and spectroscopic cuts (dashed and dotted lines, respectively). -SN Ia recovery fraction for the spectroscopic sample shown separately in four redshift bins, given as a function of ∆mag, color, galactocentric radius in the host, and %inc. The lines represent the following redshift ranges: 0.10 ≤ z < 0.35 (solid blue), 0.35 ≤ z < 0.60 (long-dashed green), 0.60 ≤ z < 0.85 (short-dashed orange), 0.85 ≤ z < 1.10 (dotted red). In each case, the high-redshift range (dotted red line) has the lowest recovery rate, due mostly to the peak magnitude and %inc restrictions on the spectroscopic sample.