DepoFramer.cxx
Go to the documentation of this file.
3 
5 
8 
9 
10 using namespace WireCell;
11 
12 Gen::DepoFramer::DepoFramer(const std::string& drifter, const std::string& ductor)
13  : m_drifter_tn(drifter)
14  , m_ductor_tn(ductor)
15 {
16 }
17 
18 Gen::DepoFramer::~DepoFramer()
19 {
20 }
21 
22 
23 WireCell::Configuration Gen::DepoFramer::default_configuration() const
24 {
26  put(cfg, "Drifter", m_drifter_tn);
27  put(cfg, "Ductor", m_ductor_tn);
28  return cfg;
29 }
30 
32 {
33  m_drifter = Factory::find_tn<IDrifter>(get(cfg, "Drifter", m_drifter_tn));
34  m_ductor = Factory::find_tn<IDuctor>(get(cfg, "Ductor", m_ductor_tn));
35 
36 }
37 
38 
39 bool Gen::DepoFramer::operator()(const input_pointer& in, output_pointer& out)
40 {
41 
42  const int ident = in->ident();
43 
44  // get depos into a mutable vector, sort and terminate
45  auto sdepos = in->depos();
46  std::vector<IDepo::pointer> depos(sdepos->begin(), sdepos->end()), drifted;
47  std::sort(depos.begin(), depos.end(), descending_time);
48  depos.push_back(nullptr);
49 
50  m_drifter->reset();
51  for (auto depo : depos) {
53  (*m_drifter)(depo, dq);
54  for (auto d : dq) {
55  drifted.push_back(d);
56  }
57  }
58  if (drifted.back()) {
59  // check if drifter is following protocol
60  std::cerr << "Gen::DepoFramer: warning: failed to get null on last drifted depo\n";
61  drifted.push_back(nullptr);
62  }
63 
64  m_ductor->reset();
65 
66  std::vector<IFrame::pointer> partial_frames;
67 
68  for (auto drifted_depo : drifted) {
69  IDuctor::output_queue frames;
70  (*m_ductor)(drifted_depo, frames);
71  for (auto f : frames) {
72  partial_frames.push_back(f);
73  }
74  }
75 
76  out = Gen::sum(partial_frames, ident);
77 
78  return true;
79 }
80 
WIRECELL_FACTORY(DepoFramer, WireCell::Gen::DepoFramer, WireCell::IDepoFramer, WireCell::IConfigurable) using namespace WireCell
STL namespace.
void put(Configuration &cfg, const std::string &dotpath, const T &val)
Put value in configuration at the dotted path.
cfg
Definition: dbjson.py:29
std::deque< output_pointer > output_queue
std::shared_ptr< const IDepoSet > input_pointer
Definition: IFunctionNode.h:39
def configure(cfg)
Definition: cuda.py:34
std::shared_ptr< const IFrame > output_pointer
Definition: IFunctionNode.h:40
IFrame::pointer sum(std::vector< IFrame::pointer > frames, int ident)
Definition: FrameUtil.cxx:15
Definition: Main.h:22
bool descending_time(const WireCell::IDepo::pointer &lhs, const WireCell::IDepo::pointer &rhs)
Compare two IDepo::pointers for by time, descending. x is used to break tie.
Definition: IDepo.cxx:29
Json::Value Configuration
Definition: Configuration.h:50