Class PrepAffinityField¶
- Defined in File PrepAffinityField.h
Class Documentation¶
-
class
PrepAffinityField
: public larcv_base¶ prepare training data for affinity field
This class creates the training data for the particle direction task of the network. This output is inspired by the “Part Affinity Field” output of the OpenPose network.
For each proposed space point, we want the network to produce the following output:
- For a true space point that was made by a track-like particle, we want the output to be a 3D vector giving the direction of the particle at that point of its trajectory
- For a true space point that was made by a shower-like particle, we want the output to be the initial direction of the shower. As a result, the direction would be the same for all space points that were a part of the same shower
- For a ghost-point, we want the vector to be (0,0,0).
This class will store the data into a ROOT tree (inside a ROOT file), name
AffinityFieldTree
. It will consist of a nested vector. The outer vector is over all proposed space points made by larflow::prep::PrepMatchTriplets for an event. The inner vector is the 3D truth vector we will train the network to output.Usage: (to do)
Public Functions
-
PrepAffinityField
()¶ default constructor
-
~PrepAffinityField
()¶ default destructor
-
void
process
(larcv::IOManager &iolcv, larlite::storage_manager &ioll, const larflow::prep::PrepMatchTriplets &match_proposals)¶ goal is to define a direction vector for every triplet proposal
for each triplet spacepoint, if good, then we project into image, get instance ID. Then if track, we find the truth mcstep segment the point is closest to to extract the direction. For showers, we find the initial detector profile direction and use that for the label.
for many pixels/triplets, we will probably fail to produce a ground truth value. we weight the contribution of these to the loss function as zero and prepare a weight in addition to the ground truth label.
- Parameters
iolcv
: LArCV IOManager containing the event dataioll
: larlite storage_manager containing the event datamatch_proposals
: copy of larflow::prep::PrepMatchTriplets containing the proposed space points for the event, along with labels for which points are true or are ghosts.
-
void
defineAnaTree
()¶ make the output tree where will store the labels
-
void
fillAnaTree
()¶ fill the output tree with the values for the current entry
-
void
writeAnaTree
()¶ write output tree to the output file
Protected Functions
-
void
_determine_triplet_labels
(const std::vector<std::vector<int>> &pixlist_v, const std::vector<float> &spacepoint_v, const std::vector<larcv::Image2D> &instance_v, const larlite::event_mctrack &ev_mctrack_v, const larlite::event_mcshower &ev_mcshower_v, std::vector<float> &label_v, float &weight)¶ make truth direction vector for all space points
For each space point we create a vector<float> with the following contents
- [0-2]: 3D direction
- [3-8]: 3 planes x 2D direction (projected direction in the wire planes)
- [9]: instance id
- Parameters
pixlist_v
: list of pixel coordinates (row,col) for each image (outer vector) for pixels with values above thresholdspacepoint_v
: given 3D space point we are making the direction label forinstance_v
: vector of larcv::Image2D, one for each plane, where each pixel stores the MC ID of the particle that made the most charge within that pixel.ev_mctrack_v
: container holding larlite::mctrack objects, which store the trajectory of the simulated track-like particlesev_mcshower_v
: container holding larlite::mcshower objects, which store the true start direction of simulated shower-like particleslabel_v
: the 3D direction for the space pointweight
: the weight calculated for this point. [unused]
-
bool
_get_track_direction
(const larlite::mctrack &track, const std::vector<double> &pt, const std::vector<larcv::Image2D> &img_v, std::vector<float> &label_v, float &weight)¶ use truth trajectory information from the simulation to get the direction label for a space point
- Parameters
track
: larlite::mctrack instance with the true trajectory of the track particlept
: the space point for which we want to know the assign a ground truth directionimg_v
: vector of wire plane imageslabel_v
: Assigned 3D directionweight
: Assigned weight for this space point. [unused]
-
bool
_get_shower_direction
(const larlite::mcshower &shower, const std::vector<double> &pt, const std::vector<larcv::Image2D> &img_v, std::vector<float> &label_v, float &weight)¶ use truth information from the simulation to get the direction label for a showering particle space point
- Parameters
shower
: larlite::mcshower instance with the truth information about the showerpt
: the space point for which we want to know the assign a ground truth directionimg_v
: vector of wire plane imageslabel_v
: Assigned 3D directionweight
: Assigned weight for this space point. [unused]
Protected Attributes
-
int
_run
¶ run ID number for an event (saved in the output tree
AffinityFieldTree
)
-
int
_subrun
¶ subrun ID number for an event (saved in the output tree
AffinityFieldTree
)
-
int
_event
¶ event ID number for an event (saved in the output tree
AffinityFieldTree
)
-
TTree *
_label_tree
¶ the tree that will store the labels. Named
AffinityFieldTree
in the ROOT file.
-
larutil::SpaceChargeMicroBooNE *
psce
¶ pointer to a copy of the space charge calculation utility class
-
std::vector<std::vector<float>>
_match_labels_v
¶ container holding the calculated direction labels for the current event