Exemplo n.º 1
0
def mapm_spe(x, eped, eped_sigma, spe, spe_sigma, lambda_):
    """
    Fit for the SPE spectrum of a MAPM

    Parameters
    ----------
    x : ndarray
        The x values to evaluate at
    eped : float
        Distance of the zeroth peak from the origin
    eped_sigma : float
        Sigma of the zeroth peak, represents electronic noise of the system
    spe : float
        Signal produced by 1 photo-electron
    spe_sigma : float
        Spread in the number of photo-electrons incident on the MAPMT
    lambda_ : float
        Poisson mean (average illumination in p.e.)

    Returns
    -------
    spectrum : ndarray
        The y values of the total spectrum.
    """
    # Obtain pedestal peak
    p_ped = exp(-lambda_)
    spectrum = p_ped * normal_pdf(x, eped, eped_sigma)

    pk_max = 0

    # Loop over the possible total number of cells fired
    for k in range(1, 100):
        p = poisson(k, lambda_)  # Probability to get k avalanches

        # Skip insignificant probabilities
        if p > pk_max:
            pk_max = p
        elif p < 1e-4:
            break

        # Combine spread of pedestal and pe peaks
        pe_sigma = sqrt(k * spe_sigma**2 + eped_sigma**2)

        # Evaluate probability at each value of x
        spectrum += p * normal_pdf(x, eped + k * spe, pe_sigma)

    return spectrum
Exemplo n.º 2
0
 def _get_spectra(n_illuminations, data_x, lookup, *parameter_values):
     spectra = []
     for i in range(n_illuminations):
         spectrum = normal_pdf(
             data_x,
             parameter_values[lookup[i]['mean']],
             parameter_values[lookup[i]['std']],
         )
         spectra.append(spectrum)
     return spectra
Exemplo n.º 3
0
 def _get_likelihood(n_illuminations, data_x, data_y, lookup,
                     *parameter_values):
     likelihood = 0
     for i in range(n_illuminations):
         spectrum = normal_pdf(
             data_x,
             parameter_values[lookup[i]['mean']],
             parameter_values[lookup[i]['std']],
         )
         likelihood += np.nansum(-2 * poisson_logpmf(data_y[i], spectrum))
     return likelihood
Exemplo n.º 4
0
def test_normal_pdf():
    x = np.linspace(-10, 10, 100, dtype=np.float32)
    mean = 0
    std = 5
    assert_allclose(normal_pdf(x, mean, std),
                    scipy_stats.norm.pdf(x, mean, std))
Exemplo n.º 5
0
def sipm_gentile_spe(x, eped, eped_sigma, spe, spe_sigma, opct, lambda_):
    """
    Fit for the SPE spectrum of a SiPM

    Parameters
    ----------
    x : ndarray
        The x values to evaluate at
    eped : float
        Distance of the zeroth peak from the origin
    eped_sigma : float
        Sigma of the zeroth peak, represents electronic noise of the system
    spe : float
        Signal produced by 1 photo-electron
    spe_sigma : float
        Spread in the number of photo-electrons incident on the MAPMT
    opct : float
        Optical crosstalk probability
    lambda_ : float
        Poisson mean (average illumination in p.e.)


    Returns
    -------
    spectrum : ndarray
        The y values of the total spectrum.
    """
    # Obtain pedestal peak
    p_ped = exp(-lambda_)
    spectrum = p_ped * normal_pdf(x, eped, eped_sigma)

    pk_max = 0

    # Loop over the possible total number of cells fired
    for k in range(1, 100):
        pk = 0
        for j in range(1, k + 1):
            pj = poisson(j, lambda_)  # Probability for j initial fired cells

            # Skip insignificant probabilities
            if pj < 1e-4:
                continue

            # Sum the probability from the possible combinations which result
            # in a total of k fired cells to get the total probability of k
            # fired cells
            pk += pj * pow(1 - opct, j) * pow(opct, k - j) * binom(
                k - 1, j - 1)

        # Skip insignificant probabilities
        if pk > pk_max:
            pk_max = pk
        elif pk < 1e-4:
            break

        # Combine spread of pedestal and pe peaks
        pe_sigma = sqrt(k * spe_sigma**2 + eped_sigma**2)

        # Evaluate probability at each value of x
        spectrum += pk * normal_pdf(x, eped + k * spe, pe_sigma)

    return spectrum