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

#include <PerChannelResponse.h>

Inheritance diagram for WireCell::SigProc::PerChannelResponse:
WireCell::IChannelResponse WireCell::IConfigurable WireCell::IComponent< IChannelResponse > WireCell::IComponent< IConfigurable > WireCell::Interface WireCell::Interface

Public Member Functions

 PerChannelResponse (const char *filename="")
 
virtual ~PerChannelResponse ()
 
virtual const Waveform::realseq_tchannel_response (int channel_ident) const
 
virtual Binning channel_response_binning () const
 Return the binning that the channel_response follows. 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::IChannelResponse
virtual ~IChannelResponse ()
 
- Public Member Functions inherited from WireCell::IComponent< IChannelResponse >
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_filename
 
std::unordered_map< int, Waveform::realseq_tm_cr
 
Binning m_bins
 

Additional Inherited Members

- Public Types inherited from WireCell::IComponent< IChannelResponse >
typedef std::shared_ptr< IChannelResponsepointer
 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 16 of file PerChannelResponse.h.

Constructor & Destructor Documentation

SigProc::PerChannelResponse::PerChannelResponse ( const char *  filename = "")

Definition at line 15 of file PerChannelResponse.cxx.

17 {
18 }
string filename
Definition: train.py:213
SigProc::PerChannelResponse::~PerChannelResponse ( )
virtual

Definition at line 20 of file PerChannelResponse.cxx.

21 {
22 }

Member Function Documentation

const Waveform::realseq_t & SigProc::PerChannelResponse::channel_response ( int  channel_ident) const
virtual

Provide the channel response for the given channel ID number. Note the binning of the returned waveform should be coordinated through configuration.

Implements WireCell::IChannelResponse.

Definition at line 66 of file PerChannelResponse.cxx.

67 {
68  const auto& it = m_cr.find(channel_ident);
69  if (it == m_cr.end()) {
70  THROW(KeyError() << errmsg{String::format("no response for channel %d", channel_ident)});
71  }
72  return it->second;
73 }
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
std::unordered_map< int, Waveform::realseq_t > m_cr
#define THROW(e)
Definition: Exceptions.h:25
std::string format(const std::string &form, TYPES...objs)
Definition: String.h:45
def channel_ident(G, wire)
Definition: apa.py:445
Binning SigProc::PerChannelResponse::channel_response_binning ( ) const
virtual

Return the binning that the channel_response follows.

Implements WireCell::IChannelResponse.

Definition at line 75 of file PerChannelResponse.cxx.

76 {
77  return m_bins;
78 }
void SigProc::PerChannelResponse::configure ( const WireCell::Configuration config)
virtual

Accept a configuration.

Implements WireCell::IConfigurable.

Definition at line 31 of file PerChannelResponse.cxx.

32 {
33  m_filename = get(cfg, "filename", m_filename);
34  if (m_filename.empty()) {
35  THROW(ValueError() << errmsg{"must supply a PerChannelResponse filename"});
36  }
37 
39  const double tick = top["tick"].asFloat();
40  const double t0 = top["t0"].asFloat();
41  auto jchannels = top["channels"];
42  if (jchannels.isNull()) {
43  THROW(ValueError() << errmsg{"no channels given in file " + m_filename});
44  }
45 
46  for (auto jchresp : jchannels) {
47  const int ch = jchresp[0].asInt();
48  auto jresp = jchresp[1];
49  const int nsamp = jresp.size();
50  if (nsamp == 0) {
51  THROW(ValueError() << errmsg{"zero length response in file " + m_filename});
52  }
53  Waveform::realseq_t resp(nsamp, 0);
54  for (int ind=0; ind<nsamp; ++ind) {
55  resp[ind] = jresp[ind].asFloat();
56  }
57  m_cr[ch] = resp;
58  if (!m_bins.nbins()) { // first time
59  m_bins = Binning(nsamp, t0, t0+nsamp*tick);
60  }
61  }
62 
63 }
code to link reconstructed objects back to the MC truth information
Sequence< real_t > realseq_t
Definition: Waveform.h:31
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
cfg
Definition: dbjson.py:29
const double tick
std::unordered_map< int, Waveform::realseq_t > m_cr
Json::Value load(const std::string &filename, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t())
Definition: Persist.cxx:121
#define THROW(e)
Definition: Exceptions.h:25
int nbins() const
Definition: Binning.h:42
WireCell::Configuration SigProc::PerChannelResponse::default_configuration ( ) const
virtual

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

Reimplemented from WireCell::IConfigurable.

Definition at line 24 of file PerChannelResponse.cxx.

25 {
27  cfg["filename"] = m_filename;
28  return cfg;
29 }
cfg
Definition: dbjson.py:29
Json::Value Configuration
Definition: Configuration.h:50

Member Data Documentation

Binning WireCell::SigProc::PerChannelResponse::m_bins
private

Definition at line 34 of file PerChannelResponse.h.

std::unordered_map<int,Waveform::realseq_t> WireCell::SigProc::PerChannelResponse::m_cr
private

Definition at line 33 of file PerChannelResponse.h.

std::string WireCell::SigProc::PerChannelResponse::m_filename
private

Definition at line 32 of file PerChannelResponse.h.


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