DepoChunker.cxx
Go to the documentation of this file.
3 #include "WireCellUtil/Units.h"
4 
8 using namespace std;
9 using namespace WireCell;
10 
12  : m_count(0)
13  , m_gate(0,0)
14  , m_starting_gate(0,0)
15 {
16 
17 }
18 
19 Gen::DepoChunker::~DepoChunker()
20 {
21 }
22 
24 {
26 
27  /// Set the time gate with a two element array of times. Only
28  /// depos within the gate are output.
29  cfg["gate"] = Json::arrayValue;
30 
31  return cfg;
32 }
33 
35 {
36  m_starting_gate = m_gate = std::pair<double,double>(cfg["gate"][0].asDouble(),
37  cfg["gate"][1].asDouble());
38 }
39 
41 {
42  out.push_back(std::make_shared<SimpleDepoSet>(m_count, m_depos));
43  m_depos.clear();
44  ++m_count;
45 }
46 
48 {
49  if (!depo) { // EOS
50  emit(deposetqueue);
51  m_depos.push_back(depo);
53  return true;
54  }
55 
56  const double now = depo->time();
57 
58  // inside current gate.
59  if (m_gate.first <= now and now < m_gate.second) {
60  m_depos.push_back(depo);
61  return true;
62  }
63 
64  if (now >= m_gate.second) { // start new gate
65  emit(deposetqueue);
66  const double window = m_gate.second - m_gate.first;
67  m_gate = std::pair<double,double>(m_gate.second, m_gate.second + window);
68  m_depos.push_back(depo);
69  return true;
70  }
71 
72  std::cerr << "Gen::DepoChunker: out of time order depo received: now=" << now/units::s << "s\n";
73  return false;
74 }
75 
76 
WIRECELL_FACTORY(DepoChunker, WireCell::Gen::DepoChunker, WireCell::IDepoCollector, WireCell::IConfigurable) using namespace std
void emit(output_queue &out)
Definition: DepoChunker.cxx:40
std::pair< double, double > m_gate
Definition: DepoChunker.h:43
virtual WireCell::Configuration default_configuration() const
Optional, override to return a hard-coded default configuration.
Definition: DepoChunker.cxx:23
STL namespace.
cfg
Definition: dbjson.py:29
std::deque< output_pointer > output_queue
std::pair< double, double > m_starting_gate
Definition: DepoChunker.h:43
virtual void configure(const WireCell::Configuration &config)
Accept a configuration.
Definition: DepoChunker.cxx:34
Definition: Main.h:22
virtual bool operator()(const input_pointer &depo, output_queue &deposetqueue)
The calling signature:
Definition: DepoChunker.cxx:47
static const double s
Definition: Units.h:103
Json::Value Configuration
Definition: Configuration.h:50
std::shared_ptr< const IDepo > input_pointer