SilentNoise.cxx
Go to the documentation of this file.
1 #include "WireCellGen/SilentNoise.h" // holly noise
3 #include "WireCellUtil/Units.h"
6 
7 #include <memory>
8 
11 
12 
13 
14 using namespace WireCell;
15 
17  : m_count(0)
18 {
19 }
20 
21 Gen::SilentNoise::~SilentNoise()
22 {
23 }
24 
26 {
27  m_noutputs = get(cfg,"noutputs",0);
28  m_nchannels = get(cfg,"nchannels",0);
29  m_traces_tag = cfg["traces_tag"].asString();
30 }
31 
32 WireCell::Configuration Gen::SilentNoise::default_configuration() const
33 {
35  cfg["noutputs"] = 0; // run forever
36  cfg["nchannels"] = 0; // empty
37  cfg["traces_tag"] = ""; // empty string means no tag on traces
38  return cfg;
39 }
40 
41 
42 bool Gen::SilentNoise::operator()(output_pointer& out)
43 {
44  out = nullptr;
45  if (m_noutputs and m_count == m_noutputs) {
46  ++m_count;
47  return true;
48  }
49  if (m_noutputs and m_count >= m_noutputs) {
50  return false;
51  }
52  //std::cerr << "SilentNoise: output #" << m_count << " / " << m_noutputs << std::endl;
53  ITrace::vector traces(m_nchannels);
54  for (int ind=0; ind<m_nchannels; ++ind) {
55  traces[ind] = std::make_shared<SimpleTrace>(ind, 0, 0); // boring traces
56  }
57  auto sfout = new SimpleFrame(m_count, m_count*5.0*units::ms, traces);
58  if (m_traces_tag != "") {
59  IFrame::trace_list_t tl(m_nchannels);
60  std::iota(tl.begin(), tl.end(), 0);
61  sfout->tag_traces(m_traces_tag, tl);
62  }
63  out = IFrame::pointer(sfout);
64  ++m_count;
65  return true;
66 }
cfg
Definition: dbjson.py:29
std::vector< pointer > vector
Definition: IData.h:21
std::shared_ptr< const IFrame > output_pointer
Definition: ISourceNode.h:38
def configure(cfg)
Definition: cuda.py:34
Definition: Main.h:22
static const double ms
Definition: Units.h:100
Json::Value Configuration
Definition: Configuration.h:50
const GenericPointer< typename T::ValueType > & pointer
Definition: pointer.h:1124
WIRECELL_FACTORY(SilentNoise, WireCell::Gen::SilentNoise, WireCell::IFrameSource, WireCell::IConfigurable) using namespace WireCell
std::vector< size_t > trace_list_t
Definition: IFrame.h:36