Skip to content

Commit c488fbb

Browse files
committed
changes to bundle pos/timing determination
1 parent e3a65bf commit c488fbb

1 file changed

Lines changed: 18 additions & 27 deletions

File tree

src/graphnet/data/extractors/icecube/i3highesteparticleextractor.py

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,6 @@ def highest_energy_track(
377377
if tmp_EonEntrance > EonEntrance:
378378
particle = track_particle
379379

380-
closest_pos = np.array(
381-
[
382-
track.GetXc(),
383-
track.GetYc(),
384-
track.GetZc(),
385-
]
386-
)
387-
388380
EonEntrance = tmp_EonEntrance
389381

390382
visible_length = intersections.second - max(
@@ -421,6 +413,13 @@ def highest_energy_track(
421413
)
422414
particle.time = track.GetTi()
423415
else:
416+
closest_pos = np.array(
417+
[
418+
track.GetXc(),
419+
track.GetYc(),
420+
track.GetZc(),
421+
]
422+
)
424423
# If the track is stopping or throughgoing,
425424
# pos is point closest to detector center.
426425
distance = np.sqrt((closest_pos**2).sum())
@@ -748,7 +747,7 @@ def highest_energy_bundle(
748747
lengths = lengths[length_mask]
749748

750749
containment = GN_containment_types.stopping_bundle.value
751-
closest_pos = []
750+
highest_e = 0
752751
for track, MGtrack in zip(MMCTrackList, MuonGun_tracks):
753752
intersections = self.hull.surface.intersection(
754753
MGtrack.pos, MGtrack.dir
@@ -781,30 +780,24 @@ def highest_energy_bundle(
781780
raise # re-raise unexpected errors
782781

783782
EonEntrance += track_energy
784-
785-
closest_pos.append(
786-
np.array(
783+
if track_energy > highest_e:
784+
highest_e = track_energy
785+
closest_pos = np.array(
787786
[
788787
track.GetXc(),
789788
track.GetYc(),
790789
track.GetZc(),
791790
]
792791
)
793-
* track_energy
794-
)
795-
if closest_time is None:
796-
closest_time = track.GetTc()
797-
elif closest_time < track.GetTc():
792+
798793
closest_time = track.GetTc()
799794

800-
if intersections.second > 0:
801-
visible_length = max(
802-
visible_length, intersections.second - intersections.first
803-
)
804-
if MGtrack.length > intersections.second:
805-
containment = (
806-
GN_containment_types.throughgoing_bundle.value
807-
)
795+
if intersections.second > 0:
796+
visible_length = intersections.second - intersections.first
797+
if MGtrack.length > intersections.second:
798+
containment = (
799+
GN_containment_types.throughgoing_bundle.value
800+
)
808801

809802
# If no intersection.second is every positive
810803
# the visible_length can still be negative here
@@ -823,8 +816,6 @@ def highest_energy_bundle(
823816
visible_length >= 0
824817
), f"Visible length is negative for particle {frame['I3EventHeader']}"
825818

826-
closest_pos = np.sum(closest_pos, axis=0) / EonEntrance
827-
828819
bundle.pos = dataclasses.I3Position(
829820
closest_pos[0], closest_pos[1], closest_pos[2]
830821
)

0 commit comments

Comments
 (0)