Class PrepMatchTriplets

Class Documentation

class PrepMatchTriplets

Prepares potential spacepoints deriving from intersection of three wires.

Revision history 2020/07/22: Added doxygen documentation.

Author
Taritree Wongjirad (taritree.wongjirad@tuts.edu)
Date
$Data 2020/07/22 17:00$

Public Functions

PrepMatchTriplets()
virtual ~PrepMatchTriplets()
void process(const std::vector<larcv::Image2D> &adc_v, const std::vector<larcv::Image2D> &badch_v, const float adc_threshold, const bool check_wire_interection = false)

make the possible hit triplets from all the wire plane images

this function is expected to populate the following data members: _sparseimg_vv _imgmeta_v _triplet_v _flowdir_v

Parameters
  • adc_v: Vector of wire plane images.
  • badch_v: Vector of bad channel images.
  • adc_threshold: Threshold value for pixels we will consider.
  • check_wire_intersection: Check that triplet produces a good wire intersection inside the TPC. Also saves the 3D position for each triplet. (Makes slower; For debug.)

void process(larcv::IOManager &iolcv, std::string wire_producer, std::string chstatus_producer, const float adc_threshold = 10.0, const bool check_wire_intersection = false)

convenience function that gets the data needed from an larcv::IOManager instance and runs the process method.

Parameters
  • iolcv: larcv::IOManager instance containing needed data objects
  • wire_producer: Name of tree containing event ADC images
  • chstatus_producer: Name of tree containing badch status
  • adc_threshold: Threshold value for pixels we will consider (typically 10.0)
  • check_wire_intersection: Check that triplet produces a good wire intersection inside the TPC. Also saves the 3D position for each triplet. (Makes slower; For debug.)

void make_truth_vector(const std::vector<larcv::Image2D> &larflow_v)

use larflow truth images to assign good versus bad match for triplets

this method populates the values for: _truth_v: 1 or 0 if triplet is a correct match _truth_2plane_v: value for all 6 flows, 1 or 0 if correct flow

There should be a value of either (1) for correct triplet and (2) for false triplet

Parameters
  • larflow_v: Vector of Image2D which contain true flow information between planes.

std::vector<TH2D> plot_sparse_images(std::string hist_stem_name)

plot the sparse image pixels in a th2d

Return
vector of TH2D that visualize the sparse images.
Parameters
  • hist_stem_name: Stem of name given to generated histograms.

std::vector<TH2D> plot_truth_images(std::string hist_stem_name)

plot truth image for debug

Return
Vector of TH2D that plots the information.
Parameters
  • hist_stem_name: Stem of name given to histograms made.

void clear()

clear the containers we fill when we run process

PyObject *make_sparse_image(int plane)

return a numpy array containing the sparse image information

Return
numpy array with shape (N,3) containing info from sparse matrix. each row contains (row,col,pixel value).
Parameters
  • plane: Plane index for sparse image requested.

PyObject *make_2plane_match_array(larflow::FlowDir_t kdir, const int max_num_samples, const std::vector<int> &idx_v, const int start_idx, const bool withtruth, int &nsamples)

return a numpy array with indices to the sparse matrix object.

use a vector with index of match pair to choose matches.

PyObject *sample_2plane_matches(larflow::FlowDir_t kdir, const int &nsamples, int &nfilled, bool withtruth)

randomly select a set of 2 plane indices

PyObject *get_chunk_2plane_matches(larflow::FlowDir_t kdir, const int &start_index, const int &max_num_pairs, int &last_index, int &num_pairs_filled, bool with_truth)

get sequential set of matches

PyObject *make_triplet_array(const int max_num_samples, const std::vector<int> &idx_v, const int start_idx, const bool withtruth, int &nsamples)

return a numpy array with indices to the sparse matrix ADC array

Return
A numpy array, with type NPY_LONG and dimensions (max_num_samples, 5) columns: [u-index,v-index,y-index,truthlabel,triplet-index]
Parameters
  • max_num_samples: Maximum number of samples to return. Dim[0] of returned array.
  • idx_v: List of triplet_v indices to use
  • start_idx: First index in idx_v to copy
  • withtruth: If true, additional element added to Dim[1] which contains if triplet is true match (1) or fals match (0).
  • nsamples: Returns the number of indices we copied.

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

randomly select a set of triplet matches

PyObject *get_chunk_triplet_matches(const int &start_index, const int &max_num_pairs, int &last_index, int &num_pairs_filled, bool with_truth)

get sequential set of triplet indices

PyObject *sample_hard_example_matches(const int &nsamples, const int &nhard_samples, PyObject *triplet_scores, int &nfilled, bool withtruth)

select sample biased towards triplets that score poorly in past iteration of network.

For hard-example training.

Public Members

std::vector<larcv::ImageMeta> _imgmeta_v

image metas for the most recently processed event

std::vector<std::vector<FlowTriples::PixData_t>> _sparseimg_vv

sparse representation of image

std::vector<std::vector<int>> _triplet_v

set of sparseimage indices indicating candidate 3-plane match (U-index,V-index,Y-index,tick)

std::vector<int> _truth_v

indicates if index set in _triple_v is true match (1) or not (0)

std::vector<std::vector<int>> _truth_2plane_v

truth vectors for 2 plane flows. inner vector is 1/0 for all 2-plane flow dirs

std::vector<float> _weight_v

assigned weight for triplet

std::vector<larflow::FlowDir_t> _flowdir_v

flow direction te triplet comes from

std::vector<float> _triarea_v

area of triangle formed by the intersection of the 3 wires. measure of 3D consistency.

std::vector<std::vector<float>> _pos_v

approx. 3d position of triplet