stopping muon analysis
- class module0_flow.analysis.stopping_muon_selection.StoppingMuonSelection(**params)
Bases:
h5flow.core.H5FlowStagePerform a selection for stopping muons. A stopping event is defined by no more than one merged track segment that enters the detector fiducial volume and does not leave it. Creates a boolean array of 1:1 with events indicating stopping events, and creates a boolean array 1:1 with merged track segments if they individually meet the stopping criteria.
A dQ/dx profile is generated per event and used to discriminate stopping protons and muons, as well as through-going muons.
If the file is a MC file, also generates boolean arrays with the true value.
- apply_position_resolution(range_table, noise=0)
Update the range table
dqdxanddqdx_widthby smearing the range values by a gaussianprofile_dx
- class_version = 2.0.0
- create_dqdx_profile_templates()
- defaults
- static density_dx_correction(rr, *params)
- downward(start_xyz, end_xyz, include_cathode=False)
- Parameters:
start_xyz – array
shape: (N,3)end_xyz – array
shape: (N,3)include_cathode – if True, consider the cathode region as outside the fid
- Returns:
array
shape: (N,)
- static dx_estimate(profile_pos, hit_xyz, hit_idx, pixel_pitch, nsamples=10, tol=0.1)
Calculate the track dx to be associated with each profile point.
First finds the furthest point along the line that falls on a hit pixel. Then samples the track length between those points, checking to see if the sample point falls onto a disabled channel. The track length is calculated as the length between the furthest points, minus the approximate length on disabled channels
- Parameters:
profile_pos – xyz position of each profile point
shape: (..., nprof, 3)hit_xyz – xyz position of each hit
shape: (..., nhit, 3)hit_idx – index into
profile_posof each hitshape: (..., nhit)nsamples – number of sample points to estimate disabled fraction of track
- Returns:
dx to be associated with each profile point
shape: (..., nprof)
- event_profile_dset_name = event_profile
- static event_profile_dtype(dx, max_range)
- event_sel_dset_name = event_sel_reco
- event_sel_dtype
- event_sel_truth_dset_name = event_sel_truth
- extrapolated_intersection(start, end)
Returns the length of projected track that crosses active pixels
- finish(source_name)
- hit_profile_dset_name = hit_profile
- hit_profile_dtype
- init(source_name)
- static intersection(xyz, dxyz, pxyz, pnorm)
calculate the intersection of lines with planes
- Parameters:
xyz – (…, 3) array representing line origins
dxyz – (…, 3) array representing line directions (unit norm)
pxyz – (…, 3) array representing a point on the plane
pnorm – (…, 3) array representing plane normal (unit norm)
- Returns:
(…, 3) array representing the intersection point
- static mean_neg_loglikelihood(r0, range_table, profile_n, profile_dqdx, profile_rr, profile_pos)
- static pixel_intersection(pt, n, pixel, pixel_pitch, mask=None)
Calculate the line intersection defined by 3D position
ptand direction unit vectornwith a pixel at 2D positionpixeland a pixel width ofpixel_pitch- Parameters:
pt – 3D position
shape: (..., 3)n – 3D vector
shape: (..., 3)pixel – 2D pixel location
shape: (..., 2)pixel_pitch – pixel width
float
- static profile_likelihood(profile_rr, profile_dqdx, profile_pos, range_table, type='', mcs_weight=0.0625)
Calculates the log-likelihood score of a given dqdx v. residual range profile using a Moyal-distribution approximation.
Likelihood data is passed via the
range_tableparameter which is adictwith the following arrays:range: residual range values used in interpolationshape: (n_interp_pts,)dqdx: dQ/dx values used in interpolationshape: (n_interp_pts,)dqdx_width: dQ/dx sigma valuesshape: (n_interp_pts,)
- Parameters:
profile_rr – residual range
shape: (..., n)profile_dqdx – dqdx
shape: (..., n)profile_pos – bin position
shape: (..., n, 3)range_table –
dict, see above.type – likelihood pdf name, one of
'abs_exp','moyal','moyal_gaus','gaus'
- Returns:
likelihood
shape: (..., n)
- static profiled_dqdx_kalman(tracks, seed_pt, hit_xyz, hit_q, dx, max_range, search_dx, pixel_pitch, mask=None)
- run(source_name, source_slice, cache)
- stopping(start_xyz, end_xyz, include_cathode=False)
- Parameters:
start_xyz – array
shape: (N,3)end_xyz – array
shape: (N,3)include_cathode – if True, consider the cathode region as outside the fid
- Returns:
array
shape: (N,)
- through_going(start_xyz, end_xyz, include_cathode=False)
- Parameters:
start_xyz – array
shape: (N,3)end_xyz – array
shape: (N,3)include_cathode – if True, consider the cathode region as outside the fid
- Returns:
array
shape: (N,)
- module0_flow.analysis.stopping_muon_selection.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)
- module0_flow.analysis.stopping_muon_selection.mode(arr)
Finds the most common element along the last dimension
- Parameters:
arr – array
shape: (..., N)- Returns:
array
shape: (..., 1)
- class module0_flow.analysis.michel_id.MichelID(**params)
Bases:
h5flow.core.H5FlowStage- class_version = 0.1.0
- defaults
- finish(source_name)
- hit_label_dtype
- init(source_name)
- likelihood_bins = ()
- michel_label_dtype
- run(source_name, source_slice, cache)
- module0_flow.analysis.michel_id.fill_likelihood_pdf(cos_mu, cos_e, d, sig_label, pdf_sig, pdf_bkg, cos_mu_bins, cos_e_bins, d_bins)
- module0_flow.analysis.michel_id.load_likelihood_pdf(filename)
- module0_flow.analysis.michel_id.michel_likelihood_score(cos_mu, cos_e, d, pdf_sig, pdf_bkg, cos_mu_bins, cos_e_bins, d_bins)
- class module0_flow.analysis.muon_capture_truth_labels.MuonCaptureTruthLabels(**params)
Bases:
h5flow.core.H5FlowStage- class_version = 0.0.0
- default_truth_labels_dset_name = analysis/muon_capture/truth_labels
- default_truth_tracks_dset_name = mc_truth/tracks
- default_truth_trajectories_dset_name = mc_truth/trajectories
- init(source_name)
- ref_dtype
- run(source_name, source_slice, cache)
- truth_label_dtype
- module0_flow.analysis.muon_capture_truth_labels.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)
- module0_flow.analysis.muon_capture_truth_labels.mode(arr)
Finds the most common element along the last dimension
- Parameters:
arr – array
shape: (..., N)- Returns:
array
shape: (..., 1)
- class module0_flow.analysis.delayed_signal.DelayedSignal(**params)
Bases:
h5flow.core.H5FlowStage- class_version = 0.2.0
- defaults
- delayed_dtype
- static fit_dtype(ntpc, ndet)
- init(source_name)
- static prompt_dtype(ntpc, ndet, nterms)
- run(source_name, source_slice, cache)
- module0_flow.analysis.delayed_signal.f_delayed(t, prompt_a, prompt_t, delayed_a, delayed_t, *args, **kwargs)
- module0_flow.analysis.delayed_signal.f_scint(t, singlet_fraction=0.3, tau_t=750, tau_s=7, smearing=1)
- module0_flow.analysis.delayed_signal.loss(x, *args)