Evolution of the cluster optical galaxy luminosity function in the CFHTLS : breaking the degeneracy between mass and redshift

Obtaining large samples of galaxy clusters is important for cosmology, since cluster counts as a function of redshift and mass can constrain the parameters of our Universe. They are also useful to understand the formation and evolution of clusters. We develop an improved version of the AMACFI cluster finder (now AMASCFI) and apply it to the 154 deg2 of the Canada France Hawaii Telescope Legacy Survey (CFHTLS) to obtain a catalogue of 1371 cluster candidates with mass M200>10^14 Msun and redshift z<0.7. We derive the selection function of AMASCFI from the Millennium simulation, and cluster masses from a richness-mass scaling relation built from matching our candidates with X-ray detections. We study the evolution of these clusters with mass and redshift by computing the i'-band galaxy luminosity functions (GLFs) for the early (ETGs) and late-type galaxies (LTGs). This sample is 90% pure and 70% complete, therefore our results are representative the cluster population in these redshift and mass ranges. We find an increase of both the ETG and LTG faint populations with decreasing redshift (with Schechter slopes alpha_ETG = -0.65 +/- 0.03 at z=0.6 and alpha_ETG = -0.79 +\- 0.02 at z=0.2) and also a decrease of the LTG bright end, but not of the ETG's. Our large sample allows us to break the degeneracy between mass and redshift, finding that the redshift evolution is more pronounced in high-mass clusters, but that there is no significant dependence of the faint end on mass for a given redshift. These results show that the cluster red sequence is mainly formed at redshift z>0.7, and that faint ETGs continue to enrich the red sequence through quenching of brighter LTGs at z<0.7. The efficiency of this quenching is higher in large-mass clusters while the accretion rate of faint LTGs is lower as the more massive clusters have already emptied most of their environment at higher redshifts.


Introduction
As the most massive gravitationally bound structures in the universe, clusters of galaxies have been observed in great detail for decades. In addition to being interesting astrophysical objects, they are also a powerful probe of cosmology since galaxy cluster counts as a function of mass and redshift depend on the cosmological parameters of our Universe (see e.g. Allen et al. 2011, for a review).
In this context it is important to obtain extensive samples of clusters covering wide redshift and mass ranges. It is also necessary to know the selection function of the sample with great precision, as the cosmological constraints are obtained by comparing the observed cluster counts to the predicted ones, either from the analytical halo mass function or from N-body simulations. The development of extended imaging surveys, such as the Canada-France-Hawaii Telescope Legacy Survey (CFHTLS), provided the community with large sets of galaxy clusters observed homogeneously. It has therefore become possible to detect thousands of galaxy clusters up to redshifts z ∼ 1 (e.g. Adami et al. 2010;Durret et al. 2011). The large sky coverage of these surveys demands an automated detection, and cluster detection algorithms are a hot topic in the literature, both for the present and next generation surveys, such as that foreseen with Euclid 1 , which will uncover hundreds of thousands of clusters.
Many detection algorithms exist with differences in the selection function focusing either on purity or completeness. These algorithms can be separated into parametric and nonparametric. In the first category are matched filtering algorithms (e.g. Bellagamba et al. 2018), which apply a filter (e.g. Gaussian smoothing, Schechter function) to the galaxy field to highlight clusters, and red-sequence algorithms (Licitra et al. 2016), which use colour cuts to detect the linear relation between colour and magnitude of early-type cluster galaxies. Among the nonparametric are friend-of-friend algorithms (Farrens et al. 2011), which match close galaxies with a characteristic scale, or wavelet algorithms (Eisenhardt et al. 2008), which use the information from different scales through wavelet transformations. In the present paper we developed an improved version of the Adami & MAzure Cluster FInder (AMACFI, Mazure et al. 2007) algorithm which applies a smoothing to the galaxy density field in photo-z slices.
Galaxy clusters can also be used to study galaxy evolution through the distribution of galaxy magnitudes (i.e. the galaxy luminosity function, hereafter GLF) of different galaxy types. In particular the evolution of the faint end of the GLF with redshift and mass gives insights into the effect of environment on the quenching of star formation. For nearby clusters, the faint end of red passive galaxies appears to be flat (e.g. Gaidos 1997;Paolillo et al. 2001), while it experiences a mild decrease with redshift (e.g. Smail et al. 1998;De Lucia et al. 2004;Tanaka et al. 2005;De Lucia et al. 2007;Stott et al. 2007;Gilbank et al. 2008;Rudnick et al. 2009;Vulcani et al. 2011;Martinet et al. 2015;Zenteno et al. 2016;Martinet et al. 2017). We note that some authors find no evolution with redshift (e.g. Andreon 2008;De Propris et al. 2007, 2013. Recently Martinet et al. (2017) ruled out the possibility that these differences could arise from surface brightness selection biases between ground-and spacebased observations. Therefore, differences in the GLF faint end cannot be due to observing conditions, but are more likely to reflect variations from one cluster to another in samples of typically a few tens of clusters. The dependence of the GLF on mass is less studied, mainly because of the degeneracy between mass and redshift. Indeed, at higher redshift we only detect the most massive clusters, while at low redshift we have a complete sample in mass. Attempts to break this degeneracy have failed so far because of the high number of clusters required (Martinet et al. 2015(Martinet et al. , 2017. In the present study, we have improved the AMACFI cluster detection algorithm, and renamed this new version AMASCFI (Adami, MAzure & Sarron Cluster FInder). We apply it to the 154 square degrees covered by the four Wide fields of the CFHTLS survey. In particular, cluster positions and redshifts are now more accurate than the previous version used by Durret et al. (2011). We detect a total of 7100 cluster candidates up to redshift z ∼ 1.1 and estimate the selection function of this sample by applying the same algorithm to numerical simulations based on lightcones from the Millennium simulation by Springel et al. (2005) and modified by Henriques et al. (2012). We derive a mass for each cluster candidate using a richness-mass relation calibrated on the X-ray clusters of Gozaliasl et al. (2014) and Mirkazemi et al. (2015) that are also detected by our algorithm. We compute cluster GLFs for all galaxies, and also for early and late types separately. We study the evolution of the faint end with redshift and mass independently. And finally, we make use of the high number of clusters to break the degeneracy between mass and redshift for the first time.
The paper is structured as follows. In Sect. 2 we describe the AMASCFI code and its recent improvements. In Sect. 3 we study the properties of AMASCFI using simulations. In Sect. 4 we compare our catalogue of cluster candidates to the literature using optically and X-ray detected clusters. In Sect. 5 we explain how we derived the GLFs, and the corresponding results are given in Sect. 6. The results are discussed in Sect. 7 and the conclusions are drawn in Sect. 8. We use AB magnitudes throughout the paper, and assume a flat ΛCDM cosmology with Ω M = 0.3 and h = 0.7.

Cluster detection
We have updated the Adami & MAzure Cluster FInder (AMACFI, Mazure et al. 2007) and applied it to the CFHTLS final data release T0007 photometric redshift (hereafter photo-z, symbol z phot ) catalogues. The original AMACFI algorithm was already applied to the CFHTLS in previous studies: Mazure et al. (2007) for the Deep1 field, Adami et al. (2010) for the T0004 data release, and Durret et al. (2011) for the Wide fields of the T0006 data release. We briefly present the main features of the method, focusing on the improvements, their motivations, and their implications.

Photometric redshift catalogue
The photo-z catalogue is obtained from the CFHTLS data release T0007 2 .
CFHTLS T0007 photo-zs were computed in the 154 deg 2 sky coverage of CFHTLS using multicolour images in the u * g r i z filters of MegaCam at CFHT. We note that the i filter had to be changed during the course of the survey. The photo-zs were obtained using the LePhare software (Arnouts et al. 1999;Ilbert et al. 2006).
Details about the method are given in Coupon et al. (2009). Briefly, the photo-zs were computed using 62 templates obtained after having optimized four templates from Coleman et al. (1980) and two starburst templates from Kinney et al. (1996), and linearly interpolated between them to better sample the colour-redshift space using the VVDS spectroscopic sample (e.g. Le Fèvre et al. 2005). A particularly crucial step of the process is the calibration of the zero-points using spectroscopic samples which help in removing biases. The resulting statistical errors on photo-zs depend on the redshifts and magnitudes of the galaxies.
Following the photo-z catalogue based on the CFHTLS T0007 data release, we define the dispersion as σ ∆z phot /(1+z s ) = 1.48 × median |∆z| (1 + z s ) , which is the NMAD estimator defined in Ilbert et al. (2006), with ∆z phot = z phot − z s , where z s is the spectroscopic redshift. The outlier rate or catastrophic failure rate η is set as the proportion of objects with |∆z| ≥ 0.15 × (1 + z s ). We make use of the value reported in the release document to choose our cuts in redshift and magnitude. For cluster detection, we select galaxies in the redshift range 0.1 < z phot < 1.2 and with magnitudes i < 22.5, thus keeping the dispersion below 0.05 × (1 + z) and the outlier rate below 10% in all four Wide fields.
In our analysis, we only consider galaxies that are outside the masks from TERAPIX. These masks are located around bright stars or artefacts, and mark regions of lower photometric quality. Thus photo-zs in these regions would be of poorer quality than those outside the masked regions. These masks are dealt with in the same way for cluster detection and GLF computation, i.e. by discarding objects inside the masked regions. We note that this approach is different from the one Moutard et al. (2016) applied to the CFHTLenS, but we prefer to use the prescription from the TERAPIX team as we are using their photo-z catalogue.

AMASCFI: description of the algorithm
Our detection algorithm is based on the method described in Mazure et al. (2007). The galaxy catalogue is cut into slices of redshift, partially overlapping so as not to miss structures. Mazure et al. (2007) and subsequent studies using AMACFI chose a constant slice width of 0.1 in redshift space, each slice overlapping the adjacent ones by 0.05. In contrast, we adopt here a variable width chosen as ∆z slice = 0.05 × (1 + z slice ), (2) z slice (n + 1) = z slice (n) + 0.05. ( This enables us to better account for the noise due to photo-z statistical errors, and therefore to sample a galaxy population representative of the true underlying population in each redshift slice, especially at high redshift. For example, the slice width at z = 1.1 (maximum redshift considered in our analysis) is now taken to be ∆z slice = 0.2 rather than 0.1. The galaxies were selected in the redshift range 0.1 < z < 1.2, thus the first slice is centred at z = 0.16 and the last at z = 1.10, respectively the minimum and maximum redshifts of our detected cluster candidates. Even though the photo-z dispersion is slightly different from field to field, and depends on the redshift and magnitudes of the sources, we decided to be conservative and consider it as σ ∆z phot /(1+z s ) = 0.05 in all four fields, so we can treat them as homogeneously as possible. Two-dimensional density maps are then computed in each slice using an adaptive kernel density estimator (adaptive-KDE). So far, AMACFI chose the initial size of the kernel automatically according to the Silverman (1986) prescriptions. We decided in this work to fix the initial kernel size to 1.5 Mpc.
In this way, the kernel size (diameter) of the adaptive-KDE in the densest region (corresponding to galaxy clusters) is ∼1 Mpc, which is the right smoothing scale for detecting clusters as it is the typical size of cluster cores. In fact, our previous way of choosing the smoothing scale in AMACFI was oversmoothing the underlying distribution and was thus more suited for supercluster than cluster detection.
The SExtractor software is then applied to the density maps to detect structures. The major modification in this step of the process is the way the detection threshold is set. This threshold is now set to a number of galaxies per Mpc 2 .
For this, we iteratively compute the background level (field) in galaxies per Mpc 2 in each slice using our density map, and set the detection threshold to the 95% upper confidence limit on this number density following Gehrels (1986).
On the first iteration, the field is simply set to the mean galaxy number density in the entire density map. We compute the detection threshold and use SExtractor to detect overdensities in the map. The background level is updated as the mean galaxy number density in the map after having removed pixels of the density map in a disk of diameter 1 Mpc around the peak of each detected structure. This gives us a new detection threshold and the process is repeated until convergence. At the end of the procedure, we obtain the final field level in the slice n field , and the detection threshold thus quantifies the probability for an overdensity to be a random fluctuation of the background (due to chance alignment in the photo-z space).
We compute the mean number density of galaxies in a disk of 1 Mpc diameter centred at the peak of each overdensity as detected by SExtractor from our density maps and obtain a signal-to-noise ratio (S/N) of detection for each overdensity. The S/N of detection is defined as where n clus and n field correspond to the average number density of galaxies per Mpc −2 in a slice of width ∆z slice for cluster and field area, respectively. The overdensities thus detected in each slice are then assembled in larger structures (called cluster candidates in the following) using a friends-of-friends algorithm, the Minimal Spanning Tree, with a characteristic distance of 1 Mpc, as in Mazure et al. (2007) (see Adami & Mazure 1999, for the original description of the algorithm). This allows us to merge multiple detections of the same structure appearing in several adjacent redshift slices, or of large clusters presenting many substructures. The position of each candidate cluster in the (RA, Dec, z phot ) space is taken to be the mean of each of its individual merged detections weighted by its excess galaxy number density ( n clus − n field ).

AMASCFI selection function
In order to calibrate our method, i.e. to assess the reliability of our detections, we apply our algorithm to a set of 24 lightcones computed by Henriques et al. (2012) from the Millennium Simulation (Springel et al. 2005) and built using the Guo et al. (2011) semi-analytical model. Since then, a new set of lightcones has been built by Henriques et al. (2015) using the Planck cosmology rather than the original Millennium Simulation cosmology (WMAP1). Even so, when comparing galaxy number counts with CFHTLS data, the Henriques et al. (2012) lightcones were in better agreement than the more recent ones. The total area of the 24 independent beams is ∼50 deg 2 , and thus contains ∼1000 haloes in the redshift range 0.1 < z < 1.2 with mass M 200 > 10 14 M , where M 200 is the mass contained in a radius r 200 , inside which the density is 200 times the critical density of the Universe. Such a cosmological volume enables us to properly assess the selection function of AMASCFI. In the following, we present the modifications we applied to the lightcone to make it a fair representation of our data, and we compute the selection function of AMASCFI.

Mock catalogue modification
We converted the SDSS magnitudes of the simulated mocks to CFHTLS Megacam i -band magnitudes following the relation from the Megacam pages 3 : To make the mock galaxy catalogues from Henriques et al. (2012) comparable to our data, we need to add realistic noise to the redshift of each galaxy in the mock. Since the error on the photo-zs depends on redshift and on magnitude, we compute the mean 1σ uncertainty on individual photo-zs (as given by the LePhare software) in bins of 0.1 in redshift and 0.25 in magnitude for the W1 field. On average, this 1σ uncertainty closely follows the statistical error computed using spectroscopic redshifts, justifying the use of this quantity for our purpose. We decided not to add noise on the lightcone magnitudes themselves as the errors for the CFHTLS T0007 data release are below 0.01 for 95% of the sample at i < 23, and thus negligible compared to photo-z errors.
We then apply a Gaussian error with a zero mean and a standard deviation corresponding to the mean LePhare 1σ uncertainty in the corresponding bin of the lightcones. As in Adami et al. (2010), we did not account for catastrophic errors on the photo-zs in this simplified model. The effect on cluster detection is expected to be small since the outlier rate stays well below 10% for the chosen magnitudes and redshift cuts.
The final step consists in applying a masking procedure representative of the one used by TERAPIX on the CFHTLS T0007. To this end, we modify the sky coordinates of the galaxies in the lightcones to match a subarea of the CFHTLS representative of the observed masks and apply the VENICE program 4 to remove galaxies from the masked regions. This step is important because masking could have an impact on the detection level of a cluster whose centre falls near a mask boundary.
We thus obtain lightcones resembling CFHTLS T0007 data in terms of masking and photometric redshift distribution, on which we can accurately compute our selection function.

Completeness and purity of the cluster catalogue obtained with AMASCFI
In order to assess the quality of our cluster detection we need a way to quantify how well we detect actual overdensities of galaxies and how polluted by false detections our catalogue is. Following the literature, we compute the completeness (C) and the purity (P) of our catalogue of cluster candidates to study the performances of AMASCFI. These two quantities are widely used to infer the quality of cluster catalogues. They are defined as where N det is the number of cluster candidates detected in the simulation, N true is the total number of haloes in the simulation, and N match the number of detected clusters matched to a halo from the simulation. Ideally, an algorithm should have high completeness (all clusters are detected) and high purity (all detections are actual clusters), but there is a tradeoff between the two quantities and both cannot be maximized simultaneously. The quantities are both functions of S/N cuts, which can vary depending on application. In Sect. 5, for our study of GLFs, we wanted to choose a threshold that guarantees high purity so there is no contamination by false detections whose GLFs would resemble those of field galaxies.
We ran our detection algorithm on the simulation exactly in the same way as on the CFHTLS data, and thus obtain a catalogue of cluster candidates with a sky position, redshift, and detection significance. To compute the completeness and purity of the catalogue as a function of significance, redshift, and mass, we match our candidate cluster catalogue with the halo catalogue from the simulation. The centre of each halo is taken to be its central galaxy. To match a candidate cluster with a halo, we ranked our cluster candidates by significance and the halo catalogue by halo mass and consider that they are matched when -the sky projected distance of the centres is less than the radius r 200 of the halo at the halo redshift; Since we are interested in detecting clusters of galaxies, we compute our completeness for haloes of mass M 200 > 10 14 M . However, computing purity with the same mass threshold would be too drastic. Indeed, some of our detections may correspond to haloes of smaller masses (galaxy groups) and thus not be false detections per se. This arises from the intrinsic scatter (σ int ) that exists between halo mass and cluster richness. This scatter is found to be of the order 0.3 dex in the local Universe (Andreon & Bergé 2012). This means a halo with mass ∼3σ int below the 10 14 M threshold could have the same richness as a halo of 10 14 M . Following these considerations, we compute the purity of our candidate cluster catalogue for haloes of mass M 200 > 10 13 M . In Fig. 1, we show the cluster completeness as a function of redshift for haloes of mass M 200 > 10 14 M and as a function of halo mass in the entire redshift range 0.15 < z ≤ 1.1, for different S/N cuts. Error bars represent the 1σ confidence limit of a binomial distribution following Gehrels (1986). The bottom left panel in Fig. 1 shows the purity of our catalogue, while the bottom right panel breaks the degeneracy between mass and redshift, showing the completeness as a function of both parameters for S /N > 4. The error on the redshift assigned to a candidate cluster by AMASCFI (z AMASCFI ) is estimated using the NMAD estimator. We find σ z clus = 0.018 × (1 + z) for haloes of mass M 200 > 10 13 M . When considering only matched haloes of mass M 200 > 10 14 M , this reduces to σ z clus = 0.018 × (1 + z). This is illustrated in Fig. 2 where we plot z AMASCFI vs. the true redshift of the matched halo in the simulation z Millennium .
When computing completeness and purity as a function of redshift only, bins include clusters with a redshift ±2 × σ zclus from the central redshift of the bin, where σ zclus = 0.025 × (1 + z) is the statistical error on cluster redshift. The first bin is centred at z = 0.2 and the last at z = 1.0, with an offset of 0.1 between bins. When computing completeness as a function of mass, bins include clusters with a mass ±7.5 × 10 13 M from the central mass of the bin. The first bin is centred on 1.75 × 10 14 M and consecutive bins are offset by ±7.5 × 10 13 M , so that bins partially overlap and smooth the selection function. The last bin in mass only includes a lower limit and so includes all clusters more massive than 5 × 10 14 M .
When breaking the degeneracy between redshift and mass, we consider three bins in each parameter. This is done so that each bin is sufficiently populated to have reliable statistics. We choose to use the three redshift bins [0.1, 0.3[, [0.3, 0.5[, and [0.5, 0.7[ and mass bins ] For the three S/N cuts considered, the purity is >70% in the entire redshift range, and >80% for z clus ≤ 0.8. The completeness is >70% for the most massive clusters (log M 200 /M > 14.6) in the entire redshift range, while being always ∼70% for all clusters (log M 200 /M > 14) up to z clus = 0.4. As the redshift increases, large differences can be seen in the completeness depending on the S/N cut considered. The completeness becomes low (<30%) for all S/N cuts for z clus > 0.8. This is due to the increasing errors on the photo-zs with redshift.
Since we want to use our cluster catalogue to compute cluster GLFs, the primary criterion is a high purity of the catalogue. We thus choose a cut at S /N > 4 that guarantees a purity >90% up to z clus = 0.8. For this very pure cut, we compute the completeness as a function of both redshift and halo mass (bottom right panel in Fig. 1). For the most massive bin (log M 200 /M > 14.6), the completeness is >70% up to z bin = 0.8 and then drops. A 70% completeness threshold is reached up to z bin = 0.6 for the intermediate mass bin (14.3 < log M 200 /M ≤ 14.6) and z bin = 0.4 for the lowest mass bin (14 < log M 200 /M ≤ 14.3). In addition to its high purity, the cluster candidate catalogue used for the GLF computation is therefore also representative of clusters with mass M 200 > 10 14 M .

Mass, redshift, and S/N cuts for GLFs
In the following sections of the paper, we study the properties of cluster GLFs, using the cluster candidates detected with AMASCFI. A study of this kind is usually done with a catalogue of confirmed clusters because the results are relatively sensitive to contamination by false detections. Thus, to study the cluster candidate GLFs, we need to choose cuts in S/N, redshift, and richness (or equivalently mass), which ensures a high purity. At the same time, we would like to keep the completeness to high enough levels so that the population of cluster candidates under consideration can be considered as fairly representative of the true cluster population.
Using the selection function we computed on simulations, we chose to cut our final catalogue for GLF computation at S /N > 4, z < 0.7 and M 200 > 10 14 M . This ensures a purity higher than 90% in the full redshift range (see bottom left panel in Fig. 1) and a completeness greater than 50% in all the redshift and mass bins considered. The lower mass limit enables us to probe lowmass galaxy clusters, and the redshift range to study the cosmic evolution of the cluster properties.

AMASCFI applied to the CFHTLS T0007 data release
When applying AMASCFI to the four Wide fields of the CFHTLS T0007 data release photo-z catalogue, we detect 7100 cluster candidates at S /N > 3 in the redshift range 0.15 < z < 1.1. The full catalogue will be made available at the CDS. Optical images of three rich clusters are shown in Fig. 3 for illustration. In the following sections, we will compare our candidate cluster catalogue to previously published cluster catalogues on the Wide fields of CFHTLS. We will first make a comparison with other optically detected cluster candidate catalogues from Licitra et al. (2016) and Ford et al. (2015), and with X-ray detected cluster catalogues from Gozaliasl et al. (2014) and Mirkazemi et al. (2015).

Matching AMASCFI cluster candidates with other optically selected cluster candidates
There are two public catalogues of optically selected cluster candidates, obtained from the CFHTLS observations, although both use the CFHTLenS photometric catalogue extracted from the data rather than the TERAPIX catalogue. The first is the Ford et al. (2015) cluster catalogue. It covers the four Wide fields of the CFHTLS and was obtained using the 3D-MF algorithm developed by Milkeraitis et al. (2010). The 3D-MF algorithm is a matched filter algorithm that assumes a cluster radial profile and luminosity function and detects clusters in overlapping slices of redshift. The full published catalogue contains 22 694 cluster candidates with significance σ Ford > 3.5 in the redshift range 0.2 < z < 1.0.
To match the two catalogues we use the same matching procedure as in Sect. 3.2, except for the maximum radial projection between the centres of two matched clusters, which is fixed to 2 Mpc to account for the large errors on the sky position of cluster candidates and because we have no estimate of r 200 in the observations. When matching our catalogue with the full 3D-MF catalogue, we find 5285 cluster candidates in common, meaning that 75% of AMASCFI clusters have a counterpart in the 3D-MF catalogue. This agrees well with the purity of AMASCFI at S /N > 3, that we computed using the Millennium simulation (see Sect. 3.2), considering the 3D-MF cluster catalogue has high completeness (Milkeraitis et al. 2010). If we trim the 3D-MF catalogue to σ Ford > 5 (which corresponds to ∼1.5 × 10 13 M ) and σ Ford > 10 (which corresponds to ∼10 14 M ; Ford et al. 2015), there are respectively 6544 and 282 clusters left in the redshift range 0.2 < z < 1.0. AMASCFI respectively detects 3521 (∼54%) and 260 (∼92%) of these. Licitra et al. (2016) developed the RedGOLD cluster detection algorithm, based on the search for red-sequence galaxy overdensities. The search is done in slices of redshift, where the red-sequence colour is predicted using stellar population models. To select their cluster candidates, they impose a Navarro-Frenk-White (NFW) profile, and compute a richness estimator λ RedGOLD for each candidate. RedGOLD was applied to the CFHTLS W1 field. Their published catalogue includes 652 cluster candidates in the redshift range 0.14 ≤ z < 1.2. Out of the 7100 cluster candidates detected by AMASCFI, 2951 lie in the CFHTLS W1 field.
We use the same matching procedure as for the Ford et al. (2015) catalogue. Out of the 652 RedGOLD cluster candidates, 510 are also found by AMASCFI (78%), a result in good agreement with the ∼80% purity of both catalogues at the significance cuts used. If we only consider AMASCFI cluster candidates with S /N > 5.5, to have a comparable number of candidates in both catalogues (663 for AMASCFI and 652 for RedGold), 45% of cluster candidates are matched. Since the RedGOLD catalogue has an announced completeness of ∼70% and AMASCFI has less than 50% (at this S/N cut) in the redshift range considered, this is expected.

Matching AMASCFI cluster candidates with X-ray detected clusters
We also compare our candidate cluster catalogue with two X-ray detected cluster catalogues provided by Gozaliasl et al. (2014) and Mirkazemi et al. (2015), both obtained from XXM-Newton observations. The Gozaliasl et al. (2014) catalogue covers an area of 3 deg 2 inside the CFHTLS W1 field and includes 135 X-ray detected groups and clusters up to z = 1.1, while the Mirkazemi et al. (2015) catalogue was built by pointing at given optically selected cluster candidates; it includes 196 X-ray detected groups and clusters up to z = 1.1 in the CFHTLS W1, W2, and W4. Both catalogues provide M 200 for each cluster, obtained by applying the scaling relation between weak lensing mass and X-ray luminosity (M 200,WL − L X ) obtained by Leauthaud et al. (2010). We recalibrate these masses according to the Kettula et al. (2015) scaling relation as it presents the advantage of measuring the weak lensing mass for individual clusters, while Leauthaud et al. (2010) stacked the lowest mass clusters in quite poorly populated bins.
The intrinsic scatter in the relation and the errors on the fit parameters are propagated to obtain the errors on the mass estimates. Finally, we translated cluster masses into our own cosmology (only H 0 = 70 km s −1 Mpc −1 differs).
When comparing the mass distributions obtained from the M 200,WL − L X relations to that obtained by applying AMASCFI to the Millennium simulation, we find that the Leauthaud et al. Having obtained these mass estimates, we can match our cluster candidates with the X-ray detected clusters and look how well AMACSFI redetects them as a function of mass and redshift. However, neither Gozaliasl et al. (2014) nor Mirkazemi et al. (2015) provide the completeness of their catalogue for given mass and redshift. Thus they cannot be used to properly compute a selection function of our algorithm, but only give us insights into how AMASCFI performed on the CFHTLS T0007 data. We use the same matching procedure as in Sect. 3.2, using for r 200 the value given in the original catalogue.
There are 68 groups in the Gozaliasl et al. (2014) catalogue with z < 0.75. In the same area AMASCFI detects 51 clusters at S /N > 4 and z < 0.7, 23 of them also being in the Gozaliasl et al. (2014) catalogue (see Fig. 4). In addition, AMASCFI detects all but two X-ray clusters with M 200 > 10 14 M up to z = 0.6. The Mirkazemi et al. (2015) catalogue contains 130 clusters with z < 0.75, while AMASCFI detects 1872 clusters at S /N > 4 and z < 0.7 in the W1, W2, and W4 fields. There are 66 clusters in common between the two catalogues (see Fig. 5). When using the detections in common with the X-ray catalogues, the statistical error on the redshifts of the AMASCFI clusters is the same as that computed on the Millennium simulation (σ clus = 0.025).
We did not match our cluster candidates with X-ray detected clusters from XXL because the published catalogue from Pacaud et al. (2016)  Matching of our cluster candidates obtained with AMASCFI and X-ray groups/clusters detected in the W1, W2, and W4 fields by Mirkazemi et al. (2015). The symbols are the same as in Fig. 4.

Mass-richness calibration
The richness of a cluster is known to be a proxy for its mass, which is not measurable directly. Having an estimator with as small a scatter as possible in the mass-richness relation is of great interest to study the dependence of cluster properties on mass. We can use our GLF computation method (see Sect. 5) to derive such a richness estimator for our cluster candidates. Rykoff et al. (2012) showed that including blue cluster members in their richness estimate increased scatter in the L X -richness relation from σ ln L X |λ = 0.63 to σ ln L X |λ = 0.72 at the 2σ level. With this result in mind, we decided to build our richness estimator based on the cluster GLF of early-type galaxies (ETGs). Our goal was to count the number of red ETGs brighter than a given absolute magnitude, so we can directly use the counts in absolute magnitude that are also used to build our GLF.
We computed the ETG GLF in a 1 Mpc radius. We then summed the number counts in absolute magnitude bins, after removing field counts, for galaxies brighter than 0.2 × L * , i.e. M < M * + 1.75. Here M * (respectively L * ) is the characteristic absolute magnitude (luminosity) of a cluster, and is obtained from a Schechter fit to the GLFs stacked in redshift bins. We took a constant M * equal to the mean M * over our redshift range: M * z = −22.6. The 90% completeness limit of our sample being i = 23, we were able to reach M * + 1.75 up to z = 0.7. Thus, our richness estimator was homogeneous up to z = 0.7, and we did not compute the richness for clusters with higher redshifts.
We calibrated our richness R to X-ray derived cluster masses, using the catalogues from Gozaliasl et al. (2014) and Mirkazemi et al. (2015) to infer the mass for all our cluster candidates up to z = 0.7. We used the catalogue of matched clusters derived in Sect. 4.2 and fitted the M 200 − R relation as where the pivot value for richness is taken to be 40 as in, e.g. Licitra et al. (2016); Rykoff et al. (2012). Figure 7 shows the mass-richness relation for the 82 clusters detected by AMASCFI with an X-ray counterpart in either the Gozaliasl et al. (2014) or Mirkazemi et al. (2015) catalogues up to z AMASCFI = 0.7. The fit was done using the John Meyers python implementation of the linmix_err IDL routine (Kelly 2007) with a default superposition of three Gaussians. This Bayesian approach considers that the errors follow a Gaussian distribution, while the error on the richness is Poissonian by nature. However, we verified that every cluster has a high enough richness (R > 10) for the Poisson law to be closely approximated by a Gaussian. We note that four clusters only reach R > 5; we kept them in the analysis as they should not significantly affect the errors on the fit and improve the representation of low-mass clusters. We obtain β = 14.68 ± 0.04, α = 1.34 ± 0.15, and the intrinsic dispersion σ int = 0.13 ± 0.03 dex.
Comparing our scaling relation with the literature is not straightforward since different richness estimators will yield different scaling relations. However, our definition of richness is similar to that computed by the RedGOLD algorithm (Licitra et al. 2016), i.e. counting bright ETGs in a given radius. The main difference is that contrary to Licitra et al. (2016), who scale the radius in which the richness is computed iteratively, we fixed this radius to 1 Mpc. We compare the two estimators in Fig. 6, plotting the AMASCFI richness estimator R AMASCFI vs. the RedGOLD richness estimator λ RedGOLD for the matched clusters. We find a good correlation between them, the AMASCFI richness being 16% lower in the mean than RedGOLD richness. Parroni et al. (2017) used the RedGOLD catalogue to compute a mass-richness scaling relation from weak-lensing masses and their results are similar to ours, but with lower α and β. This is expected because our richness estimates are lower than theirs. We also find a similar intrinsic scatter σ int , showing that both estimators are similarly good mass proxies, as previously argued by Andreon & Hurn (2010).
Using the fit result, we can infer the posterior probability distribution for the mass of each candidate cluster for which we have computed a richness. As discussed previously (Sect. 4.2) this gives us a mass distribution for our cluster catalogue that is in good agreement with that derived from applying AMASCFI to simulations.

Cluster galaxy luminosity functions
We wanted to study the evolution of the cluster luminosity functions (GLFs) with redshift and their dependence on cluster mass. Our method for computing GLFs is based on the method developed in Martinet et al. (2015) (hereafter M15) and adapted to the specificity of CFHTLS T0007 data. Taking advantage of the size of our sample, we were able to break the degeneracy between mass and redshift. We computed GLFs of our cluster candidates in the i rest frame band using photo-z information to estimate the cluster membership of galaxies. We used the i band because for photo-z computation, the full T0007 catalogue was cut at i < 24, so it is complete in this band only. Martinet et al. (2015) showed that GLFs behave similarly in the V, R, and I band, so our conclusions are quite general.

Completeness limit
One key point when computing GLFs is to properly define the 90% completeness limit of the sample. The CFHTLS data have the advantage of being homogeneous across the whole field and the 80% completeness limits were computed by TERAPIX. However, these depth limits show substantial variations from tile to tile. Indeed, the deepest tile has an 80% completeness limit of c i ,80% = 24.07, while the shallowest has c i,80% = 23.30 (the mean being c i ,80% = 23.72). To obtain the 90% completeness limit, we used data provided in T0007 of the CFHTLS, where the completeness limit is assessed using simulations.
We decided to be conservative and to take the same 90% completeness limit in all the fields: c i ,90% = 23.0. This has two main advantages: the first is that we were able to study homogeneously our entire sample, and the second is that photo-zs become noisier for magnitudes fainter than i = 23 (σ ∆z phot /(1 + z s ) ∼ 0.07 and η >∼ 10-15%), so that considering fainter galaxies may have affected the quality of our analysis.
This apparent magnitude completeness limit is translated to an absolute magnitude completeness limit by adding the distance modulus and k-correction. We used the k-corrections computed by LePhare. The software computes the theoretical k-correction from the best fit template and best estimated redshift of the galaxy. Here we want our completeness value to be correct for all types of galaxies. We thus selected all the galaxies in 0.05 × (1 + z clus ) and computed for each template the mean k-correction. For our result to hold for both early-and latetype galaxies (ETGs and LTGs, see Sect. 5.4), we computed the mean k-correction over ETG templates and LTG templates and the final value was taken as the maximum of these two quantities.

Galaxy luminosity function computation
To compute our GLFs, we used the final catalogue containing all the relevant information for each galaxy: position in the sky, photo-z, and apparent and absolute magnitudes in i band. For each cluster, we selected galaxies in a cylinder of radius 1 Mpc and length ±2 × 0.05 × (1 + z clus ). Part of these galaxies are not cluster members but rather background or foreground galaxies, so we needed to remove the field contribution because the photoz statistical error of ∼0.05 × (1 + z s ) is larger than the typical size of a cluster ∼0.001 × (1 + z) (see e.g. Evrard et al. 2008). We call the galaxies thus selected the candidate cluster galaxies in the following. Once this selection was done, we fixed all the candidate cluster galaxies to the cluster redshift and re-ran LePhare without fitting the photo-zs (parameter ZFIX). LePhare only fits the best template, which might be different when we force z gal = z clus as discussed in M15. This allows us to determine the template, k-correction, and hence the absolute magnitude of each candidate cluster galaxy more accurately, as these are redshift dependent properties.
We then subtracted the field contribution from our candidate cluster galaxies. The field galaxies are defined for each redshift slice as galaxies more than 2 Mpc away from any detected cluster in the slice. We normalised the field to each cluster area before subtracting galaxy counts.
One point that needs to be dealt with carefully is that field galaxies have k-corrections computed at their own redshift, while for the candidate cluster galaxies the k-correction was computed at the cluster redshift. An error in the k-correction could move a galaxy from one absolute magnitude bin to another in our GLF, thus distorting the actual GLF. To avoid this effect, we removed the field contribution in bins of apparent magnitude. We counted candidate cluster galaxies and field galaxies in bins of 0.5 magnitude and applied a weight to all galaxies in the bin equal to the ratio of cluster to field galaxies in the bin. Once field counts were subtracted, we normalised our GLFs to 1 Mpc 2 . This was done so that we can compare the GLFs at different redshifts.

Stacking the GLFs
Because of low number counts, individual cluster GLFs are noisy. Thus, we cannot use them to infer the dependence of the faint-end slope of the GLF with mass and redshift. To increase our S/N, we stacked our GLFs in bins of redshift and mass. Stacking was done as in M15 using the standard Colless method (Colless 1989). The idea is to average cluster galaxy counts in each absolute magnitude bin, including all clusters that are 90% complete in this bin. Clusters first have to be normalized to the same area and to a fixed richness. We normalised all clusters to 1 Mpc 2 . For the richness we used our estimator described in Sect. 4.3.
The main advantage of this method compared to a classical average of GLFs is that we are able to use as much information as possible. Indeed, with a classical method, the average would only be done in the absolute magnitude bins which are 90% complete for all the clusters considered, thus limiting our capacity to probe the faint-end in a given redshift range.
Galaxy counts and their errors are summed following Eqs. (9) and (10), respectively, where N( j) and σ( j) are the stacked galaxy counts and galaxy count errors in magnitude bins j, the index i indicates single cluster values, S i is the area of cluster i, N c ( j) is the number of clusters in the bin j, and N 0,i and N 0 ( j) are the richness of cluster i and the mean richness of clusters in the j bin: To retain the Poissonian distribution of the counts, we weight the individual variances by the square of the cluster area, as for the galaxy counts, and not simply the area. We did not take into account the clustering error in our estimation of the individual variances, because it is negligible compared to the Poisson error. We fit the stacked i band GLFs with a Schechter function (Schechter 1976) where φ * is the characteristic number of galaxies per unit volume, M * the characteristic absolute magnitude, and α the faint-end slope of the GLF. The fit is done with a χ 2 minimization. The error bars on the parameters correspond to the 1σ confidence level and are computed from the covariance matrix, evaluated at the best parameter values. These single parameter error bars include the effects of correlations with other parameters. As in Martinet et al. (2017), we convert the final χ 2 value in a confidence probability p assuming a χ 2 distribution with three degrees of freedom (α, M * , φ * ): . Comparison of best fit templates for each candidate cluster galaxy for a rich candidate cluster at z clus = 0.35. The blue and red points respectively show the new templates considered as late-type galaxies (LTGs) and early-type galaxies (ETGs). The black squares show galaxies moving from ETG to LTG and vice versa. The old template is the best fit template in the original catalogue (the redshift is free to vary during the SED fitting), while the new template is the best fit template when we force the galaxy to be at the cluster redshift (z phot,gal = z clus ). This illustrates that template fitting of galaxies is quite sensitive to small changes in redshift, but that classifications are relatively stable.
We wanted to study the dependence of the GLFs with redshift and cluster mass. So we binned our cluster candidates in this 2D parameter space, and stack the clusters in each bin using the Colless method described above. As mentioned in Sect

Early-and late-type galaxies
To better understand the properties of clusters, it is interesting to study their different galaxy populations. Ideally this problem could be dealt with in a complex manner by classifying many types of galaxies (early quiescent ellipticals, late dust-free spirals, late dusty spirals, starburst galaxies, early spirals, galaxies transiting from late spiral to early elliptical, etc.). However, the automatic classification of galaxies in such a complicated scheme is very difficult. Indeed, the more templates/categories we try to fit the data with, the more degenerate the classification.
We used LePhare templates to classify galaxies as ETGs and LTGs. We recall that the LePhare SED fitting for cluster members is done using the ZFIX parameter with z gal fixed at z clus . We verified that this small redshift shift does not significantly affect our ETG-LTG separation by comparing cluster best fit galaxy templates before and after fixing galaxy redshifts. This is shown in Fig. 9 for a rich cluster at z = 0.35. We find that the best fit template is quite sensitive to a moderate change in redshift, with most galaxies having their templates changed, yet the classification as ETG or LTG only changes for ∼5% of the galaxies. This is due to the degeneracy between the spectra of ETGs and of LTGs with a dust component. It is a well-known limitation of template fitting codes, but since the proportion of these objects stays low it should not affect our conclusions.
Our classification somehow differs from the usual redsequence (RS) classification used in most of the literature. Understanding how the two compare is important to properly compare our results with previous studies. First, we would like to point out that previous studies also used techniques that differed from each other. Some used a simple colour cut (Popesso et al. 2006). Other studies fitted a proper red sequence with a tilt in a colour-magnitude diagram, but either with a fixed slope (e.g. Martinet et al. 2015;De Lucia et al. 2007) or varying both the slope and the intercept (e.g. Cerulo et al. 2016;De Propris et al. 2015). To compare both classifications, we fitted a RS to each of our clusters in (g − i) vs. i using where the slope is fixed at −0.0436, as in Martinet et al. (2015), and the intercept is computed at m * i , which is the observed characteristic magnitude computed from the mean M * over our redshift range: M * z = −22.6. As a first guess for the intercept, we interpolated the elliptical galaxy colour from Fukugita et al. (1995) to each cluster redshift and selected a wide preliminary RS with a width of 0.6 in magnitude. For the galaxies thus selected, we then fitted a RS with a free ordinate b and selected galaxies at ±0.3 in magnitude around this final RS. An example A67, page 10 of 21 of the RS fit and galaxy selection is shown in Fig. 8 for three rich clusters at different redshifts. We checked the robustness of the fit on these clusters by changing by 0.2 the colour used for preselection based on Fukugita et al. (1995) and allowing the slope to vary. Both checks prove our selection to be robust, as the slope only changes by 0.01 and the intercept by 0.05. Thus, only a few galaxies change their population type compared to our final RS selection. This RS selection is compared to our ETG/LTG classification in Fig. 8. One can see that at low redshift our selection discards part of the RS selected galaxies, especially at faint magnitudes, while the two methods agree well at high redshift. The difference at low redshift arises because some of the galaxies in the RS are actually LTGs reddened by dust. With the observing bands we have, it is hard for LePhare to properly segregate between ETGs and dusty-LTGs for a given galaxy. However, statistically speaking, our selection is closer to a true quiescent vs. star-forming selection than the RS, because it is less polluted by these dusty-LTGs. Quantitatively, for all three clusters 99%, 92%, and 73% of our ETGs are also RS galaxies. Inversely, there are, from low to high redshift 65%, 80%, and 96% of RS galaxies that are classified as ETGs.
The final effect on the GLF is hard to predict since the field of a RS selection has higher number counts than the field of an ETG selection. To properly investigate how the two methods compare with regard to the stacked GLFs, we thus built the RS GLFs for all clusters and compared the RS stacked GLFs to the ETG stacked GLFs in our nine bins of masses and redshifts. This is illustrated in Fig. A.1. We see that at high redshift the two selections are in good agreement for all mass bins, so our conclusions concerning the evolution of the ETG GLF are not affected by the chosen selection criterion.

Results
In this section we present the results of the GLFs of our cluster sample. We first analysed how the fraction of ETGs depends on redshift and mass. We then studied the stacked GLFs of our cluster sample. As pointed out in Sect. 3.3, we stacked cluster candidates with a mass larger than 10 14 M and redshift 0.15 < z clus < 0.7 in corresponding redshift and mass bins. We study in particular how the parameters of our fitted Schechter functions depend on redshift and mass independently, to finally break the degeneracy between these two parameters by binning our stacked GLFs in this 2D parameter space.

ETG fraction in clusters
Using the methods presented in Sects. 5.2 and 5.4 we are able, for each individual cluster candidate, to compute the number of ETGs and LTGs down to M * + 1.75. We can thus compute the fraction of ETGs in each candidate cluster. As for the richness computation, counting galaxies down to M * + 1.75 enables us to cover the redshift range 0.15 < z clus < 0.7 homogeneously, as all clusters are complete at this magnitude limit in this redshift range.
To study the dependence on redshift and mass, we first bin our cluster candidates with mass larger than 10 14 M in three mass bins. For each mass bin, cluster candidates are binned in redshift and the mean ETG fraction and LTG fraction is computed for clusters. The results are shown in Fig. 10, where the galaxy type proportions are compared to the redshift dependence when no segregation in mass is performed. The error bars represent the standard error on the mean. This analysis shows a clear increase in the fraction of ETGs in cluster candidates (M 200 > 10 14 M ) with redshift, from 53 ± 1% at z = 0.6 to 69 ± 1% at z = 0.2.
When segregating our cluster candidates into mass bins, we find that the fraction of ETGs at a given redshift is strongly dependent on mass. At z = 0.2, the mean proportion of ETGs in our cluster candidates is 66 ± 2% for the lowest mass bin (14 < log M 200 /M ≤ 14.3), 72 ± 2% for the intermediate mass bin (14.3 < log M 200 /M ≤ 14.6), and 78 ± 2% for the highest mass bin (log M 200 /M > 14.6). At z = 0.6, the mean proportion of ETGs in our cluster candidates is 49 ± 1% for the lowest mass bin, 57 ± 1% for the intermediate mass bin, and 67 ± 2% for the highest mass bin.

GLFs of clusters stacked in redshift
Computing the stacked GLFs of our cluster candidates in bins of redshift, we are able to study the redshift evolution of our Schechter fit parameters. As mentioned in Sect. 5.3, the Schechter fits of individual cluster candidates are too noisy to study their redshift or mass dependence. We thus stack our cluster candidates using the Colless method.
The results are shown in Fig. 11  redshift, and mean mass. The best fit parameters are listed in Table C.1, where we also provide the absolute magnitude limit to which the fit is performed (compl) and a goodness of fit parameter (p) defined in Eq. (12). In our three redshift bins, the Schechter fits to the GLFs of all the galaxies, ETGs and LTGs all converged with a goodness of fit parameter p > 0.94. We study the evolution of the three fitted parameters: the normalisation φ * , the characteristic absolute magnitude of the knee M * , and the faint-end parameter α. Figure 12 summarizes the results, where each parameter is plotted against redshift. Figure B.1 shows the confidence ellipses on the values of M * and α.
For the faint-end parameter α, there is a mild flattening with decreasing redshift for the ETG and the LTG populations. The ETG population GLF faint end flattens from α ETG = −0.65 ± 0.03 at z = 0.6 to α ETG = −0.79 ± 0.02 at z = 0.2, i.e. a difference of 0.14 with a significance of 3.9σ. The LTG population GLF faint end steepens from α LTG = −0.95 ± 0.04 at z = 0.6 to α LTG = −1.26 ± 0.03 at z = 0.2, i.e. a difference of 0.31 with a significance of 6.2σ. The overall population GLF faint end steepens from α all = −0.96 ± 0.02 at z = 0.6 to α all = −1.08 ± 0.02 at z = 0.2, i.e. a difference of 0.12 with a significance of 4.2σ.
The absolute magnitude characteristic parameter M * is compatible with no evolution for all galaxies and LTGs. The ETG population M * redshift dependence is compatible with passive evolution. The normalization φ * of the overall population decreases with decreasing redshift, with a significance of 2.8σ. This is due to the LTG population, which follows a similar evolution (with significance >10σ), while the ETG population shows no redshift dependence.

GLFs of clusters stacked in mass bins
We also make use of our mass inference derived from the mass-richness calibration described in Sect. 4.3 to study the dependence of our fitted parameters with the mass of the cluster candidates. We use the same stacking method as in the previous section.
The results are shown in Fig. 13, where for each panel we indicate the number of cluster candidates stacked, their mean redshift, and mean mass. The best fit parameters are listed in Table C.2, where we also provide the absolute magnitude limit to which the fit is performed (compl) and the goodness of fit parameter p defined in Eq. (12).
In our three mass bins, the Schechter fits to the GLFs of all the galaxies, of ETGs, and LTGs all converged with a goodness of fit parameter p > 0.72. Using these fits, we study the evolution of the Schechter parameters. Figure 14 summarizes the results with each parameter plotted against mass. Figure B.2 shows the confidence ellipses on the values of M * and α.
For the faint-end parameter α, we observe a steepening with increasing mass for the LTG population, from α LTG = −1.05 ± 0.02 for 14 < log (M 200 ) ≤ 14.3 to α LTG = −1.21 ± 0.04 for log (M 200 ) > 14.6, with a significance of 3.6σ. The ETG population and the full galaxy population show no clear evidence for a mass dependence of the faint end. The absolute magnitude characteristic parameter M * is compatible with no mass dependence for the full galaxy population or for the LTGs. For the ETG population, M * decreases with increasing mass with a significance of ∼3σ. The normalization φ * depends on mass for the overall galaxy population, with a significance of 9.7σ. This is expected since the normalization of the GLFs is directly related to richness, and richness is a proxy for mass. This is also true for the ETG population, which shows a clear dependence (with a >12σ significance) meaning that there are more ETGs in massive clusters. On the other hand, the normalization of the GLF of the LTG population seems independent of mass.

Breaking the degeneracy: GLFs of clusters stacked in mass-redshift bins
When studying a sample of clusters, there is usually a degeneracy between mass and redshift. Indeed, because more massive clusters are rarer, by binning our clusters in redshift space only we actually sample a population that is more representative of low-mass clusters. However, low-mass clusters are more difficult to detect at high redshift, so the two effects act oppositely and it is difficult to know which one dominates.
To break this degeneracy we need to bin in the 2D parameter space of both mass and redshift. To date this had not been possible because studies of the evolution of cluster GLFs with redshift have been limited to small samples, and extensive studies of the mass dependence concern only low-redshift objects (see e.g. Lan et al. 2016, on SDSS data).
The large size of our cluster candidate catalogue and the depth of the CFHTLS enable us to carry out such an analysis. Indeed, considering the four Wide fields of the CFHTLS, we detect 1371 cluster candidates with M 200 > 10 14 M , S /N > 4 and z < 0.7. Since we computed a robust selection function from the simulations, we know how representative of the true underlying cluster population our sample is in terms of completeness. Our catalogue is >90% pure in the redshift range considered and at worse ∼50% complete (for the lowest mass and highest redshift bin). Overall, the 2D bins are well populated, with 12 cluster candidates in the less populated bin and 160 clusters per bin in the mean.
The GLFs obtained in the three redshift bins and three mass bins are shown in Fig. 15, where for each panel we indicate the number of cluster candidates stacked, their mean redshift, and mean mass. The best Schechter fit to each galaxy population is overplotted. A grey arrow indicates the absolute magnitude where the red and blue GLFs intersect. We can see that for all cluster masses the intersection moves towards brighter magnitudes as the redshift increases. Therefore the proportion of faint LTGs increases with decreasing redshift. For a given redshift, the grey arrow moves towards fainter magnitudes as the cluster mass increases, implying that in massive clusters the contribution of bright ETGs is higher than in low-mass clusters. At fixed mass, the slope flattens (α more negative) for ETGs and steepens (α more negative) for LTGs from high to low redshift. This leads to the magnitude at which the two populations cross getting brighter at higher redshift. We see the opposite evolution of the slopes with increasing mass compared to the redshift evolution, so that the crossing happens at brighter magnitudes for low-mass clusters.
The best fit parameters are presented in Table C.3, where we also provide the absolute magnitude limit compl to which the fit is performed and the goodness of fit parameter p defined in Eq. (12). The Schechter fits to the GLFs of the full galaxy population and ETG population are obtained with goodness of fit parameters p > 0.94. For the LTG population, the goodness of fit parameter is lower on average, but always greater than 0.68. Using these fits, we can study the evolution of the fitted parameters. Figure 16 summarizes the results, by plotting α, M * , and φ * as a function of redshift for each of the three mass bins. Figure B.2 shows the confidence ellipses on the values of M * and α.
For ETGs, the faint-end slope α slightly flattens with decreasing redshift in the three mass bins. In the lowest mass bin (14 < log (M 200 ) ≤ 14.3), it decreases from α ETG = −0.66 ± 0.04 at z = 0.6 to α ETG = −0.77 ± 0.03 at z = 0.2, i.e. a difference of 0.11 with a significance of only 2.2σ. The same trend is observed for the intermediate mass bin (14.3 < log (M 200 ) ≤ 14.6), the faint-end slope flattening from α ETG = −0.63 ± 0.04 at z = 0.6 to α ETG = −0.80 ± 0.03 at z = 0.2, i.e. a difference of 0.17 with a significance of 3.4σ, and in the highest mass bin (log (M 200 ) > 14.6) with a flattening from α ETG = −0.58 ± 0.09 at z = 0.6 to α ETG = −0.82 ± 0.04 at z = 0.2, i.e. a difference of 0.24 with a significance of 2.4σ. These results also hint to a mass dependence of the faint-end slope at a given redshift. Indeed, in the high-redshift bin (z = 0.6) the slope is flatter for the low-mass clusters, with a difference of 0.08. The opposite is observed in the low-redshift bin (z = 0.2) where the slope is flatter for the high-mass clusters, with a difference of 0.05. However, these hints are detected at a low significance level and would thus need extended mass and/or redshift coverage to be verified.
For LTGs the faint-end slope decreases with decreasing redshift in the two lowest mass bins and shows no clear evolution in the highest mass bin. In the lowest mass bin, it steepens from α LTG = −0.92 ± 0.05 at z = 0.6 to α LTG = −1.25 ± 0.04 at z = 0.2, i.e. a difference of 0.33 with a significance of 5.2σ. The same trend is observed for the intermediate mass bin, where the faint-end slope steepens from α LTG = −1.00 ± 0.07 at z = 0.6 to α LTG = −1.19 ± 0.05 at z = 0.2, i.e. a difference of 0.19 with a significance of 2.2σ.
The faint-end slope of the overall population also steepens with decreasing redshift in the three mass bins. In the lowest mass bin, it steepens from α all = −0.95 ± 0.03 at z = 0.6 to α all = −1.09 ± 0.02 at z = 0.2, i.e. a difference of 0.14 with a significance of 3.9σ. The same trend is observed for the intermediate mass bin (14.3 < log (M 200 ) ≤ 14.6) but with a lower significance level, the faint-end slope steepening from α all = −0.94 ± 0.04 at z = 0.6 to α all = −1.03 ± 0.03 at z = 0.2, i.e. a difference of 0.09 with a significance of 1.8σ, and in the highest mass bin (log (M 200 ) > 14.6) with a steepening from α all = −0.90 ± 0.07 at z = 0.6 to α all = −1.13 ± 0.03 at z = 0.2, i.e. a difference of 0.23 with a significance of 3σ.
In Fig. 16, we see an evolution of M * compatible with both passive evolution and no evolution for ETGs in the two lowest mass bins. No particular evolution is seen for other populations.
When looking at the normalization parameter φ * , we observe a decrease with decreasing redshift for the LTG population, respectively at 6.8σ, 3.5σ, and 2.2σ in the low-, intermediate-, and high-mass bins, between z = 0.6 and z = 0.2. The ETG population shows a rather constant normalisation with redshift, so that the overall population normalisation tends to follow the LTG evolution.
These results are discussed in Sect. 7.

ETG fraction
We first consider the evolution of cluster galaxy types with redshift for galaxies brighter than M * + 1.75. The fraction of bright ETGs increases with decreasing redshift whatever the mass. The evolution is stronger for the low-mass clusters, with a change of about 20% in the fraction of ETGs over the probed redshift range, against only 10% for high-mass clusters. At fixed redshift, however, we see a higher fraction of ETGs in high-mass clusters compared to low-mass clusters. These two pieces of information can be interpreted as a different behaviour between the highand low-mass clusters. The low-mass clusters undergo a significant evolution of the bright ETG fraction over the redshift range 0.1 < z < 0.7; however, this ETG fraction is lower than that of high-mass clusters, which probably underwent a similar evolution earlier in their history, at z > 0.7. In this scenario, the massive clusters are more evolved than the low-mass clusters, which are still evolving towards higher masses either by accreting ETGs from preprocessed groups or by an evolution of LTGs into ETGs.

GLF redshift evolution
We focus on the variations of the Schechter parameters with cluster redshift. To study the GLF behaviour, we differentiate between galaxies with M abs (i) < M * + 1.75, which we call bright galaxies, and galaxies with M abs (i) > M * + 1.75, which we call faint galaxies. In Sect. 6.2 we see that when clusters of all masses are included, α steepens and φ * decreases with decreasing redshift for the LTG population, while M * remains constant. This implies that there are more faint LTGs (α LTG more negative) and less bright LTGs (smaller φ * ) at z = 0.2 than at z = 0.6. This can be seen in Fig. 17, which shows how the Schechter function changes with redshift for both ETGs and LTGs. This is also in agreement with the evolution of galaxy types with redshift. For the ETG population, we observe a slight flattening of α ETG and an increase in M * between z = 0.6 and z = 0.2 (compatible with a passive evolution) and a constant φ * . These effects combine so that there are more faint ETGs (α ETG flattens) at z = 0.2 than at z = 0.6, while the number of bright ETGs is slightly higher at z = 0.6. The passive evolution is consistent with a single stellar population model of Bruzual & Charlot (2003), with a single burst of star formation at z = 3. The redshift evolution of the faint-end slope parameter α ETG is in agreement with previous studies (e.g. Martinet et al. 2017, and references therein). Zhang et al. (2017) recently found a compatible redshift dependence of the faint-end slope for the red-sequence GLF using Dark Energy Survey (DES) data. We also note that when comparing our results to those of Martinet et al. (2017), our faint-end slope parameter α is slightly steeper at low redshift than theirs, but within the error bars. However, some studies-most recently De Propris et al. (2015) and Cerulo et al. (2016)-see no clear redshift evolution in the faint-end slope of the red-sequence GLF. Both studies build the stacked GLFs of high-redshift clusters and find faint-end slope values compatible with low redshift values. Cerulo et al. (2016) has studied a sample of nine very highredshift clusters (0.8 < z < 1.5) and find a somewhat weaker evolution of the faint end than ours. Namely, they measured α RS = −0.889 +0.009 −0.001 for red-sequence galaxies. The difference with our study could be explained by the low number of M abs (i) clusters they consider, together with the different range of redshift, or by a contamination of our cluster candidate sample by false detections. The latter option is unlikely, however, as we ensured a 90% purity in our selected sample. De Propris et al.
(2015) studied a sample of four clusters at a mean redshift of z = 1.25. When looking at the stacked red-sequence GLFs, they seem to find a weaker evolution than ours. Even though no error bars on the faint-end parameter is given, when looking at their M * vs. α confidence ellipses, their best fit seems to be compatible with α RS ∼ −0.5, so there should be less than a 1σ discrepancy with our results. Two different scenarios could explain our observations. In the first, the evolution of cluster GLFs with redshift is driven by stripping of LTGs (explaining the decrease in bright LTG density and the increase in faint LTG density) and accretion of preprocessed galaxy groups (explaining the increase in faint ETG density). In the second, the evolution results from the combination of accretion of faint LTGs from the field and quenching of bright LTGs into ETGs of slightly fainter magnitudes. This second scenario also agrees with the model of Peng et al. (2010).

GLF mass dependence
We see in Sect. 6.3 that when clusters are binned in mass to compute the stacked GLFs, α is mass dependent for LTGs only, while M * shows a slight mass dependence for ETGs alone (Fig. 18). This is mostly in agreement with the Lan et al. (2016) results on SDSS data where no mass dependence was found for α or M * for both galaxy populations in the mass range studied here. Zhang et al. (2017) also recently reported no evidence for a mass dependence of both parameters on red-sequence galaxies. Moreover, the Lan et al. (2016) value of α LTG is somewhat steeper than ours, being around −1.5, whatever the cluster mass. This suggests that the evolution of faint LTGs we see in our study continues toward lower redshifts. The normalisation φ * is strongly mass dependent for ETGs, with more massive clusters having a higher normalization, while it is independent of mass for LTGs. This shows that the number of bright ETGs is a good proxy of the mass, contrary to the LTGs. The combination of the α and φ * mass dependence implies that more massive clusters contain more faint LTGs than low-mass clusters do, and also contain more bright ETGs.
This suggests that accretion of faint LTGs from the field could be more efficient in more massive clusters. The constant number of bright LTGs with cluster mass disfavours stripping or disruption of bright LTGs into faint LTGs. Indeed, these effects are driven by the environment density and are thus expected to be mass dependent.

GLF redshift evolution with redshift and mass
As already stated, the dependence of GLFs with redshift or mass, although it gives insights into the physical processes happening in clusters, suffers from the degeneracy between these two parameters. By breaking the degeneracy, we can look at how the GLFs depend on redshift for given cluster masses, or inversely look at how they depend on mass for given cluster redshifts.
When looking at the redshift evolution for different mass bins, we have seen in Sect. 6.4 that the faint-end slope α ETG of ETG GLFs slightly flattens with decreasing redshift for all cluster masses, but the more massive the cluster, the more it flattens between z = 0.6 and z = 0.2 (see Fig. 16). This is even clearer when directly comparing the Schechter function evolution at different masses (see Fig. 19). The combined evolution of the three parameters implies that there is a significant increase in the number density of faint ETGs with decreasing redshift, and that it is stronger for higher masses. This means that more massive clusters see their faint ETG population grow faster between z = 0.6 and z = 0.2 than less massive ones. For LTGs, α LTG flattens with decreasing redshift for the lowest mass bin, while it shows no clear redshift evolution in the two higher mass bins. At the same time, the normalization φ * decreases with decreasing redshift, this effect also being stronger for lower mass clusters. The number density of bright LTGs decreases with decreasing redshift for all cluster masses.
When looking at the mass dependence for different redshift bins (see Fig. 20), we see that the shapes of the ETG GLFs at a given redshift are independent of mass. Only the normalisation changes: more massive clusters have more ETGs, both bright and faint. For LTGs α LTG gets steeper as the mass increases whatever the redshift. Also, high-mass clusters have more faint LTGs in our redshift range. We see that the number density of bright LTGs does not depend on mass, whatever the redshift. We find more faint LTGs in high-mass clusters, but a larger increase with decreasing redshift for the low mass, which suggests that high-mass clusters have already accreted most of their environment at higher redshift. We note that this last conclusion becomes obvious only when breaking the mass-redshift degeneracy.

Physical interpretation
To sum up, the number of faint ETGs increases with decreasing redshift, the effect being stronger at higher masses. The number of faint LTGs tends to be higher in higher mass clusters whatever the redshift, but only low-mass clusters see their number density of faint LTGs increase in the redshift range studied. The number density of bright LTGs decreases with decreasing redshift, whatever the mass. This favours the scenario where the red-sequence formed at z > 0.7 with low to no evolution of bright ETGs at z < 0.7. This red-sequence is then enriched between z = 0.7 and z = 0.15 through quenching of bright LTGs into ETGs of slightly fainter magnitudes. This quenching is more efficient in high-mass clusters. At the same time, accretion of faint LTGs is more efficient at low mass, as high-mass clusters have already emptied their environment at z > 0.7.

Conclusions
We used our new AMASCFI cluster detection algorithm to detect 7100 cluster candidates with S /N > 3 and 0.15 < z ≤ 1.1 in the four Wide fields of the CFHTLS. Using lightcones extracted from the Millennium simulation, we derived the selection function of AMASCFI. At this S/N, we have a completeness of ∼50% and a purity >80% over the full redshift range and of ∼80% and ∼90% respectively for z < 0.7. We computed a richness estimate for clusters with S /N > 4 and z < 0.7 and converted it to a mass estimate using a mass-richness scaling relation obtained from matching our cluster candidates with X-ray detected clusters. We obtained a catalogue of 1371 cluster candidates with mass M 200 > 10 14 M , S /N > 4 and z < 0.7 in the four Wide fields of the CFHTLS, with a completeness of ∼70% and purity ∼90%.
With our large and pure sample of cluster candidates, we are able to compute stacked GLFs for ETGs, LTGs, and for the overall population in three redshift bins and three cluster mass bins. Our main results are the following: -the number of faint ETGs increases with decreasing redshift, the effect being stronger for higher mass clusters; -the number of faint LTGs tends to be higher in higher mass clusters, whatever the redshift; -the number density of faint LTGs increases only in low-mass clusters in the studied redshift range; -the number density of bright LTGs decreases with decreasing redshift, whatever the mass.
These results show that the cluster red sequence is mainly formed at redshift z > 0.7, and that faint ETGs continue to enrich the red sequence through quenching of brighter LTGs at z ≤ 0.7. The efficiency of this quenching is higher in high-mass clusters, and the accretion rate of faint LTGs is higher in low-mass clusters as high-mass clusters have already accreted most of their environment.
The large number of clusters in our sample has allowed us to understand cluster galaxy evolution at intermediate redshifts (0.15 ≤ z < 0.7) and mass M 200 > 10 14 M , and to break the degeneracy between these two observables. One interesting continuation would be to study the fraction of ETGs and LTGs in infalling filaments in order to help understand the accretion processes. Finally, the Euclid satellite will detect tens of thousands of clusters, allowing us to probe the higher redshift and lower mass clusters and groups. Black is for all galaxies, red for ETGs, and blue for LTGs.

Notes.
As in Fig. 11, the central redshift of the slice is indicated. Galaxy clusters are selected in the range z slice ± 0.1. The "compl" and "p" columns correspond to the completeness limit to which the fit is done and the goodness of the fit normalized to one, respectively. Notes.
The mass of the bin is indicated, "compl" and "p" correspond to the completeness limit to which the fit is done and the goodness of the fit normalized to one, respectively.