2 #include "art/Framework/Principal/Handle.h"
7 #include "art/Framework/Principal/Event.h"
8 #include "art/Framework/Principal/Run.h"
10 #include "TTimeStamp.h"
13 #include "WireCellIface/IFrame.h"
18 mutable art::Handle< std::vector<raw::RawDigit> >
m_rdvh;
22 mutable WireCell::ITrace::ChargeSequence
m_charge;
26 LazyTrace(art::Handle< std::vector<raw::RawDigit> > rdvh,
size_t index)
31 virtual int tbin()
const {
return 0; }
33 virtual const ChargeSequence&
charge()
const {
52 LazyFrame(art::Handle< std::vector<raw::RawDigit> > rdvh,
55 const size_t nrds = rdvh->size();
56 auto*
traces =
new std::vector<LazyTrace::pointer>(nrds);
57 for (
size_t ind = 0; ind < nrds; ++ind) {
58 traces->at(ind) = std::make_shared<LazyTrace>(rdvh, ind);
70 static tag_list_t dummy;
75 static trace_list_t dummy;
80 static trace_summary_t dummy;
85 virtual WireCell::ITrace::shared_vector
traces()
const {
93 virtual double time()
const {
97 virtual double tick()
const {
108 #include "WireCellUtil/NamedFactory.h"
114 using namespace wcls;
115 using namespace WireCell;
122 LazyFrameSource::~LazyFrameSource()
127 WireCell::Configuration LazyFrameSource::default_configuration()
const
131 cfg[
"tick"] = 0.5*WireCell::units::us;
132 cfg[
"frame_tags"][0] =
"orig";
133 cfg[
"nticks"] = m_nticks;
137 void LazyFrameSource::configure(
const WireCell::Configuration& cfg)
139 const std::string art_tag = cfg[
"art_tag"].asString();
140 if (art_tag.empty()) {
141 THROW(ValueError() << errmsg{
"LazyFrameSource requires a source_label"});
143 m_inputTag = cfg[
"art_tag"].asString();
145 m_tick = cfg[
"tick"].asDouble();
146 for (
auto jtag : cfg[
"frame_tags"]) {
147 m_frame_tags.push_back(jtag.asString());
149 m_nticks =
get(cfg,
"nticks", m_nticks);
156 double tdiff(
const art::Timestamp& ts1,
const art::Timestamp& ts2)
158 TTimeStamp tts1(ts1.timeHigh(), ts1.timeLow());
159 TTimeStamp tts2(ts2.timeHigh(), ts2.timeLow());
160 return tts2.AsDouble() - tts1.AsDouble();
163 void LazyFrameSource::visit(art::Event & event)
166 const double tick = m_tick;
168 art::Handle< std::vector<raw::RawDigit> > rdvh;
169 bool okay =
event.getByLabel(m_inputTag, rdvh);
171 std::string
msg =
"LazyFrameSource failed to get vector<raw::RawDigit>: " + m_inputTag.encode();
173 THROW(RuntimeError() << errmsg{msg});
175 else if (rdvh->size() == 0)
return;
176 const double time =
tdiff(event.getRun().beginTime(),
event.time());
178 std::cerr <<
"LazyFrameSource: got " << rdvh->size() <<
" raw::RawDigit objects\n";
180 m_frames.push_back(std::make_shared<LazyFrame>(rdvh, event.event(), time,
tick, m_frame_tags));
181 m_frames.push_back(
nullptr);
184 bool LazyFrameSource::operator()(WireCell::IFrame::pointer& frame)
187 if (m_frames.empty()) {
190 frame = m_frames.front();
191 m_frames.pop_front();
WireCell::ITrace::ChargeSequence m_charge
virtual double tick() const
BEGIN_PROLOG could also be cerr
virtual int channel() const
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
Definition of basic raw digits.
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
virtual const trace_list_t & tagged_traces(const tag_t &tag) const
virtual const tag_list_t & frame_tags() const
auto end(FixedBins< T, C > const &) noexcept
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
virtual double time() const
WIRECELL_FACTORY(wclsChannelNoiseDB, wcls::ChannelNoiseDB, wcls::IArtEventVisitor, WireCell::IChannelNoiseDatabase) using namespace WireCell
auto begin(FixedBins< T, C > const &) noexcept
virtual WireCell::ITrace::shared_vector traces() const
WireCell::ITrace::shared_vector m_traces
art::Handle< std::vector< raw::RawDigit > > m_rdvh
virtual const trace_summary_t & trace_summary(const tag_t &tag) const
LazyFrame(art::Handle< std::vector< raw::RawDigit > > rdvh, int ident, double time, double tick, const tag_list_t &tags)
virtual int ident() const
virtual const ChargeSequence & charge() const
virtual const tag_list_t & trace_tags() const
LazyTrace(art::Handle< std::vector< raw::RawDigit > > rdvh, size_t index)