Public Member Functions | Private Attributes | List of all members
WireCell::Img::ClusterSink Class Reference

#include <ClusterSink.h>

Inheritance diagram for WireCell::Img::ClusterSink:
WireCell::IClusterSink WireCell::IConfigurable WireCell::ISinkNode< ICluster > WireCell::IComponent< IConfigurable > WireCell::ISinkNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface

Public Member Functions

 ClusterSink ()
 
virtual ~ClusterSink ()
 
virtual void configure (const WireCell::Configuration &cfg)
 Accept a configuration. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
virtual bool operator() (const ICluster::pointer &cluster)
 The calling signature: More...
 
- Public Member Functions inherited from WireCell::IClusterSink
virtual ~IClusterSink ()
 
virtual std::string signature ()
 
- Public Member Functions inherited from WireCell::ISinkNode< ICluster >
virtual ~ISinkNode ()
 
virtual bool operator() (const boost::any &anyin)
 
virtual std::vector< std::stringinput_types ()
 
- Public Member Functions inherited from WireCell::ISinkNodeBase
virtual ~ISinkNodeBase ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
- Public Member Functions inherited from WireCell::INode
virtual ~INode ()
 
virtual int concurrency ()
 
virtual std::vector< std::stringoutput_types ()
 
virtual void reset ()
 
- Public Member Functions inherited from WireCell::IComponent< INode >
virtual ~IComponent ()
 
- Public Member Functions inherited from WireCell::Interface
virtual ~Interface ()
 
- Public Member Functions inherited from WireCell::IConfigurable
virtual ~IConfigurable ()
 
- Public Member Functions inherited from WireCell::IComponent< IConfigurable >
virtual ~IComponent ()
 

Private Attributes

std::string m_filename
 
std::string m_node_types
 

Additional Inherited Members

- Public Types inherited from WireCell::IClusterSink
typedef std::shared_ptr< IClusterSinkpointer
 
- Public Types inherited from WireCell::ISinkNode< ICluster >
typedef ICluster input_type
 
typedef std::shared_ptr< const IClusterinput_pointer
 
- Public Types inherited from WireCell::ISinkNodeBase
typedef std::shared_ptr< ISinkNodeBasepointer
 
- Public Types inherited from WireCell::INode
enum  NodeCategory {
  unknown, sourceNode, sinkNode, functionNode,
  queuedoutNode, joinNode, splitNode, faninNode,
  fanoutNode, multioutNode, hydraNode
}
 
- Public Types inherited from WireCell::IComponent< INode >
typedef std::shared_ptr< INodepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 
- Public Types inherited from WireCell::Interface
typedef std::shared_ptr< Interfacepointer
 
- Public Types inherited from WireCell::IComponent< IConfigurable >
typedef std::shared_ptr< IConfigurablepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 

Detailed Description

Definition at line 12 of file ClusterSink.h.

Constructor & Destructor Documentation

Img::ClusterSink::ClusterSink ( )

Definition at line 19 of file ClusterSink.cxx.

20  : m_filename("")
21  , m_node_types("bsm")
22 {
23 }
Img::ClusterSink::~ClusterSink ( )
virtual

Definition at line 25 of file ClusterSink.cxx.

26 {
27 }

Member Function Documentation

void Img::ClusterSink::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 29 of file ClusterSink.cxx.

30 {
31  m_filename = get(cfg, "filename", m_filename);
32  m_node_types = get(cfg, "node_types", m_node_types);
33 }
cfg
Definition: dbjson.py:29
WireCell::Configuration Img::ClusterSink::default_configuration ( ) const
virtual

Optional, override to return a hard-coded default configuration.

Reimplemented from WireCell::IConfigurable.

Definition at line 35 of file ClusterSink.cxx.

36 {
38  cfg["filename"] = m_filename;
39 
40  // A string with any of characters "wcbsm". Including wires and
41  // channels tends to make a crazy big plot so by default they are
42  // excluded.
43  cfg["node_types"] = m_node_types;
44  return cfg;
45 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool Img::ClusterSink::operator() ( const ICluster::pointer in)
virtual

The calling signature:

Implements WireCell::ISinkNode< ICluster >.

Definition at line 98 of file ClusterSink.cxx.

99 {
100  if (!cluster) {
101  return true;
102  }
103 
105  if (fname.empty()) {
106  return true;
107  }
108 
109  if (m_filename.find("%") != std::string::npos) {
110  fname = String::format(m_filename, cluster->ident());
111  }
112  std::ofstream out(fname.c_str());
113  spdlog::info("Writing graphviz to {}", fname);
114 
115  std::unordered_set<char> keep(m_node_types.begin(), m_node_types.end());
116 
117  // use indexed graph basically just for the copy()
118  const cluster_graph_t& gr = cluster->graph();
120 
121  for (const auto& v : boost::make_iterator_range(boost::vertices(gr))) {
122  const auto& vobj = gr[v];
123  if (!keep.count(vobj.code())) {
124  continue;
125  }
126  grind.vertex(vobj);
127  for (auto edge : boost::make_iterator_range(boost::out_edges(v, gr))) {
128  auto v2 = boost::target(edge, gr);
129  const auto& vobj2 = gr[v2];
130  if (keep.count(vobj2.code())) {
131  grind.edge(vobj, vobj2);
132  }
133  }
134  }
135  const cluster_graph_t& gr2 = grind.graph();
136  boost::write_graphviz(out, gr2, label_writer_t{gr2});
137 
138  return true;
139 }
IndexedGraph< cluster_node_t > cluster_indexed_graph_t
Definition: ICluster.h:105
void info(const char *fmt, const Args &...args)
Definition: spdlog.h:189
std::string string
Definition: nybbler.cc:12
Cluster finding and building.
std::pair< int, int > edge(const realseq_t &wave)
Definition: Waveform.cxx:121
boost::adjacency_list< boost::setS, boost::vecS, boost::undirectedS, cluster_node_t > cluster_graph_t
Definition: ICluster.h:87
std::string format(const std::string &form, TYPES...objs)
Definition: String.h:45

Member Data Documentation

std::string WireCell::Img::ClusterSink::m_filename
private

Definition at line 22 of file ClusterSink.h.

std::string WireCell::Img::ClusterSink::m_node_types
private

Definition at line 23 of file ClusterSink.h.


The documentation for this class was generated from the following files: