コード例 #1
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
コード例 #2
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
コード例 #3
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
コード例 #4
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
コード例 #5
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
コード例 #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
コード例 #7
0
def plot_peak(x, y, name):
    """Plot pulse heights for array of pulses"""
    peak, peakErr = calc.calcPeak(x,y)
    bins = np.arange((peak-8*peakErr), (peak+8*peakErr), (peakErr/5.))
    hist = ROOT.TH1D("%s" % name,"%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Pulse hieght")
    hist.GetXaxis().SetTitle("Pulse height (V)")
    f = calc.positive_check(y)
    if f == True:
        for i in range(len(y[:,0])-1):
            hist.Fill(max(y[i,:]))
    else:
        for i in range(len(y[:,0])-1):
            hist.Fill(min(y[i,:]))
    return hist, peak, peakErr
コード例 #8
0
def plot_peak(x, y, name):
    """Plot pulse heights for array of pulses"""
    peak, peakErr = calc.calcPeak(x, y)
    bins = np.arange((peak - 8 * peakErr), (peak + 8 * peakErr),
                     (peakErr / 5.))
    hist = ROOT.TH1D("%s" % name, "%s" % name, len(bins), bins[0], bins[-1])
    hist.SetTitle("Pulse hieght")
    hist.GetXaxis().SetTitle("Pulse height (V)")
    f = calc.positive_check(y)
    if f == True:
        for i in range(len(y[:, 0]) - 1):
            hist.Fill(max(y[i, :]))
    else:
        for i in range(len(y[:, 0]) - 1):
            hist.Fill(min(y[i, :]))
    return hist, peak, peakErr
コード例 #9
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
コード例 #10
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