combined (charge+light) reconstruction

T0 reconstruction

class module0_flow.reco.combined.t0_reco.T0Reconstruction(**params)

Bases: h5flow.core.H5FlowStage

Reconstructs an event T0 using light signals or embedded timestamps. Depending on the available data for each event, one of the following algorithms is used:

  • EXT_TRIG: only embedded timestamp is available, so use earliest embedded timestamp

  • LIGHT_MATCHED: light trigger data is available, so uses the rising edge of the largest light signal

  • NONE: no timing data is available, so just uses earliest hit timestamp

Parameters:
  • t0_dset_name: str, path to output dataset

  • light_hits_dset_name: str, path to input light hits dataset, None to disable light hit lookup

  • ext_trigs_dset_name: str, path to input external trigger dataset, None to disable ext trig lookup

Both light_hits_dset_name and ext_trigs_dset_name are required in the cache, if enabled.

Requires RunData resource in workflow.

t0 datatype:

id          u4,     unique identifier
ts          f8,     PPS timestamp to be used for T0 [crs ticks]
ts_err      f8,     estimated error on T0 [crs ticks]
type        u1,     type indicator for T0 algorithm used, see attr. ``type_lookup`` for value definitions
class_version = 0.0.1
default_ext_trigs_dset_name
default_light_hits_dset_name
default_t0_dset_name = combined/t0
init(source_name)
run(source_name, source_slice, cache)
t0_dtype
t0_type

drift reconstruction

class module0_flow.reco.combined.drift_reco.DriftReconstruction(**params)

Bases: h5flow.core.H5FlowStage

Reconstructs hit positions based on drift time and T0

Parameters:
  • t0_dset_name: str, path to input T0 dataset

  • hits_dset_name: str, path to input hits dataset

  • drift_dset_name: str, path to output dataset

Both hits_dset_name and t0_dset_name are required in the cache, if enabled.

Requires RunData, LArData, and Geometry resource in workflow.

drift datatype:

id          u4,     unique identifier
t_drift     f8,     relative PPS timestamp to be used for T0 [crs ticks]
d_drift     f8,     drift distance [mm]
z           f8,     z (drift) coordinate of hit [mm]
class_version = 0.0.0
default_drift_dset_name = combined/hits_drift
default_hits_dset_name = charge/hits
default_t0_dset_name = combined/t0
drift_dtype
init(source_name)
run(source_name, source_slice, cache)

electron lifetime calibration

class module0_flow.reco.combined.electron_lifetime.ElectronLifetimeCalib(**params)

Bases: h5flow.core.H5FlowStage

Reconstructs hit positions based on drift time and T0

If run in “generate” mode, this module will generate an electron lifetime value for the given run and insert into the specified .npz file

If run in “calibration” mode, this module will apply the electron lifetime calibration to each hit charge and save it to a new dataset

Parameters:
  • hits_dset_name: str, path to input hits dataset

  • charge_dset_name: str, path to input charge dataset (must have "q" field and be 1:1 with hits dataset)

  • drift_dset_name: str, path to input drift dataset

  • mode: str, one of “generate” or “calibration”

  • electron_lifetime_file: str, path to .npz file to update with new electron lifetime values (only applies to “generate” mode), will name with the measured unix timestamp

  • tracks_dset_name: str, path to input tracks dataset (only applies to generate mode)

  • true_segments_dset_name: str, path to input true segments dataset for each hit (only applies to generate mode for simulation)

  • update_result: bool, flag to add to existing calibration file, otherwise will create a new file based on the timestamp (only applies to generate mode)

  • calib_dset_name: str, path to output dataset (only applies to “calibration” mode)

Important note!! hits_dset_name and drift_dset_name do double duty and have different requirements depending on the run mode: in "generate" mode these represent the hits and drift info for the hits associated with each track, whereas in "calibration" mode these are the hits and drift info for the event. So the nominal corresponding requirements field should be:

requirements: # generate mode
  - 'combined/tracklets'
  - name: 'track_hit_drift'
    path: ['combined/trackets', 'charge/hits', 'combined/hit_drift']
  - name: 'track_hits'
    path: ['combined/tracklets', 'charge/hits']

requirements: # calibration mode
  - name: 'combined/hit_drift'
    path: ['charge/hits', 'combined/hit_drift']
  - 'charge/hits'

Both hits_dset_name and drift_dset are required in the cache.

Requires RunData, LArData, and Geometry resource in workflow.

calib datatype:

id          u4,     unique identifier
f           f4,     calibration factor (q_calib = f * q)
q           f4,     resulting calibrated value [mV]

The output electron lifetime file is a .npz collection containing:

  • ntracks: number of tracks used in fit

  • drift_bins: 1D array of drift time bin edges

  • dqdx_bins: 1D array of dQ/dx bin edges

  • dedx_bins: 1D array of dE/dx bin edges (simulation only)

  • timestamp: averaged unix time across run [s]

  • hist: 2D array of bin counts for track dQ/dx

  • dedx_hist: 2D array of bin counts for track true dE/dx (simulation only)

  • lifetime: best fit electron lifetime

  • lifetime_err: best fit electron lifetime error

  • dqdx0: best fit dQ/dx(t=0)

  • dqdx0_err: best fit dQ/dx(t=0) error

  • other_fit_p: 1D array of power law best fit parameters

  • other_fit_p_err: 1D array of power lay best fit parameter errors

  • dqdx_p: 2D array of peak value extracted from each drift bin for each bootstrap sample

  • dqdx_p_valid: 2D boolean array, True if peak value extraction was successful

CALIBRATE = calib
DX = 30
GENERATE = gen
calib_dtype
class_version = 0.0.0
default_calib_dset_name = combined/q_calib
default_charge_dset_name = charge/hits
default_dedx_bins
default_dndx_bins
default_dqdx_bins
default_drift_bins
default_drift_dset_name = combined/hit_drift
default_hits_dset_name = charge/hits
default_tracks_dset_name = combined/tracklets
default_true_segments_dset_name = mc_truth/hits/tracks
default_update_result = True
static f_decay(t, max_, tau, power, power_scale)

Power-law modified exponential to account for electron lifetime and signal truncation close to anode

static f_poly(dqdx, *args)

Polynomial function of arbitrary complexity (= args[0] + args[1] * dqdx + args[2] * dqdx^2 + ...)

finish(source_name)
init(source_name)
static langau(dqdx, norm, mpv, eta, sigma, A)
run(source_name, source_slice, cache)
static weighted_percentile(values, weights, p=0.5)

Finds the percentile p of values given weights weights along the last axis using a linear interpolation of the CDF, requires values strictly increasing along last axis

module0_flow.reco.combined.electron_lifetime.condense_array(arr, mask)

Densify a masked array on last axis, throwing out invalid values (up to the size needed to keep the array regular). E.g.:

mask = [[False, True, True],
        [False, False, True],
        [True, False, True]]

will condense a 3x3 array to shape: (3, 2) and produce a final mask of:

new_mask = [[False, True],
            [False, False],
            [False, True]]

Note that this operation does not have an inverse.

Parameters:
  • arr – array shape: (..., N, M)

  • mask – boolean array shape: (..., N, M), True == invalid

Returns:

array shape: (..., N, m)

tracklet reconstruction

class module0_flow.reco.combined.tracklet_reco.TrackletReconstruction(**params)

Bases: h5flow.core.H5FlowStage

Reconstructs “tracklets” or short, collinear track segments from hit data using DBSCAN and RANSAC. The track direction is estimated using a PCA fit.

Parameters:
  • tracklet_dset_name: str, path to output dataset

  • hits_dset_name: str, path to input charge hits dataset

  • charge_dset_name: str, path to input charge dataset (1:1 with hits dataset, requires "q" field)

  • hit_drift_dset_name: str, path to charge hits drift data

  • dbscan_eps: float, dbscan epsilon parameter

  • dbscan_min_samples: int, dbscan min neighbor points to consider as “core” point

  • ransac_min_samples: int, min points to run ransac algorithm

  • ransac_residual_threshold: float, max distance from trial axis

  • ransac_max_trials: int, number of ransac trials per cluster

  • max_iterations: int, max number of fitting iterations before giving up

  • max_nhit: int, skip track fitting on events with greater number of hits, None to apply no cut

Both hits_dset_name, charge_dset_name, and hits_drift_dset_name are required in the cache.

Requires Geometry, RunData, and Units resource in workflow.

tracklets datatype:

id          u4,     unique identifier
theta       f8,     track inclination w.r.t anode
phi         f8,     track orientation w.r.t anode
xp          f8,     intersection of track with ``x=0,y=0`` plane [mm]
yp          f8,     intersection of track with ``x=0,y=0`` plane [mm]
nhit        i8,     number of hits in track
q           f8,     charge sum [mV]
ts_start    f8,     PPS timestamp of track start [crs ticks]
ts_end      f8,     PPS timestamp of track end [crs ticks]
residual    f8(3,)  average track fit error in (x,y,z) [mm]
length      f8      track length [mm]
start       f8(3,)  track start point (x,y,z) [mm]
end         f8(3,)  track end point (x,y,z) [mm]
trajectory          f8(trajectory_pts, 3,)      track approximation points (x,y,z) [mm]
trajectory_residual f8(trajectory_pts-1,)       track approximation average error [mm]
dx                  f8(trajectory_pts-1, 3)     track approximation displacement (dx,dy,dz) [mm]
dq                  f8(trajectory_pts-1,)       charge along track displacement [mV]
dn                  i8(trajectory_pts-1,)       nhit along track displacement
classmethod calc_tracks(hits, hit_q, hit_z, track_ids, trajectory_pts, trajectory_dx, trajectory_residual_mode)

Calculate track parameters from hits

Parameters:
  • hits – masked array, shape: (N,M)

  • hit_q – masked array, shape: (N,M)

  • hit_z – masked array, shape: (N,M)

  • track_ids – masked array, shape: (N,M)

  • trajectory_pts – int

  • trajectory_dx – float

Returns:

masked array, shape: (N,m)

class_version = 1.1.0
default_charge_dset_name = charge/hits
default_dbscan_eps = 25
default_dbscan_min_samples = 5
default_hit_drift_dset_name = combined/hit_drift
default_hits_dset_name = charge/hits
default_max_iterations = 100
default_max_nhit = 3000
default_ransac_max_trials = 100
default_ransac_min_samples = 2
default_ransac_residual_threshold = 8
default_tracklet_dset_name = combined/tracklets
default_trajectory_dx = 10
default_trajectory_pts = 5
default_trajectory_residual_mode = 1
static do_pca(xyz, mask)
Parameters:
  • xyzshape: (N,3) array of 3D positions

  • maskshape: (N,) boolean array of valid positions (True == valid)

Returns:

tuple of shape: (3,), shape: (3,) of centroid and central axis

find_tracks(hits, hit_z)

Extract tracks from a given hits array

Parameters:
  • hits – masked array shape: (N, n)

  • hit_z – masked array shape: (N, n)

Returns:

mask array shape: (N, n) of track ids for each hit, a value of -1 means no track is associated with the hit

static hit_xyz(hits, hit_z)
init(source_name)
static local_mean(xyz, pt, dx, weights=None)
Parameters:
  • xyzshape: (N, 3)

  • ptshape: (3,)

  • dxfloat radius to include in mean

  • weightsshape: (N,) relative weights for each pt, None applies same weights

Returns:

shape: (M, 3)

static phi(axis)
Parameters:

axis – array, shape: (3,)

Returns:

orientation of axis about z-axis

static projected_limits(centroid, axis, xyz)
run(source_name, source_slice, cache)
static theta(axis)
Parameters:

axis – array, shape: (3,)

Returns:

angle of axis w.r.t z-axis

static track_residual(centroid, axis, xyz)
static tracklet_dtype(npts=default_trajectory_pts)
static trajectory_approx(centroid, axis, xyz, mode, npts, dx, weights=None)
Parameters:
  • centroidshape: (3,) pre-calculated centroid of 3D positions

  • axisshape: (3,) pre-calculated PCA of 3D positions

  • xyzshape: (N, 3) array of 3D positions

Returns:

shape: (npts, 3) array of piecewise-linear approximation

static trajectory_residual(xyz, traj, mode)
Parameters:
  • xyzshape: (N, 3), 3D positions

  • trajshape: (npts, 3)`, trajectory 3D positions

Returns:

distance to nearest trajectory edge shape: (npts-1, N)

static xyp(axis, centroid)
Parameters:
  • axis – array, shape: (3,)

  • centroid – array, shape: (3,)

Returns:

x,y coordinate where line intersects x=0,y=0 plane

tracklet merging

class module0_flow.reco.combined.tracklet_merging.TrackletMerger(**params)

Bases: h5flow.core.H5FlowStage

Merges existing tracks with neighbors based on a multi-dimensional likelihood ratio metric. The observables used in the likelihood estimation are:

  • sin^2(theta): angle between the two track segments

  • transverse distance: maximum transverse displacement of track from the axis of the first track [mm]

  • missing length: length of line segment between closer two endpoints that crosses active pixels [mm]

  • overlap: quadrature sum of 1D overlap of tracks in x, y, and z [mm]

  • delta-dQ/dx: difference in raw dQ/dx [mV]

Requires an input histogram .npz file consisting of 4 arrays:

  • '{sig}': an array of shape: (N0, N1, ... N4) representing the number of signal events in each bin of the 5 observables

  • '{sig}_bins': an array of 5 arrays each with shape: Ni+1 representing the bin edges

  • '{bkg}': an array of shape: (N0, N1, ... N4) representing the number of background events in each bin of the 5 observables

The selection is performed by normalizing the input histograms to a PDF, calculating the signal/background likelihood ratio, and rescaling to a normalized metric between 0 and 1. The p-value (or inefficiency) of this metric is calculated based on the signal histogram. The track merging selection cut is applied on this p-value, e.g. a pvalue_cut = 0.05 will result in a 95% selection efficiency for merging neighboring tracks (at least for the sample used to generate the input histograms).

Parameters:
  • pdf_filename: str, path to .npz file containing multi-dimensional pdf (more details above)

  • pdf_sig_name: str, name of array in .npz file containing the “signal” histogram

  • pdf_bkg_name: str, name of array in .npz file containing the “background” histogram

  • pvalue_cut: float, p-value/inefficiency used as cut for likelihood ratio

  • max_neighbors: int, number of neighbor tracks to attempt merge procedure

  • track_charge_dset_name: str, path to input charge dataset (1:1 with track hits, requires 'q' field)

  • hit_drift_dset_name: str, path to charge hit drift data

  • hits_dset_name: str, path to input charge hits dataset

  • track_hits_dset_name: str, path to input track-referred charge hits dataset

  • tracks_dset_name: str, path to input track dataset

  • merged_dset_name: str, path to output track dataset

All of hits_dset_name, hit_drift_dset_name, track_hits_dset_name, and tracks_dset_name are required in the cache.

Requires both Geometry and DisabledChannels resources in workflow.

merged datatype is the same as the TrackletReconstruction.tracklet_dtype.

Example config:

track_merge:
    classname: TrackletMerger
    requires:
     - 'combined/tracklets'
     - name: 'combined/track_hits
       path: ['combined/tracklets', charge/hits']
     - name: 'combined/track_hit_drift
       path: ['combined/tracklets', charge/hits', 'combined/hit_drift']
    params:
        merged_dset_name: 'combined/tracklets/merged'
        hit_drift_dset_name: 'combined/hit_drift'
        hits_dset_name: 'charge/hits'
        track_charge_dset_name: 'charge/hits'
        tracks_dset_name: 'combined/tracklets'
        pdf_filename: 'joint_pdf.npz'
        pvalue_cut: 0.10
        max_neighbors: 5
static calc_2track_deflection_angle(tracks, neighbor)
static calc_2track_missing_length(tracks, neighbor, missing_track_segments, pixel_x, pixel_y, disabled_channel_lut, cathode_region, pixel_pitch=None)
static calc_2track_overlap(tracks, neighbor)
static calc_2track_sin2theta(tracks, neighbor)
static calc_2track_transverse_sin2theta(tracks, neighbor)
cathode_region = 15
class_version = 3.1.0
static closest_trajectories(tracks0, tracks1)
Parameters:
  • tracks0 – track dtype of shape: (..., M,)

  • tracks1 – track dtype of shape: (..., M,)

Returns:

start and end points of closest trajectory segments and points of closest approach, shape: (..., M, 3)

static create_groups(mask)

Combine masks of n x n ajacency matrix such that the mask of row i is equal to the OR of the rows that can be reached from i and the rows that can reach i. E.g.:

arr = [[1,0,1],
       [0,1,0],
       [0,0,1]]
new_arr = create_groups(arr)
new_arr # [[1,0,1],
           [0,1,0],
           [1,0,1]]

and:

arr = [[0,1,0],
       [0,0,1],
       [1,1,0]]
new_arr = create_groups(arr)
new_arr # [[1,1,1],
           [1,1,1],
           [0,1,1]]
Parameters:

mask – ajacency matrix (shape: (..., n, n))

Returns:

updated ajacency matrix (shape: (..., n, n))

default_hit_drift_dset_name = combined/track_hit_drift
default_hits_dset_name = charge/hits
default_max_neighbors = 5
default_merged_dset_name = combined/tracklets/merged
default_pdf_bkg_name = origin
default_pdf_filename = joint_pdf-2_0_1.npz
default_pdf_sig_name = rereco
default_pvalue_cut = 0.1
default_track_charge_dset_name = charge/hits
default_track_hits_dset_name = combined/track_hits
default_tracks_dset_name = combined/tracklets
static find_k_neighbor(tracks, mask=None, k=1)

Find k-th neighbor based on endpoint distance and require no overlap:

  • tracks is an (N,M) array of tracks

  • mask is boolean of same shape as tracks

  • mask true indicates a valid track to search for neighbors

init(source_name)
static load_r_values(filename, sig_key, bkg_key)

Load the N-D pdf histogram from an .npz file. Loads and normalizes the histograms stored under {sig_key} and {bkg_key} with bins stored under {key}_bins to create a PDF. The likelihood ratio (R) is then calculated and converted to a normalized value between 0-1 (r) with the following transformation:

r = 1 - e^(-R)

Bins with 0 entries are assigned an R-value of 0.

Parameters:
  • filename – path to .npz file with arrays

  • sig_key – name of “signal” histogram in .npz file

  • bkg_key – name of “background” histogram in .npz file

Returns:

tuple of r histogram (shape: (N0, N1, ...)), r bins in each dimension (shape: (D, Ni)), an array possible r values (shape: (1001,), and corresponding p-values (shape: (1001,))

static make_missing_segment(start1, end1, start2, end2)
merged_dtype
missing_track_segments = 150
static poca(start_xyz0, end_xyz0, start_xyz1, end_xyz1)

Finds the scale factor to point of closest approach of two lines each defined by 2 3D points. The scale factor is a number between 0 and 1 representing the position along the line. To extract the 3D point of closest approach on each line:

s0, s1 = poca(start0, end0, start1, end1) # shape: (N, 1)
poca0 = (1 - s0) * start0 + s0 * end0 # shape: (N, 3)
poca1 = (1 - s1) * start1 + s1 * end1
Parameters:

end}_xyz(i) ({start,) – start/end point of line i, shape: (..., N, 3)

Returns:

tuple of line segment 0 and 1, shape: (..., N, 1)

run(source_name, source_slice, cache)
static score_neighbor(r, r_bins, statistic_bins, p_bins, *params)

Calculates a p-value based on a binned, multi-dimensional PDF

Parameters:
  • r – likelihood ratio, shape: (N,)*D

  • r_bins – bin edge for each parameter, shape: (D, N+1)

  • statistic_bins – bins for statistic, range 0-1, shape: (n,)

  • p_bins – bins for p value range 0-1, shape: (n,)

  • *params

    array of parameters to use to calculate p-value, requires D parameters in the same sequence as listed in the bins, each with the same shape

Returns:

array of same shape as the params arrays with a p-value between 0-1

class module0_flow.reco.combined.tracklet_merging.TrackletReconstruction(**params)

Bases: h5flow.core.H5FlowStage

Reconstructs “tracklets” or short, collinear track segments from hit data using DBSCAN and RANSAC. The track direction is estimated using a PCA fit.

Parameters:
  • tracklet_dset_name: str, path to output dataset

  • hits_dset_name: str, path to input charge hits dataset

  • charge_dset_name: str, path to input charge dataset (1:1 with hits dataset, requires "q" field)

  • hit_drift_dset_name: str, path to charge hits drift data

  • dbscan_eps: float, dbscan epsilon parameter

  • dbscan_min_samples: int, dbscan min neighbor points to consider as “core” point

  • ransac_min_samples: int, min points to run ransac algorithm

  • ransac_residual_threshold: float, max distance from trial axis

  • ransac_max_trials: int, number of ransac trials per cluster

  • max_iterations: int, max number of fitting iterations before giving up

  • max_nhit: int, skip track fitting on events with greater number of hits, None to apply no cut

Both hits_dset_name, charge_dset_name, and hits_drift_dset_name are required in the cache.

Requires Geometry, RunData, and Units resource in workflow.

tracklets datatype:

id          u4,     unique identifier
theta       f8,     track inclination w.r.t anode
phi         f8,     track orientation w.r.t anode
xp          f8,     intersection of track with ``x=0,y=0`` plane [mm]
yp          f8,     intersection of track with ``x=0,y=0`` plane [mm]
nhit        i8,     number of hits in track
q           f8,     charge sum [mV]
ts_start    f8,     PPS timestamp of track start [crs ticks]
ts_end      f8,     PPS timestamp of track end [crs ticks]
residual    f8(3,)  average track fit error in (x,y,z) [mm]
length      f8      track length [mm]
start       f8(3,)  track start point (x,y,z) [mm]
end         f8(3,)  track end point (x,y,z) [mm]
trajectory          f8(trajectory_pts, 3,)      track approximation points (x,y,z) [mm]
trajectory_residual f8(trajectory_pts-1,)       track approximation average error [mm]
dx                  f8(trajectory_pts-1, 3)     track approximation displacement (dx,dy,dz) [mm]
dq                  f8(trajectory_pts-1,)       charge along track displacement [mV]
dn                  i8(trajectory_pts-1,)       nhit along track displacement
classmethod calc_tracks(hits, hit_q, hit_z, track_ids, trajectory_pts, trajectory_dx, trajectory_residual_mode)

Calculate track parameters from hits

Parameters:
  • hits – masked array, shape: (N,M)

  • hit_q – masked array, shape: (N,M)

  • hit_z – masked array, shape: (N,M)

  • track_ids – masked array, shape: (N,M)

  • trajectory_pts – int

  • trajectory_dx – float

Returns:

masked array, shape: (N,m)

class_version = 1.1.0
default_charge_dset_name = charge/hits
default_dbscan_eps = 25
default_dbscan_min_samples = 5
default_hit_drift_dset_name = combined/hit_drift
default_hits_dset_name = charge/hits
default_max_iterations = 100
default_max_nhit = 3000
default_ransac_max_trials = 100
default_ransac_min_samples = 2
default_ransac_residual_threshold = 8
default_tracklet_dset_name = combined/tracklets
default_trajectory_dx = 10
default_trajectory_pts = 5
default_trajectory_residual_mode = 1
static do_pca(xyz, mask)
Parameters:
  • xyzshape: (N,3) array of 3D positions

  • maskshape: (N,) boolean array of valid positions (True == valid)

Returns:

tuple of shape: (3,), shape: (3,) of centroid and central axis

find_tracks(hits, hit_z)

Extract tracks from a given hits array

Parameters:
  • hits – masked array shape: (N, n)

  • hit_z – masked array shape: (N, n)

Returns:

mask array shape: (N, n) of track ids for each hit, a value of -1 means no track is associated with the hit

static hit_xyz(hits, hit_z)
init(source_name)
static local_mean(xyz, pt, dx, weights=None)
Parameters:
  • xyzshape: (N, 3)

  • ptshape: (3,)

  • dxfloat radius to include in mean

  • weightsshape: (N,) relative weights for each pt, None applies same weights

Returns:

shape: (M, 3)

static phi(axis)
Parameters:

axis – array, shape: (3,)

Returns:

orientation of axis about z-axis

static projected_limits(centroid, axis, xyz)
run(source_name, source_slice, cache)
static theta(axis)
Parameters:

axis – array, shape: (3,)

Returns:

angle of axis w.r.t z-axis

static track_residual(centroid, axis, xyz)
static tracklet_dtype(npts=default_trajectory_pts)
static trajectory_approx(centroid, axis, xyz, mode, npts, dx, weights=None)
Parameters:
  • centroidshape: (3,) pre-calculated centroid of 3D positions

  • axisshape: (3,) pre-calculated PCA of 3D positions

  • xyzshape: (N, 3) array of 3D positions

Returns:

shape: (npts, 3) array of piecewise-linear approximation

static trajectory_residual(xyz, traj, mode)
Parameters:
  • xyzshape: (N, 3), 3D positions

  • trajshape: (npts, 3)`, trajectory 3D positions

Returns:

distance to nearest trajectory edge shape: (npts-1, N)

static xyp(axis, centroid)
Parameters:
  • axis – array, shape: (3,)

  • centroid – array, shape: (3,)

Returns:

x,y coordinate where line intersects x=0,y=0 plane

module0_flow.reco.combined.tracklet_merging.condense_array(arr, mask)

Densify a masked array on last axis, throwing out invalid values (up to the size needed to keep the array regular). E.g.:

mask = [[False, True, True],
        [False, False, True],
        [True, False, True]]

will condense a 3x3 array to shape: (3, 2) and produce a final mask of:

new_mask = [[False, True],
            [False, False],
            [False, True]]

Note that this operation does not have an inverse.

Parameters:
  • arr – array shape: (..., N, M)

  • mask – boolean array shape: (..., N, M), True == invalid

Returns:

array shape: (..., N, m)