mlreco.utils.groups module¶
-
mlreco.utils.groups.get_group_types(particle_v, meta, point_type='3d')[source]¶ Gets particle classes for voxel groups
-
mlreco.utils.groups.filter_duplicate_voxels(data, usebatch=True)[source]¶ return array that will filter out duplicate voxels Only first instance of voxel will appear Assume data[:4] = [x,y,z,batchid] Assumes data is lexicographically sorted in x,y,z,batch order
-
mlreco.utils.groups.filter_duplicate_voxels_ref(data, reference, meta, usebatch=True, precedence=[1, 2, 0, 3, 4])[source]¶ return array that will filter out duplicate voxels Sort with respect to a reference and following the specified precedence order Assume data[:4] = [x,y,z,batchid] Assumes data is lexicographically sorted in x,y,z,batch order
-
mlreco.utils.groups.filter_nonimg_voxels(data_grp, data_img, usebatch=True)[source]¶ return array that will filter out voxels in data_grp that are not in data_img ASSUME: data_grp and data_img are lexicographically sorted in x,y,z,batch order ASSUME: all points in data_img are also in data_grp ASSUME: all voxels in data are unique
-
mlreco.utils.groups.filter_group_data(data_grp, data_img)[source]¶ return return array that will permute and filter out voxels so that data_grp and data_img have same voxel locations 1) lexicographically sort group data (images are lexicographically sorted) 2) remove voxels from group data that are not in image 3) choose only one group per voxel (by lexicographic order) WARNING: (3) is certainly not a canonical choice
-
mlreco.utils.groups.process_group_data(data_grp, data_img)[source]¶ return processed group data 1) lexicographically sort group data (images are lexicographically sorted) 2) remove voxels from group data that are not in image 3) choose only one group per voxel (by lexicographic order) WARNING: (3) is certainly not a canonical choice
-
mlreco.utils.groups.get_interaction_id(particle_v, num_ancestor_loop=1)[source]¶ A function to sort out interaction ids. Note that this assumes cluster_id==particle_id. Inputs:
particle_v (array) : larcv::EventParticle.as_vector()
num_ancestor_loop (int): number of ancestor loops (default 1)
- Outputs:
interaction_ids: a numpy array with the shape (n,)
-
mlreco.utils.groups.get_nu_id(cluster_event, particle_v, interaction_ids, particle_mpv=None)[source]¶ A function to sorts interactions into nu or not nu (0 for cosmic, 1 for nu). CAVEAT: Dirty way to sort out nu_ids
Assuming only one nu interaction is generated and first group/cluster belongs to such interaction
- Inputs:
cluster_event (larcv::EventClusterVoxel3D): (N) Array of cluster tensors
particle_v vector: larcv::EventParticle.as_vector()
interaction_id: a numpy array with shape (n, 1) where 1 is interaction id
(optional) particle_mpv: vector of particles from mpv generator, used to work around
the lack of proper interaction id for the time being.
- Outputs:
nu_id: a numpy array with the shape (n,1)
-
mlreco.utils.groups.get_particle_id(particles_v, nu_ids, include_mpr=False, include_secondary=False)[source]¶ Function that gives one of five labels to particles of particle species predictions. This function ensures: - Particles that do not originate from an MPV are labeled -1,
unless the include_mpr flag is set to true
Secondary particles (includes Michel/delta and neutron activity) are labeled -1, unless the include_secondary flag is true
All shower daughters are labeled the same as their primary. This makes sense as otherwise an electron primary gets overruled by its many photon daughters (voxel-wise majority vote). This can lead to problems as, if an electron daughter is not clustered with the primary, it is labeled electron, which is counter-intuitive. This is handled downstream with the high_purity flag.
Particles that are not in the list target are labeled -1
- Inputs:
particles_v (array of larcv::Particle) : (N) LArCV Particle objects
nu_ids: a numpy array with shape (n, 1) where 1 is neutrino id (0 if not an MPV)
include_mpr: include MPR (cosmic-like) particles to PID target
include_secondary: include secondary particles into the PID target
- Outputs:
array: (N) list of group ids
-
mlreco.utils.groups.get_shower_primary_id(cluster_event, particles_v)[source]¶ Function that assigns valid primary tags to shower fragments. This could be handled somewhere else (e.g. SUPERA)
- Inputs:
cluster_event (larcv::EventClusterVoxel3D): (N) Array of cluster tensors
particles_v (array of larcv::Particle) : (N) LArCV Particle objects
- Outputs:
array: (N) list of group ids
-
mlreco.utils.groups.get_group_primary_id(particles_v, nu_ids=None, include_mpr=True)[source]¶ Function that assigns valid primary tags to particle groups. This could be handled somewhere else (e.g. SUPERA)
- Inputs:
particles_v (array of larcv::Particle) : (N) LArCV Particle objects
nu_ids: a numpy array with shape (n, 1) where 1 is neutrino id (0 if not an MPV)
include_mpr: include MPR (cosmic-like) particles to primary target
- Outputs:
array: (N) list of group ids