Class PrepKeypointData

Class Documentation

class PrepKeypointData

Make the training data for the key-point+larmatch task.

The job is to provide labels for the proposed matches for the network. It can either remake proposals or it can make labels for old proposals.

The cases we are trying to label:

  • cosmic muon start and stop, primary ancestor only.
  • cosmic proton start and stop, primary ancestor only.
  • neutrino primary track start and stop
  • neutrino primary shower start and stop
  • cosmic shower start, primary ancestor only (hard)

maybe, depending on quality of truth data neutrino secondaries scattering secondaries.

The outputs we are trying to get the network to make are:

  1. for each space point (i.e. triplet) proposed, scores (one for each keypoint type) which come from a gaussian between the 3D position of the space point and the closest true keypoint of that class.
  2. If the closest true keypoint is greater than some distance, the score is set to 0.0
  3. The classes are { neutrino vertex, shower start, track ends }

Public Functions

PrepKeypointData()

constructor

~PrepKeypointData()

deconstructor

void process(larcv::IOManager &iolcv, larlite::storage_manager &ioll)

process one event, given io managers

expect the following inputs within the event data containers in IOManager:

  • charge image with tree name _adc_image_treename, specifiable using setADCimageTreeName
  • ”segment” images indicating particle type at a given pixel
  • ”instance” images indicating MC ID of particle making charge at pixel
  • ”ancestor” images indicating ancestor track ID for particle making charge at pixel

in larlite:

  • ”mcreco” MCTrack tree, holding truth info for track-like particles
  • ”mcreco” MCShower tree, holding truth info for shower-like particles
  • ”generator” MCTruth tree, holding truth about neutrino interaction in image (if exists)

important class data members produced by this method:

  • _kpd_v vector of KPdata class which holds info on ground truth keypoints
  • _match_proposal_labels_v[3] For each keypoint type (total 3), hold a vector of floats for every 3D spacepoint proposal There will be a vector<float> for each triplet in PrepMatchTriplet::_triplet_v
  • _kppos_v[3] For each keypoint type (total 3), store 3D position for each ground truth keypoint identified

Parameters
  • iolcv: LArCV IOManager containing event data
  • ioll: LArLite storage_manager containing event data

void process(const std::vector<larcv::Image2D> &adc_v, const std::vector<larcv::Image2D> &badch_v, const std::vector<larcv::Image2D> &segment_v, const std::vector<larcv::Image2D> &instance_v, const std::vector<larcv::Image2D> &ancestor_v, const larlite::event_mctrack &mctrack_v, const larlite::event_mcshower &mcshower_v, const larlite::event_mctruth &mctruth_v)

process one event, directly given input containers

void make_proposal_labels(const larflow::prep::PrepMatchTriplets &match_proposals)

given a set of space point (i.e. triplet match) proposals, we define a vector<float> which we use to we make ground truth information

vector elements: [0]: 1.0 if has true end-point with 0.3*50 cm, 0.0 if not. [1-3]: shift in 3D points from point to closest end-point [4-7]: shift in 2D pixels from image points to closest end-point: drow, dU, dV, dY

void setADCimageTreeName(std::string treename)

set the tree name used to get wire plane images

Parameters
  • treename: Name of tree in ROOT file following image2d_[treename]_tree

const std::vector<KPdata> &getKPdata() const

get the vector of true keypoints labeled in the image

Return
vector of keypoints represented by KPdata class

void printKeypoints() const

dump keypoint locations to standard out

PyObject *get_keypoint_array(int ikpclass) const

return a numpy array with keypoints for a given class

Return
Numpy array with columns [tick,wire-U,wire-V,wire-Y,x,y,z,isshower,origin,pid]
Parameters

PyObject *get_triplet_score_array(float sig) const

return a numpy array with keypoint class scores

The score is calculated for each proposed spacepoint using a gaussian where the mean is the 3d position of the closest ground truth keypoint for the given class. For any point 50*0.3 cm away from a ground truth keypoint, the score is set to zero.

Assumes that process has already been run.

Return
Numpy array with shape [num space points, larflow::kNumKeyPoints classes ]
Parameters
  • sig: The sigma used in Gaussian to calculate keypoint class score

void defineAnaTree()

define ROOT tree where we save the labels

this TTree is intended to be used to save ground truth information we can load during training

void writeAnaTree()

call the ana tree’s Write method

void fillAnaTree()

if analysis tree has been created, fill data to tree for current event

void writeHists()

write tracking histograms

std::vector<TH2D> makeScoreImage(const int ikpclass, const float sigma, const std::string histname, const larflow::prep::PrepMatchTriplets &tripmaker, const std::vector<larcv::Image2D> &adc_v) const

dump out th2d of scores, for visualization and debugging

Return
vector of TH2D, one for each
Parameters
  • ikpclass: KeyPoint_t type
  • sigma: Width of score Gaussian in cm
  • histname: Stem of name to use for TH2D
  • tripmaker: Instance of PrepMatchTriplet with prepared triplets
  • adc_v: vector of Image2D images, for meta

Public Members

TH1F *hdist[3]

histograms contaning distance to true keypoint for the spacepoints

TH1F *hdpix[4]

Don’t remember.

int _nclose

number of space point proposals within some radius of a true keypoint

int _nfar

number of space point proposals further than some radius of a true keypoint

Protected Functions

std::vector<KPdata> getMuonEndpoints(ublarcvapp::mctools::MCPixelPGraph &mcpg, const std::vector<larcv::Image2D> &adc_v, const larlite::event_mctrack &mctrack_v, larutil::SpaceChargeMicroBooNE *psce)

make list of end-points for track-like particles

Return
Vector of KPdata instances, one for each ground truth track end
Parameters
  • mcpg: Instance of MCPixelPGraph, which organizes information true particle information into graph, while also associating to each truth particle, the pixels in the image (if any)
  • adc_v: Vector of wire charge image, one for each plane
  • mctrack_v: Event container (vector) of mctrack objects, containing truth information of track-like particles in the event
  • psce: Pointer to SpaceChargeMicroBooNE class. For converting true 3D trajectory information into the observed trajectory due to space charge effects

std::vector<KPdata> getShowerStarts(ublarcvapp::mctools::MCPixelPGraph &mcpg, const std::vector<larcv::Image2D> &adc_v, const larlite::event_mcshower &mcshower_v, larutil::SpaceChargeMicroBooNE *psce)

make list of end-points for shower-like particles

Return
Vector of KPdata instances, one for each ground truth shower start
Parameters
  • mcpg: Instance of MCPixelPGraph, which organizes information true particle information into graph, while also associating to each truth particle, the pixels in the image (if any). We get a list of showers using this graph, and only consider those who have at least 10 visible pixels in one of the planes.
  • adc_v: Vector of wire charge image, one for each plane
  • mcshower_v: Event container (vector) of mcshower objects, containing truth information of shower-like particles in the event
  • psce: Pointer to SpaceChargeMicroBooNE class. For converting true 3D trajectory information into the observed trajectory due to space charge effects

void _label_nu_keypoints(const larlite::event_mctruth &mctruth_v, const std::vector<larcv::Image2D> &adc_v, larutil::SpaceChargeMicroBooNE *psce, std::vector<KPdata> &kpdata_v)

loop through existing keypoints and change type to neutrino if close to neutrino vertex.

Parameters
  • mctruth_v: Truth information about the neutrino interaction.
  • img_v: Wire Images, just for the meta
  • psce: Pointer to space-charge microboone instance
  • kpdata_v: Keypoint elements to potentially change

void filter_duplicates()

filter out duplicates

Protected Attributes

std::string _adc_image_treename

name of tree storing charge image2d

std::vector<KPdata> _kpd_v

info on true keypoints found using MC truth

std::vector<std::vector<float>> _match_proposal_labels_v[3]

provides the labels for triplet proposals made by larflow::prep::PrepMatchTriplets

int _run

run ID number of event

int _subrun

subrun ID number of event

int _event

event ID number

TTree *_label_tree

ROOT TTree for storing labels.

std::vector<std::vector<float>> _kppos_v[3]

container of true keypoint 3D positions in cm, for each of the 3 classes