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

#include <AddNoise.h>

Inheritance diagram for WireCell::Gen::AddNoise:
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

 AddNoise (const std::string &model="", const std::string &rng="Random")
 
virtual ~AddNoise ()
 
virtual bool operator() (const input_pointer &inframe, output_pointer &outframe)
 IFrameFilter. More...
 
virtual void configure (const WireCell::Configuration &config)
 IConfigurable. More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. 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

IRandom::pointer m_rng
 
IChannelSpectrum::pointer m_model
 
std::string m_model_tn
 
std::string m_rng_tn
 
int m_nsamples
 
double m_rep_percent
 
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 22 of file AddNoise.h.

Constructor & Destructor Documentation

Gen::AddNoise::AddNoise ( const std::string model = "",
const std::string rng = "Random" 
)

Definition at line 19 of file AddNoise.cxx.

20  : m_model_tn(model)
21  , m_rng_tn(rng)
22  , m_nsamples(9600)
23  , m_rep_percent(0.02) // replace 2% at a time
24  , log(Log::logger("sim"))
25 {
26 }
Log::logptr_t log
Definition: AddNoise.h:44
std::string m_model_tn
Definition: AddNoise.h:40
logptr_t logger(std::string name)
Definition: Logging.cxx:71
std::string m_rng_tn
Definition: AddNoise.h:40
Gen::AddNoise::~AddNoise ( )
virtual

Definition at line 29 of file AddNoise.cxx.

30 {
31 }

Member Function Documentation

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

IConfigurable.

Implements WireCell::IConfigurable.

Definition at line 46 of file AddNoise.cxx.

47 {
48  m_rng_tn = get(cfg, "rng", m_rng_tn);
49  m_rng = Factory::find_tn<IRandom>(m_rng_tn);
50  m_model_tn = get(cfg, "model", m_model_tn);
51  m_model = Factory::find_tn<IChannelSpectrum>(m_model_tn);
52  m_nsamples = get<int>(cfg,"nsamples",m_nsamples);
53  m_rep_percent = get<double>(cfg,"replacement_percentage",m_rep_percent);
54 
55  log->debug("AddNoise: using IRandom: \"{}\", IChannelSpectrum: \"{}\"",
56  m_rng_tn, m_model_tn);
57 }
cfg
Definition: dbjson.py:29
Log::logptr_t log
Definition: AddNoise.h:44
IChannelSpectrum::pointer m_model
Definition: AddNoise.h:38
std::string m_model_tn
Definition: AddNoise.h:40
IRandom::pointer m_rng
Definition: AddNoise.h:37
std::string m_rng_tn
Definition: AddNoise.h:40
WireCell::Configuration Gen::AddNoise::default_configuration ( ) const
virtual

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

Reimplemented from WireCell::IConfigurable.

Definition at line 33 of file AddNoise.cxx.

34 {
36 
37  // fixme: maybe add some tag support?
38 
39  cfg["model"] = m_model_tn;
40  cfg["rng"] = m_rng_tn;
41  cfg["nsamples"] = m_nsamples;
42  cfg["replacement_percentage"] = m_rep_percent;
43  return cfg;
44 }
cfg
Definition: dbjson.py:29
std::string m_model_tn
Definition: AddNoise.h:40
Json::Value Configuration
Definition: Configuration.h:50
std::string m_rng_tn
Definition: AddNoise.h:40
bool Gen::AddNoise::operator() ( const input_pointer inframe,
output_pointer outframe 
)
virtual

IFrameFilter.

Implements WireCell::IFunctionNode< IFrame, IFrame >.

Definition at line 61 of file AddNoise.cxx.

62 {
63  if (!inframe) {
64  outframe = nullptr;
65  return true;
66  }
67 
68  ITrace::vector outtraces;
69  for (const auto& intrace : *inframe->traces()) {
70  int chid = intrace->channel();
71  const auto& spec = (*m_model)(chid);
73 
74  wave.resize(m_nsamples,0);
75  Waveform::increase(wave, intrace->charge());
76  auto trace = make_shared<SimpleTrace>(chid, intrace->tbin(), wave);
77  outtraces.push_back(trace);
78  }
79  outframe = make_shared<SimpleFrame>(inframe->ident(), inframe->time(),
80  outtraces, inframe->tick());
81  return true;
82 }
Sequence< real_t > realseq_t
Definition: Waveform.h:31
std::vector< pointer > vector
Definition: IData.h:21
void increase(Sequence< Val > &seq, Val scalar)
Increase (shift) sequence values by scalar.
Definition: Waveform.h:129
WireCell::Waveform::realseq_t generate_waveform(const std::vector< float > &spec, IRandom::pointer rng, double replace=0.02)
Definition: Noise.cxx:7
IRandom::pointer m_rng
Definition: AddNoise.h:37

Member Data Documentation

Log::logptr_t WireCell::Gen::AddNoise::log
private

Definition at line 44 of file AddNoise.h.

IChannelSpectrum::pointer WireCell::Gen::AddNoise::m_model
private

Definition at line 38 of file AddNoise.h.

std::string WireCell::Gen::AddNoise::m_model_tn
private

Definition at line 40 of file AddNoise.h.

int WireCell::Gen::AddNoise::m_nsamples
private

Definition at line 41 of file AddNoise.h.

double WireCell::Gen::AddNoise::m_rep_percent
private

Definition at line 42 of file AddNoise.h.

IRandom::pointer WireCell::Gen::AddNoise::m_rng
private

Definition at line 37 of file AddNoise.h.

std::string WireCell::Gen::AddNoise::m_rng_tn
private

Definition at line 40 of file AddNoise.h.


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