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

#include <CookedFrameSource.h>

Inheritance diagram for wcls::CookedFrameSource:
wcls::IArtEventVisitor

Public Member Functions

 CookedFrameSource ()
 
virtual ~CookedFrameSource ()
 
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 22 of file CookedFrameSource.h.

Constructor & Destructor Documentation

CookedFrameSource::CookedFrameSource ( )

Definition at line 22 of file CookedFrameSource.cxx.

CookedFrameSource::~CookedFrameSource ( )
virtual

Definition at line 24 of file CookedFrameSource.cxx.

24 {}

Member Function Documentation

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

Definition at line 38 of file CookedFrameSource.cxx.

39 {
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"});
43  }
44  m_inputTag = cfg["art_tag"].asString();
45 
46  m_tick = cfg["tick"].asDouble();
47  for (auto jtag : cfg["frame_tags"]) {
48  m_frame_tags.push_back(jtag.asString());
49  }
50  m_nticks = get(cfg, "nticks", m_nticks);
51 }
std::string string
Definition: nybbler.cc:12
std::vector< std::string > m_frame_tags
WireCell::Configuration CookedFrameSource::default_configuration ( ) const
virtual

IConfigurable.

Definition at line 27 of file CookedFrameSource.cxx.

28 {
29  Configuration cfg;
30  cfg["art_tag"] = ""; // how to look up the cooked digits
31  cfg["tick"] = 0.5 * WireCell::units::us;
32  cfg["frame_tags"][0] = "orig"; // the tags to apply to this frame
33  cfg["nticks"] = m_nticks; // if nonzero, truncate or zero-pad frame to this number of ticks.
34  return cfg;
35 }
static constexpr double us
Definition: Units.h:97
bool CookedFrameSource::operator() ( WireCell::IFrame::pointer &  frame)
virtual

IFrameSource.

Definition at line 135 of file CookedFrameSource.cxx.

136 {
137  frame = nullptr;
138  if (m_frames.empty()) { return false; }
139  frame = m_frames.front();
140  m_frames.pop_front();
141  return true;
142 }
std::deque< WireCell::IFrame::pointer > m_frames
void CookedFrameSource::visit ( art::Event event)
virtual

IArtEventVisitor.

Implements wcls::IArtEventVisitor.

Definition at line 90 of file CookedFrameSource.cxx.

91 {
92  auto const& event = e;
93  // fixme: want to avoid depending on DetectorPropertiesService for now.
94  const double tick = m_tick;
96  bool okay = event.getByLabel(m_inputTag, rwvh);
97  if (!okay) {
99  "WireCell::CookedFrameSource failed to get vector<recob::Wire>: " + m_inputTag.encode();
100  std::cerr << msg << std::endl;
101  THROW(RuntimeError() << errmsg{msg});
102  }
103  else if (rwvh->size() == 0)
104  return;
105 
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";
109 
110  WireCell::ITrace::vector traces(nchannels);
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));
114  if (!ind) { // first time through
115  if (m_nticks) {
116  std::cerr << "\tinput nticks=" << rw.NSignal() << " setting to " << m_nticks << std::endl;
117  }
118  else {
119  std::cerr << "\tinput nticks=" << rw.NSignal() << " keeping as is" << std::endl;
120  }
121  }
122  }
123 
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) {
127  //std::cerr << "\ttagged: " << tag << std::endl;
128  sframe->tag_frame(tag);
129  }
130  m_frames.push_back(WireCell::IFrame::pointer(sframe));
131  m_frames.push_back(nullptr);
132 }
EventNumber_t event() const
Definition: DataViewImpl.cc:85
void msg(const char *fmt,...)
Definition: message.cpp:107
std::string string
Definition: nybbler.cc:12
struct vector vector
std::string encode() const
Definition: InputTag.cc:97
std::vector< std::string > m_frame_tags
const double e
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
Run const & getRun() const
Definition: Event.cc:50
static SimpleTrace * make_trace(const recob::Wire &rw, unsigned int nticks_want)
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
std::deque< WireCell::IFrame::pointer > m_frames
Timestamp const & beginTime() const
Definition: DataViewImpl.cc:92
QTextStream & endl(QTextStream &s)

Member Data Documentation

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

Definition at line 44 of file CookedFrameSource.h.

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

Definition at line 40 of file CookedFrameSource.h.

art::InputTag wcls::CookedFrameSource::m_inputTag
private

Definition at line 41 of file CookedFrameSource.h.

int wcls::CookedFrameSource::m_nticks
private

Definition at line 43 of file CookedFrameSource.h.

double wcls::CookedFrameSource::m_tick
private

Definition at line 42 of file CookedFrameSource.h.


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