Class LoaderAffinityField

Class Documentation

class LoaderAffinityField

used to help load affinity field ground truth data for training

This class will load data from the AffinityFieldTree produced by larflow::keypoints::PrepAffinityField.

This data comes in the form of a 3D direction for each proposed spacepoint in an image. This is the target output of the network.

Functions are provided to get these training labels in the form of numpy arrays in order to interface with DL frameworks. (We usually develop with pytorch in mind.)

Usage: (to do)

Public Functions

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

constructor with list of input ROOT files

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

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

add input ROOT file to be loaded

Parameters
  • input: path to ROOT file containing AffinityFieldTree

void exclude_false_triplets(bool exclude)

set flag that, if true, will only return labels for true (i.e. non-ghost) points

void load_tree()

load TTree class data members and define TBranches

unsigned long load_entry(int entry)

load data for a given entry

Return
number of bytes loaded from the file. zero is no more entries or there was an error.
Parameters
  • entry: entry number in TChain

unsigned long GetEntries()

get total entries

Return
number of entries in the TChain _paf

PyObject *get_match_data(PyObject *triplet_matches_pyobj, bool exclude_neg_examples)

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

returns a python dictionary. Contents include (list starts with key of entry)

    • paf_label:affinity field ground truth (direction of particle at spacepoint)
    • paf_weight:weight for affinity field labels}

Return
Python dictionary with numpy arrays
Parameters
  • triplet_matches_pyobj: The sampled larmatch triplets. Expected shape: (N,4).
  • exclude_neg_examples: Exclude negative examples

Public Members

std::vector<std::string> input_files

list of input files to load

TChain *tpaf

pointer to TChain for AffinityFieldTree

std::vector<std::vector<float>> *_label_v

direction labels for each space point in the image

Protected Functions

int make_paf_arrays(const int nfilled, const std::vector<int> &pos_match_index, const bool exclude_neg_examples, PyArrayObject *match_array, PyArrayObject *&paf_label, PyArrayObject *&paf_weight)

make particle affinity field ground truth numpy arrays

Return
always returns 0
Parameters
  • nfilled: number of samples actually returned
  • pos_match_index: vector index in return samples for space points which are true/good
  • exclude_neg_examples: If true, training samples return do not have negative/bad spacepoint examples
  • match_array: numpy array containing indices to sparse image for each spacepoint
  • paf_label: numpy array containing target direction for each spacepoint. shape (N,3)
  • paf_weight: numpy array containing weight for each spacepoint. shape (N,)

Protected Attributes

bool _exclude_neg_examples

flag that, if true, causes get_match_data() to return only true (i.e. non-ghost) points

Protected Static Attributes

bool _setup_numpy = false

flag indicating if import_numpy() has been called