StaticChannelStatus.cxx
Go to the documentation of this file.
2 
4 
5 
8 
9 using namespace WireCell;
10 
12  double nominal_shaping,
13  channel_status_map_t deviants)
14  : m_nominal_gain(nominal_gain)
15  , m_nominal_shaping(nominal_shaping)
16  , m_deviants(deviants)
17 {
18 }
19 
20 Gen::StaticChannelStatus::~StaticChannelStatus()
21 {
22 }
23 
24 
25 WireCell::Configuration Gen::StaticChannelStatus::default_configuration() const
26 {
27  Configuration cfg; // load hard-coded defaults
28  cfg["nominal_gain"] = m_nominal_gain;
29  cfg["nominal_shaping"] = m_nominal_shaping;
30  cfg["deviants"] = Json::arrayValue;
31  for (auto it : m_deviants) {
32  Json::Value jdev(Json::objectValue);
33  jdev["chid"] = it.first;
34  jdev["gain"] = it.second.gain;
35  jdev["shaping"] = it.second.shaping;
36  cfg["deviants"].append(jdev);
37  }
38  return cfg;
39 }
40 
41 
43 {
44  // let user override any defaults
45  m_nominal_gain = get(cfg, "nominal_gain", m_nominal_gain);
46  m_nominal_shaping = get(cfg, "nominal_shaping", m_nominal_shaping);
47 
48  auto jdev = cfg["deviants"];
49  if (jdev.isNull()) {
50  return;
51  }
52  for (auto jone : jdev) {
53  const int chid = jone["chid"].asInt(); // must supply
54  const double gain = get(jone, "gain", m_nominal_gain);
55  const double shaping = get(jone, "shaping", m_nominal_shaping);
56  m_deviants[chid] = ChannelStatus(gain, shaping);
57  }
58 }
59 
60 
61 
62 double Gen::StaticChannelStatus::preamp_gain(int chid) const
63 {
64  auto it = m_deviants.find(chid);
65  if (it == m_deviants.end()) {
66  return m_nominal_gain;
67  }
68  return it->second.gain;
69 }
70 double Gen::StaticChannelStatus::preamp_shaping(int chid) const
71 {
72  auto it = m_deviants.find(chid);
73  if (it == m_deviants.end()) {
74  return m_nominal_shaping;
75  }
76  return it->second.shaping;
77 }
78 
WIRECELL_FACTORY(StaticChannelStatus, WireCell::Gen::StaticChannelStatus, WireCell::IChannelStatus, WireCell::IConfigurable) using namespace WireCell
cfg
Definition: dbjson.py:29
def configure(cfg)
Definition: cuda.py:34
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2106
Definition: Main.h:22
std::unordered_map< int, ChannelStatus > channel_status_map_t
const double nominal_shaping
Json::Value Configuration
Definition: Configuration.h:50
const double nominal_gain