10 #include "WireCellIface/IFrame.h" 11 #include "WireCellIface/ITrace.h" 12 #include "WireCellUtil/NamedFactory.h" 26 CookedFrameSink::~CookedFrameSink()
34 cfg[
"anode"] =
"AnodePlane";
36 cfg[
"frame_tags"][0] =
"gauss";
37 cfg[
"frame_tags"][1] =
"wiener";
44 const std::string anode_tn = cfg[
"anode"].asString();
45 if (anode_tn.empty()) {
46 THROW(ValueError() << errmsg{
"CookedFrameSink requires an anode plane"});
50 m_anode = Factory::find_tn<IAnodePlane>(anode_tn);
52 auto jtags = cfg[
"frame_tags"];
53 std::cerr <<
"CookedFrameSink: saving " << jtags.size() <<
" tags\n";
54 for (
auto jtag : jtags) {
56 std::cerr <<
"\t" << tag <<
"\n";
65 std::cerr <<
"CookedFrameSink: promising to produce recob::Wires named \"" <<
tag <<
"\"\n";
66 collector.
produces< std::vector<recob::Wire> >(tag);
75 auto const& all_traces = frame->traces();
76 for (
size_t index : frame->tagged_traces(tag)) {
77 ret.push_back(all_traces->at(
index));
82 auto ftags = frame->frame_tags();
83 if (std::find(ftags.begin(), ftags.end(), tag) == ftags.end()) {
93 std::cerr <<
"CookedFrameSink: I have no frame to save to art::Event\n";
97 std::cerr <<
"CookedFrameSink: got " <<
m_frame->traces()->size() <<
" total traces\n";
102 if (traces.empty()) {
103 std::cerr <<
"CookedFrameSink: no traces for tag \"" <<
tag <<
"\"\n";
108 std::unique_ptr<std::vector<recob::Wire> > outwires(
new std::vector<recob::Wire>);
112 for (
const auto&
trace : traces) {
114 const int tbin =
trace->tbin();
115 const int chid =
trace->channel();
116 const auto& charge =
trace->charge();
121 size_t ncharge = charge.size();
122 int nticks = tbin + ncharge;
130 roi.
add_range(tbin, charge.begin(), charge.begin() + ncharge);
136 auto const& gc = *lar::providerFrom<geo::Geometry>();
137 auto view = gc.View(chid);
142 outwires->emplace_back(
recob::Wire(roi, chid, view));
144 std::cerr <<
"CookedFrameSink saving " << outwires->size() <<
" recob::Wires named \""<<
tag<<
"\"\n";
std::vector< std::string > m_frame_tags
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.
art framework interface to geometry description
M::value_type trace(const M &m)
virtual bool operator()(const WireCell::IFrame::pointer &frame)
IFrameSink.
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
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.
Event finding and building.