335 if (nticks_want < 0) {
337 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(event);
338 nticks_want =
detProp.NumberTimeSamples();
339 std::cerr <<
"wclsFrameSaver saving cooked to " << nticks_want <<
" ticks\n";
343 for (
size_t iftag = 0; iftag < nftags; ++iftag) {
350 if (traces.empty()) {
351 std::cerr <<
"wclsFrameSaver: no traces tagged \"" << ftag <<
"\"\n";
355 std::cerr <<
"wclsFrameSaver: saving " << traces.size() <<
" traces tagged \"" << ftag
362 std::unique_ptr<std::vector<recob::Wire>> outwires(
new std::vector<recob::Wire>);
364 double total_charge = 0.0;
365 int total_samples = 0;
368 const int chid = chv.first;
369 const auto& traces = bychan[chid];
373 for (
const auto&
trace : traces) {
374 const int tbin =
trace->tbin();
375 const auto& charge =
trace->charge();
377 auto beg = charge.begin();
378 const auto first = beg;
379 auto end = charge.end();
381 if (tbin >= nticks_want) { beg =
end; }
383 int backup = tbin + charge.size() - nticks_want;
384 if (backup > 0) {
end -= backup; }
388 std::cerr <<
"wclsFrameSaver: no samples within desired window for channel " << chid
393 std::vector<float> scaled(beg,
end);
394 for (
size_t i = 0; i < scaled.size(); ++i)
397 rois.add_range(tbin, scaled.begin(), scaled.end());
403 beg = std::find_if(beg,
end, [](
float v) {
return v != 0.0; });
404 if (beg ==
end) {
break; }
405 auto mid = std::find_if(beg,
end, [](
float v) {
return v == 0.0; });
406 std::vector<float> scaled(beg, mid);
407 for (
int ind = 0; ind < mid - beg; ++ind) {
408 scaled[ind] *= scale;
409 total_charge += scaled[ind];
412 rois.add_range(tbin + beg -
first, scaled.begin(), scaled.end());
418 outwires->emplace_back(
recob::Wire(rois, chid, view));
420 std::cerr <<
"FrameSaver: q=" << total_charge <<
" n=" << total_samples <<
" tag=" << ftag
422 event.put(std::move(outwires), ftag);
std::map< int, geo::View_t > m_chview
BEGIN_PROLOG could also be cerr
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
static void tagged_traces(IFrame::pointer frame, std::string tag, ITrace::vector &ret)
M::value_type trace(const M &m)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< std::string > m_frame_tags
auto end(FixedBins< T, C > const &) noexcept
std::unordered_map< int, ITrace::vector > traces_bychan_t
WireCell::IFrame::pointer m_frame
static void traces_bychan(ITrace::vector &traces, traces_bychan_t &ret)
std::vector< double > m_frame_scale
Class holding the regions of interest of signal from a channel.