Functions
wct::sigproc Namespace Reference

Functions

void dump_frame (WireCell::IFrame::pointer frame)
 
void raster (WireCell::Array::array_xxf &block, WireCell::ITrace::vector traces, const std::vector< int > &channels)
 
int maxcount_baseline (const WireCell::ITrace::vector &traces, const WireCell::Binning &binning=WireCell::Binning(4096, 0, 4096))
 
WireCell::ITrace::vector tagged_traces (WireCell::IFrame::pointer frame, WireCell::IFrame::tag_t tag)
 

Function Documentation

void wct::sigproc::dump_frame ( WireCell::IFrame::pointer  frame)

Definition at line 10 of file FrameUtils.cxx.

11 {
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();
17 
18  auto mr = Waveform::mean_rms(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());
24 
25  if (std::isnan(mr.second)) {
26  std::cerr << "Frame: channel " << trace->channel() << " rms is NaN\n";
27  }
28 
29  for (int ind=0; ind<nsamps; ++ind) {
30  float val = charge[ind];
31  if (std::isnan(val)) {
32  std::cerr << "Frame: channel " << trace->channel() << " sample " << ind << " is NaN\n";
33  }
34  if (std::isinf(val)) {
35  std::cerr << "Frame: channel " << trace->channel() << " sample " << ind << " is INF\n";
36  }
37  }
38  }
39  double meanmean = Waveform::sum(means)/ntraces;
40  double totrms = sqrt(Waveform::sum(rmses));
41  double meanlen = Waveform::sum(lengths)/ntraces;
42  double meantbin = Waveform::sum(tbins)/ntraces;
43  std::cerr << "Frame: " << ntraces << " traces,"
44  << " <mean>=" << meanmean
45  << " TotRMS=" << totrms
46  << " <tbin>=" << meantbin
47  << " <len>=" << meanlen
48  << std::endl;
49  for (auto it : frame->masks()) {
50  std::cerr << "\t" << it.first << " : " << it.second.size() << std::endl;
51  }
52 }
Binning tbins(nticks, t0, t0+readout_time)
dummy_int isinf(...)
Definition: format.h:276
IFrame::pointer sum(std::vector< IFrame::pointer > frames, int ident)
Definition: FrameUtil.cxx:15
std::pair< double, double > mean_rms(const realseq_t &wave)
Definition: Waveform.cxx:24
QTextStream & endl(QTextStream &s)
dummy_int isnan(...)
Definition: format.h:278
int wct::sigproc::maxcount_baseline ( const WireCell::ITrace::vector traces,
const WireCell::Binning binning = WireCell::Binning(4096, 0, 4096) 
)
void wct::sigproc::raster ( WireCell::Array::array_xxf block,
WireCell::ITrace::vector  traces,
const std::vector< int > &  channels 
)

Definition at line 55 of file FrameUtils.cxx.

58 {
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;
63  }
64 
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();
70 
71  if (tbin >= ncols) { // underflow impossible as they are unsigned.
72  continue; // trace is off screen
73  }
74 
75  // find the row to fill
76  const int ch = trace->channel();
77  const auto chit = ch2col.find(ch);
78  if (chit == ch2col.end()) {
79  continue;
80  }
81  const size_t irow = chit->second;
82  WireCell::Array::array_xf tofill(ncols-tbin);
83  const size_t maxbin = std::min(nsamples, ncols-tbin);
84  for (size_t bin=0; bin<maxbin; ++bin) {
85  tofill[bin] = samples[bin];
86  }
87  block.block(irow, tbin, 1, ncols-tbin).row(0) += tofill;
88  }
89 }
Eigen::ArrayXf array_xf
Definition: Array.h:41
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
QTextStream & bin(QTextStream &s)
WireCell::ITrace::vector wct::sigproc::tagged_traces ( WireCell::IFrame::pointer  frame,
WireCell::IFrame::tag_t  tag 
)