diff options
-rw-r--r-- | chroma/io/root.py | 20 |
1 files 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() |