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

#include <PerChannelVariation.h>

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

 PerChannelVariation ()
 
virtual ~PerChannelVariation ()
 
virtual bool operator() (const input_pointer &in, output_pointer &out)
 The calling signature: More...
 
virtual WireCell::Configuration default_configuration () const
 Optional, override to return a hard-coded default configuration. More...
 
virtual void configure (const WireCell::Configuration &cfg)
 Accept a 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

std::string m_per_chan_resp
 
WireCell::IChannelResponse::pointer m_cr
 
int m_nsamples
 
WireCell::Waveform::realseq_t m_from
 
bool m_truncate
 

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 32 of file PerChannelVariation.h.

Constructor & Destructor Documentation

Gen::PerChannelVariation::PerChannelVariation ( )

Definition at line 15 of file PerChannelVariation.cxx.

16 {
17 }
Gen::PerChannelVariation::~PerChannelVariation ( )
virtual

Definition at line 19 of file PerChannelVariation.cxx.

20 {
21 }

Member Function Documentation

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

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 52 of file PerChannelVariation.cxx.

53 {
54  m_per_chan_resp = get<std::string>(cfg, "per_chan_resp", "");
55 
56  if (! m_per_chan_resp.empty()) {
57  std::cerr<<"SIMULATION: CH-BY-CH ELECTRONICS RESPONSE VARIATION\n";
58  m_cr = Factory::find_tn<IChannelResponse>(m_per_chan_resp);
59  double tick = cfg["tick"].asDouble();
60  auto cr_bins = m_cr->channel_response_binning();
61  if (cr_bins.binsize() != tick) {
62  THROW(ValueError() << errmsg{"PerChannelVariation: channel response tbin size mismatch!"});
63  }
64  m_nsamples = cr_bins.nbins();
65  WireCell::Binning tbins(m_nsamples, cr_bins.min(), cr_bins.min() + m_nsamples*tick);
66  m_from = Response::ColdElec(cfg["gain"].asDouble(),
67  cfg["shaping"].asDouble()).generate(tbins);
68  }
69 
70  m_truncate = cfg["truncate"].asBool();
71 }
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
cfg
Definition: dbjson.py:29
const double tick
Binning tbins(nticks, t0, t0+readout_time)
WireCell::Waveform::realseq_t m_from
#define THROW(e)
Definition: Exceptions.h:25
WireCell::IChannelResponse::pointer m_cr
WireCell::Configuration Gen::PerChannelVariation::default_configuration ( ) const
virtual

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

If to truncate the waveforms. The convolution used to apply the misconfiguring will extend the a trace's waveform by nsamples-1. Truncating will clip that much off so the waveform will remains the same length but some information may be lost. If not truncated, this longer waveform likely needs to be handled in some way by the user.

ch-by-ch electronics responses by calibration

Reimplemented from WireCell::IConfigurable.

Definition at line 24 of file PerChannelVariation.cxx.

25 {
27 
28  // nominally correctly configured amplifiers in MB. They should
29  // match what ever was used to create the input waveforms.
30  cfg["gain"] = 14.0*units::mV/units::fC;
31  cfg["shaping"] = 2.2*units::us;
32 
33  // The number of nsamples of the response functions.
34  cfg ["nsamples"] = 310;
35  // The period of sampling the response functions
36  cfg["tick"] = 0.5*units::us;
37 
38  /// If to truncate the waveforms. The convolution
39  /// used to apply the misconfiguring will extend the a trace's
40  /// waveform by nsamples-1. Truncating will clip that much off so
41  /// the waveform will remains the same length but some information
42  /// may be lost. If not truncated, this longer waveform likely
43  /// needs to be handled in some way by the user.
44  cfg["truncate"] = true;
45 
46  /// ch-by-ch electronics responses by calibration
47  cfg["per_chan_resp"] = "";
48 
49  return cfg;
50 }
static const double mV
Definition: Units.h:180
cfg
Definition: dbjson.py:29
static const double fC
Definition: Units.h:113
Json::Value Configuration
Definition: Configuration.h:50
static const double us
Definition: Units.h:105
bool Gen::PerChannelVariation::operator() ( const input_pointer in,
output_pointer out 
)
virtual

The calling signature:

Implements WireCell::IFunctionNode< IFrame, IFrame >.

Definition at line 73 of file PerChannelVariation.cxx.

74 {
75  if (!in) {
76  out = nullptr;
77  return true;
78  }
79 
80  if (m_per_chan_resp.empty()) {
81  std::cerr << "Gen::PerChannelVariation: warning no ch-by-ch response was found!\n";
82  out = in;
83  return true;
84  }
85 
86  auto traces = in->traces();
87  if (!traces) {
88  std::cerr << "Gen::PerChannelVariation: error no traces in frame for me\n";
89  return false;
90  }
91 
92 
93  size_t ntraces = traces->size();
94  ITrace::vector out_traces(ntraces);
95  for (size_t ind=0; ind<ntraces; ++ind) {
96  auto trace = traces->at(ind);
97  auto chid = trace->channel();
98  Waveform::realseq_t tch_resp = m_cr->channel_response(chid);
99  tch_resp.resize(m_nsamples, 0);
100  auto wave = Waveform::replace_convolve(trace->charge(),
101  tch_resp, m_from, m_truncate);
102  out_traces[ind] = std::make_shared<SimpleTrace>(chid, trace->tbin(), wave);
103  }
104 
105  out = std::make_shared<SimpleFrame>(in->ident(), in->time(), out_traces, in->tick());
106  return true;
107 }
Sequence< real_t > realseq_t
Definition: Waveform.h:31
std::vector< pointer > vector
Definition: IData.h:21
realseq_t replace_convolve(Waveform::realseq_t wave, Waveform::realseq_t newres, Waveform::realseq_t oldres, bool truncate=true)
Definition: Waveform.cxx:187
WireCell::Waveform::realseq_t m_from
WireCell::IChannelResponse::pointer m_cr

Member Data Documentation

WireCell::IChannelResponse::pointer WireCell::Gen::PerChannelVariation::m_cr
private

Definition at line 46 of file PerChannelVariation.h.

WireCell::Waveform::realseq_t WireCell::Gen::PerChannelVariation::m_from
private

Definition at line 48 of file PerChannelVariation.h.

int WireCell::Gen::PerChannelVariation::m_nsamples
private

Definition at line 47 of file PerChannelVariation.h.

std::string WireCell::Gen::PerChannelVariation::m_per_chan_resp
private

Definition at line 45 of file PerChannelVariation.h.

bool WireCell::Gen::PerChannelVariation::m_truncate
private

Definition at line 49 of file PerChannelVariation.h.


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