.. _program_listing_file_larflow_PrepFlowMatchData_FlowMatchHitMaker.h: Program Listing for File FlowMatchHitMaker.h ============================================ |exhale_lsh| :ref:`Return to documentation for file ` (``larflow/PrepFlowMatchData/FlowMatchHitMaker.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef __FLOW_MATCH_HIT_MAKER_H__ #define __FLOW_MATCH_HIT_MAKER_H__ #include #include "bytesobject.h" #include #include #include #include "larcv/core/DataFormat/EventChStatus.h" #include "core/DataFormat/larflow3dhit.h" #include "larcv/core/DataFormat/ImageMeta.h" #include "larcv/core/DataFormat/Image2D.h" namespace larflow { namespace prep { class FlowMatchHitMaker { public: FlowMatchHitMaker() : _match_score_threshold(0.5), has_ssnet_scores(false), has_kplabel_scores(false), has_paf(false) {}; virtual ~FlowMatchHitMaker() {}; struct match_t { int Y; int U; int V; float YU; float YV; float UV; float UY; float VU; float VY; std::array tyz; std::vector ssnet_scores; std::vector keypoint_scores; std::vector paf; int istruth; match_t() : Y(0),U(0),V(0), YU(0),YV(0),UV(0),UY(0),VU(0),VY(0), keypoint_scores( std::vector(3,0) ), paf( std::vector(3,0) ), istruth(0) {}; bool operator<(const match_t& rhs) const { if (YYU ) YU = prob; else if ( target_plane==1 && prob>YV ) YV = prob; } else if ( source_plane==1 ) { if ( target_plane==0 && prob>VU ) VU = prob; else if ( target_plane==2 && prob>VY ) VY = prob; } else if ( source_plane==0 ) { if ( target_plane==1 && prob>UV ) UV = prob; else if ( target_plane==2 && prob>UY ) UY = prob; }; }; std::vector get_scores() const { std::vector s(6,0); s[0] = YU; s[1] = YV; s[2] = UV; s[3] = UY; s[4] = VU; s[5] = VY; return s; }; }; float _match_score_threshold; std::vector _matches_v; std::map< std::vector, int > _match_map; bool has_ssnet_scores; bool has_kplabel_scores; bool has_paf; void clear() { _matches_v.clear(); _match_map.clear(); has_ssnet_scores=false; has_kplabel_scores=false; has_paf=false; }; int add_match_data( PyObject* pair_probs, PyObject* source_sparseimg, PyObject* target_sparseimg, PyObject* matchpairs, const int source_plane, const int target_plane, const larcv::ImageMeta& source_meta, const std::vector& img_v, const larcv::EventChStatus& ev_chstatus ); void set_score_threshold( float score ) { _match_score_threshold = score; }; int add_triplet_match_data( PyObject* triple_probs, PyObject* triplet_indices, PyObject* sparseimg_u, PyObject* sparseimg_v, PyObject* sparseimg_y, const std::vector< std::vector >& pos_vv, const std::vector& adc_v ); int add_triplet_ssnet_scores( PyObject* triplet_indices, PyObject* sparseimg_u, PyObject* sparseimg_v, PyObject* sparseimg_y, const larcv::ImageMeta& meta, PyObject* ssnet_scores ); int add_triplet_keypoint_scores( PyObject* triplet_indices, PyObject* sparseimg_u, PyObject* sparseimg_v, PyObject* sparseimg_y, const larcv::ImageMeta& meta, PyObject* kplabel_scores ); int add_triplet_affinity_field( PyObject* triplet_indices, PyObject* imgu_sparseimg, PyObject* imgv_sparseimg, PyObject* imgy_sparseimg, const larcv::ImageMeta& meta, PyObject* paf_pred ); void make_hits( const larcv::EventChStatus& ev_chstatus, std::vector& hit_v ) const; }; } } #endif