コード例 #1
0
def load_hits_skipping_NN(DST_file_name, evt_number):
    """Return the Hits as PD DataFrames."""

    dst = load_dst(DST_file_name,'RECO','Events')
    dst_size = len(dst)
    all_events = {}

    event = dst.event.values
    time  = dst.time .values
    npeak = dst.npeak.values
    X     = dst.X    .values
    Y     = dst.Y    .values
    Z     = dst.Z    .values
    Q     = dst.Q    .values
    E     = dst.E    .values

    for i in range(dst_size):
        if event[i] == evt_number:
            current_event = all_events.setdefault(event[i],
                                                  HitCollection(event[i], time[i] * 1e-3))
            hit = Hit(npeak[i],
                      Cluster(Q[i], xy(X[i], Y[i]), xy(0, 0),
                              0, Z[i], E[i]), Z[i], E[i], xy(0, 0))
            if(hit.Q != NN):
                current_event.hits.append(hit)

    good_events = {}
    for event, hitc in all_events.items():
        if len(hitc.hits) > 0:
            good_events[event] = hitc

    return good_events
コード例 #2
0
base_vsize = float(sys.argv[3])
kind = str(sys.argv[4])

with tb.open_file(the_file) as h5in:
    table = getattr(getattr(h5in.root, 'CHITS'), 'highTh').read()
    hits_df = pd.DataFrame.from_records(table)
    this_evt_df = hits_df[hits_df.event == evt_number]
    the_hits = []

    xs = this_evt_df.X
    ys = this_evt_df.Y
    zs = this_evt_df.Z
    es = this_evt_df.Ec

    for x, y, z, e in zip(xs, ys, zs, es):
        h = Hit(0, Cluster(0, xy(x, y), xy(0, 0), 0), z, e * 1000, xy(0, 0))
        the_hits.append(h)

voxels = voxelize_hits(the_hits, np.array([base_vsize, base_vsize,
                                           base_vsize]), False)

vsizex = voxels[0].size[0]
vsizey = voxels[0].size[1]
vsizez = voxels[0].size[2]

min_corner_x = min(v.X for v in voxels) - vsizex / 2.
min_corner_y = min(v.Y for v in voxels) - vsizey / 2.
min_corner_z = min(v.Z for v in voxels) - vsizez / 2.

x = [np.round(v.X / vsizex) for v in voxels]
y = [np.round(v.Y / vsizey) for v in voxels]
コード例 #3
0
if mc:
    drift_velocity = 1

with tb.open_file(the_file) as h5in:
    table = getattr(getattr(h5in.root, 'RECO'), 'Events').read()
    hits_df = pd.DataFrame.from_records(table)
    this_evt_df = hits_df[hits_df.event == evt_number]
    the_hits = []
    ## exclude NN hits from plot
    xs = this_evt_df[this_evt_df.Q >= 0].X
    ys = this_evt_df[this_evt_df.Q >= 0].Y
    zs = this_evt_df[this_evt_df.Q >= 0].Z
    es = this_evt_df[this_evt_df.Q >= 0].E

    for x, y, z, e in zip(xs, ys, zs, es):
        h = Hit(0, Cluster(0, xy(x, y), xy(0, 0), 0), z * drift_velocity, e,
                xy(0, 0))
        the_hits.append(h)

voxels = voxelize_hits(the_hits, np.array([10., 10., 10]), False)

fig = plt.figure()  #figsize=(20, 10))
ax = fig.add_subplot(111, projection='3d')
#ax = fig.gca(projection='3d')
#ax.set_aspect("equal")

energies = [v.E for v in voxels]
energies = np.array(energies)
min_energy = energies.min()
max_energy = energies.max()
print('Minimum energy = {}, maximum energy = {}'.format(
コード例 #4
0
def convert_df_to_hits(df):
    return [
        Hit(0, Cluster(0, xy(h.X, h.Y), xy(0, 0), 0), h.Z, h.E, xy(0, 0))
        for h in df.itertuples(index=False)
    ]
コード例 #5
0
ファイル: pc_hits_voxels.py プロジェクト: jerenner/dnntoy
#
#            # Only correct if we have nonzero Q'.
#            if(Qptot > 0):
#                for hh in hqcoll:
#                    hh.energy = hh.E*(Qtot/Qptot)*XYQcorr(hh.X,hh.Y).value*LTQcorr(hh.Z,hh.X,hh.Y).value
#        #else:
#        #    print("Not correcting for {} hits".format(len(hqcoll)))

    for hh in hc.hits:

        hecorr  = hh.E*XYcorr(hh.X,hh.Y).value*LTcorr(hh.Z,hh.X,hh.Y).value**(ftlife) #/np.exp(-hh.Z/tlife)
        hegcorr = hh.E*XYcorr(hh.X,hh.Y).value
        hetcorr = hh.E*LTcorr(hh.Z,hh.X,hh.Y).value**(ftlife) #/np.exp(-hh.Z/tlife)
        hegtglobalcorr = hh.E*XYcorr(hh.X,hh.Y).value/np.exp(-hh.Z/tlife)
            
        hucorr = Hit(0,Cluster(0, xy(hh.X,hh.Y), xy(0,0), 0),hh.Z,hh.E)
        hcorr  = Hit(0,Cluster(0, xy(hh.X,hh.Y), xy(0,0), 0),hh.Z,hecorr)
        hgcorr = Hit(0,Cluster(0, xy(hh.X,hh.Y), xy(0,0), 0),hh.Z,hegcorr)
        htcorr = Hit(0,Cluster(0, xy(hh.X,hh.Y), xy(0,0), 0),hh.Z,hetcorr)
        hgtglobalcorr = Hit(0,Cluster(0, xy(hh.X,hh.Y), xy(0,0), 0),hh.Z,hegtglobalcorr)
            
        hc_ucorr.append(hucorr); hc_corr.append(hcorr); hc_gcorr.append(hgcorr); hc_tcorr.append(htcorr); hc_gtglobalcorr.append(hgtglobalcorr)

    # Only save events with >= 2 hits.
    if(len(hc_corr) >= 2):
        hitc_uevt.append(hc_ucorr)
        hitc_cevt.append(hc_corr)
        hitc_gevt.append(hc_gcorr)
        hitc_tevt.append(hc_tcorr)
        hitc_gtglobalevt.append(hc_gtglobalcorr)
コード例 #6
0
    for ee, hc in good_hits.items():
        bad_evt = False
        hc_corr = []

        hX = [hh.X for hh in hc.hits]
        hY = [hh.Y for hh in hc.hits]
        hZ = [hh.Z for hh in hc.hits]
        hE = [hh.E for hh in hc.hits]

        hEcorr = hE * LTcorrection(hZ, hX, hY).value * XYcorrection(hX, hY).value

        for h, ec in zip(hc.hits, hEcorr):
            if ec == 0:
                bad_evt = True
                break
            hcorr = Hit(0, Cluster(0, xy(h.X,h.Y), xy(0,0), 0), h.Z*drift_velocity, ec, xy(h.Xpeak,h.Ypeak))
            hc_corr.append(hcorr)


        hits_evt[ee] = hc_corr
        bad_event[ee] = bad_evt
        times[ee] = hc.time
        raw_energy[ee] = sum(hE)

    events_in += len(hits_evt)
    for nevt, hitc in hits_evt.items():

        if bad_event[nevt]:
            not_fid += 1
            continue
コード例 #7
0
def convert_df_to_hits(df):
    return [
        Hit(0, Cluster(0, xy(h.x, h.y), xy(0, 0), 0), h.z, h.energy, xy(0, 0))
        for h in df.itertuples(index=False)
    ]
コード例 #8
0
    bad_event = {}
    for ee, hc in good_hits.items():
        bad_evt = False
        hc_corr = []
        raw_e = 0.
        for hh in hc.hits:
            raw_e += hh.E
            # temporary - in the future no zeros in maps.
            if XYcorrection(hh.X, hh.Y).value == 0:
                bad_evt = True
                break
            hecorr = hh.E * LTcorrection(
                hh.Z, hh.X, hh.Y).value * XYcorrection(hh.X, hh.Y).value
            # here we convert time to space for z.
            z = hh.Z * drift_velocity
            hcorr = Hit(0, Cluster(0, xy(hh.X, hh.Y), xy(0, 0), 0), z, hecorr,
                        xy(0, 0))
            hc_corr.append(hcorr)
        hits_evt[ee] = hc_corr
        raw_energy[ee] = raw_e
        bad_event[ee] = bad_evt

    events_in += len(hits_evt)
    for nevt, hitc in hits_evt.items():

        if bad_event[nevt]:
            not_fid += 1
            continue

        vmaxX = -1e+06
        vminX = 1e+06