Public Member Functions | Private Attributes | List of all members
wcls::LazyFrameSource Class Reference

#include <LazyFrameSource.h>

Inheritance diagram for wcls::LazyFrameSource:
wcls::IArtEventVisitor

Public Member Functions

 LazyFrameSource ()
 
virtual ~LazyFrameSource ()
 
virtual void visit (art::Event &event)
 IArtEventVisitor. More...
 
virtual bool operator() (WireCell::IFrame::pointer &frame)
 IFrameSource. More...
 
virtual WireCell::Configuration default_configuration () const
 IConfigurable. More...
 
virtual void configure (const WireCell::Configuration &config)
 
- Public Member Functions inherited from wcls::IArtEventVisitor
virtual ~IArtEventVisitor ()
 
virtual void produces (art::ProducesCollector &collector)
 

Private Attributes

std::deque< WireCell::IFrame::pointer > m_frames
 
art::InputTag m_inputTag
 
double m_tick
 
int m_nticks
 
std::vector< std::stringm_frame_tags
 

Detailed Description

Definition at line 24 of file LazyFrameSource.h.

Constructor & Destructor Documentation

LazyFrameSource::LazyFrameSource ( )

Definition at line 117 of file LazyFrameSource.cxx.

118  : m_nticks(0)
119 {
120 }
LazyFrameSource::~LazyFrameSource ( )
virtual

Definition at line 122 of file LazyFrameSource.cxx.

123 {
124 }

Member Function Documentation

void LazyFrameSource::configure ( const WireCell::Configuration &  config)
virtual

Definition at line 137 of file LazyFrameSource.cxx.

138 {
139  const std::string art_tag = cfg["art_tag"].asString();
140  if (art_tag.empty()) {
141  THROW(ValueError() << errmsg{"LazyFrameSource requires a source_label"});
142  }
143  m_inputTag = cfg["art_tag"].asString();
144 
145  m_tick = cfg["tick"].asDouble();
146  for (auto jtag : cfg["frame_tags"]) {
147  m_frame_tags.push_back(jtag.asString());
148  }
149  m_nticks = get(cfg, "nticks", m_nticks);
150 }
std::string string
Definition: nybbler.cc:12
art::InputTag m_inputTag
std::vector< std::string > m_frame_tags
WireCell::Configuration LazyFrameSource::default_configuration ( ) const
virtual

IConfigurable.

Definition at line 127 of file LazyFrameSource.cxx.

128 {
129  Configuration cfg;
130  cfg["art_tag"] = ""; // how to look up the raw digits
131  cfg["tick"] = 0.5*WireCell::units::us;
132  cfg["frame_tags"][0] = "orig"; // the tags to apply to this frame
133  cfg["nticks"] = m_nticks; // if nonzero, truncate or baseline-pad frame to this number of ticks.
134  return cfg;
135 }
static constexpr double us
Definition: Units.h:97
bool LazyFrameSource::operator() ( WireCell::IFrame::pointer &  frame)
virtual

IFrameSource.

Definition at line 184 of file LazyFrameSource.cxx.

185 {
186  frame = nullptr;
187  if (m_frames.empty()) {
188  return false;
189  }
190  frame = m_frames.front();
191  m_frames.pop_front();
192  return true;
193 }
std::deque< WireCell::IFrame::pointer > m_frames
void LazyFrameSource::visit ( art::Event event)
virtual

IArtEventVisitor.

Implements wcls::IArtEventVisitor.

Definition at line 163 of file LazyFrameSource.cxx.

164 {
165  // fixme: want to avoid depending on DetectorPropertiesService for now.
166  const double tick = m_tick;
167 
169  bool okay = event.getByLabel(m_inputTag, rdvh);
170  if (!okay) {
171  std::string msg = "LazyFrameSource failed to get vector<raw::RawDigit>: " + m_inputTag.encode();
172  std::cerr << msg << std::endl;
173  THROW(RuntimeError() << errmsg{msg});
174  }
175  else if (rdvh->size() == 0) return;
176  const double time = tdiff(event.getRun().beginTime(), event.time());
177 
178  std::cerr << "LazyFrameSource: got " << rdvh->size() << " raw::RawDigit objects\n";
179 
180  m_frames.push_back(std::make_shared<LazyFrame>(rdvh, event.event(), time, tick, m_frame_tags));
181  m_frames.push_back(nullptr);
182 }
EventNumber_t event() const
Definition: DataViewImpl.cc:85
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
std::deque< WireCell::IFrame::pointer > m_frames
std::string encode() const
Definition: InputTag.cc:97
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
Run const & getRun() const
Definition: Event.cc:50
art::InputTag m_inputTag
std::vector< std::string > m_frame_tags
Timestamp const & beginTime() const
Definition: DataViewImpl.cc:92
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::vector<std::string> wcls::LazyFrameSource::m_frame_tags
private

Definition at line 46 of file LazyFrameSource.h.

std::deque<WireCell::IFrame::pointer> wcls::LazyFrameSource::m_frames
private

Definition at line 42 of file LazyFrameSource.h.

art::InputTag wcls::LazyFrameSource::m_inputTag
private

Definition at line 43 of file LazyFrameSource.h.

int wcls::LazyFrameSource::m_nticks
private

Definition at line 45 of file LazyFrameSource.h.

double wcls::LazyFrameSource::m_tick
private

Definition at line 44 of file LazyFrameSource.h.


The documentation for this class was generated from the following files: