BlobClustering.h
Go to the documentation of this file.
1 /** Cluster blobs.
2 
3  This takes a stream of IBlobSets and mints a new ICluster on EOS
4  or earlier if a gap in time slice is found.
5 
6  It assumes each blob set represents all blobs found in one time
7  slice (including none) and that blob sets are delivered in time
8  order. Blobs in the set may span both faces of an anode plane.
9  Gaps in time between blob sets will be determined by the set's
10  slice.
11 
12  Clusters will not span a gap. Likewise, when an EOS is
13  encountered, all clusters are flushed to the output queue. If the
14  "spans" config param is 0 then no gap testing is done.
15 
16  The produced ICluster has b, w, c and s nodes.
17 
18  Note, that input blob sets and thus their blobs may be held
19  between calls (via their shared pointers).
20 
21  */
22 
23 #ifndef WIRECELLIMG_BLOBCLUSTERING
24 #define WIRECELLIMG_BLOBCLUSTERING
25 
28 #include "WireCellIface/IWire.h"
29 #include "WireCellIface/IChannel.h"
30 #include "WireCellIface/IBlob.h"
31 #include "WireCellIface/ISlice.h"
32 #include "WireCellIface/IBlobSet.h"
33 
35 #include "WireCellUtil/Logging.h"
36 
37 namespace WireCell {
38  namespace Img {
39 
40  class BlobClustering : public IClustering, public IConfigurable {
41  public:
43  virtual ~BlobClustering();
44 
45  virtual void configure(const WireCell::Configuration& cfg);
47 
48  virtual bool operator()(const input_pointer& blobset, output_queue& clusters) ;
49 
50  private:
51  // User may configure how many slices can go missing
52  // before breaking the clusters. Default is 1.0, slices
53  // must be adjacent in time or clusters will flush.
54  double m_spans;
55 
56  // for judging gap and spatial clustering.
58 
60 
61  // internal methods
62  void add_slice(const ISlice::pointer& islice);
63  void add_blobs(const input_pointer& newbs);
64 
65  // flush graph to output queue
66  void flush(output_queue& clusters);
67 
68  // Add the newbs to the graph. Return true if a flush is needed (eg, because of a gap)
69  bool graph_bs(const input_pointer& newbs);
70 
71  // return true if a gap exists between the slice of newbs and the last bs.
72  bool judge_gap(const input_pointer& newbs);
73 
74  // Blob set must be kept, this saves them.
75  void intern(const input_pointer& newbs);
76 
78  };
79  }
80 }
81 
82 #endif
virtual void configure(const WireCell::Configuration &cfg)
Accept a configuration.
std::shared_ptr< const IBlobSet > pointer
Definition: IData.h:19
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
cfg
Definition: dbjson.py:29
void add_blobs(const input_pointer &newbs)
void add_slice(const ISlice::pointer &islice)
std::deque< output_pointer > output_queue
cluster_indexed_graph_t m_grind
void intern(const input_pointer &newbs)
bool judge_gap(const input_pointer &newbs)
bool graph_bs(const input_pointer &newbs)
std::shared_ptr< spdlog::logger > logptr_t
Definition: Logging.h:24
Definition: Main.h:22
void flush(output_queue &clusters)
Json::Value Configuration
Definition: Configuration.h:50
virtual bool operator()(const input_pointer &blobset, output_queue &clusters)
The calling signature:
std::shared_ptr< const IBlobSet > input_pointer