13 using namespace WireCell::SigProc;
20 ChannelSelector::~ChannelSelector()
30 cfg[
"channels"] = Json::arrayValue;
34 cfg[
"tags"] = Json::arrayValue;
42 auto jtags = cfg[
"tags"];
43 int ntags = jtags.size();
46 for (
int ind=0; ind<ntags; ++ind) {
47 m_tags[ind] = jtags[ind].asString();
51 for (
auto jchan : cfg[
"channels"]) {
59 for(
int ch : channels) {
69 log->debug(
"ChannelSelector: sees EOS");
73 std::vector<ITrace::vector> tracesvin;
77 size_t ntags =
m_tags.size();
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();
85 tracesvin.resize(ntags);
87 ss <<
"ChannelSelector: see frame: "<<in->ident() <<
" looking for " << ntags <<
" tags:";
88 for (
size_t ind=0; ind<ntags; ++ind) {
91 ss <<
" " << tag <<
":[" << tracesvin[ind].size() <<
" traces]";
92 ntraces += tracesvin[ind].size();
97 log->warn(
"ChannelSelector: see no traces from frame {}", in->ident());
102 std::vector<IFrame::trace_list_t> tagged_trace_indices;
104 for (
size_t ind=0; ind<tracesvin.size(); ++ind) {
105 auto& traces = tracesvin[ind];
108 for (
size_t trind=0; trind < traces.size(); ++trind) {
109 auto&
trace = traces[trind];
113 tl.push_back(out_traces.size());
114 out_traces.push_back(
trace);
116 tagged_trace_indices.push_back(tl);
119 std::stringstream taginfo;
121 auto sf =
new SimpleFrame(in->ident(), in->time(), out_traces, in->tick());
123 for (
size_t ind=0; ind<ntags; ++ind) {
125 sf->tag_traces(tag, tagged_trace_indices[ind]);
126 taginfo << tag <<
" ";
129 for(
auto ftag: in->frame_tags()){
131 taginfo <<
"frame tag: " << ftag;
135 log->debug(
"ChannelSelector: producing {} traces, tags: {}",
136 out->traces()->size(), taginfo.str());
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
std::shared_ptr< const IFrame > pointer
virtual bool operator()(const input_pointer &in, output_pointer &out)
IFrameFilter interface.
std::vector< std::string > m_tags
std::unordered_set< int > m_channels
std::vector< pointer > vector
std::shared_ptr< const IFrame > input_pointer
WIRECELL_FACTORY(ChannelSelector, WireCell::SigProc::ChannelSelector, WireCell::IFrameFilter, WireCell::IConfigurable) using namespace WireCell
std::shared_ptr< const IFrame > output_pointer
logptr_t logger(std::string name)
virtual void set_channels(const std::vector< int > &channels)
void log(source_loc source, level::level_enum lvl, const char *fmt, const Args &...args)
Json::Value Configuration
std::vector< size_t > trace_list_t
virtual void configure(const WireCell::Configuration &config)
IConfigurable interface.