From ac4bdcae5a79a239f5e6086d998ce41ba202457e Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Tue, 1 Jan 2013 19:03:08 -0600 Subject: no channels was resulting in a seg fault. for now if there are no channels, just set the python event channels to None. --- chroma/io/root.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/chroma/io/root.py b/chroma/io/root.py index ebae9d6..438da01 100644 --- a/chroma/io/root.py +++ b/chroma/io/root.py @@ -85,13 +85,17 @@ def root_event_to_python_event(ev): pyev.photons_end = photons # channels - 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) + 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 - ROOT.get_channels(ev, hit, t, q, flags) - pyev.channels = event.Channels(hit.astype(bool), t, q, flags) return pyev class RootReader(object): @@ -223,6 +227,10 @@ class RootWriter(object): self.ev.nhit = 0 self.ev.channels.resize(0) self.ev.nchannels = len(pyev.channels.hit) + else: + self.ev.nhit = 0 + self.ev.channels.resize(0) + self.ev.nchannels = 0 self.T.Fill() -- cgit