Public Member Functions | Private Attributes | List of all members
WireCell::SigProc::ChannelSplitter Class Reference

#include <ChannelSplitter.h>

Inheritance diagram for WireCell::SigProc::ChannelSplitter:
WireCell::IFrameFanout WireCell::IConfigurable WireCell::IFanoutNode< IFrame, IFrame, 0 > WireCell::IComponent< IConfigurable > WireCell::IFanoutNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface

Public Member Functions

 ChannelSplitter (size_t multiplicity=0)
 
virtual ~ChannelSplitter ()
 
virtual std::vector< std::stringoutput_types ()
 
virtual bool operator() (const input_pointer &in, output_vector &outv)
 
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...
 
- Public Member Functions inherited from WireCell::IFrameFanout
virtual ~IFrameFanout ()
 
virtual std::string signature ()
 
- Public Member Functions inherited from WireCell::IFanoutNode< IFrame, IFrame, 0 >
virtual ~IFanoutNode ()
 
virtual bool operator() (const boost::any &anyin, any_vector &anyv)
 The calling signature: More...
 
virtual std::vector< std::stringinput_types ()
 
- Public Member Functions inherited from WireCell::IFanoutNodeBase
virtual ~IFanoutNodeBase ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
virtual int concurrency ()
 Fanout nodes can usually do their thing stateless. More...
 
- Public Member Functions inherited from WireCell::INode
virtual ~INode ()
 
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::unordered_map< int, int > m_c2p
 
std::vector< std::stringm_tags
 
size_t m_multiplicity
 
tagrules::Context m_ft
 
Log::logptr_t log
 

Additional Inherited Members

- Public Types inherited from WireCell::IFanoutNode< IFrame, IFrame, 0 >
typedef IFrame input_type
 
typedef IFrame output_type
 
typedef std::shared_ptr< const IFrameinput_pointer
 
typedef std::shared_ptr< const IFrameoutput_pointer
 
typedef std::vector< output_pointeroutput_vector
 
- Public Types inherited from WireCell::IFanoutNodeBase
typedef std::shared_ptr< IFanoutNodeBasepointer
 
typedef std::vector< boost::any > any_vector
 
- 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 21 of file ChannelSplitter.h.

Constructor & Destructor Documentation

SigProc::ChannelSplitter::ChannelSplitter ( size_t  multiplicity = 0)

Definition at line 14 of file ChannelSplitter.cxx.

15  : m_multiplicity(multiplicity)
16  , log(Log::logger("glue"))
17 {
18 }
logptr_t logger(std::string name)
Definition: Logging.cxx:71
SigProc::ChannelSplitter::~ChannelSplitter ( )
virtual

Definition at line 19 of file ChannelSplitter.cxx.

20 {
21 }

Member Function Documentation

void SigProc::ChannelSplitter::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 38 of file ChannelSplitter.cxx.

39 {
40  m_multiplicity = 0;
41  m_c2p.clear();
42  for (auto janode : cfg["anodes"]) {
43  auto anode = Factory::find_tn<IAnodePlane>(janode.asString());
44  for (auto c : anode->channels()) {
46  }
48  }
49  if (m_c2p.empty()) {
50  THROW(ValueError() << errmsg{"ChannelSplitter must have at least one annode"});
51  }
52  m_ft.configure(cfg["tag_rules"]);
53 }
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
cfg
Definition: dbjson.py:29
#define THROW(e)
Definition: Exceptions.h:25
std::unordered_map< int, int > m_c2p
void configure(const Configuration &cfg)
Definition: TagRules.cxx:61
WireCell::Configuration SigProc::ChannelSplitter::default_configuration ( ) const
virtual

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

Reimplemented from WireCell::IConfigurable.

Definition at line 23 of file ChannelSplitter.cxx.

24 {
26 
27  // A list of anode names
28  cfg["anodes"] = Json::arrayValue;
29  // Tag rules are an array, one element per output port. Each
30  // element is an object keyed with "frame" or "trace". Each of
31  // their values are an object keyed by a regular expression
32  // (regex) and with values that are a single tag or an array of
33  // tags. See util/test_tagrules for examples.
34  cfg["tag_rules"] = Json::arrayValue;
35 
36  return cfg;
37 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool SigProc::ChannelSplitter::operator() ( const input_pointer in,
output_vector outv 
)
virtual

Implements WireCell::IFanoutNode< IFrame, IFrame, 0 >.

Definition at line 64 of file ChannelSplitter.cxx.

65 {
66  outv.resize(m_multiplicity);
67 
68  if (!in) { // pass on EOS
69  for (size_t ind=0; ind < m_multiplicity; ++ind) {
70  outv[ind] = in;
71  }
72  log->debug("ChannelSplitter: see EOS");
73  return true;
74  }
75 
76  std::vector<ITrace::vector> port_traces(m_multiplicity);
77 
78  for (const auto& itrace : *(in->traces())) {
79  int chan = itrace->channel();
80  const auto& it = m_c2p.find(chan);
81  if (it == m_c2p.end()) {
82  log->debug("ChannelSplitter: no port for channel {}, dropping", chan);
83  continue;
84  }
85  const int port = it->second;
86  port_traces[port].push_back(itrace);
87  }
88 
89  auto fintags = in->frame_tags();
90  std::stringstream taginfo;
91  for (size_t iport=0; iport<m_multiplicity; ++iport) {
92 
93  // Basic frame stays the same.
94  auto sfout = new SimpleFrame(in->ident(), in->time(), port_traces[iport], in->tick());
95 
96  // Transform any frame tags based on a per output port ruleset
97  auto fouttags = m_ft.transform(iport, "frame", fintags);
98 
99  for (auto ftag : fouttags) {
100  sfout->tag_frame(ftag);
101  taginfo << " ftag:" << ftag;
102  }
103 
104  for (auto inttag : in->trace_tags()) {
105  tagrules::tagset_t touttags = m_ft.transform(iport, "trace", inttag);
106  if (touttags.empty()) {
107  continue;
108  }
109  const auto& traces = in->tagged_traces(inttag);
110  const auto& summary = in->trace_summary(inttag);
111  for (auto otag : touttags) {
112  sfout->tag_traces(otag, traces, summary);
113  taginfo << " " << inttag << "->" << otag;
114  }
115  };
116 
117  outv[iport] = IFrame::pointer(sfout);
118  }
119 
120  std::string tagmsg = taginfo.str();
121  if (!tagmsg.empty()) {
122  log->debug("ChannelSplitter: tagnifo:{}", taginfo.str());
123  }
124  return true;
125 }
std::shared_ptr< const IFrame > pointer
Definition: IData.h:19
std::unordered_set< tag_t > tagset_t
Definition: TagRules.h:48
std::string string
Definition: nybbler.cc:12
tagset_t transform(size_t ind, const std::string &name, const tag_t &tag)
Definition: TagRules.cxx:80
def summary(store)
Definition: info.py:119
std::unordered_map< int, int > m_c2p
std::vector< std::string > SigProc::ChannelSplitter::output_types ( )
virtual

Implements WireCell::IFrameFanout.

Definition at line 56 of file ChannelSplitter.cxx.

57 {
58  const std::string tname = std::string(typeid(output_type).name());
59  std::vector<std::string> ret(m_multiplicity, tname);
60  return ret;
61 }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12

Member Data Documentation

Log::logptr_t WireCell::SigProc::ChannelSplitter::log
private

Definition at line 42 of file ChannelSplitter.h.

std::unordered_map<int, int> WireCell::SigProc::ChannelSplitter::m_c2p
private

Definition at line 38 of file ChannelSplitter.h.

tagrules::Context WireCell::SigProc::ChannelSplitter::m_ft
private

Definition at line 41 of file ChannelSplitter.h.

size_t WireCell::SigProc::ChannelSplitter::m_multiplicity
private

Definition at line 40 of file ChannelSplitter.h.

std::vector<std::string> WireCell::SigProc::ChannelSplitter::m_tags
private

Definition at line 39 of file ChannelSplitter.h.


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