14 Gen::Retagger::~Retagger()
21 m_trctx.configure(cfg[
"tag_rules"]);
27 cfg[
"tag_rules"] = Json::arrayValue;
40 auto sfout =
new SimpleFrame(inframe->ident(), inframe->time(), *inframe->traces(), inframe->tick());
47 fintags.push_back(
"");
48 auto fouttags = m_trctx.transform(0,
"frame", fintags);
49 for (
auto ftag : fouttags) {
55 for (
auto inttag : inframe->trace_tags()) {
57 if (touttags.empty()) {
60 const auto& traces = inframe->tagged_traces(inttag);
61 const auto&
summary = inframe->trace_summary(inttag);
62 for (
auto otag : touttags) {
63 sfout->tag_traces(otag, traces,
summary);
69 typedef std::tuple<tagrules::tag_t, IFrame::trace_list_t, IFrame::trace_summary_t> tag_trace_list_summary_t;
70 typedef std::vector< tag_trace_list_summary_t > ttls_stash_t;
71 typedef std::unordered_map<std::string, ttls_stash_t> ttls_stash_map_t;
72 ttls_stash_map_t stashmap;
73 for (
auto inttag : inframe->trace_tags()) {
76 if (touttags.empty()) {
79 const auto& traces = inframe->tagged_traces(inttag);
80 const auto&
summary = inframe->trace_summary(inttag);
81 for (
auto otag : touttags) {
82 stashmap[otag].push_back(std::make_tuple(inttag, traces,
summary));
85 for (
auto it : stashmap) {
86 auto& otag = it.first;
87 auto& stashv = it.second;
88 size_t ntraces = 0, nsummary=0;
93 for (
auto& ttls : stashv) {
94 ntraces += get<1>(ttls).
size();
95 nsummary += get<2>(ttls).
size();
98 otraces.reserve(ntraces);
101 osummary.reserve(ntraces);
103 for (
auto& ttls : stashv) {
104 auto& traces = get<1>(ttls);
105 otraces.insert(otraces.end(), traces.begin(), traces.end());
114 for (
size_t ind=0; ind<traces.size(); ++ind) {
122 std::cerr <<
"Retagger: tagging trace set: " << otag
123 <<
" with " << otraces.size() <<
" traces, " << osummary.size() <<
" summary\n";
125 sfout->tag_traces(otag, otraces, osummary);
std::unordered_set< tag_t > tagset_t
virtual const tag_list_t & frame_tags() const
void tag_frame(const tag_t &tag)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::shared_ptr< const IFrame > input_pointer
WIRECELL_FACTORY(Retagger, WireCell::Gen::Retagger, WireCell::IFrameFilter, WireCell::IConfigurable) using namespace WireCell
std::vector< double > trace_summary_t
std::shared_ptr< const IFrame > output_pointer
Json::Value Configuration
const GenericPointer< typename T::ValueType > & pointer
std::vector< size_t > trace_list_t