Public Member Functions | Private Attributes | List of all members
WireCell::SigProc::Omnibus Class Reference

#include <Omnibus.h>

Inheritance diagram for WireCell::SigProc::Omnibus:
WireCell::IApplication WireCell::IConfigurable WireCell::IComponent< IApplication > WireCell::IComponent< IConfigurable > WireCell::Interface WireCell::Interface

Public Member Functions

 Omnibus ()
 
virtual ~Omnibus ()
 
virtual void execute ()
 Implement to run something. 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::IApplication
virtual ~IApplication ()
 
- Public Member Functions inherited from WireCell::IComponent< IApplication >
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::string m_input_tn
 
std::string m_output_tn
 
std::vector< std::stringm_filters_tn
 
IFrameSource::pointer m_input
 
std::vector< IFrameFilter::pointerm_filters
 
IFrameSink::pointer m_output
 

Additional Inherited Members

- Public Types inherited from WireCell::IComponent< IApplication >
typedef std::shared_ptr< IApplicationpointer
 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 20 of file Omnibus.h.

Constructor & Destructor Documentation

SigProc::Omnibus::Omnibus ( )

Definition at line 17 of file Omnibus.cxx.

18 {
19 }
SigProc::Omnibus::~Omnibus ( )
virtual

Definition at line 21 of file Omnibus.cxx.

22 {
23 }

Member Function Documentation

void SigProc::Omnibus::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 35 of file Omnibus.cxx.

36 {
37  m_input_tn = cfg["source"].asString(); // keep for printouts later
38  m_input = Factory::find_tn<IFrameSource>(m_input_tn);
39 
40  m_output_tn = cfg["sink"].asString(); // keep for printouts later
41  if (m_output_tn.empty()) {
42  std::cerr << "Omnibus has no final frame sink component.\n";
43  m_output = nullptr;
44  }
45  else {
46  m_output = Factory::find_tn<IFrameSink>(m_output_tn);
47  }
48 
49  m_filters.clear();
50  auto jffl = cfg["filters"];
51  for (auto jff : jffl) {
52  std::string fftn = jff.asString();
53  std::cerr << "Omnibus adding frame filter: \"" << fftn << "\"\n";
54  auto ff = Factory::find_tn<IFrameFilter>(fftn);
55  m_filters.push_back(ff);
56  m_filters_tn.push_back(fftn);
57  }
58 }
std::string string
Definition: nybbler.cc:12
std::vector< std::string > m_filters_tn
Definition: Omnibus.h:35
cfg
Definition: dbjson.py:29
IFrameSource::pointer m_input
Definition: Omnibus.h:36
std::string m_input_tn
Definition: Omnibus.h:34
IFrameSink::pointer m_output
Definition: Omnibus.h:38
std::string m_output_tn
Definition: Omnibus.h:34
std::vector< IFrameFilter::pointer > m_filters
Definition: Omnibus.h:37
WireCell::Configuration SigProc::Omnibus::default_configuration ( ) const
virtual

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

Reimplemented from WireCell::IConfigurable.

Definition at line 26 of file Omnibus.cxx.

27 {
29  cfg["source"] = ""; // required
30  cfg["filters"] = Json::arrayValue;
31  cfg["sink"] = ""; // optional
32  return cfg;
33 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
void SigProc::Omnibus::execute ( )
virtual

Implement to run something.

Implements WireCell::IApplication.

Definition at line 61 of file Omnibus.cxx.

62 {
63  // ExecMon em("omnibus starts");
64 
65  IFrame::pointer frame;
66  if (!(*m_input)(frame)) {
67  std::cerr << "Omnibus: failed to get input frame from " << m_input_tn << "\n";
68  THROW(RuntimeError() << errmsg{"Omnibus: failed to get input frame"});
69  }
70  if (!frame) {
71  std::cerr << "Omnibus: got null frame, forwarding, assuming we have reached EOS\n";
72  }
73  else {
74  if (!frame->traces()->size()) {
75  std::cerr << "Omnibus: got empty input frame, something is busted\n";
76  THROW(RuntimeError() << errmsg{"Omnibus: got empty input frame, something is busted"});
77  }
78  else {
79  std::cerr << "Omnibus: got input frame from "<<m_input_tn<<" with " << frame->traces()->size() << " traces\n";
80  dump_frame(frame);
81  }
82  }
83 
84  //em("sourced frame");
85 
86  int count = 0;
87  for (auto ff : m_filters) {
88  std::string tn = m_filters_tn[count++];
89  IFrame::pointer nextframe;
90  if (!(*ff)(frame, nextframe)) {
91  std::cerr << "Failed to filter frame from "<<tn<<"\n"; // fixme, give more info
92  THROW(RuntimeError() << errmsg{"failed to filter frame"});
93  }
94  if (!nextframe && !frame) {
95  continue; // processing EOS
96  }
97  if (!nextframe) {
98  std::cerr << "Omnibus: filter "<<tn<<" returned a null frame\n";
99  THROW(RuntimeError() << errmsg{"filter returned a null frame"});
100  }
101  //em("filtered frame from " + tn);
102 
103  frame = nextframe;
104  nextframe = nullptr;
105  //em("dropped input to " + tn);
106 
107  if (frame) {
108  std::cerr << "Omnibus: got frame from "<<tn<<" with " << frame->traces()->size() << " traces\n";
109  dump_frame(frame);
110  }
111  }
112 
113  if (m_output) {
114  if (!(*m_output)(frame)) {
115  std::cerr << "Omnibus: failed to send output frame to "<<m_output_tn<<"\n";
116  THROW(RuntimeError() << errmsg{"failed to send output frame"});
117  }
118  }
119  //em("sunk frame");
120 
121  frame = nullptr;
122  //em("dropped output frame");
123 
124  //std::cerr << em.summary() << std::endl;
125 }
std::shared_ptr< const IFrame > pointer
Definition: IData.h:19
std::string string
Definition: nybbler.cc:12
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
std::vector< std::string > m_filters_tn
Definition: Omnibus.h:35
void dump_frame(WireCell::IFrame::pointer frame)
Definition: FrameUtils.cxx:10
IFrameSource::pointer m_input
Definition: Omnibus.h:36
std::string m_input_tn
Definition: Omnibus.h:34
IFrameSink::pointer m_output
Definition: Omnibus.h:38
#define THROW(e)
Definition: Exceptions.h:25
std::string m_output_tn
Definition: Omnibus.h:34
std::vector< IFrameFilter::pointer > m_filters
Definition: Omnibus.h:37

Member Data Documentation

std::vector<IFrameFilter::pointer> WireCell::SigProc::Omnibus::m_filters
private

Definition at line 37 of file Omnibus.h.

std::vector<std::string> WireCell::SigProc::Omnibus::m_filters_tn
private

Definition at line 35 of file Omnibus.h.

IFrameSource::pointer WireCell::SigProc::Omnibus::m_input
private

Definition at line 36 of file Omnibus.h.

std::string WireCell::SigProc::Omnibus::m_input_tn
private

Definition at line 34 of file Omnibus.h.

IFrameSink::pointer WireCell::SigProc::Omnibus::m_output
private

Definition at line 38 of file Omnibus.h.

std::string WireCell::SigProc::Omnibus::m_output_tn
private

Definition at line 34 of file Omnibus.h.


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