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

#include <ChannelSelector.h>

Inheritance diagram for WireCell::SigProc::ChannelSelector:
WireCell::IFrameFilter WireCell::IConfigurable WireCell::IFunctionNode< IFrame, IFrame > WireCell::IComponent< IConfigurable > WireCell::IFunctionNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface WireCell::SigProc::DBChannelSelector

Public Member Functions

 ChannelSelector ()
 
virtual ~ChannelSelector ()
 
virtual bool operator() (const input_pointer &in, output_pointer &out)
 IFrameFilter interface. More...
 
virtual void configure (const WireCell::Configuration &config)
 IConfigurable interface. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
- Public Member Functions inherited from WireCell::IFrameFilter
virtual ~IFrameFilter ()
 
virtual std::string signature ()
 Set the signature for all subclasses. More...
 
- Public Member Functions inherited from WireCell::IFunctionNode< IFrame, IFrame >
virtual ~IFunctionNode ()
 
virtual bool operator() (const boost::any &anyin, boost::any &anyout)
 The calling signature: More...
 
virtual std::vector< std::stringinput_types ()
 
virtual std::vector< std::stringoutput_types ()
 
- Public Member Functions inherited from WireCell::IFunctionNodeBase
virtual ~IFunctionNodeBase ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
virtual int concurrency ()
 By default assume all subclasses are 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 ()
 

Protected Member Functions

virtual void set_channels (const std::vector< int > &channels)
 

Private Attributes

std::vector< std::stringm_tags
 
std::unordered_set< int > m_channels
 
Log::logptr_t log
 

Additional Inherited Members

- Public Types inherited from WireCell::IFrameFilter
typedef std::shared_ptr< IFrameFilterpointer
 
- Public Types inherited from WireCell::IFunctionNode< IFrame, IFrame >
typedef IFrame input_type
 
typedef IFrame output_type
 
typedef std::shared_ptr< const IFrameinput_pointer
 
typedef std::shared_ptr< const IFrameoutput_pointer
 
typedef IFunctionNode< IFrame, IFramesignature_type
 
- Public Types inherited from WireCell::IFunctionNodeBase
typedef std::shared_ptr< IFunctionNodeBasepointer
 
- 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 20 of file ChannelSelector.h.

Constructor & Destructor Documentation

ChannelSelector::ChannelSelector ( )

Definition at line 15 of file ChannelSelector.cxx.

16  : log(Log::logger("glue"))
17 {
18 }
logptr_t logger(std::string name)
Definition: Logging.cxx:71
ChannelSelector::~ChannelSelector ( )
virtual

Definition at line 20 of file ChannelSelector.cxx.

21 {
22 }

Member Function Documentation

void ChannelSelector::configure ( const WireCell::Configuration config)
virtual

IConfigurable interface.

Implements WireCell::IConfigurable.

Reimplemented in WireCell::SigProc::DBChannelSelector.

Definition at line 39 of file ChannelSelector.cxx.

40 {
41  // tags need some order
42  auto jtags = cfg["tags"];
43  int ntags = jtags.size();
44  m_tags.clear();
45  m_tags.resize(ntags);
46  for (int ind=0; ind<ntags; ++ind) {
47  m_tags[ind] = jtags[ind].asString();
48  }
49 
50  // channels are just a bag
51  for (auto jchan : cfg["channels"]) {
52  m_channels.insert(jchan.asInt());
53  }
54 }
std::vector< std::string > m_tags
std::unordered_set< int > m_channels
cfg
Definition: dbjson.py:29
WireCell::Configuration ChannelSelector::default_configuration ( ) const
virtual

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

Only traces with channels in this array will be in the output.

Only traces with these tags will be in the output. If no tags are given then tags are not considered.

Reimplemented from WireCell::IConfigurable.

Reimplemented in WireCell::SigProc::DBChannelSelector.

Definition at line 25 of file ChannelSelector.cxx.

26 {
28 
29  /// Only traces with channels in this array will be in the output.
30  cfg["channels"] = Json::arrayValue;
31 
32  /// Only traces with these tags will be in the output. If no tags
33  /// are given then tags are not considered.
34  cfg["tags"] = Json::arrayValue;
35 
36  return cfg;
37 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool ChannelSelector::operator() ( const input_pointer in,
output_pointer out 
)
virtual

IFrameFilter interface.

Implements WireCell::IFunctionNode< IFrame, IFrame >.

Reimplemented in WireCell::SigProc::DBChannelSelector.

Definition at line 65 of file ChannelSelector.cxx.

66 {
67  out = nullptr;
68  if (!in) {
69  log->debug("ChannelSelector: sees EOS");
70  return true; // eos
71  }
72 
73  std::vector<ITrace::vector> tracesvin;
74 
75  size_t ntraces = 0;
76 
77  size_t ntags = m_tags.size();
78  if (!ntags) {
79  tracesvin.push_back(FrameTools::untagged_traces(in));
80  log->debug("ChannelSelector: see frame: {} no tags, whole frame ({} traces out of {})",
81  in->ident(), tracesvin.back().size(), in->traces()->size());
82  ntraces += tracesvin[0].size();
83  }
84  else {
85  tracesvin.resize(ntags);
86  std::stringstream ss;
87  ss << "ChannelSelector: see frame: "<<in->ident() << " looking for " << ntags << " tags:";
88  for (size_t ind=0; ind<ntags; ++ind) {
89  std::string tag = m_tags[ind];
90  tracesvin[ind] = FrameTools::tagged_traces(in, tag);
91  ss << " " << tag << ":[" << tracesvin[ind].size() << " traces]";
92  ntraces += tracesvin[ind].size();
93  }
94  log->debug(ss.str());
95  }
96  if (!ntraces) {
97  log->warn("ChannelSelector: see no traces from frame {}", in->ident());
98  }
99 
100 
101  ITrace::vector out_traces;
102  std::vector<IFrame::trace_list_t> tagged_trace_indices;
103 
104  for (size_t ind=0; ind<tracesvin.size(); ++ind) {
105  auto& traces = tracesvin[ind];
106 
108  for (size_t trind=0; trind < traces.size(); ++trind) {
109  auto& trace = traces[trind];
110  if (m_channels.find(trace->channel()) == m_channels.end()) {
111  continue;
112  }
113  tl.push_back(out_traces.size());
114  out_traces.push_back(trace);
115  }
116  tagged_trace_indices.push_back(tl);
117  }
118 
119  std::stringstream taginfo;
120 
121  auto sf = new SimpleFrame(in->ident(), in->time(), out_traces, in->tick());
122  if (ntags) {
123  for (size_t ind=0; ind<ntags; ++ind) {
124  std::string tag = m_tags[ind];
125  sf->tag_traces(tag, tagged_trace_indices[ind]);
126  taginfo << tag << " ";
127  }
128  }
129  for(auto ftag: in->frame_tags()){
130  sf->tag_frame(ftag);
131  taginfo << "frame tag: " << ftag;
132  }
133 
134  out = IFrame::pointer(sf);
135  log->debug("ChannelSelector: producing {} traces, tags: {}",
136  out->traces()->size(), taginfo.str());
137 
138  return true;
139 }
ITrace::vector tagged_traces(IFrame::pointer frame, IFrame::tag_t tag)
Definition: FrameTools.cxx:111
std::shared_ptr< const IFrame > pointer
Definition: IData.h:19
std::string string
Definition: nybbler.cc:12
std::vector< std::string > m_tags
std::unordered_set< int > m_channels
std::vector< pointer > vector
Definition: IData.h:21
ITrace::vector untagged_traces(IFrame::pointer frame)
Definition: FrameTools.cxx:90
std::vector< size_t > trace_list_t
Definition: IFrame.h:36
void ChannelSelector::set_channels ( const std::vector< int > &  channels)
protectedvirtual

Definition at line 56 of file ChannelSelector.cxx.

57 {
58  m_channels.clear();
59  for(int ch : channels) {
60  m_channels.insert(ch);
61  }
62 }
std::unordered_set< int > m_channels

Member Data Documentation

Log::logptr_t WireCell::SigProc::ChannelSelector::log
private

Definition at line 40 of file ChannelSelector.h.

std::unordered_set<int> WireCell::SigProc::ChannelSelector::m_channels
private

Definition at line 38 of file ChannelSelector.h.

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

Definition at line 37 of file ChannelSelector.h.


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