diff options
Diffstat (limited to 'threadtest.py')
-rw-r--r-- | threadtest.py | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/threadtest.py b/threadtest.py index d7b9d7c..681b019 100644 --- a/threadtest.py +++ b/threadtest.py @@ -28,25 +28,9 @@ def generate_event(detector, position=(0,0,0), nphotons=5000): job = output.get() - last_hit_triangles = job.last_hit_triangles - solids = detector.solid_id[last_hit_triangles] - solids[last_hit_triangles == -1] = -1 - surface_absorbed = job.states == 2 - - for i in np.unique(job.states): - print 'state %2i %i' % (i, len(job.states[job.states == i])) - - event_times = [] - for i in detector.pmtids: - photons = np.logical_and(solids == i, surface_absorbed) - - hit_times = job.times[photons] - - if len(hit_times) > 0: - event_times.append((i, np.min(hit_times))) - + pmt_times = job.earliest_times[detector.pmtids] + event_times = [ (i, t) for i, t in zip(detector.pmtids, pmt_times) if t < 1e8 ] print '%i hit pmts' % len(event_times) - return event_times def likelihood(detector, event_times, position=(0,0,0), nphotons=5000, neval=100): @@ -54,31 +38,15 @@ def likelihood(detector, event_times, position=(0,0,0), nphotons=5000, neval=100 jobs.put(create_job(position, nphotons)) jobs.join() - t = {} + t = np.zeros(shape=(neval, max(detector.pmtids)+1), dtype=np.float32) for i in range(neval): job = output.get() - - last_hit_triangles = job.last_hit_triangles - solids = detector.solid_id[job.last_hit_triangles] - solids[last_hit_triangles == -1] = -1 - surface_absorbed = job.states == 2 - - for j in detector.pmtids: - pmt_photons = solids == j - photons = np.logical_and(pmt_photons, surface_absorbed) - - if j not in t: - t[j] = [] - - hit_times = job.times[photons] - - if len(hit_times) > 0: - t[j].append(np.min(hit_times)) + t[i] = job.earliest_times log_likelihood = ufloat((0,0)) for i, time in event_times: h = Histogram(100, (-0.5e-9, 99.5e-9)) - h.fill(t[i]) + h.fill(t[:,i]) if h.nentries > 0: h.normalize() |