Class LoaderKeypointData

Class Documentation

class LoaderKeypointData

load keypoint ground truth data for training

The class, larflow::keypoints::PrepKeypointData, stores keypoint information into a ROOT tree (which is stored in a ROOT file).

The purpose of this class is to be able to read the tree (from the input files) and produec numpy arrays for convolutional neural network training.

Since the keypoint information does not make sense without the space point information, this loader also provides that too.

example usage: (to do)

Public Functions

LoaderKeypointData()
LoaderKeypointData(std::vector<std::string> &input_v)

constructor given list of input files

Parameters
  • input_v: List of paths to input ROOT files containing ground truth data

~LoaderKeypointData()
void add_input_file(std::string input)

add an individual ROOT file to be loaded

void exclude_false_triplets(bool exclude)

set flag that, if True, only loads true (non-ghost) spacepoints for training ssnet and keypoint labels (default is false)

void load_tree()

load TTree class data members and define TBranch variables

unsigned long load_entry(int entry)

load event data for the different trees

Return
number of bytes loaded from the tkeypoint tree data. returns 0 if end of file or error.
Parameters
  • entry: number

unsigned long GetEntries()

get total entries

Return
number of entries in the ttrplet ROOT tree (chain)

PyObject *sample_data(const int &num_max_samples, int &nfilled, bool withtruth)

return a ground truth data, return a subsample of all truth matches

returns a python dictionary. The dictionary contents are:

  • “matchtriplet”:numpy array with sparse image indices for each place, representing pixels a candidate space point project into
  • ”match_weight”:weight of “matchtriplet” examples
  • ”positive_indices”:indices of entries in “matchtriplet” array that correspond to good/true spacepoints
  • ”ssnet_label”:class label for space point
  • ”ssnet_top_weight”:weight based on topology (i.e. on boundary, near nu-vertex)
  • ”ssnet_class_weight”:weight based on class frequency
  • ”kplabel”:keypoint score numpy array
  • ”kplabel_weight”:weight for keypoint label
  • ”kpshift”:shift in 3D from space point position to nearest keypoint

Return
Python dictionary object with various numpy arrays
Parameters
  • num_max_samples: maximum number of space points for which we return ground truth data
  • nfilled: The number of space points, for which we actually return data
  • withtruth: withtruth If true, return info on whether space point is true (i.e. good)

Public Members

std::vector<std::string> input_files

list of input ROOT files to load

TChain *ttriplet

TTree containing space point information (TChain can be thought of as a TTree loading data over several input files)

TChain *tkeypoint

TTree containing keypoint information (TChain can be thought of as a TTree loading data over several input files)

TChain *tssnet

TTree containing sssnet information (TChain can be though of as a TTree loading data over several input files)

std::vector<larflow::prep::PrepMatchTriplets> *triplet_v

pointer to triplet data loaded from ttriplet ROOT tree

std::vector<std::vector<float>> *kplabel_v[3]

pointer to keypoint labels loaded from the tkeypoint ROOT tree

std::vector<std::vector<float>> *kpshift_v

pointer to vector to closet true keypoint loaded from the tkeypoint ROOT tree

std::vector<int> *ssnet_label_v

pointer to ssnet label for each space point loaded from the tssnet ROOT tree

std::vector<float> *ssnet_weight_v

pointer to class-weights for each space point loaded from the tssnet ROOT tree

Protected Functions

int make_ssnet_arrays(const int &num_max_samples, int &nfilled, bool withtruth, std::vector<int> &pos_match_index, PyArrayObject *match_array, PyArrayObject *&ssnet_label, PyArrayObject *&ssnet_top_weight, PyArrayObject *&ssnet_class_weight)

make the ssnet numpy arrays

Return
always returns 0
Parameters
  • num_max_samples: Max number of samples to return
  • nfilled: number of samples actually returned
  • withtruth: if true, return flag indicating if true/good space point
  • pos_match_index: vector index in return samples for space points which are true/good
  • match_array: numpy array containing indices to sparse image for each spacepoint
  • ssnet_label: numpy array containing ssnet class labels for each spacepoint
  • ssnet_top_weight: numpy array containing topological weight
  • ssnet_class_weight: numpy array containing class weights

int make_kplabel_arrays(const int &num_max_samples, int &nfilled, bool withtruth, std::vector<int> &pos_match_index, PyArrayObject *match_array, PyArrayObject *&kplabel_label, PyArrayObject *&kplabel_weight)

make keypoint ground truth numpy arrays

Return
always returns 0
Parameters
  • num_max_samples: Max number of samples to return
  • nfilled: number of samples actually returned
  • withtruth: if true, return flag indicating if true/good space point
  • pos_match_index: vector index in return samples for space points which are true/good
  • match_array: numpy array containing indices to sparse image for each spacepoint
  • kplabel_label: numpy array containing ssnet class labels for each spacepoint
  • kplabel_weight: numpy array containing weight for each spacepoint

int make_kpshift_arrays(const int &num_max_samples, int &nfilled, bool withtruth, PyArrayObject *match_array, PyArrayObject *&kpshift_label)

make keypoint shift ground truth numpy arrays

Return
always returns 0
Parameters
  • num_max_samples: Max number of samples to return
  • nfilled: number of samples actually returned
  • withtruth: if true, return flag indicating if true/good space point
  • match_array: numpy array containing indices to sparse image for each spacepoint
  • kpshift_label: numpy array containing ground truth position shifts

Protected Attributes

bool _exclude_neg_examples

if flag set to true, only true (i.e. non-ghost) spacepoints are loaded for training ssnet and keypoint labels

Protected Static Attributes

bool _setup_numpy = false

if true setup numpy by calling import_numpy(0)