5 #include <unordered_map> 12 auto traces = frame->traces();
13 const size_t ntraces = traces->size();
14 std::vector<double> means, rmses, lengths,
tbins;
15 for (
auto trace : *traces) {
16 auto const& charge =
trace->charge();
19 means.push_back(mr.first);
20 rmses.push_back(mr.second*mr.second);
21 const int nsamps = charge.size();
22 lengths.push_back(nsamps);
23 tbins.push_back(
trace->tbin());
26 std::cerr <<
"Frame: channel " <<
trace->channel() <<
" rms is NaN\n";
29 for (
int ind=0; ind<nsamps; ++ind) {
30 float val = charge[ind];
32 std::cerr <<
"Frame: channel " <<
trace->channel() <<
" sample " << ind <<
" is NaN\n";
35 std::cerr <<
"Frame: channel " <<
trace->channel() <<
" sample " << ind <<
" is INF\n";
43 std::cerr <<
"Frame: " << ntraces <<
" traces," 44 <<
" <mean>=" << meanmean
45 <<
" TotRMS=" << totrms
46 <<
" <tbin>=" << meantbin
47 <<
" <len>=" << meanlen
49 for (
auto it : frame->masks()) {
50 std::cerr <<
"\t" << it.first <<
" : " << it.second.size() <<
std::endl;
59 const size_t nchannels = channels.size();
60 std::unordered_map<int, size_t> ch2col;
61 for (
size_t ind=0; ind<nchannels; ++ind) {
62 ch2col[channels[ind]] = ind;
65 const size_t ncols = block.cols();
66 for (
auto trace : traces) {
67 const auto& samples =
trace->charge();
68 const size_t nsamples = samples.size();
69 const size_t tbin =
trace->tbin();
76 const int ch =
trace->channel();
77 const auto chit = ch2col.find(ch);
78 if (chit == ch2col.end()) {
81 const size_t irow = chit->second;
83 const size_t maxbin =
std::min(nsamples, ncols-tbin);
85 tofill[
bin] = samples[
bin];
87 block.block(irow, tbin, 1, ncols-tbin).row(0) += tofill;
93 std::vector<int>
hist(binning.
nbins(), 0);
94 for (
auto trace : traces) {
95 auto const& samples =
trace->charge();
96 for (
auto sample : samples) {
100 auto mme = std::minmax_element(
hist.begin(),
hist.end());
101 return mme.second -
hist.begin();
106 auto const& all_traces = frame->traces();
108 for (
size_t index : frame->tagged_traces(tag)) {
109 ret.push_back(all_traces->at(
index));
114 auto ftags = frame->frame_tags();
115 if (
std::find(ftags.begin(), ftags.end(), tag) == ftags.end()) {
std::shared_ptr< const IFrame > pointer
void dump_frame(WireCell::IFrame::pointer frame)
std::vector< pointer > vector
void raster(WireCell::Array::array_xxf &block, WireCell::ITrace::vector traces, const std::vector< int > &channels)
Binning tbins(nticks, t0, t0+readout_time)
int bin(double val) const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
int maxcount_baseline(const WireCell::ITrace::vector &traces, const WireCell::Binning &binning=WireCell::Binning(4096, 0, 4096))
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
WireCell::ITrace::vector tagged_traces(WireCell::IFrame::pointer frame, WireCell::IFrame::tag_t tag)
QTextStream & bin(QTextStream &s)
QTextStream & endl(QTextStream &s)
Eigen::ArrayXXf array_xxf
A real, 2D array.