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

#include <Reframer.h>

Inheritance diagram for WireCell::Gen::Reframer:
WireCell::IFrameFilter WireCell::IConfigurable WireCell::IFunctionNode< IFrame, IFrame > WireCell::IComponent< IConfigurable > WireCell::IFunctionNodeBase WireCell::Interface WireCell::INode WireCell::IComponent< INode > WireCell::Interface

Public Member Functions

 Reframer ()
 
virtual ~Reframer ()
 
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...
 
virtual bool operator() (const input_pointer &inframe, output_pointer &outframe)
 The calling signature: More...
 
- Public Member Functions inherited from WireCell::IFrameFilter
virtual ~IFrameFilter ()
 
virtual std::string signature ()
 Set the signature for all subclasses. More...
 
- Public Member Functions inherited from WireCell::IFunctionNode< IFrame, IFrame >
virtual ~IFunctionNode ()
 
virtual bool operator() (const boost::any &anyin, boost::any &anyout)
 The calling signature: More...
 
virtual std::vector< std::stringinput_types ()
 
virtual std::vector< std::stringoutput_types ()
 
- Public Member Functions inherited from WireCell::IFunctionNodeBase
virtual ~IFunctionNodeBase ()
 
virtual NodeCategory category ()
 Return the behavior category type. More...
 
virtual int concurrency ()
 By default assume all subclasses are 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

IAnodePlane::pointer m_anode
 
std::vector< std::stringm_input_tags
 
double m_toffset
 
double m_fill
 
int m_tbin
 
int m_nticks
 
Log::logptr_t log
 

Additional Inherited Members

- Public Types inherited from WireCell::IFrameFilter
typedef std::shared_ptr< IFrameFilterpointer
 
- Public Types inherited from WireCell::IFunctionNode< IFrame, IFrame >
typedef IFrame input_type
 
typedef IFrame output_type
 
typedef std::shared_ptr< const IFrameinput_pointer
 
typedef std::shared_ptr< const IFrameoutput_pointer
 
typedef IFunctionNode< IFrame, IFramesignature_type
 
- Public Types inherited from WireCell::IFunctionNodeBase
typedef std::shared_ptr< IFunctionNodeBasepointer
 
- 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 44 of file Reframer.h.

Constructor & Destructor Documentation

Gen::Reframer::Reframer ( )

Definition at line 20 of file Reframer.cxx.

21  : m_toffset(0.0)
22  , m_fill(0.0)
23  , m_tbin(0)
24  , m_nticks(0)
25  , log(Log::logger("sim"))
26 {
27 }
Log::logptr_t log
Definition: Reframer.h:63
logptr_t logger(std::string name)
Definition: Logging.cxx:71
Gen::Reframer::~Reframer ( )
virtual

Definition at line 29 of file Reframer.cxx.

30 {
31 }

Member Function Documentation

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

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 48 of file Reframer.cxx.

49 {
50  const std::string anode_tn = cfg["anode"].asString();
51  log->debug("Gen::Reframer: using anode: \"{}\"", anode_tn);
52  m_anode = Factory::find_tn<IAnodePlane>(anode_tn);
53 
54  m_input_tags.clear();
55  for (auto jtag : cfg["tags"]) {
56  m_input_tags.push_back(jtag.asString());
57  }
58  m_toffset = get(cfg, "toffset", m_toffset);
59  m_tbin = get(cfg, "tbin", m_tbin);
60  m_fill = get(cfg, "fill", m_fill);
61  m_nticks = get(cfg, "nticks", m_nticks);
62 }
std::vector< std::string > m_input_tags
Definition: Reframer.h:59
std::string string
Definition: nybbler.cc:12
cfg
Definition: dbjson.py:29
Log::logptr_t log
Definition: Reframer.h:63
IAnodePlane::pointer m_anode
Definition: Reframer.h:56
WireCell::Configuration Gen::Reframer::default_configuration ( ) const
virtual

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

Reimplemented from WireCell::IConfigurable.

Definition at line 33 of file Reframer.cxx.

34 {
36 
37  cfg["anode"] = "";
38 
39  cfg["tags"] = Json::arrayValue;
40  cfg["tbin"] = m_tbin;
41  cfg["nticks"] = m_nticks;
42  cfg["toffset"] = m_toffset;
43  cfg["fill"] = m_fill;
44 
45  return cfg;
46 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50
bool Gen::Reframer::operator() ( const input_pointer in,
output_pointer out 
)
virtual

The calling signature:

Implements WireCell::IFunctionNode< IFrame, IFrame >.

Definition at line 67 of file Reframer.cxx.

68 {
69  if (!inframe) {
70  outframe = nullptr;
71  return true;
72  }
73 
74  // Storage for samples indexed by channel ident.
75  std::map<int, std::vector<float> > waves;
76 
77  // initialize a "rectangular" 2D array of samples
78  for (auto chid : m_anode->channels()) {
79  waves[chid].resize(m_nticks, m_fill);
80  }
81 
82  // Get traces to consider
83  std::vector<ITrace::pointer> traces;
84  auto all_traces = inframe->traces();
85  if (m_input_tags.empty()) { // all traces
86  traces.insert(traces.begin(), all_traces->begin(), all_traces->end());
87  }
88  else {
89  // get tagged traces, but don't double count
90  std::unordered_set<int> trace_indices;
91  for (auto tag : m_input_tags) {
92  auto indices = inframe->tagged_traces(tag);
93  trace_indices.insert(indices.begin(), indices.end());
94  }
95  for (int ind : trace_indices) {
96  traces.push_back(all_traces->at(ind));
97  }
98  }
99 
100  // Lay down input traces over output waves
101  for (auto trace : traces) {
102  const int chid = trace->channel();
103 
104  const int tbin_in = trace->tbin();
105  auto in_it = trace->charge().begin();
106 
107  auto& wave = waves[chid]; // reference
108  auto out_it = wave.begin();
109 
110  const int delta_tbin = m_tbin - tbin_in;
111  if (delta_tbin > 0) { // must truncate input
112  in_it += delta_tbin;
113  }
114  else { // must pad output
115  out_it += -delta_tbin;
116  }
117 
118  // Go as far as possible but don't walk of the end of either
119  const auto in_end = trace->charge().end();
120  const auto out_end = wave.end();
121  while (in_it < in_end and out_it < out_end) {
122  *out_it += *in_it; // accumulate
123  ++in_it;
124  ++out_it;
125  }
126 
127  }
128 
129  // Transfer waves into traces.
130  ITrace::vector out_traces;
131  for (auto& it : waves) {
132  const int chid = it.first;
133  auto& wave = it.second;
134  auto out_trace = make_shared<SimpleTrace>(chid, 0, wave);
135  out_traces.push_back(out_trace);
136  }
137 
138  outframe = make_shared<SimpleFrame>(inframe->ident(),
139  inframe->time() + m_toffset + m_tbin*inframe->tick(),
140  out_traces,
141  inframe->tick());
142  log->debug("Gen::Reframer: frame {} {} traces, {} ticks",
143  inframe->ident(), out_traces.size(), m_nticks);
144  return true;
145 }
std::vector< std::string > m_input_tags
Definition: Reframer.h:59
std::vector< pointer > vector
Definition: IData.h:21
Log::logptr_t log
Definition: Reframer.h:63
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
IAnodePlane::pointer m_anode
Definition: Reframer.h:56

Member Data Documentation

Log::logptr_t WireCell::Gen::Reframer::log
private

Definition at line 63 of file Reframer.h.

IAnodePlane::pointer WireCell::Gen::Reframer::m_anode
private

Definition at line 56 of file Reframer.h.

double WireCell::Gen::Reframer::m_fill
private

Definition at line 61 of file Reframer.h.

std::vector<std::string> WireCell::Gen::Reframer::m_input_tags
private

Definition at line 59 of file Reframer.h.

int WireCell::Gen::Reframer::m_nticks
private

Definition at line 62 of file Reframer.h.

int WireCell::Gen::Reframer::m_tbin
private

Definition at line 62 of file Reframer.h.

double WireCell::Gen::Reframer::m_toffset
private

Definition at line 61 of file Reframer.h.


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