8 #include "art/Framework/Principal/Event.h"
9 #include "art/Framework/Core/EDProducer.h"
11 #include "WireCellIface/IFrame.h"
12 #include "WireCellIface/ITrace.h"
13 #include "WireCellUtil/NamedFactory.h"
19 using namespace WireCell;
27 CookedFrameSink::~CookedFrameSink()
35 cfg[
"anode"] =
"AnodePlane";
37 cfg[
"frame_tags"][0] =
"gauss";
38 cfg[
"frame_tags"][1] =
"wiener";
45 const std::string anode_tn = cfg[
"anode"].asString();
46 if (anode_tn.empty()) {
47 THROW(ValueError() << errmsg{
"CookedFrameSink requires an anode plane"});
51 m_anode = Factory::find_tn<IAnodePlane>(anode_tn);
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();
66 std::cerr <<
"CookedFrameSink: promising to produce recob::Wires named \"" << tag <<
"\"\n";
67 collector.produces< std::vector<recob::Wire> >(tag);
76 auto const& all_traces = frame->traces();
77 for (
size_t index : frame->tagged_traces(tag)) {
78 ret.push_back(all_traces->at(index));
83 auto ftags = frame->frame_tags();
84 if (std::find(ftags.begin(), ftags.end(), tag) == ftags.end()) {
94 std::cerr <<
"CookedFrameSink: I have no frame to save to art::Event\n";
98 std::cerr <<
"CookedFrameSink: got " <<
m_frame->traces()->size() <<
" total traces\n";
103 if (traces.empty()) {
104 std::cerr <<
"CookedFrameSink: no traces for tag \"" << tag <<
"\"\n";
109 std::unique_ptr<std::vector<recob::Wire> > outwires(
new std::vector<recob::Wire>);
113 for (
const auto&
trace : traces) {
115 const int tbin =
trace->tbin();
116 const int chid =
trace->channel();
117 const auto& charge =
trace->charge();
122 size_t ncharge = charge.size();
123 int nticks = tbin + ncharge;
131 roi.
add_range(tbin, charge.begin(), charge.begin() + ncharge);
137 auto const& gc = *lar::providerFrom<geo::Geometry>();
138 auto view = gc.View(chid);
143 outwires->emplace_back(
recob::Wire(roi, chid, view));
145 std::cerr <<
"CookedFrameSink saving " << outwires->size() <<
" recob::Wires named \""<<tag<<
"\"\n";
146 event.put(std::move(outwires), tag);
Utilities related to art service access.
std::vector< std::string > m_frame_tags
BEGIN_PROLOG could also be cerr
virtual WireCell::Configuration default_configuration() const
IConfigurable.
const datarange_t & add_range(size_type offset, ITER first, ITER last)
Adds a sequence of elements as a range with specified offset.
M::value_type trace(const M &m)
virtual bool operator()(const WireCell::IFrame::pointer &frame)
IFrameSink.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
WireCell::IAnodePlane::pointer m_anode
static ITrace::vector tagged_traces(IFrame::pointer frame, IFrame::tag_t tag)
virtual void configure(const WireCell::Configuration &config)
WIRECELL_FACTORY(wclsChannelNoiseDB, wcls::ChannelNoiseDB, wcls::IArtEventVisitor, WireCell::IChannelNoiseDatabase) using namespace WireCell
virtual void produces(art::ProducesCollector &collector)
IArtEventVisitor.
WireCell::IFrame::pointer m_frame
Class holding the regions of interest of signal from a channel.
Declaration of basic channel signal object.
virtual void visit(art::Event &event)
Implement to visit an Art event.
art framework interface to geometry description