6 #include <boost/graph/graph_traits.hpp> 7 #include <boost/graph/adjacency_list.hpp> 8 #include <boost/graph/connected_components.hpp> 35 m_gap =
get(
cfg,
"gap", 1);
50 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> graph_t;
51 typedef boost::graph_traits<graph_t>::vertex_descriptor vertex_t;
59 std::unordered_map<IWire::pointer, IChannel::pointer> wire_to_chan;
60 std::unordered_map<IChannel::pointer, vertex_t> chan_to_node;
61 std::unordered_map<vertex_t, ISlice::pair_t> node_to_chanval;
62 std::unordered_map<int, IWireIndexSet> hit_wires;
65 for (
const auto& cv : slice->activity()) {
66 auto ichan = cv.first;
67 auto node = boost::add_vertex(graph);
68 chan_to_node[ichan] = node;
69 node_to_chanval[node] = cv;
70 for (
auto iwire : ichan->wires()) {
71 const auto pid = iwire->planeid();
72 hit_wires[
pid.ident()].insert(iwire);
73 wire_to_chan[iwire] = ichan;
78 for (
const auto& phw : hit_wires) {
80 vertex_t last_wire = 0;
81 for (
auto iwire : phw.second) {
82 auto ichan = wire_to_chan[iwire];
83 vertex_t chan_node = chan_to_node[ichan];
84 vertex_t wire_node = boost::add_vertex(graph);
85 const int this_index = iwire->index();
88 boost::add_edge(chan_node, wire_node, graph);
90 const size_t dind = this_index - last_ind;
91 if (last_ind >= 0 and dind <= m_gap) {
92 boost::add_edge(last_wire, wire_node, graph);
94 last_ind = this_index;
95 last_wire = wire_node;
103 std::unordered_map<vertex_t, int> subclusters;
104 std::unordered_map<int, Img::Data::Stripe*> cluster_to_stripe;
105 boost::connected_components(graph, boost::make_assoc_property_map(subclusters));
108 for (
auto&
p : subclusters) {
109 auto ncvit = node_to_chanval.find(
p.first);
110 if (ncvit == node_to_chanval.end()) {
113 auto& cv = ncvit->second;
114 auto stripe = cluster_to_stripe[
p.second];
118 stripe->append(cv.first, cv.second);
122 for (
auto ss : cluster_to_stripe) {
std::shared_ptr< const IStripe > pointer
def graph(desc, maker=maker)
std::shared_ptr< const ISlice > input_pointer
WIRECELL_FACTORY(NaiveStriper, WireCell::Img::NaiveStriper, WireCell::ISliceStriper, WireCell::IConfigurable) using namespace WireCell
void push_back(const IStripe::pointer &s)
std::shared_ptr< const IStripeSet > output_pointer
Json::Value Configuration
const GenericPointer< typename T::ValueType > & pointer