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

#include <RawFrameSource.h>

Inheritance diagram for wcls::RawFrameSource:
wcls::IArtEventVisitor

Public Member Functions

 RawFrameSource ()
 
virtual ~RawFrameSource ()
 
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 RawFrameSource.h.

Constructor & Destructor Documentation

RawFrameSource::RawFrameSource ( )

Definition at line 24 of file RawFrameSource.cxx.

25  : m_nticks(0)
26 {
27 }
RawFrameSource::~RawFrameSource ( )
virtual

Definition at line 29 of file RawFrameSource.cxx.

30 {
31 }

Member Function Documentation

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

Definition at line 44 of file RawFrameSource.cxx.

45 {
46  const std::string art_tag = cfg["art_tag"].asString();
47  if (art_tag.empty()) {
48  THROW(ValueError() << errmsg{"WireCell::RawFrameSource requires a source_label"});
49  }
50  m_inputTag = cfg["art_tag"].asString();
51 
52  m_tick = cfg["tick"].asDouble();
53  for (auto jtag : cfg["frame_tags"]) {
54  m_frame_tags.push_back(jtag.asString());
55  }
56  m_nticks = get(cfg, "nticks", m_nticks);
57 }
art::InputTag m_inputTag
std::string string
Definition: nybbler.cc:12
std::vector< std::string > m_frame_tags
WireCell::Configuration RawFrameSource::default_configuration ( ) const
virtual

IConfigurable.

Definition at line 34 of file RawFrameSource.cxx.

35 {
36  Configuration cfg;
37  cfg["art_tag"] = ""; // how to look up the raw digits
38  cfg["tick"] = 0.5*WireCell::units::us;
39  cfg["frame_tags"][0] = "orig"; // the tags to apply to this frame
40  cfg["nticks"] = m_nticks; // if nonzero, truncate or baseline-pad frame to this number of ticks.
41  return cfg;
42 }
static constexpr double us
Definition: Units.h:97
bool RawFrameSource::operator() ( WireCell::IFrame::pointer &  frame)
virtual

IFrameSource.

Definition at line 145 of file RawFrameSource.cxx.

146 {
147  frame = nullptr;
148  if (m_frames.empty()) {
149  return false;
150  }
151  frame = m_frames.front();
152  m_frames.pop_front();
153  return true;
154 }
std::deque< WireCell::IFrame::pointer > m_frames
void RawFrameSource::visit ( art::Event event)
virtual

IArtEventVisitor.

Implements wcls::IArtEventVisitor.

Definition at line 100 of file RawFrameSource.cxx.

101 {
102  // fixme: want to avoid depending on DetectorPropertiesService for now.
103  const double tick = m_tick;
105  bool okay = event.getByLabel(m_inputTag, rdvh);
106  if (!okay) {
107  std::string msg = "WireCell::RawFrameSource failed to get vector<raw::RawDigit>: " + m_inputTag.encode();
108  std::cerr << msg << std::endl;
109  THROW(RuntimeError() << errmsg{msg});
110  }
111  else if (rdvh->size() == 0) return;
112 
113  const std::vector<raw::RawDigit>& rdv(*rdvh);
114  const size_t nchannels = rdv.size();
115  std::cerr << "RawFrameSource: got " << nchannels << " raw::RawDigit objects\n";
116 
117  WireCell::ITrace::vector traces(nchannels);
118  for (size_t ind=0; ind<nchannels; ++ind) {
119  auto const& rd = rdv.at(ind);
120  traces[ind] = ITrace::pointer(make_trace(rd, m_nticks));
121  if (!ind) {
122  if (m_nticks) {
123  std::cerr
124  << "\tinput nticks=" << rd.ADCs().size() << " setting to " << m_nticks
125  << std::endl;
126  }
127  else {
128  std::cerr
129  << "\tinput nticks=" << rd.ADCs().size() << " keeping as is"
130  << std::endl;
131  }
132  }
133  }
134 
135  const double time = tdiff(event.getRun().beginTime(), event.time());
136  auto sframe = new WireCell::SimpleFrame(event.event(), time, traces, tick);
137  for (auto tag : m_frame_tags) {
138  //std::cerr << "\ttagged: " << tag << std::endl;
139  sframe->tag_frame(tag);
140  }
141  m_frames.push_back(WireCell::IFrame::pointer(sframe));
142  m_frames.push_back(nullptr);
143 }
art::InputTag m_inputTag
EventNumber_t event() const
Definition: DataViewImpl.cc:85
static SimpleTrace * make_trace(const raw::RawDigit &rd, unsigned int nticks_want)
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::deque< WireCell::IFrame::pointer > m_frames
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:75
Run const & getRun() const
Definition: Event.cc:50
std::vector< std::string > m_frame_tags
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
Timestamp const & beginTime() const
Definition: DataViewImpl.cc:92
QTextStream & endl(QTextStream &s)

Member Data Documentation

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

Definition at line 44 of file RawFrameSource.h.

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

Definition at line 40 of file RawFrameSource.h.

art::InputTag wcls::RawFrameSource::m_inputTag
private

Definition at line 41 of file RawFrameSource.h.

int wcls::RawFrameSource::m_nticks
private

Definition at line 43 of file RawFrameSource.h.

double wcls::RawFrameSource::m_tick
private

Definition at line 42 of file RawFrameSource.h.


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