108 if (traces.empty()) {
109 log->warn(
"OmnibusNoiseFilter: no traces for tag \"{}\", sending empty frame",
m_intag);
110 outframe = std::make_shared<SimpleFrame>(inframe->ident(), inframe->time(),
111 std::make_shared<ITrace::vector>(),
118 log->debug(
"OmnibusNoiseFilter: will resize working waveforms from {} to {}",
119 traces.at(0)->charge().size(),
m_nticks);
124 m_nticks = traces.at(0)->charge().size();
125 log->debug(
"OmnibusNoiseFilter: nticks based on first waveform: {}",
m_nticks);
134 std::vector<int> bad_channels =
m_noisedb->bad_channels();
140 for (
size_t i = 0; i< bad_channels.size();i++){
141 temp[bad_channels.at(i)].push_back(bad_bins);
145 temp_map[
"bad"] = temp;
150 int nchanged_samples = 0;
153 std::unordered_map<int, SimpleTrace*> bychan;
154 for (
auto trace : traces) {
155 int ch =
trace->channel();
158 SimpleTrace* signal =
new SimpleTrace(ch, 0,
m_nticks);
162 if (
find(bad_channels.begin(), bad_channels.end(),ch) == bad_channels.end()) {
164 auto const& charge =
trace->charge();
165 const size_t ncharges = charge.size();
167 signal->charge().assign(charge.begin(), charge.begin() +
std::min(
m_nticks, ncharges));
168 signal->charge().resize(
m_nticks, 0.0);
178 auto masks =
filter->apply(ch, signal->charge());
188 if (nchanged_samples) {
189 log->warn(
"OmnibusNoiseFilter: warning, truncated or extended {} samples", nchanged_samples);
192 int group_counter = 0;
194 for (
auto group :
m_noisedb->coherent_channels()) {
200 for (
auto ch : group) {
202 if (bychan.find(ch)==bychan.end()) {
207 chgrp[ch] = bychan[ch]->charge();
211 if (flag == 0)
continue;
214 auto masks =
filter->apply(chgrp);
219 for (
auto cs : chgrp) {
221 bychan[
cs.first]->charge().assign(
cs.second.begin(),
cs.second.end());
226 log->debug(
"OmnibusNoiseFilter: {} unknown channels (probably the channel selector is in use)", nunknownchans);
230 for (
auto& it : bychan) {
231 const int ch = it.first;
234 auto masks =
filter->apply(ch, signal);
241 for (
auto&
cs : bychan) {
247 auto sframe =
new SimpleFrame(inframe->ident(), inframe->time(), itraces, inframe->tick(), cmm);
249 for (
size_t ind=0; ind<itraces.size(); ++ind) {
253 sframe->tag_frame(
"noisefilter");
std::shared_ptr< const ITrace > pointer
std::vector< WireCell::IChannelFilter::pointer > m_perchan
Waveform::realseq_t signal_t
std::map< std::string, std::string > m_maskmap
std::vector< pointer > vector
std::vector< WireCell::IChannelFilter::pointer > m_grouped
Configuration find(Configuration &lst, const std::string &dotpath, const T &val)
Return dictionary in given list if it value at dotpath matches.
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
std::vector< WireCell::IChannelFilter::pointer > m_perchan_status
std::map< int, signal_t > channel_signals_t
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
WireCell::ITrace::vector tagged_traces(WireCell::IFrame::pointer frame, WireCell::IFrame::tag_t tag)
WireCell::IChannelNoiseDatabase::pointer m_noisedb
std::vector< size_t > trace_list_t