Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add F2, change chi's name #11

Merged
merged 2 commits into from
Dec 17, 2024
Merged
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
58 changes: 53 additions & 5 deletions src/cr39py/scan/base_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def from_tracks(cls, tracks: TrackData, etch_time: float):

# Attach the selected tracks object to the axes objects
for ax in obj._axes.values():
ax.tracks = obj._selected_tracks
ax.tracks = obj.selected_tracks

return obj

Expand Down Expand Up @@ -771,8 +771,8 @@ def histogram(

return ax0.axis, ax1.axis, arr

def overlap_parameter_histogram(self) -> tuple[np.ndarray]:
"""The Zylstra overlap parameter for each cell.
def chi(self) -> tuple[np.ndarray]:
"""The Zylstra overlap parameter ``chi`` for each cell.

Only includes currently selected tracks.

Expand All @@ -788,6 +788,10 @@ def overlap_parameter_histogram(self) -> tuple[np.ndarray]:
chi : `~np.ndarray`
Histogram of chi for each cell

Notes
-----
See A. B. Zylstra et al. Nucl. Instrum. Methods Phys. Res. A 2012

"""
x, y, ntracks = self.histogram(axes=("X", "Y"))
x, y, D = self.histogram(axes=("X", "Y"), quantity="D")
Expand All @@ -802,6 +806,47 @@ def overlap_parameter_histogram(self) -> tuple[np.ndarray]:

return x, y, chi

def F2(self) -> tuple[np.ndarray]:
"""The Zylstra overlap parameter ``F2`` for each cell.

F2 is the fraction of tracks that overlap one other track, and
is a reasonable approximation of the number of tracks that will
be lost due to track overlap.

.. math::
F_2 = \chi (1 - 2\chi/3)

As shown in the paper, this analytical model starts to fail
when the ``chi`` parameter excceeds about 25%. Above this
threshold, the analytical model over-estimtates the true
number of track overlaps (according to Monte-Carlo simulations).

Only includes currently selected tracks.

Returns
-------

hax : `~np.ndarray`
Horizontal axis

vax : `~np.ndarray`
Vertical axis

F2 : `~np.ndarray`
Histogram of F2 for each cell

Notes
-----
See A. B. Zylstra et al. Nucl. Instrum. Methods Phys. Res. A 2012

"""

x, y, chi = self.chi()

F2 = chi * (1 - 2 * chi / 3)

return x, y, F2

# *************************************************************************
# Track Manipulation
# *************************************************************************
Expand All @@ -824,7 +869,8 @@ def plot(
In addition to the track quantities [X,Y,D,C,E,Z], the following
custom quantities can also be plotted:

- CHI : The track overlap parameter from Zylstra et al. 2012
- CHI : The ``chi`` track overlap parameter from Zylstra et al. 2012
- F2 : The ``F2`` track overlap parameter from Zylstra et al. 2012

Parameters
----------
Expand Down Expand Up @@ -902,7 +948,9 @@ def plot(

# Get the requested histogram
if quantity == "CHI":
xax, yax, arr = self.overlap_parameter_histogram()
xax, yax, arr = self.chi()
elif quantity == "F2":
xax, yax, arr = self.F2()
else:
xax, yax, arr = self.histogram(axes=axes, tracks=tracks)

Expand Down
Loading