diff options
author | Anthony LaTorre <devnull@localhost> | 2013-01-01 19:03:08 -0600 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2021-05-09 08:42:39 -0700 |
commit | ac4bdcae5a79a239f5e6086d998ce41ba202457e (patch) | |
tree | 06ad0ebf1c18c8666ad0d71f868dd545fbae17b6 | |
parent | 53d300df2287a43d97420f0f47710f4d5ab2726a (diff) | |
download | chroma-ac4bdcae5a79a239f5e6086d998ce41ba202457e.tar.gz chroma-ac4bdcae5a79a239f5e6086d998ce41ba202457e.tar.bz2 chroma-ac4bdcae5a79a239f5e6086d998ce41ba202457e.zip |
no channels was resulting in a seg fault. for now if there are no channels, just set the python event channels to None.
-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() |