Beispiel #1
0
def plot_rise(x, y, name, scale=1e9):
    """Calc and plot rise time of pulses"""
    rise, riseErr = calc.calcRise(x, y)
    print rise, riseErr
    bins = np.arange((rise - 8 * riseErr) * scale,
                     (rise + 8 * riseErr) * scale, (riseErr / 5.) * scale)
    hist = ROOT.TH1D("%s" % name, "%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Rise time")
    hist.GetXaxis().SetTitle("Rise time (ns)")
    f = calc.positive_check(y)
    if f == True:
        for i in range(len(y[:, 0]) - 1):
            m = max(y[i, :])
            lo_thresh = m * 0.1
            hi_thresh = m * 0.9
            low = calc.interpolate_threshold(x, y[i, :], lo_thresh)
            high = calc.interpolate_threshold(x, y[i, :], hi_thresh)
            hist.Fill((high - low) * scale)
    else:
        for i in range(len(y[:, 0]) - 1):
            m = min(y[i, :])
            lo_thresh = m * 0.1
            hi_thresh = m * 0.9
            low = calc.interpolate_threshold(x, y[i, :], lo_thresh, rise=False)
            high = calc.interpolate_threshold(x,
                                              y[i, :],
                                              hi_thresh,
                                              rise=False)
            hist.Fill((high - low) * scale)
    return hist, rise, riseErr
def plot_width(x, y, name, scale = 1e9):
    """Calc and plot FWHM of pulses"""
    width, widthErr = calc.calcWidth(x,y)
    print width, widthErr
    bins = np.arange((width-8*widthErr)*scale, (width+8*widthErr)*scale, (widthErr/5.)*scale)
    hist = ROOT.TH1D("%s" % name,"%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Pulse width")
    hist.GetXaxis().SetTitle("FWHM (ns)")
    f = calc.positive_check(y)
    if f == True:
        for i in range(len(y[:,0])-1):
            m = max(y[i,:])
            m_index = np.where(y[i,:] == m)[0][0]
            thresh = m*0.5
            first = calc.interpolate_threshold(x[:m_index], y[i,:m_index], thresh, rise=True)
            second = calc.interpolate_threshold(x[m_index:], y[i,m_index:], thresh, rise=False)
            hist.Fill((second - first)*scale)
    else:
        for i in range(len(y[:,0])-1):
            m = min(y[i,:])
            m_index = np.where(y[i,:] == m)[0][0]
            thresh = m*0.5
            first = calc.interpolate_threshold(x[:m_index], y[i,:m_index], thresh, rise=False)
            second = calc.interpolate_threshold(x[m_index:], y[i,m_index:], thresh, rise=True)
            hist.Fill((second - first)*scale)
    return hist, width, widthErr
def plot_fall(x, y, name, scale = 1e9):
    """Calc and plot fall time of pulses"""
    fall, fallErr = calc.calcFall(x,y)
    print fall, fallErr 
    bins = np.arange((fall-8*fallErr)*scale, (fall+8*fallErr)*scale, (fallErr/5.)*scale)
    hist = ROOT.TH1D("%s" % name,"%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Fall time")
    hist.GetXaxis().SetTitle("Fall time (ns)")
    f = calc.positive_check(y)
    if f == True:
        for i in range(len(y[:,0])-1):
            m = max(y[i,:])
            m_index = np.where(y[i,:] == m)[0][0]
            lo_thresh = m*0.1
            hi_thresh = m*0.9
            low = calc.interpolate_threshold(x[m_index:], y[i,m_index:], lo_thresh, rise=False)
            high = calc.interpolate_threshold(x[m_index:], y[i,m_index:], hi_thresh, rise=False)
            hist.Fill((low - high)*scale)
    else:
        for i in range(len(y[:,0])-1):
            m = min(y[i,:])
            m_index = np.where(y[i,:] == m)[0][0]
            lo_thresh = m*0.1
            hi_thresh = m*0.9
            low = calc.interpolate_threshold(x[m_index:], y[i,m_index:], lo_thresh)
            high = calc.interpolate_threshold(x[m_index:], y[i,m_index:], hi_thresh)
            hist.Fill((low - high)*scale)
    return hist, fall, fallErr
def plot_rise(x, y, name, scale = 1e9):
    """Calc and plot rise time of pulses"""
    rise, riseErr = calc.calcRise(x,y)
    print rise, riseErr
    bins = np.arange((rise-8*riseErr)*scale, (rise+8*riseErr)*scale, (riseErr/5.)*scale)
    hist = ROOT.TH1D("%s" % name,"%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Rise time")
    hist.GetXaxis().SetTitle("Rise time (ns)")
    f = calc.positive_check(y)
    if f == True:
        for i in range(len(y[:,0])-1):
            m = max(y[i,:])
            lo_thresh = m*0.1
            hi_thresh = m*0.9
            low = calc.interpolate_threshold(x, y[i,:], lo_thresh)
            high = calc.interpolate_threshold(x, y[i,:], hi_thresh)
            hist.Fill((high - low)*scale)
    else:
        for i in range(len(y[:,0])-1):
            m = min(y[i,:])
            lo_thresh = m*0.1
            hi_thresh = m*0.9
            low = calc.interpolate_threshold(x, y[i,:], lo_thresh, rise=False)
            high = calc.interpolate_threshold(x, y[i,:], hi_thresh, rise=False)
            hist.Fill((high - low)*scale)
    return hist, rise, riseErr
def plot_jitter(x1, y1, x2, y2, name, scale = 1e9):
    """Calc and plot jitter of pulse pairs"""
    sep, jitter, jittErr = calc.calcJitter(x1, y1, x2, y2)
    bins = np.arange((sep-8*jitter)*scale, (sep+8*jitter)*scale, (jitter/5.)*scale)
    hist = ROOT.TH1D("%s" % name,"%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Jitter between signal and trigger out")
    hist.GetXaxis().SetTitle("Pulse separation (ns)")
    p1 = calc.positive_check(y1)
    p2 = calc.positive_check(y2)
    for i in range(len(y1[:,0])-1):
        m1 = calc.calcSinglePeak(p1, y1[i,:])
        m2 = calc.calcSinglePeak(p2, y2[i,:])
        time_1 = calc.interpolate_threshold(x1, y1[i,:], 0.1*m1, rise=p1)
        time_2 = calc.interpolate_threshold(x2, y2[i,:], 0.1*m2, rise=p2)
        hist.Fill((time_1 - time_2)*scale)
    return hist, jitter, jittErr
Beispiel #6
0
def plot_jitter(x1, y1, x2, y2, name, scale=1e9):
    """Calc and plot jitter of pulse pairs"""
    sep, jitter, jittErr = calc.calcJitter(x1, y1, x2, y2)
    bins = np.arange((sep - 8 * jitter) * scale, (sep + 8 * jitter) * scale,
                     (jitter / 5.) * scale)
    hist = ROOT.TH1D("%s" % name, "%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Jitter between signal and trigger out")
    hist.GetXaxis().SetTitle("Pulse separation (ns)")
    p1 = calc.positive_check(y1)
    p2 = calc.positive_check(y2)
    for i in range(len(y1[:, 0]) - 1):
        m1 = calc.calcSinglePeak(p1, y1[i, :])
        m2 = calc.calcSinglePeak(p2, y2[i, :])
        time_1 = calc.interpolate_threshold(x1, y1[i, :], 0.1 * m1, rise=p1)
        time_2 = calc.interpolate_threshold(x2, y2[i, :], 0.1 * m2, rise=p2)
        hist.Fill((time_1 - time_2) * scale)
    return hist, jitter, jittErr
def get_pmt_time_and_spread(x1,y1,pulse_thresh=-5e-3):
     pmt_times = []
     for i in range(len(y1)):
	 if np.min(y1[i]) < pulse_thresh:
            pmt_times.append(calc.interpolate_threshold(x1,y1[i],pulse_thresh,rise=False))
     pmt_time_avg = np.mean(pmt_times)
     pmt_time_err = np.std(pmt_times)/np.sqrt(len(pmt_times))
     return pmt_time_avg*1.0e9, pmt_time_err*1.0e9
Beispiel #8
0
def plot_width(x, y, name, scale=1e9):
    """Calc and plot FWHM of pulses"""
    width, widthErr = calc.calcWidth(x, y)
    print width, widthErr
    bins = np.arange((width - 8 * widthErr) * scale,
                     (width + 8 * widthErr) * scale, (widthErr / 5.) * scale)
    hist = ROOT.TH1D("%s" % name, "%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Pulse width")
    hist.GetXaxis().SetTitle("FWHM (ns)")
    f = calc.positive_check(y)
    if f == True:
        for i in range(len(y[:, 0]) - 1):
            m = max(y[i, :])
            m_index = np.where(y[i, :] == m)[0][0]
            thresh = m * 0.5
            first = calc.interpolate_threshold(x[:m_index],
                                               y[i, :m_index],
                                               thresh,
                                               rise=True)
            second = calc.interpolate_threshold(x[m_index:],
                                                y[i, m_index:],
                                                thresh,
                                                rise=False)
            hist.Fill((second - first) * scale)
    else:
        for i in range(len(y[:, 0]) - 1):
            m = min(y[i, :])
            m_index = np.where(y[i, :] == m)[0][0]
            thresh = m * 0.5
            first = calc.interpolate_threshold(x[:m_index],
                                               y[i, :m_index],
                                               thresh,
                                               rise=False)
            second = calc.interpolate_threshold(x[m_index:],
                                                y[i, m_index:],
                                                thresh,
                                                rise=True)
            hist.Fill((second - first) * scale)
    return hist, width, widthErr
Beispiel #9
0
def plot_fall(x, y, name, scale=1e9):
    """Calc and plot fall time of pulses"""
    fall, fallErr = calc.calcFall(x, y)
    print fall, fallErr
    bins = np.arange((fall - 8 * fallErr) * scale,
                     (fall + 8 * fallErr) * scale, (fallErr / 5.) * scale)
    hist = ROOT.TH1D("%s" % name, "%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Fall time")
    hist.GetXaxis().SetTitle("Fall time (ns)")
    f = calc.positive_check(y)
    if f == True:
        for i in range(len(y[:, 0]) - 1):
            m = max(y[i, :])
            m_index = np.where(y[i, :] == m)[0][0]
            lo_thresh = m * 0.1
            hi_thresh = m * 0.9
            low = calc.interpolate_threshold(x[m_index:],
                                             y[i, m_index:],
                                             lo_thresh,
                                             rise=False)
            high = calc.interpolate_threshold(x[m_index:],
                                              y[i, m_index:],
                                              hi_thresh,
                                              rise=False)
            hist.Fill((low - high) * scale)
    else:
        for i in range(len(y[:, 0]) - 1):
            m = min(y[i, :])
            m_index = np.where(y[i, :] == m)[0][0]
            lo_thresh = m * 0.1
            hi_thresh = m * 0.9
            low = calc.interpolate_threshold(x[m_index:], y[i, m_index:],
                                             lo_thresh)
            high = calc.interpolate_threshold(x[m_index:], y[i, m_index:],
                                              hi_thresh)
            hist.Fill((low - high) * scale)
    return hist, fall, fallErr