def root_event_to_python_event(ev): '''Returns a new chroma.event.Event object created from the contents of the ROOT event `ev`.''' pyev = event.Event(ev.id) # photon begin if ev.photons_beg.size() > 0: photons = make_photon_with_arrays(ev.photons_beg.size()) ROOT.get_photons(ev.photons_beg, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags) pyev.photons_beg = photons # photon end if ev.photons_end.size() > 0: photons = make_photon_with_arrays(ev.photons_end.size()) ROOT.get_photons(ev.photons_end, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags) pyev.photons_end = photons return pyev
def root_event_to_python_event(ev): '''Returns a new chroma.event.Event object created from the contents of the ROOT event `ev`.''' pyev = event.Event(ev.id) pyev.primary_vertex = root_vertex_to_python_vertex(ev.primary_vertex) for vertex in ev.vertices: pyev.vertices.append(root_vertex_to_python_vertex(vertex)) # photon begin if ev.photons_beg.size() > 0: photons = make_photon_with_arrays(ev.photons_beg.size()) ROOT.get_photons(ev.photons_beg, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags) pyev.photons_beg = photons # photon end if ev.photons_end.size() > 0: photons = make_photon_with_arrays(ev.photons_end.size()) ROOT.get_photons(ev.photons_end, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags) pyev.photons_end = photons # channels if ev.nchannels > 0: hit = np.empty(ev.nchannels, dtype=np.int32) t = np.empty(ev.nchannels, dtype=np.float32) q = np.empty(ev.nchannels, dtype=np.float32) flags = np.empty(ev.nchannels, dtype=np.uint32) ROOT.get_channels(ev, hit, t, q, flags) pyev.channels = event.Channels(hit.astype(bool), t, q, flags) else: pyev.channels = None return pyev
def root_event_to_python_event(ev): '''Returns a new chroma.event.Event object created from the contents of the ROOT event `ev`.''' pyev = event.Event(ev.id) for vertex in ev.vertices: pyev.vertices.append(root_vertex_to_python_vertex(vertex)) # photon begin if ev.photons_beg.size() > 0: photons = make_photon_with_arrays(ev.photons_beg.size()) ROOT.get_photons(ev.photons_beg, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags, photons.channel) pyev.photons_beg = photons # photon end if ev.photons_end.size() > 0: photons = make_photon_with_arrays(ev.photons_end.size()) ROOT.get_photons(ev.photons_end, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags, photons.channel) pyev.photons_end = photons # photon tracks if ev.photon_tracks.size() > 0: photon_tracks = [] for i in range(ev.photon_tracks.size()): photons = make_photon_with_arrays(ev.photon_tracks[i].size()) ROOT.get_photons(ev.photon_tracks[i], photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags, photons.channel) photon_tracks.append(photons) pyev.photon_tracks = photon_tracks pyev.photon_parent_trackids = np.asarray(ev.photon_parent_trackids).copy() # hits if ev.hits.size() > 0: pyev.hits = {} for hit in ev.hits: photons = make_photon_with_arrays(hit.second.size()) ROOT.get_photons(hit.second, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags, photons.channel) pyev.hits[hit.first] = photons # flat_hits if ev.flat_hits.size() > 0: photons = make_photon_with_arrays(ev.flat_hits.size()) ROOT.get_photons(ev.flat_hits, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags, photons.channel) pyev.flat_hits = photons # photon end if ev.photons_end.size() > 0: photons = make_photon_with_arrays(ev.photons_end.size()) ROOT.get_photons(ev.photons_end, photons.pos.ravel(), photons.dir.ravel(), photons.pol.ravel(), photons.wavelengths, photons.t, photons.last_hit_triangles, photons.flags, photons.channel) pyev.photons_end = photons # channels if ev.nchannels > 0: hit = np.zeros(ev.nchannels, dtype=np.int32) t = np.zeros(ev.nchannels, dtype=np.float32) q = np.zeros(ev.nchannels, dtype=np.float32) flags = np.zeros(ev.nchannels, dtype=np.uint32) ROOT.get_channels(ev, hit, t, q, flags) pyev.channels = event.Channels(hit.astype(bool), t, q, flags) else: pyev.channels = None return pyev