RayClustering.h
Go to the documentation of this file.
1 #ifndef WIRECELL_RAYCLUSTERING
2 #define WIRECELL_RAYCLUSTERING
3 
5 
6 #include <functional>
7 #include <unordered_set>
8 #include <vector>
9 
10 namespace WireCell {
11  namespace RayGrid {
12 
14  typedef typename std::vector<blobref_t> blobvec_t;
15  typedef typename std::vector<blobvec_t> blobproj_t;
16 
17  struct blobref_hash {
18  size_t operator()(blobref_t blobref) const {
19  return std::hash<int*>()((int*)&*blobref);
20  }
21  };
22  typedef typename std::unordered_set<blobref_t, blobref_hash> blobset_t;
23 
24 
25  // project blobs along rays in layer
26  blobproj_t projection(const blobvec_t& blobs, layer_index_t layer);
27 
28  // Return blobs in projection bound by the half open [ibeg,iend) range.
29  blobvec_t select(const blobproj_t& proj, grid_range_t range);
30 
31  // Return blobs in projection which overlap with blob along
32  // ray lines of given layer and all lower layers.
33  blobvec_t overlap(const blobref_t& blob, const blobproj_t& proj, layer_index_t layer);
34 
35  // Return true if a's strips are all inside b's strips or vice versa.
36  bool surrounding(const blobref_t& a, const blobref_t& b);
37 
38  // Helper to make a vector of references from the backing vector.
39  blobvec_t references(const blobs_t& blobs);
40 
41 
42  // High level API.
43 
44  typedef std::function<void(blobref_t& a, blobref_t& b)> associator_t;
45 
46  // Associate blobs from set one with blobs from set two which
47  // mutually overlap. The associator function will be called
48  // with every pair of two overlapping blobs.
49  void associate(const blobs_t& one, const blobs_t& two, associator_t func);
50 
51  }
52 }
53 
54 #endif
std::vector< blobref_t > blobvec_t
Definition: RayClustering.h:14
intermediate_table::const_iterator const_iterator
blobvec_t select(const blobproj_t &proj, grid_range_t range)
def blobs(cm, hist)
Definition: plots.py:79
std::vector< blobvec_t > blobproj_t
Definition: RayClustering.h:15
void associate(const blobs_t &one, const blobs_t &two, associator_t func)
std::function< void(blobref_t &a, blobref_t &b)> associator_t
Definition: RayClustering.h:44
std::pair< grid_index_t, grid_index_t > grid_range_t
Definition: RayGrid.h:58
blobs_t::const_iterator blobref_t
Definition: RayClustering.h:13
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
Definition: Main.h:22
std::vector< Blob > blobs_t
Definition: RayTiling.h:134
size_t operator()(blobref_t blobref) const
Definition: RayClustering.h:18
blobvec_t references(const blobs_t &blobs)
blobvec_t overlap(const blobref_t &blob, const blobproj_t &proj, layer_index_t layer)
def func()
Definition: docstring.py:7
static bool * b
Definition: config.cpp:1043
blobproj_t projection(const blobvec_t &blobs, layer_index_t layer)
bool surrounding(const blobref_t &a, const blobref_t &b)
std::unordered_set< blobref_t, blobref_hash > blobset_t
Definition: RayClustering.h:22