-
Notifications
You must be signed in to change notification settings - Fork 1
/
FirstHLC.py
69 lines (51 loc) · 2.41 KB
/
FirstHLC.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from icecube import icetray, dataclasses
from numpy import array, sum
import os
class FirstHLC(icetray.I3ConditionalModule):
def __init__(self, context):
icetray.I3ConditionalModule.__init__(self, context)
self.AddParameter('InputPulseSeries',
'Pulse series that will be used for hit search',
'OfflinePulses')
self.AddParameter('Vertex',
'Vertex in I3Particle container',
'FirstHLCvertex')
self.AddParameter('EarlySLC',
'Name for count of early SLC hits',
'EarlySLC_')
self.AddOutBox('OutBox')
def Configure(self):
self.input_pulses = self.GetParameter('InputPulseSeries')
self.vertex = self.GetParameter('Vertex')
self.earlyslc = self.GetParameter('EarlySLC') + self.input_pulses
def Physics(self, frame):
geometry = frame['I3Geometry']
if not frame.Has(self.input_pulses):
print 'No pulse series with name: ' + self.input_pulses
self.PushFrame(frame)
return True
if type(frame[self.input_pulses]) == dataclasses.I3RecoPulseSeriesMap:
hit_map = frame.Get(self.input_pulses)
elif type(frame[self.input_pulses]) == dataclasses.I3RecoPulseSeriesMapMask:
hit_map = frame[self.input_pulses].apply(frame)
all_times = array([10.E5]*len(hit_map))
# Find the earliest HLC!
earliest_om = None
earliest_time = 10.E9
for index, one_dom in enumerate(hit_map):
all_times[index] = one_dom[1][0].time
for one_hit in one_dom[1]:
if one_hit.flags & dataclasses.I3RecoPulse.PulseFlags.LC:
if one_hit.time < earliest_time:
earliest_om = one_dom[0]
earliest_time = one_hit.time
early_hits = dataclasses.I3Double(1.*sum(all_times < earliest_time))
frame[self.earlyslc] = early_hits
myvertex = dataclasses.I3Particle()
myvertex.pos.x = geometry.omgeo[earliest_om].position.x
myvertex.pos.y = geometry.omgeo[earliest_om].position.y
myvertex.pos.z = geometry.omgeo[earliest_om].position.z
myvertex.time = earliest_time
frame[self.vertex] = myvertex
self.PushFrame(frame)
return True