DepoMerger.cxx
Go to the documentation of this file.
2 
4 
5 
8 
9 
10 using namespace WireCell;
11 
13  : m_nin0(0), m_nin1(0), m_nout(0), m_eos(false)
14 {
15 }
16 Gen::DepoMerger::~DepoMerger()
17 {
18 }
19 
20 
21 bool Gen::DepoMerger::operator()(input_queues_type& inqs,
22  output_queues_type& outqs)
23 {
24  if (m_eos) { // already closed off all our outputs
25  return false;
26  }
27 
28  auto& inq0 = get<0>(inqs);
29  auto& inq1 = get<1>(inqs);
30 
31  if (inq0.empty() or inq1.empty()) {
32  std::cerr << "DepoMerger: called empty input\n";
33  return false;
34  }
35 
36  auto& outq = get<0>(outqs);
37 
38  //std::cerr << "DepoMerger queue sizes on input: in:["<< inq0.size()<<","<<inq1.size()<<"], "
39  // << "out:["<<outq.size()<<"]\n";
40 
41  IDepo::pointer d0 = inq0.front();
42  IDepo::pointer d1 = inq1.front();
43 
44  if (d0 and d1) {
45  double t0 = d0->time(); // keep the newest one
46  double t1 = d1->time(); // which may be both if they coincide
47  if (t0 <= t1) {
48  ++m_nout;
49  ++m_nin0;
50  outq.push_back(d0);
51  inq0.pop_front();
52  //std::cerr << "DepoMerger: stream 0 output: t0="<<t0<<", t1="<<t1<<"\n";
53  }
54  if (t1 <= t0) {
55  ++m_nout;
56  ++m_nin1;
57  outq.push_back(d1);
58  inq1.pop_front();
59  //std::cerr << "DepoMerger: stream 1 output: t0="<<t0<<", t1="<<t1<<"\n";
60  }
61  return true;
62  }
63 
64  if (d0) { // d1 is eos
65  ++m_nout;
66  ++m_nin0;
67  outq.push_back(d0);
68  inq0.pop_front();
69  //std::cerr << "DepoMerger: stream 0 only output: nout="<<m_nout<<"\n";
70  return true;
71  }
72 
73  if (d1) { // d0 is eos
74  ++m_nout;
75  ++m_nin1;
76  outq.push_back(d1);
77  inq1.pop_front();
78  //std::cerr << "DepoMerger: stream 1 only output: nout="<<m_nout<<"\n";
79  return true;
80  }
81 
82  // both are eos for the first time.
83  m_eos = true;
84  outq.push_back(nullptr);
85  std::cerr << "DepoMerger: global EOS: in: "
86  << m_nin0 << " + " << m_nin1
87  << ", out: " << m_nout << " depos\n";
88 
89  return true;
90 }
91 
92 
94 {
95 }
96 
97 WireCell::Configuration Gen::DepoMerger::default_configuration() const
98 {
100  return cfg;
101 }
code to link reconstructed objects back to the MC truth information
std::shared_ptr< const IDepo > pointer
Definition: IData.h:19
WIRECELL_FACTORY(DepoMerger, WireCell::Gen::DepoMerger, WireCell::IDepoMerger, WireCell::IConfigurable) using namespace WireCell
cfg
Definition: dbjson.py:29
def configure(cfg)
Definition: cuda.py:34
Definition: Main.h:22
Json::Value Configuration
Definition: Configuration.h:50