Пример #1
0
    def __init__(self):
        super(NEW_meta, self).__init__()

        # Load the database objects
        self._det_geo = load_db.DetectorGeo()
        self._pmt_data = load_db.DataPMT()
        self._sipm_data = load_db.DataSiPM()

        self.skim_det_info(self._det_geo)
Пример #2
0
def test_compute_drift_v_when_moving_edge():
    edge = np.random.uniform(530, 570)
    Nevents = 100 * 1000
    data = np.random.uniform(450, edge, Nevents)
    data = np.random.normal(data, 1)
    dv, dvu = compute_drift_v(data, 60, [500, 600], [1500, 550, 1, 0], 'new')
    dv_th = DB.DetectorGeo('new').ZMAX[0] / edge

    assert dv_th == approx(dv, abs=5 * dvu)
Пример #3
0
 def __init__(self):
     super(io_manager, self).__init__()
     
     # Load the database objects
     self._det_geo   = load_db.DetectorGeo()
     self._pmt_data  = load_db.DataPMT()
     self._sipm_data = load_db.DataSiPM()
     self._events = []
     self._entry = 0
     self._max_entry = 0
     self._run = 5
Пример #4
0
def compute_drift_v(zdata: np.array,
                    nbins: int = 35,
                    zrange: Tuple[float, float] = (500, 640),
                    seed: Tuple[float, float, float, float] = None,
                    detector: str = 'new') -> Tuple[float, float]:
    """
    Computes the drift velocity for a given distribution
    using the sigmoid function to get the cathode edge.

    Parameters
    ----------
    zdata: array_like
        Values of Z coordinate.
    nbins: int (optional)
        The number of bins in the z coordinate for the binned fit.
    zrange: length-2 tuple (optional)
        Fix the range in z.
    seed: length-4 tuple (optional)
        Seed for the fit.
    detector: string (optional)
        Used to get the cathode position from DB.
    plot_fit: boolean (optional)
        Flag for plotting the results.

    Returns
    -------
    dv: float
        Drift velocity.
    dvu: float
        Drift velocity uncertainty.
    """

    y, x = np.histogram(zdata, nbins, zrange)
    x = shift_to_bin_centers(x)

    if seed is None: seed = np.max(y), np.mean(zrange), 0.5, np.min(y)

    z_cathode = DB.DetectorGeo(detector).ZMAX[0]
    try:
        f = fitf.fit(sigmoid,
                     x,
                     y,
                     seed,
                     sigma=poisson_sigma(y),
                     fit_range=zrange)
        dv = z_cathode / f.values[1]
        dvu = dv / f.values[1] * f.errors[1]
    except RuntimeError:
        print(
            "WARNING: Sigmoid fit for dv computation fails. NaN value will be set in its place."
        )
        dv, dvu = np.nan, np.nan

    return dv, dvu
Пример #5
0
def compute_drift_v(zdata: np.array,
                    nbins: int = 35,
                    zrange: Tuple[float, float] = (500, 640),
                    seed: Tuple[float, float, float, float] = None,
                    detector: str = 'new',
                    plot_fit: bool = False) -> Tuple[float, float]:
    """
    Computes the drift velocity for a given distribution
    using the sigmoid function to get the cathode edge.

    Parameters
    ----------
    zdata: array_like
        Values of Z coordinate.
    nbins: int (optional)
        The number of bins in the z coordinate for the binned fit.
    zrange: length-2 tuple (optional)
        Fix the range in z.
    seed: length-4 tuple (optional)
        Seed for the fit.
    detector: string (optional)
        Used to get the cathode position from DB.
    plot_fit: boolean (optional)
        Flag for plotting the results.

    Returns
    -------
    dv: float
        Drift velocity.
    dvu: float
        Drift velocity uncertainty.
    """

    y, x = np.histogram(zdata, nbins, zrange)
    x = shift_to_bin_centers(x)

    if seed is None: seed = np.max(y), np.mean(zrange), 0.5, np.min(y)

    f = fitf.fit(sigmoid, x, y, seed, sigma=poisson_sigma(y), fit_range=zrange)

    z_cathode = DB.DetectorGeo(detector).ZMAX[0]
    dv = z_cathode / f.values[1]
    dvu = dv / f.values[1] * f.errors[1]

    if plot_fit:
        plt.figure()
        plt.hist(zdata, nbins, zrange)
        xx = np.linspace(zrange[0], zrange[1], nbins)
        plt.plot(xx, sigmoid(xx, *f[1]), color='red')

    return dv, dvu