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

Detailed Description

Definition at line 22 of file RawFrameSource.h.

Constructor & Destructor Documentation

RawFrameSource::RawFrameSource ( )

Definition at line 26 of file RawFrameSource.cxx.

27  : m_nticks(0)
28 {
29 }
RawFrameSource::~RawFrameSource ( )
virtual

Definition at line 31 of file RawFrameSource.cxx.

32 {
33 }

Member Function Documentation

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

Definition at line 46 of file RawFrameSource.cxx.

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

IConfigurable.

Definition at line 36 of file RawFrameSource.cxx.

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

IFrameSource.

Definition at line 147 of file RawFrameSource.cxx.

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

IArtEventVisitor.

Implements wcls::IArtEventVisitor.

Definition at line 102 of file RawFrameSource.cxx.

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

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: