def plot_short_map(short_map, name):
    data_top = short_map["top"]
    data_bot = short_map["bottom"]
    new_data = {}

    for cell_num in data_top.keys():
        if cell_num not in data_bot.keys():
            # This shouldn't happen
            raise ValueError
        top = bool(data_top[cell_num])
        bot = bool(data_bot[cell_num])
        if top and bot:
            new_data[cell_num] = 3
        elif top and not bot:
            new_data[cell_num] = 2
        elif not top and bot:
            new_data[cell_num] = 1
        else:
            new_data[cell_num] = 0

    sn_tracker = sn.tracker("short_" + name, with_palette=True)
    sn_tracker.draw_content = False
    sn_tracker.draw_cellnum = False
    sn_tracker.draw_cellid = False

    for cell_num in new_data.keys():
        # cell_num = side * 113 * 9 + row * 9 + layer
        if cell_num == 0 * 113 * 9 + 108 * 9 + 4:
            continue
        elif cell_num == 0 * 113 * 9 + 89 * 9 + 1:
            continue
        sn_tracker.setcontent(cell_num, new_data[cell_num])
    sn_tracker.draw()
    sn_tracker.save("/Users/williamquinn/Desktop/tracksioning")
    del sn_tracker
示例#2
0
def plot_event_map(name: str, hits: list, output_directory):
    sntracker = sn.tracker(name, with_palette=True)
    sntracker.draw_cellid_label()
    sntracker.draw_content_label('{:.2f}')

    for i_cell in range(len(hits)):
        if hits[i_cell] == 0:
            continue
        sntracker.setcontent(i_cell, hits[i_cell])

    # sntracker.setrange(0, 35)

    sntracker.draw()
    sntracker.save(output_directory)
示例#3
0
def draw_propagation_vs_time(run: int, events):
    sn_tracker = sndisplay.tracker('tr_prop_vs_time_' + str(run))
    sn_tracker.draw_cellid_label()
    sn_tracker.draw_content_label('{:.0e}')

    lower = 0
    higher = 100
    x = [[] for i in range(2034)]
    y = [[] for i in range(2034)]
    for event in events:
        event_time = []
        for calo_event in event[0]:
            event_time.append(calo_event.time)
        event_time = np.array(event_time)
        if event_time.size == 0:
            continue
        event_time = np.min(event_time)
        tracker_events = event[1]
        for tracker_event in tracker_events:
            if tracker_event.timestamp_r1 is None or tracker_event.timestamp_r2 is None \
                    or tracker_event.time_bottom_cathode is None or tracker_event.time_top_cathode is None:
                continue
            t5 = (tracker_event.time_bottom_cathode - event_time) * 1e6
            t6 = (tracker_event.time_top_cathode - event_time) * 1e6

            t1 = (tracker_event.timestamp_r1 * 1.25e-8 - event_time) * 1e6
            t2 = (tracker_event.timestamp_r2 * 1.25e-8 - event_time) * 1e6

            if t5 < 10 and t6 < 10:
                continue

            if lower < t1 < higher and lower < t2 < higher:
                x[tracker_event.cell_num].append(event_time)
                y[tracker_event.cell_num].append(t5 + t6)

    for i_cell in range(len(x)):
        try:
            popt, pcov = curve_fit(xdata=x[i_cell], ydata=y[i_cell], f=linear)
            m = popt[0]
            c = popt[1]
            sn_tracker.setcontent(i_cell, m)
        except:
            pass

    sn_tracker.setrange(-0.001, 0.001)
    sn_tracker.draw()
    sn_tracker.save("/Users/williamquinn/Desktop/" + str(run))
示例#4
0
def draw_bottom_cathode_events(run: int, events):
    sn_tracker = sndisplay.tracker('tr_bottom_cathode_' + str(run))
    sn_tracker.draw_cellid_label()
    sn_tracker.draw_content_label('{}')

    n_events = [0 for i in range(2034)]

    for event in events:
        tracker_events = event[1]
        for i_tr in tracker_events:
            if i_tr.time_bottom_cathode is not None:
                n_events[i_tr.cell_num] += 1
    for i in range(2034):
        if n_events[i] > 0:
            sn_tracker.setcontent(i, n_events[i])

    sn_tracker.draw()
    sn_tracker.save("/Users/williamquinn/Desktop/" + str(run))
示例#5
0
def draw_normalised_anode_events(run: int, events):
    sn_tracker = sndisplay.tracker('tr_anode_normalised_' + str(run))
    sn_tracker.draw_cellid_label()
    sn_tracker.draw_content_label('{:.3f}')

    n_events = [0 for i in range(2034)]

    for event in events:
        tracker_events = event[1]
        for i_tr in tracker_events:
            if i_tr.time_anode is not None:
                n_events[i_tr.cell_num] += 1
    for i in range(2034):
        if n_events[i] > 0:
            sn_tracker.setcontent(i, n_events[i] / np.sum(n_events))

    sn_tracker.setrange(0, 0.01)
    sn_tracker.draw()
    sn_tracker.save("/Users/williamquinn/Desktop/" + str(run))
示例#6
0
def draw_av_propagation(run: int, events):
    lower = -50
    higher = 100

    sn_tracker = sndisplay.tracker('tr_av_propagation_' + str(run))
    sn_tracker.draw_cellid_label()
    sn_tracker.draw_content_label('{:.2f}')

    propagation_times = [[] for i in range(2034)]

    for event in events:
        event_time = []
        for calo_event in event[0]:
            event_time.append(calo_event.time)
        event_time = np.array(event_time)
        if event_time.size == 0:
            continue
        event_time = np.min(event_time)
        tracker_events = event[1]
        for tracker_event in tracker_events:
            if tracker_event.time_bottom_cathode is None or tracker_event.time_top_cathode is None:
                continue
            t5 = (tracker_event.time_bottom_cathode - event_time) * 1e6
            t6 = (tracker_event.time_top_cathode - event_time) * 1e6
            # print(t5 + t6)
            if t5 < 10 and t6 < 10:
                continue
            if lower < t5 < higher and lower < t6 < higher:
                propagation_times[int(tracker_event.cell_num)].append(t5 + t6)

    for i_cell in range(len(propagation_times)):
        average = 0
        if len(propagation_times[i_cell]) == 0:
            continue
        for i_propagation in range(len(propagation_times[i_cell])):
            average += propagation_times[i_cell][i_propagation]
        average = average / len(propagation_times[i_cell])
        sn_tracker.setcontent(i_cell, average)

    sn_tracker.draw()
    sn_tracker.save("/Users/williamquinn/Desktop/" + str(run))
示例#7
0
def draw_std_propagation(run: int, events):
    lower = -50
    higher = 100

    sn_tracker = sndisplay.tracker('tr_std_propagation_' + str(run))
    sn_tracker.draw_cellid_label()
    sn_tracker.draw_content_label('{:.2f}')

    propagation_times = [[] for i in range(2034)]

    for event in events:
        event_time = []
        for calo_event in event[0]:
            event_time.append(calo_event.time)
        event_time = np.array(event_time)
        if event_time.size == 0:
            continue
        event_time = np.min(event_time)
        tracker_events = event[1]
        for tracker_event in tracker_events:
            if tracker_event.time_bottom_cathode is None or tracker_event.time_top_cathode is None:
                continue
            t5 = (tracker_event.time_bottom_cathode - event_time) * 1e6
            t6 = (tracker_event.time_top_cathode - event_time) * 1e6
            if t5 < 10 and t6 < 10:
                continue
            if lower < t5 < higher and lower < t6 < higher:
                propagation_times[tracker_event.cell_num].append(t5 + t6)

    for i_cell in range(2034):
        temp_propagation = np.array(propagation_times[i_cell], dtype='float')
        if temp_propagation.size == 0:
            continue
        std = np.std(temp_propagation)
        sn_tracker.setcontent(i_cell, std)

    sn_tracker.draw()
    sn_tracker.save("/Users/williamquinn/Desktop/" + str(run))
def plot_event_map(data: dict, output_path):
    sntracker = sn.tracker(new_name='tracker_event_map', with_palette=True)
    sntracker.draw_cellid_label()
    sntracker.draw_content_label('{}')

    for event in data:
        cell_info = data[event]["cells"]
        for cell in cell_info:
            sntracker.fill(cell, 1)

    sntracker.draw()
    sntracker.save(output_path)
    del sntracker

    sncalo = sn.calorimeter(new_name='calo_event_map', with_palette=True)
    sncalo.draw_content_label('{}')
    sncalo.draw_omid_label()
    for event in data:
        om_info = data[event]["oms"]
        for om in om_info:
            sncalo.fill(om)
    sncalo.draw()
    sncalo.save(output_path)