FrameSummer.cxx
Go to the documentation of this file.
5 
8 
9 using namespace WireCell;
10 
11 
12 Configuration Gen::FrameSummer::default_configuration() const
13 {
14  // fixme: maybe add operators, scaleing, offsets.
15 
17 
18  // if true, the time of the second frame is ignored in favor of
19  // the first. Does not affect "tbin" values of individual traces.
20  cfg["align"] = m_align;
21 
22  // Amount of time offset to apply to the time of the second frame.
23  // If frame two is "aligned" then this offset is applied to frame
24  // two relative to the time of frame one
25  cfg["offset"] = m_toffset;
26 
27  return cfg;
28 }
29 
31 {
32  m_align = get(cfg, "align", m_align);
33  m_toffset = get(cfg, "offset", m_toffset);
34 }
35 
36 bool Gen::FrameSummer::operator()(const input_tuple_type& intup,
37  output_pointer& out)
38 {
39  auto one = std::get<0>(intup);
40  auto two = std::get<1>(intup);
41  if (!one or !two) {
42  // assume eos
43  out = nullptr;
44  return true;
45  }
46 
47  double t2 = two->time();
48  if (m_align) {
49  t2 = one->time();
50  }
51  t2 += m_toffset;
52 
53  auto vtraces2 = two->traces();
54  ITrace::vector out_traces(vtraces2->begin(), vtraces2->end());
55  auto newtwo = std::make_shared<SimpleFrame>(two->ident(), t2, out_traces, two->tick());
56 
57  out = Gen::sum(IFrame::vector{one,two}, one->ident());
58  return true;
59 }
60 
61 
62 Gen::FrameSummer::FrameSummer()
63  : m_toffset(0.0)
64  , m_align(false)
65 
66 {
67 }
68 
70 {
71 }
WIRECELL_FACTORY(FrameSummer, WireCell::Gen::FrameSummer, WireCell::IFrameJoiner, WireCell::IConfigurable) using namespace WireCell
port_helper_type::template WrappedConst< std::shared_ptr >::type input_tuple_type
Definition: IJoinNode.h:46
cfg
Definition: dbjson.py:29
std::vector< pointer > vector
Definition: IData.h:21
def configure(cfg)
Definition: cuda.py:34
IFrame::pointer sum(std::vector< IFrame::pointer > frames, int ident)
Definition: FrameUtil.cxx:15
Definition: Main.h:22
Json::Value Configuration
Definition: Configuration.h:50