Public Member Functions | Private Attributes | List of all members
WireCell::Sio::BeeDepoSource Class Reference

#include <BeeDepoSource.h>

Inheritance diagram for WireCell::Sio::BeeDepoSource:
WireCell::IDepoSource WireCell::IConfigurable WireCell::ISourceNode< IDepo > WireCell::IComponent< IConfigurable > WireCell::ISourceNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface

Public Member Functions

 BeeDepoSource ()
 
virtual ~BeeDepoSource ()
 
virtual bool operator() (IDepo::pointer &out)
 IDepoSource. More...
 
virtual WireCell::Configuration default_configuration () const
 IConfigurable. More...
 
virtual void configure (const WireCell::Configuration &config)
 Accept a configuration. More...
 
- Public Member Functions inherited from WireCell::IDepoSource
virtual ~IDepoSource ()
 
virtual std::string signature ()
 Set the signature for all subclasses. More...
 
- Public Member Functions inherited from WireCell::ISourceNode< IDepo >
virtual ~ISourceNode ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
virtual bool operator() (boost::any &anyout)
 
virtual std::vector< std::stringoutput_types ()
 
- Public Member Functions inherited from WireCell::ISourceNodeBase
virtual ~ISourceNodeBase ()
 
- Public Member Functions inherited from WireCell::INode
virtual ~INode ()
 
virtual int concurrency ()
 
virtual std::vector< std::stringinput_types ()
 
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

std::vector< std::stringm_filenames
 
std::string m_policy
 
IDepo::vector m_depos
 

Additional Inherited Members

- Public Types inherited from WireCell::IDepoSource
typedef std::shared_ptr< IDepoSourcepointer
 
- Public Types inherited from WireCell::ISourceNode< IDepo >
typedef IDepo output_type
 
typedef ISourceNode< IDeposignature_type
 
typedef std::shared_ptr< signature_typepointer
 
typedef std::shared_ptr< const IDepooutput_pointer
 
- Public Types inherited from WireCell::ISourceNodeBase
typedef std::shared_ptr< ISourceNodeBasepointer
 
- 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 38 of file BeeDepoSource.h.

Constructor & Destructor Documentation

Sio::BeeDepoSource::BeeDepoSource ( )

Definition at line 21 of file BeeDepoSource.cxx.

22  : m_policy("")
23 {
24 }
Sio::BeeDepoSource::~BeeDepoSource ( )
virtual

Definition at line 26 of file BeeDepoSource.cxx.

27 {
28 }

Member Function Documentation

void Sio::BeeDepoSource::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 86 of file BeeDepoSource.cxx.

87 {
88  m_filenames = get< std::vector<std::string> >(cfg, "filelist");
89  std::reverse(m_filenames.begin(), m_filenames.end()); // to use pop_back().
90  m_policy = get<std::string>(cfg, "policy", "");
91 }
cfg
Definition: dbjson.py:29
std::vector< std::string > m_filenames
Definition: BeeDepoSource.h:54
static unsigned int reverse(QString &chars, unsigned char *level, unsigned int a, unsigned int b)
Definition: qstring.cpp:11649
WireCell::Configuration Sio::BeeDepoSource::default_configuration ( ) const
virtual

IConfigurable.

Reimplemented from WireCell::IConfigurable.

Definition at line 77 of file BeeDepoSource.cxx.

78 {
80  cfg["filelist"] = Json::arrayValue; // list of input files, empties are skipped
81  cfg["policy"] = ""; // set to "stream" to avoid sending EOS after each file's worth of depos.
82  return cfg;
83 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool Sio::BeeDepoSource::operator() ( IDepo::pointer out)
virtual

IDepoSource.

Implements WireCell::ISourceNode< IDepo >.

Definition at line 30 of file BeeDepoSource.cxx.

31 {
32  out = nullptr;
33 
34  if (m_depos.size() > 0) {
35  out = m_depos.back();
36  m_depos.pop_back();
37  return true;
38  }
39 
40  // refill
41  while (!m_filenames.empty()) {
42 
43  std::string fname = m_filenames.back();
44  m_filenames.pop_back();
45  Json::Value jdat = Persist::load(fname);
46  int ndepos = jdat["x"].size();
47  if (!ndepos) {
48  continue;
49  }
50 
51  m_depos.resize(ndepos, nullptr);
52  for (int idepo=0; idepo < ndepos; ++idepo) {
53  m_depos[idepo] = std::make_shared<SimpleDepo>(
54  jdat["t"][idepo].asDouble(),
55  Point(
56  jdat["x"][idepo].asDouble(),
57  jdat["y"][idepo].asDouble(),
58  jdat["z"][idepo].asDouble()),
59  jdat["q"][idepo].asDouble());
60  }
61  if (m_policy != "stream") {
62  m_depos.push_back(nullptr); // chunk by file
63  }
64  std::reverse(m_depos.begin(), m_depos.end());
65  break;
66  }
67 
68  if (m_depos.empty()) {
69  return false;
70  }
71 
72  out = m_depos.back();
73  m_depos.pop_back();
74  return true;
75 }
D3Vector< double > Point
A 3D Cartesian point in double precision.
Definition: Point.h:15
std::string string
Definition: nybbler.cc:12
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2106
const int ndepos
Json::Value load(const std::string &filename, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t())
Definition: Persist.cxx:121
std::vector< std::string > m_filenames
Definition: BeeDepoSource.h:54
static unsigned int reverse(QString &chars, unsigned char *level, unsigned int a, unsigned int b)
Definition: qstring.cpp:11649

Member Data Documentation

IDepo::vector WireCell::Sio::BeeDepoSource::m_depos
private

Definition at line 56 of file BeeDepoSource.h.

std::vector<std::string> WireCell::Sio::BeeDepoSource::m_filenames
private

Definition at line 54 of file BeeDepoSource.h.

std::string WireCell::Sio::BeeDepoSource::m_policy
private

Definition at line 55 of file BeeDepoSource.h.


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