8 #include "TTimeStamp.h" 10 #include "WireCellIface/SimpleFrame.h" 11 #include "WireCellIface/SimpleTrace.h" 12 #include "WireCellUtil/NamedFactory.h" 17 WireCell::IFrameSource)
24 CookedFrameSource::~CookedFrameSource() {}
27 CookedFrameSource::default_configuration()
const 32 cfg[
"frame_tags"][0] =
"orig";
33 cfg[
"nticks"] = m_nticks;
40 const std::string art_tag = cfg[
"art_tag"].asString();
41 if (art_tag.empty()) {
42 THROW(ValueError() << errmsg{
"WireCell::CookedFrameSource requires a source_label"});
44 m_inputTag = cfg[
"art_tag"].asString();
46 m_tick = cfg[
"tick"].asDouble();
47 for (
auto jtag : cfg[
"frame_tags"]) {
48 m_frame_tags.push_back(jtag.asString());
50 m_nticks =
get(cfg,
"nticks", m_nticks);
60 return tts2.AsDouble() - tts1.AsDouble();
69 const std::vector<float> sig = rw.
Signal();
71 const float baseline = 0.0;
72 unsigned int nsamp = sig.size();
73 if (nticks_want > 0) { nsamp =
std::min(nsamp, nticks_want); }
78 auto strace =
new SimpleTrace(chid, tbin, nticks_want);
79 auto& q = strace->charge();
80 for (
unsigned int itick = 0; itick < nsamp; ++itick) {
81 q[itick] = sig[itick];
83 for (
unsigned int itick = nsamp; itick < nticks_want; ++itick) {
92 auto const&
event =
e;
94 const double tick = m_tick;
96 bool okay =
event.getByLabel(m_inputTag, rwvh);
99 "WireCell::CookedFrameSource failed to get vector<recob::Wire>: " + m_inputTag.encode();
101 THROW(RuntimeError() << errmsg{msg});
103 else if (rwvh->size() == 0)
106 const std::vector<recob::Wire>& rwv(*rwvh);
107 const size_t nchannels = rwv.size();
108 std::cerr <<
"CookedFrameSource: got " << nchannels <<
" recob::Wire objects\n";
111 for (
size_t ind = 0; ind < nchannels; ++ind) {
112 auto const& rw = rwv.at(ind);
113 traces[ind] = ITrace::pointer(
make_trace(rw, m_nticks));
116 std::cerr <<
"\tinput nticks=" << rw.NSignal() <<
" setting to " << m_nticks <<
std::endl;
119 std::cerr <<
"\tinput nticks=" << rw.NSignal() <<
" keeping as is" <<
std::endl;
124 const double time =
tdiff(
event.getRun().beginTime(),
event.time());
125 auto sframe =
new WireCell::SimpleFrame(
event.event(), time, traces,
tick);
126 for (
auto tag : m_frame_tags) {
128 sframe->tag_frame(
tag);
130 m_frames.push_back(WireCell::IFrame::pointer(sframe));
131 m_frames.push_back(
nullptr);
135 CookedFrameSource::operator()(WireCell::IFrame::pointer& frame)
138 if (m_frames.empty()) {
return false; }
139 frame = m_frames.front();
140 m_frames.pop_front();
constexpr std::uint32_t timeLow() const
static constexpr double us
void msg(const char *fmt,...)
constexpr std::uint32_t timeHigh() const
WIRECELL_FACTORY(wclsCookedFrameSource, wcls::CookedFrameSource, wcls::IArtEventVisitor, WireCell::IFrameSource) using namespace wcls
raw::ChannelID_t Channel() const
Returns the ID of the channel (or InvalidChannelID)
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
std::vector< float > Signal() const
Return a zero-padded full length vector filled with RoI signal.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
static SimpleTrace * make_trace(const recob::Wire &rw, unsigned int nticks_want)
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
Class holding the regions of interest of signal from a channel.
Declaration of basic channel signal object.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
QTextStream & endl(QTextStream &s)
Event finding and building.