10 #include "TTimeStamp.h" 13 #include "WireCellIface/SimpleFrame.h" 14 #include "WireCellIface/SimpleTrace.h" 15 #include "WireCellUtil/NamedFactory.h" 29 RawFrameSource::~RawFrameSource()
39 cfg[
"frame_tags"][0] =
"orig";
40 cfg[
"nticks"] = m_nticks;
46 const std::string art_tag = cfg[
"art_tag"].asString();
47 if (art_tag.empty()) {
48 THROW(ValueError() << errmsg{
"WireCell::RawFrameSource requires a source_label"});
50 m_inputTag = cfg[
"art_tag"].asString();
52 m_tick = cfg[
"tick"].asDouble();
53 for (
auto jtag : cfg[
"frame_tags"]) {
54 m_frame_tags.push_back(jtag.asString());
56 m_nticks =
get(cfg,
"nticks", m_nticks);
67 return tts2.AsDouble() - tts1.AsDouble();
79 unsigned int nadcs = adcv.size();
80 if (nticks_want > 0) {
81 if (nticks_want > nadcs) {
82 baseline = Waveform::most_frequent(adcv);
84 nadcs =
std::min(nadcs, nticks_want);
90 auto strace =
new SimpleTrace(chid, tbin, nticks_want);
91 for (
unsigned int itick=0; itick < nadcs; ++ itick) {
92 strace->charge()[itick] = adcv[itick];
94 for (
unsigned int itick = nadcs; itick < nticks_want; ++itick) {
95 strace->charge()[itick] = baseline;
103 const double tick = m_tick;
105 bool okay =
event.getByLabel(m_inputTag, rdvh);
107 std::string msg =
"WireCell::RawFrameSource failed to get vector<raw::RawDigit>: " + m_inputTag.encode();
109 THROW(RuntimeError() << errmsg{msg});
111 else if (rdvh->size() == 0)
return;
113 const std::vector<raw::RawDigit>& rdv(*rdvh);
114 const size_t nchannels = rdv.size();
115 std::cerr <<
"RawFrameSource: got " << nchannels <<
" raw::RawDigit objects\n";
118 for (
size_t ind=0; ind<nchannels; ++ind) {
119 auto const& rd = rdv.at(ind);
120 traces[ind] = ITrace::pointer(
make_trace(rd, m_nticks));
124 <<
"\tinput nticks=" << rd.ADCs().size() <<
" setting to " << m_nticks
129 <<
"\tinput nticks=" << rd.ADCs().size() <<
" keeping as is" 136 auto sframe =
new WireCell::SimpleFrame(event.
event(), time, traces,
tick);
137 for (
auto tag : m_frame_tags) {
139 sframe->tag_frame(
tag);
141 m_frames.push_back(WireCell::IFrame::pointer(sframe));
142 m_frames.push_back(
nullptr);
145 bool RawFrameSource::operator()(WireCell::IFrame::pointer& frame)
148 if (m_frames.empty()) {
151 frame = m_frames.front();
152 m_frames.pop_front();
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
constexpr std::uint32_t timeLow() const
EventNumber_t event() const
static constexpr double us
static SimpleTrace * make_trace(const raw::RawDigit &rd, unsigned int nticks_want)
Collection of charge vs time digitized from a single readout channel.
void msg(const char *fmt,...)
constexpr std::uint32_t timeHigh() const
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
WIRECELL_FACTORY(wclsRawFrameSource, wcls::RawFrameSource, wcls::IArtEventVisitor, WireCell::IFrameSource) using namespace wcls
Run const & getRun() const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
Timestamp const & beginTime() const
QTextStream & endl(QTextStream &s)
Event finding and building.