summaryrefslogtreecommitdiff
path: root/camera.py
diff options
context:
space:
mode:
Diffstat (limited to 'camera.py')
-rwxr-xr-xcamera.py42
1 files changed, 17 insertions, 25 deletions
diff --git a/camera.py b/camera.py
index e54c3b8..53c028e 100755
--- a/camera.py
+++ b/camera.py
@@ -14,6 +14,7 @@ from chroma.tools import timeit
from chroma.transform import rotate
from chroma.optics import vacuum, lambertian_surface
import chroma.project as project
+from chroma.fileio.root import RootReader
import pygame
from pygame.locals import *
@@ -620,27 +621,14 @@ class Camera(Thread):
class EventViewer(Camera):
def __init__(self, geometry, filename, **kwargs):
Camera.__init__(self, geometry, **kwargs)
-
- import ROOT
-
- self.f = ROOT.TFile(filename)
- self.T = self.f.Get('T')
- self.T.GetEntry(0)
- self.nsolids = geometry.solid_id.max() + 1
+ self.rr = RootReader(filename)
def color_hit_pmts(self):
self.gpu.reset_colors()
- hit = np.empty(self.nsolids, np.int32)
- t = np.empty(self.nsolids, np.float32)
- q = np.empty(self.nsolids, np.float32)
-
- # self.nsolids has a weird data type that PyROOT doesn't understand
- self.T.ev.get_channels(int(self.nsolids), hit, t, q)
-
- # PyROOT prints warnings when we try to pass a bool array directly
- # so we convert afterward
- hit = hit.astype(np.bool)
+ hit = self.ev.channels.hit
+ t = self.ev.channels.t
+ q = self.ev.channels.q
# Important: Compute range only with HIT channels
solid_colors = map_to_color(q, range=(q[hit].min(),q[hit].max()))
@@ -650,18 +638,22 @@ class EventViewer(Camera):
def process_event(self, event):
if event.type == KEYDOWN:
if event.key == K_PAGEUP:
- entry = self.T.GetReadEntry()
- if entry < self.T.GetEntries() - 1:
- self.T.GetEntry(entry+1)
+ try:
+ self.ev = self.rr.next()
+ except StopIteration:
+ pass
+ else:
self.color_hit_pmts()
- return
+ return
elif event.key == K_PAGEDOWN:
- entry = self.T.GetReadEntry()
- if entry > 0:
- self.T.GetEntry(entry-1)
+ try:
+ self.ev = self.rr.prev()
+ except StopIteration:
+ pass
+ else:
self.color_hit_pmts()
- return
+ return
Camera.process_event(self, event)