Skip to content

Commit 8b70030

Browse files
Merge pull request #104 from francois-drielsma/develop
Cathode crosser fixes
2 parents 6380ab0 + c73ec0f commit 8b70030

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

spine/data/out/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ class OutBase(PosDataBase):
8989
# Attributes that must not be stored to file when storing lite files
9090
_lite_skip_attrs = ('index',)
9191

92+
def reset_match(self):
93+
"""Resets the reco/truth matching information for the object."""
94+
self.is_matched = False
95+
self.match_ids = np.empty(0, dtype=np.int64)
96+
9297
@property
9398
def size(self):
9499
"""Total number of voxels that make up the object.

spine/post/reco/cathode_cross.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""Cathode crossing identification + merging module."""
22

33
import numpy as np
4+
from scipy.spatial.distance import cdist
45

56
from spine.data import RecoInteraction, TruthInteraction
67

7-
from spine.math.distance import cdist, farthest_pair
8+
from spine.math.distance import farthest_pair
89

910
from spine.utils.globals import TRACK_SHP
1011
from spine.utils.geo import Geometry
@@ -81,7 +82,6 @@ def __init__(self, crossing_point_tolerance, offset_tolerance,
8182
keys['points'] = True
8283
if run_mode != 'reco':
8384
keys[truth_point_mode] = True
84-
8585
self.update_keys(keys)
8686

8787
def process(self, data):
@@ -92,6 +92,11 @@ def process(self, data):
9292
data : dict
9393
Dictionary of data products
9494
"""
95+
# Reset all particle/interaction matches, they are broken by merging
96+
for obj_key in self.obj_keys:
97+
for obj in data[obj_key]:
98+
obj.reset_match()
99+
95100
# Loop over particle types
96101
update_dict = {}
97102
for part_key in self.particle_keys:
@@ -188,8 +193,7 @@ def process(self, data):
188193
# Check if the two particles stop at roughly the same
189194
# position in the plane of the cathode
190195
compat = True
191-
dist_mat = cdist(
192-
end_points_i[:, caxes], end_points_j[:, caxes])
196+
dist_mat = cdist(end_points_i[:, caxes], end_points_j[:, caxes])
193197
argmin = np.argmin(dist_mat)
194198
pair_i, pair_j = np.unravel_index(argmin, (2, 2))
195199
compat &= (
@@ -257,7 +261,6 @@ def adjust_positions(self, data, idx_i, idx_j=None, truth=False):
257261
Index of a matched cathode crosser fragment
258262
truth : bool, default False
259263
If True, adjust truth object positions
260-
261264
Results
262265
-------
263266
np.ndarray

spine/utils/geo/detector/tpc.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ def cathode_pos(self):
195195
"""
196196
return np.mean([c.cathode_pos for c in self.chambers])
197197

198+
@property
199+
def cathode_thickness(self):
200+
"""Thickness of the cathode.
201+
202+
Returns
203+
-------
204+
float
205+
Thickness of the cathode
206+
"""
207+
return abs(self.chambers[1].cathode_pos - self.chambers[0].cathode_pos)
208+
198209
def __len__(self):
199210
"""Returns the number of TPCs in the module.
200211

spine/utils/geo/source/icarus_geometry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tpc:
2-
dimensions: [148.2, 316.82, 1789.901]
2+
dimensions: [148.2, 316.82, 1789.902]
33
module_ids: [0, 0, 1, 1]
44
det_ids: [0, 0, 1, 1]
55
positions:

spine/utils/geo/source/sbnd_geometry.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
tpc:
2-
dimensions: [201.3, 400.016, 499.51562]
2+
dimensions: [201.1, 400.016, 499.51562]
33
module_ids: [0, 0]
44
positions:
5-
- [-100.65, 0.0, 254.70019]
6-
- [100.65, 0.0, 254.70019]
5+
- [-100.75, 0.0, 254.70019]
6+
- [100.75, 0.0, 254.70019]
77
optical:
88
volume: module
99
shape: [box, ellipsoid]

0 commit comments

Comments
 (0)