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::stringm_frame_tags
 
int m_nticks
 

Detailed Description

Definition at line 20 of file CookedFrameSink.h.

Constructor & Destructor Documentation

CookedFrameSink::CookedFrameSink ( )

Definition at line 20 of file CookedFrameSink.cxx.

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

Definition at line 26 of file CookedFrameSink.cxx.

27 {
28 }

Member Function Documentation

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

Definition at line 42 of file CookedFrameSink.cxx.

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

IConfigurable.

Definition at line 31 of file CookedFrameSink.cxx.

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

IFrameSink.

Definition at line 151 of file CookedFrameSink.cxx.

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

IArtEventVisitor.

Reimplemented from wcls::IArtEventVisitor.

Definition at line 62 of file CookedFrameSink.cxx.

63 {
64  for (auto tag : m_frame_tags) {
65  std::cerr << "CookedFrameSink: promising to produce recob::Wires named \"" << tag << "\"\n";
66  collector.produces< std::vector<recob::Wire> >(tag);
67  }
68 }
std::vector< std::string > m_frame_tags
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
void CookedFrameSink::visit ( art::Event event)
virtual

Implement to visit an Art event.

Implements wcls::IArtEventVisitor.

Definition at line 90 of file CookedFrameSink.cxx.

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