Public Member Functions | Private Attributes | List of all members
WireCell::Gen::DepoMerger Class Reference

#include <DepoMerger.h>

Inheritance diagram for WireCell::Gen::DepoMerger:
WireCell::IDepoMerger WireCell::IConfigurable WireCell::IHydraNode< std::tuple< IDepo, IDepo >, std::tuple< IDepo > > WireCell::IComponent< IConfigurable > WireCell::IHydraNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface

Public Member Functions

 DepoMerger ()
 
virtual ~DepoMerger ()
 
virtual bool operator() (input_queues_type &inqs, output_queues_type &outqs)
 Typed interface for subclass to implement. More...
 
virtual void configure (const WireCell::Configuration &config)
 Accept a configuration. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
- Public Member Functions inherited from WireCell::IDepoMerger
virtual ~IDepoMerger ()
 
virtual std::string signature ()
 
- Public Member Functions inherited from WireCell::IHydraNode< std::tuple< IDepo, IDepo >, std::tuple< IDepo > >
virtual ~IHydraNode ()
 
virtual bool operator() (any_queue_vector &anyinq, any_queue_vector &anyoutq)
 Translate call from any to types and back. More...
 
virtual std::vector< std::stringinput_types ()
 
virtual std::vector< std::stringoutput_types ()
 
- Public Member Functions inherited from WireCell::IHydraNodeBase
virtual ~IHydraNodeBase ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
virtual int concurrency ()
 By default assume hydra nodes can do their thing stateless. More...
 
- Public Member Functions inherited from WireCell::INode
virtual ~INode ()
 
virtual void reset ()
 
- Public Member Functions inherited from WireCell::IComponent< INode >
virtual ~IComponent ()
 
- Public Member Functions inherited from WireCell::Interface
virtual ~Interface ()
 
- Public Member Functions inherited from WireCell::IConfigurable
virtual ~IConfigurable ()
 
- Public Member Functions inherited from WireCell::IComponent< IConfigurable >
virtual ~IComponent ()
 

Private Attributes

int m_nin0
 
int m_nin1
 
int m_nout
 
bool m_eos
 

Additional Inherited Members

- Public Types inherited from WireCell::IDepoMerger
typedef std::shared_ptr< IDepoMergerpointer
 
- Public Types inherited from WireCell::IHydraNode< std::tuple< IDepo, IDepo >, std::tuple< IDepo > >
typedef std::tuple< IDepo, IDepoinput_tuple_type
 
typedef std::tuple< IDepooutput_tuple_type
 
typedef shared_queued< std::tuple< IDepo, IDepo > > input_shqed
 
typedef shared_queued< std::tuple< IDepo > > output_shqed
 
typedef input_shqed::shared_queued_tuple_type input_queues_type
 
typedef output_shqed::shared_queued_tuple_type output_queues_type
 
- Public Types inherited from WireCell::IHydraNodeBase
typedef std::shared_ptr< IHydraNodeBasepointer
 
typedef std::deque< boost::any > any_queue
 
typedef std::vector< any_queueany_queue_vector
 
- Public Types inherited from WireCell::INode
enum  NodeCategory {
  unknown, sourceNode, sinkNode, functionNode,
  queuedoutNode, joinNode, splitNode, faninNode,
  fanoutNode, multioutNode, hydraNode
}
 
- Public Types inherited from WireCell::IComponent< INode >
typedef std::shared_ptr< INodepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 
- Public Types inherited from WireCell::Interface
typedef std::shared_ptr< Interfacepointer
 
- Public Types inherited from WireCell::IComponent< IConfigurable >
typedef std::shared_ptr< IConfigurablepointer
 Access subclass facet by pointer. More...
 
typedef std::vector< pointervector
 Vector of shared pointers. More...
 

Detailed Description

Definition at line 10 of file DepoMerger.h.

Constructor & Destructor Documentation

Gen::DepoMerger::DepoMerger ( )

Definition at line 12 of file DepoMerger.cxx.

Gen::DepoMerger::~DepoMerger ( )
virtual

Definition at line 16 of file DepoMerger.cxx.

17 {
18 }

Member Function Documentation

void Gen::DepoMerger::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 93 of file DepoMerger.cxx.

94 {
95 }
WireCell::Configuration Gen::DepoMerger::default_configuration ( ) const
virtual

Optional, override to return a hard-coded default configuration.

Reimplemented from WireCell::IConfigurable.

Definition at line 97 of file DepoMerger.cxx.

98 {
100  return cfg;
101 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool Gen::DepoMerger::operator() ( input_queues_type inqs,
output_queues_type outqs 
)
virtual

Typed interface for subclass to implement.

Implements WireCell::IHydraNode< std::tuple< IDepo, IDepo >, std::tuple< IDepo > >.

Definition at line 21 of file DepoMerger.cxx.

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 }
code to link reconstructed objects back to the MC truth information
std::shared_ptr< const IDepo > pointer
Definition: IData.h:19

Member Data Documentation

bool WireCell::Gen::DepoMerger::m_eos
private

Definition at line 27 of file DepoMerger.h.

int WireCell::Gen::DepoMerger::m_nin0
private

Definition at line 26 of file DepoMerger.h.

int WireCell::Gen::DepoMerger::m_nin1
private

Definition at line 26 of file DepoMerger.h.

int WireCell::Gen::DepoMerger::m_nout
private

Definition at line 26 of file DepoMerger.h.


The documentation for this class was generated from the following files: