Skip to content

Commit be64336

Browse files
committed
Simplify i3truthextractor set_gcd
1 parent 6777498 commit be64336

1 file changed

Lines changed: 4 additions & 36 deletions

File tree

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

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -101,44 +101,12 @@ def set_gcd(self, i3_file: str, gcd_file: Optional[str] = None) -> None:
101101
the i3 file instead. If either one of those are not
102102
present, `RuntimeErrors` will be raised.
103103
"""
104-
if gcd_file is None:
105-
# If no GCD file is provided, search the I3 file for frames
106-
# containing geometry (GFrame) and calibration (CFrame)
107-
gcd = dataio.I3File(i3_file)
108-
else:
109-
# Ideally ends here
110-
gcd = dataio.I3File(gcd_file)
111-
112-
# Get GFrame
113-
try:
114-
g_frame = gcd.pop_frame(icetray.I3Frame.Geometry)
115-
# If the line above fails, it means that no gcd file was given
116-
# and that the i3 file does not have a G-Frame in it.
117-
except RuntimeError as e:
118-
self.error(
119-
"No GCD file was provided "
120-
f"and no G-frame was found in {i3_file.split('/')[-1]}."
121-
)
122-
raise e
123-
124-
# Get CFrame
125-
try:
126-
c_frame = gcd.pop_frame(icetray.I3Frame.Calibration)
127-
# If the line above fails, it means that no gcd file was given
128-
# and that the i3 file does not have a C-Frame in it.
129-
except RuntimeError as e:
130-
self.warning(
131-
"No GCD file was provided and no C-frame "
132-
f"was found in {i3_file.split('/')[-1]}."
133-
)
134-
raise e
135-
136-
# Save information as member variables of I3Extractor
137-
self._gcd_dict = g_frame["I3Geometry"].omgeo
138-
self._calibration = c_frame["I3Calibration"]
104+
super().set_gcd(i3_file=i3_file, gcd_file=gcd_file)
139105

106+
# Modifications specific to I3TruthExtractor
107+
# These modifications are needed to identify starting events
140108
coordinates = []
141-
for omkey, g in self._gcd_dict.items():
109+
for _, g in self._gcd_dict.items():
142110
if g.position.z > 1200:
143111
continue # We want to exclude icetop
144112
coordinates.append([g.position.x, g.position.y, g.position.z])

0 commit comments

Comments
 (0)