Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions spine/data/out/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ class RecoParticle(ParticleBase, RecoBase):
interaction vertex position in cm
start_dedx : float
dE/dx around a user-defined neighborhood of the start point in MeV/cm
end_dedx : float
dE/dx around a user-defined neighborhood of the end point in MeV/cm
start_straightness : float
Explained variance ratio of the beginning of the particle
directional_spread : float
Expand All @@ -231,6 +233,7 @@ class RecoParticle(ParticleBase, RecoBase):
ppn_points: np.ndarray = None
vertex_distance: float = -1.
start_dedx: float = -1.
end_dedx: float = -1.
start_straightness: float = -1.
directional_spread: float = -1.
axial_spread: float = -np.inf
Expand Down
2 changes: 1 addition & 1 deletion spine/io/parse/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .base import ParserBase
from .data import ParserObjectList

__all__ = ['MetaParser', 'RunInfoParser',
__all__ = ['MetaParser', 'RunInfoParser', 'FlashParser',
'CRTHitParser', 'TriggerParser']


Expand Down
49 changes: 32 additions & 17 deletions spine/post/reco/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@
from scipy.stats import pearsonr
from sklearn.decomposition import PCA

from spine.utils.globals import PHOT_PID, ELEC_PID
from spine.utils.globals import SHOWR_SHP, PHOT_PID, ELEC_PID
from spine.utils.gnn.cluster import cluster_dedx, cluster_dedx_dir

from spine.post.base import PostBase

__all__ = ['ParticleStartDEDXProcessor', 'ParticleStartStraightnessProcessor',
__all__ = ['ParticleDEDXProcessor', 'ParticleStartStraightnessProcessor',
'ParticleSpreadProcessor']


class ParticleStartDEDXProcessor(PostBase):
class ParticleDEDXProcessor(PostBase):
"""Compute the dE/dx of the particle start by summing the energy depositions
along the particle start and dividing by the total length of the start.
"""

# Name of the post-processor (as specified in the configuration)
name = 'start_dedx'
name = 'local_dedx'

# Aliases for the post-processor
aliases = ('start_dedx', 'end_dedx')

# List of recognized dE/dx computation modes
_modes = ('default', 'direction')
Expand Down Expand Up @@ -79,19 +82,31 @@ def process(self, data):
if part.pid not in self.include_pids:
continue

# Compute the particle start dE/dx
if self.mode == 'default':
# Use all depositions within a radius of the particle start
part.start_dedx = cluster_dedx(
part.points, part.depositions, part.start_point,
max_dist=self.radius, anchor=self.anchor)

else:
# Use the particle direction estimate as a guide
part.start_dedx = cluster_dedx_dir(
part.points, part.depositions, part.start_point,
part.start_dir, max_dist=self.radius,
anchor=self.anchor)[0]
# Loop over the two sides of the particle
for side in ('start', 'end'):
# Showers have no end points, skip
if side == 'end' and part.shape == SHOWR_SHP:
continue

# Fetch the point
ref_point = getattr(part, f'{side}_point')

# Compute the particle end dE/dx
if self.mode == 'default':
# Use all depositions within a radius of the particle point
dedx = cluster_dedx(
part.points, part.depositions, ref_point,
max_dist=self.radius, anchor=self.anchor)

else:
# Use the particle direction estimate as a guide
ref_dir = getattr(part, f'{side}_dir')*(-1)**(end == 'end')
dedx = cluster_dedx_dir(
part.points, part.depositions, ref_point, ref_dir,
max_dist=self.radius, anchor=self.anchor)[0]

# Store the dE/dx
setattr(part, f'{side}_dedx', dedx)


class ParticleStartStraightnessProcessor(PostBase):
Expand Down
Loading