Example #1
0
 def write(self, data: vectors.ParticlePool):
     # I like f-strings, but this is the fastest way to make a string
     self.__file_handle.write("%i\n" % data.particle_count)
     for p in data.iter_particles():
         self.__file_handle.write(
             "%d %d %.20f %.20f %.20f %.20f\n" %
             (p.id, p.charge, p.x[0], p.y[0], p.z[0], p.e[0]))
Example #2
0
 def __append_particle_data(self, data: vectors.ParticlePool):
     for event in data.iter_events():
         for p, leaf in zip(event.iter_particles(), self.__root.leaves):
             row = leaf.row
             row["x"] = p.x
             row["y"] = p.y
             row["z"] = p.z
             row["e"] = p.e
             row.append()
Example #3
0
def get_event_mass(collection: vectors.ParticlePool) -> npy.ndarray:
    found_photon, found_proton = 0, 0
    vector_sum = vectors.FourVector(collection.event_count)
    for event_particle in collection.iter_particles():
        if not found_photon and event_particle.id == 1:
            found_photon = True
        elif not found_proton and event_particle.id == 14:
            found_proton = True
        else:
            vector_sum += event_particle
    return vector_sum.get_mass()
Example #4
0
def get_t_prime(collection: vectors.ParticlePool) -> npy.ndarray:
    # Get initial values
    proton = collection.get_particles_by_name("Proton")[0]
    s_value = get_s(collection)
    sqrt_s = npy.sqrt(s_value)
    mx2 = get_event_mass(collection)**2

    # Calculate for Px and Ex
    ex = (s_value * mx2 * _PROTON_GEV**2) / 2 * sqrt_s
    px = npy.sqrt((ex**2) - mx2)

    # Calculate t0
    t0_left = (mx2 / (2 * sqrt_s))**2
    t0_right = (((proton.e * _PROTON_GEV) / sqrt_s) - px)**2
    t0 = t0_left - t0_right

    return get_t(collection) - t0
Example #5
0
def get_s(collection: vectors.ParticlePool) -> npy.ndarray:
    proton = collection.get_particles_by_name("Proton")[0]
    momenta = proton.x**2 + proton.y**2 + proton.z**2
    energy = (proton.e + _PROTON_GEV)**2
    return energy - momenta
Example #6
0
 def write(self, filename: Path, data: vectors.ParticlePool):
     with _GampWriter(filename) as stream:
         for event in data.iter_events():
             stream.write(event)