All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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::string > m_frame_tags
 

Detailed Description

Definition at line 22 of file CookedFrameSource.h.

Constructor & Destructor Documentation

CookedFrameSource::CookedFrameSource ( )

Definition at line 24 of file CookedFrameSource.cxx.

CookedFrameSource::~CookedFrameSource ( )
virtual

Definition at line 26 of file CookedFrameSource.cxx.

26 {}

Member Function Documentation

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

Definition at line 40 of file CookedFrameSource.cxx.

41 {
42  const std::string art_tag = cfg["art_tag"].asString();
43  if (art_tag.empty()) {
44  THROW(ValueError() << errmsg{"WireCell::CookedFrameSource requires a source_label"});
45  }
46  m_inputTag = cfg["art_tag"].asString();
47 
48  m_tick = cfg["tick"].asDouble();
49  for (auto jtag : cfg["frame_tags"]) {
50  m_frame_tags.push_back(jtag.asString());
51  }
52  m_nticks = get(cfg, "nticks", m_nticks);
53 }
std::vector< std::string > m_frame_tags
WireCell::Configuration CookedFrameSource::default_configuration ( ) const
virtual

IConfigurable.

Definition at line 29 of file CookedFrameSource.cxx.

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

IFrameSource.

Definition at line 137 of file CookedFrameSource.cxx.

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

IArtEventVisitor.

Implements wcls::IArtEventVisitor.

Definition at line 92 of file CookedFrameSource.cxx.

93 {
94  auto const& event = e;
95  // fixme: want to avoid depending on DetectorPropertiesService for now.
96  const double tick = m_tick;
97  art::Handle<std::vector<recob::Wire>> rwvh;
98  bool okay = event.getByLabel(m_inputTag, rwvh);
99  if (!okay) {
100  std::string msg =
101  "WireCell::CookedFrameSource failed to get vector<recob::Wire>: " + m_inputTag.encode();
102  std::cerr << msg << std::endl;
103  THROW(RuntimeError() << errmsg{msg});
104  }
105  else if (rwvh->size() == 0)
106  return;
107 
108  const std::vector<recob::Wire>& rwv(*rwvh);
109  const size_t nchannels = rwv.size();
110  std::cerr << "CookedFrameSource: got " << nchannels << " recob::Wire objects\n";
111 
112  WireCell::ITrace::vector traces(nchannels);
113  for (size_t ind = 0; ind < nchannels; ++ind) {
114  auto const& rw = rwv.at(ind);
115  traces[ind] = ITrace::pointer(make_trace(rw, m_nticks));
116  if (!ind) { // first time through
117  if (m_nticks) {
118  std::cerr << "\tinput nticks=" << rw.NSignal() << " setting to " << m_nticks << std::endl;
119  }
120  else {
121  std::cerr << "\tinput nticks=" << rw.NSignal() << " keeping as is" << std::endl;
122  }
123  }
124  }
125 
126  const double time = tdiff(event.getRun().beginTime(), event.time());
127  auto sframe = new SimpleFrame(event.event(), time, traces, tick);
128  for (auto tag : m_frame_tags) {
129  //std::cerr << "\ttagged: " << tag << std::endl;
130  sframe->tag_frame(tag);
131  }
132  m_frames.push_back(WireCell::IFrame::pointer(sframe));
133  m_frames.push_back(nullptr);
134 }
BEGIN_PROLOG could also be cerr
std::vector< std::string > m_frame_tags
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
static SimpleTrace * make_trace(const recob::Wire &rw, unsigned int nticks_want)
do i e
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
std::deque< WireCell::IFrame::pointer > m_frames

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: