29 cfg[
"mergemap"] = Json::arrayValue;
39 cfg[
"rule"] =
"replace";
54 auto one = std::get<0>(intup);
55 auto two = std::get<1>(intup);
57 std::cerr <<
"FrameMerger: EOS\n";
62 auto jmergemap = m_cfg[
"mergemap"];
63 const int nsets = jmergemap.size();
67 std::vector<ITrace::vector> tracesv1, tracesv2;
71 std::cerr <<
"FrameMerger: see frame: "<<one->ident()<<
" no tags, whole frame\n";
74 std::cerr <<
"FrameMerger: see frame: "<<one->ident()<<
" with tags:\n";
75 for (
int ind=0; ind<nsets; ++ind) {
76 auto jtags = jmergemap[ind];
82 std::cerr <<
"\ttags: " 83 << tag1 <<
"[" << tracesv1.back().size() <<
"]" 85 << tag2 <<
"[" << tracesv2.back().size() <<
"]" 92 std::vector<IFrame::trace_list_t> tagged_trace_indices;
97 auto rule = get<std::string>(m_cfg,
"rule");
98 if (rule ==
"replace") {
100 for (
size_t ind=0; ind<tracesv1.size(); ++ind) {
101 auto& traces1 = tracesv1[ind];
102 auto& traces2 = tracesv2[ind];
104 std::unordered_map<int, ITrace::pointer> ch2tr;
105 for (
auto trace : traces2) {
108 for (
auto trace : traces1) {
113 for (
auto chtr : ch2tr) {
114 tl.push_back(out_traces.size());
115 out_traces.push_back(chtr.second);
117 tagged_trace_indices.push_back(tl);
120 if (rule ==
"include") {
121 for (
size_t ind=0; ind<tracesv1.size(); ++ind) {
122 auto& traces1 = tracesv1[ind];
123 auto& traces2 = tracesv2[ind];
126 for (
size_t trind=0; trind < traces1.size(); ++trind) {
127 tl.push_back(out_traces.size());
128 out_traces.push_back(traces1[trind]);
130 for (
size_t trind=0; trind < traces2.size(); ++trind) {
131 tl.push_back(out_traces.size());
132 out_traces.push_back(traces2[trind]);
134 tagged_trace_indices.push_back(tl);
138 auto sf =
new SimpleFrame(two->ident(), two->time(), out_traces, two->tick());
140 for (
int ind=0; ind<nsets; ++ind) {
142 sf->tag_traces(otag, tagged_trace_indices[ind]);
150 SigProc::FrameMerger::FrameMerger()
154 SigProc::FrameMerger::~FrameMerger()
port_helper_type::template WrappedConst< std::shared_ptr >::type input_tuple_type
std::vector< pointer > vector
WIRECELL_FACTORY(FrameMerger, WireCell::SigProc::FrameMerger, WireCell::IFrameJoiner, WireCell::IConfigurable) using namespace WireCell
static ITrace::vector tagged_traces(IFrame::pointer frame, IFrame::tag_t tag)
std::shared_ptr< const IFrame > output_pointer
Json::Value Configuration
const GenericPointer< typename T::ValueType > & pointer
std::vector< size_t > trace_list_t