Public Member Functions | Private Attributes | List of all members
WireCell::Gen::FrameFanout Class Reference

#include <FrameFanout.h>

Inheritance diagram for WireCell::Gen::FrameFanout:
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

 FrameFanout (size_t multiplicity=0)
 
virtual ~FrameFanout ()
 
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

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 13 of file FrameFanout.h.

Constructor & Destructor Documentation

Gen::FrameFanout::FrameFanout ( size_t  multiplicity = 0)

Definition at line 13 of file FrameFanout.cxx.

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

Definition at line 18 of file FrameFanout.cxx.

19 {
20 }

Member Function Documentation

void Gen::FrameFanout::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 35 of file FrameFanout.cxx.

36 {
37  int m = get<int>(cfg, "multiplicity", (int)m_multiplicity);
38  if (m<=0) {
39  THROW(ValueError() << errmsg{"FrameFanout multiplicity must be positive"});
40  }
41  m_multiplicity = m;
42 
43  m_ft.configure(cfg["tag_rules"]);
44 }
static const double m
Definition: Units.h:79
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
tagrules::Context m_ft
Definition: FrameFanout.h:31
void configure(const Configuration &cfg)
Definition: TagRules.cxx:61
WireCell::Configuration Gen::FrameFanout::default_configuration ( ) const
virtual

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

Reimplemented from WireCell::IConfigurable.

Definition at line 22 of file FrameFanout.cxx.

23 {
25  // How many output ports
26  cfg["multiplicity"] = (int)m_multiplicity;
27  // Tag rules are an array, one element per output port. Each
28  // element is an object keyed with "frame" or "trace". Each of
29  // their values are an object keyed by a regular expression
30  // (regex) and with values that are a single tag or an array of
31  // tags. See util/test_tagrules for examples.
32  cfg["tag_rules"] = Json::arrayValue;
33  return cfg;
34 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool Gen::FrameFanout::operator() ( const input_pointer in,
output_vector outv 
)
virtual

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

Definition at line 55 of file FrameFanout.cxx.

56 {
57  outv.resize(m_multiplicity);
58 
59  if (!in) { // pass on EOS
60  for (size_t ind=0; ind<m_multiplicity; ++ind) {
61  outv[ind] = in;
62  }
63  log->debug("FrameFanout: see EOS");
64  return true;
65  }
66 
67  auto fintags = in->frame_tags();
68  // Add empty tag to allow rules to create an output tag even if none exist.
69  // No equivalent should be made for trace tags.
70  fintags.push_back("");
71 
72 
73  std::stringstream taginfo;
74 
75  for (size_t ind=0; ind<m_multiplicity; ++ind) {
76 
77  // Basic frame stays the same.
78  auto sfout = new SimpleFrame(in->ident(), in->time(), *in->traces(), in->tick());
79 
80  // Transform any frame tags based on a per output port ruleset
81  auto fouttags = m_ft.transform(ind, "frame", fintags);
82 
83  for (auto ftag : fouttags) {
84  sfout->tag_frame(ftag);
85  taginfo << " ftag:" << ftag;
86  }
87 
88  for (auto inttag : in->trace_tags()) {
89  tagrules::tagset_t touttags = m_ft.transform(ind, "trace", inttag);
90  if (touttags.empty()) {
91  continue;
92  }
93  const auto& traces = in->tagged_traces(inttag);
94  const auto& summary = in->trace_summary(inttag);
95  for (auto otag : touttags) {
96  sfout->tag_traces(otag, traces, summary);
97  taginfo << " " << inttag << "->" << otag;
98  }
99  };
100 
101  outv[ind] = IFrame::pointer(sfout);
102  }
103 
104  std::string tagmsg = taginfo.str();
105  if (!tagmsg.empty()) {
106  log->debug("FrameFanout: tagnifo:{}", taginfo.str());
107  }
108  return true;
109 }
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
tagrules::Context m_ft
Definition: FrameFanout.h:31
def summary(store)
Definition: info.py:119
std::vector< std::string > Gen::FrameFanout::output_types ( )
virtual

Implements WireCell::IFrameFanout.

Definition at line 47 of file FrameFanout.cxx.

48 {
49  const std::string tname = std::string(typeid(output_type).name());
50  std::vector<std::string> ret(m_multiplicity, tname);
51  return ret;
52 }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12

Member Data Documentation

Log::logptr_t WireCell::Gen::FrameFanout::log
private

Definition at line 32 of file FrameFanout.h.

tagrules::Context WireCell::Gen::FrameFanout::m_ft
private

Definition at line 31 of file FrameFanout.h.

size_t WireCell::Gen::FrameFanout::m_multiplicity
private

Definition at line 29 of file FrameFanout.h.


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