All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
wcls::CookedFrameSink Class Reference

#include <CookedFrameSink.h>

Inheritance diagram for wcls::CookedFrameSink:
wcls::IArtEventVisitor

Public Member Functions

 CookedFrameSink ()
 
virtual ~CookedFrameSink ()
 
virtual void produces (art::ProducesCollector &collector)
 IArtEventVisitor. More...
 
virtual void visit (art::Event &event)
 Implement to visit an Art event. More...
 
virtual bool operator() (const WireCell::IFrame::pointer &frame)
 IFrameSink. 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 ()
 

Private Attributes

WireCell::IFrame::pointer m_frame
 
WireCell::IAnodePlane::pointer m_anode
 
std::vector< std::string > m_frame_tags
 
int m_nticks
 

Detailed Description

Definition at line 20 of file CookedFrameSink.h.

Constructor & Destructor Documentation

CookedFrameSink::CookedFrameSink ( )

Definition at line 21 of file CookedFrameSink.cxx.

22  : m_frame(nullptr)
23  , m_nticks(0)
24 {
25 }
WireCell::IFrame::pointer m_frame
CookedFrameSink::~CookedFrameSink ( )
virtual

Definition at line 27 of file CookedFrameSink.cxx.

28 {
29 }

Member Function Documentation

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

Definition at line 43 of file CookedFrameSink.cxx.

44 {
45  const std::string anode_tn = cfg["anode"].asString();
46  if (anode_tn.empty()) {
47  THROW(ValueError() << errmsg{"CookedFrameSink requires an anode plane"});
48  }
49 
50  // this throws if not found
51  m_anode = Factory::find_tn<IAnodePlane>(anode_tn);
52 
53  auto jtags = cfg["frame_tags"];
54  std::cerr << "CookedFrameSink: saving " << jtags.size() << " tags\n";
55  for (auto jtag : jtags) {
56  std::string tag = jtag.asString();
57  std::cerr << "\t" << tag << "\n";
58  m_frame_tags.push_back(tag);
59  }
60  m_nticks = get(cfg, "nticks", m_nticks);
61 }
std::vector< std::string > m_frame_tags
BEGIN_PROLOG could also be cerr
WireCell::IAnodePlane::pointer m_anode
WireCell::Configuration CookedFrameSink::default_configuration ( ) const
virtual

IConfigurable.

Definition at line 32 of file CookedFrameSink.cxx.

33 {
34  Configuration cfg;
35  cfg["anode"] = "AnodePlane";
36  // frames to output
37  cfg["frame_tags"][0] = "gauss";
38  cfg["frame_tags"][1] = "wiener";
39  cfg["nticks"] = m_nticks; // if nonzero, force number of ticks in output waveforms.
40  return cfg;
41 }
bool CookedFrameSink::operator() ( const WireCell::IFrame::pointer &  frame)
virtual

IFrameSink.

Definition at line 152 of file CookedFrameSink.cxx.

153 {
154  // set an IFrame based on last visited event.
155  m_frame = frame;
156  return true;
157 }
WireCell::IFrame::pointer m_frame
void CookedFrameSink::produces ( art::ProducesCollector &  collector)
virtual

IArtEventVisitor.

Reimplemented from wcls::IArtEventVisitor.

Definition at line 63 of file CookedFrameSink.cxx.

64 {
65  for (auto tag : m_frame_tags) {
66  std::cerr << "CookedFrameSink: promising to produce recob::Wires named \"" << tag << "\"\n";
67  collector.produces< std::vector<recob::Wire> >(tag);
68  }
69 }
std::vector< std::string > m_frame_tags
BEGIN_PROLOG could also be cerr
void CookedFrameSink::visit ( art::Event &  event)
virtual

Implement to visit an Art event.

Implements wcls::IArtEventVisitor.

Definition at line 91 of file CookedFrameSink.cxx.

92 {
93  if (!m_frame) {
94  std::cerr << "CookedFrameSink: I have no frame to save to art::Event\n";
95  return;
96  }
97 
98  std::cerr << "CookedFrameSink: got " << m_frame->traces()->size() << " total traces\n";
99 
100  for (auto tag : m_frame_tags) {
101 
102  auto traces = tagged_traces(m_frame, tag);
103  if (traces.empty()) {
104  std::cerr << "CookedFrameSink: no traces for tag \"" << tag << "\"\n";
105  continue;
106  }
107 
108 
109  std::unique_ptr<std::vector<recob::Wire> > outwires(new std::vector<recob::Wire>);
110 
111  // what about the frame's time() and ident()?
112 
113  for (const auto& trace : traces) {
114 
115  const int tbin = trace->tbin();
116  const int chid = trace->channel();
117  const auto& charge = trace->charge();
118 
119  //std::cerr << tag << ": chid=" << chid << " tbin=" << tbin << " nq=" << charge.size() << std::endl;
120 
121  // enforce number of ticks if we are so configured.
122  size_t ncharge = charge.size();
123  int nticks = tbin + ncharge;
124  if (m_nticks) { // force output waveform size
125  if (m_nticks < nticks) {
126  ncharge = m_nticks - tbin;
127  }
128  nticks = m_nticks;
129  }
131  roi.add_range(tbin, charge.begin(), charge.begin() + ncharge);
132 
133  // FIXME: the current assumption in this code is that LS channel
134  // numbers are identified with WCT channel IDs.
135  // Fact: the plane view for the ICARUS induction-1 is "geo::kY",
136  // instead of "geo::kU"
137  auto const& gc = *lar::providerFrom<geo::Geometry>();
138  auto view = gc.View(chid);
139 
140  // what about those pesky channel map masks?
141  // they are dropped for now.
142 
143  outwires->emplace_back(recob::Wire(roi, chid, view));
144  }
145  std::cerr << "CookedFrameSink saving " << outwires->size() << " recob::Wires named \""<<tag<<"\"\n";
146  event.put(std::move(outwires), tag);
147  }
148 
149  m_frame = nullptr;
150 }
std::vector< std::string > m_frame_tags
BEGIN_PROLOG could also be cerr
M::value_type trace(const M &m)
static ITrace::vector tagged_traces(IFrame::pointer frame, IFrame::tag_t tag)
WireCell::IFrame::pointer m_frame
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118

Member Data Documentation

WireCell::IAnodePlane::pointer wcls::CookedFrameSink::m_anode
private

Definition at line 40 of file CookedFrameSink.h.

WireCell::IFrame::pointer wcls::CookedFrameSink::m_frame
private

Definition at line 39 of file CookedFrameSink.h.

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

Definition at line 41 of file CookedFrameSink.h.

int wcls::CookedFrameSink::m_nticks
private

Definition at line 42 of file CookedFrameSink.h.


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