BlobGrouping.cxx
Go to the documentation of this file.
2 
4 
6 
7 #include <boost/graph/connected_components.hpp>
8 
11 
12 using namespace WireCell;
13 
15 
17 {
18 }
19 
20 Img::BlobGrouping::~BlobGrouping()
21 {
22 }
23 
25 {
26 }
27 
28 WireCell::Configuration Img::BlobGrouping::default_configuration() const
29 {
31  return cfg;
32 }
33 
34 
35 
36 static
38  const cluster_indexed_graph_t& grind,
39  IBlob::pointer iblob)
40 {
41  cluster_node_t nblob{iblob};
42 
43  for (auto wvtx : grind.neighbors(nblob)) {
44  if (wvtx.code() != 'w') {
45  continue;
46  }
47  auto iwire = std::get<IWire::pointer>(wvtx.ptr);
48  auto layer = iwire->planeid().layer();
49  auto& lg = lgs[layer];
50 
51  for (auto cvtx : grind.neighbors(wvtx)) {
52  if (cvtx.code() != 'c') {
53  continue;
54  }
55  //auto ich = std::get<IChannel::pointer>(cvtx.ptr);
56  lg.edge(nblob, cvtx);
57  }
58  }
59 }
60 
61 
62 static
64  ISlice::pointer islice)
65 {
66  layer_graphs_t lgs;
67 
68  for (auto other : grind.neighbors(islice)) {
69  if (other.code() != 'b') {
70  continue;
71  }
72  IBlob::pointer iblob = std::get<IBlob::pointer>(other.ptr);
73  fill_blob(lgs, grind, iblob);
74  }
75 
76  for (auto lgit : lgs) {
77  auto& lgrind = lgit.second;
78  auto groups = lgrind.groups();
79  for (auto& group : groups) {
80  // add a "measurement" to the graph
82  IChannel::shared_vector imeas = IChannel::shared_vector(chans);
83 
84  for (auto& v : group.second) {
85  if (v.code() == 'b') {
86  // (b-m)
87  grind.edge(v.ptr, imeas);
88  continue;
89  }
90  if (v.code() == 'c') {
91  // (c-m)
92  grind.edge(v.ptr, imeas);
93  chans->push_back(std::get<IChannel::pointer>(v.ptr));
94  continue;
95  }
96  }
97  }
98  }
99 }
100 
101 
102 bool Img::BlobGrouping::operator()(const input_pointer& in, output_pointer& out)
103 {
104  if (!in) {
105  out = nullptr;
106  return true;
107  }
108 
109  cluster_indexed_graph_t grind(in->graph());
110 
111  for (auto islice : oftype<ISlice::pointer>(grind)) {
112  fill_slice(grind, islice);
113  }
114 
115  out = std::make_shared<SimpleCluster>(grind.graph());
116  return true;
117 }
118 
IndexedGraph< cluster_node_t > cluster_indexed_graph_t
Definition: ICluster.h:105
WIRECELL_FACTORY(BlobGrouping, WireCell::Img::BlobGrouping, WireCell::IClusterFilter, WireCell::IConfigurable) using namespace WireCell
struct vector vector
STL namespace.
cfg
Definition: dbjson.py:29
static void fill_slice(cluster_indexed_graph_t &grind, ISlice::pointer islice)
std::shared_ptr< const ICluster > input_pointer
Definition: IFunctionNode.h:39
static void fill_blob(layer_graphs_t &lgs, const cluster_indexed_graph_t &grind, IBlob::pointer iblob)
def configure(cfg)
Definition: cuda.py:34
char * lg(uint32_t n, Handler h) FMT_ALWAYS_INLINE
Definition: format.h:832
std::shared_ptr< const ICluster > output_pointer
Definition: IFunctionNode.h:40
Definition: Main.h:22
std::unordered_map< WirePlaneLayer_t, cluster_indexed_graph_t > layer_graphs_t
Json::Value Configuration
Definition: Configuration.h:50
WirePlaneLayer_t
Enumerate layer IDs. These are not indices!
Definition: WirePlaneId.h:13
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1124