ChannelNoiseDB.cxx
Go to the documentation of this file.
1 /**
2  This channel noise database class inherits from OmniChannelNoiseDB
3  and thus may be fully configured via WCT configuration.
4 
5  It additionally provides some select and configurable means to
6  override this configuration with information taken from Art
7  services.
8 
9  - If `bad_channel_policy` is set then take bad channels from the
10  ChannelStatusService. Example WCT config:
11 
12  bad_channel: {policy: "replace"},
13  bad_channel: {policy: "union"},
14 
15  - If `misconfig_channel_policy` is set then take misconfigured
16  channels from ElectronicsCalibService. Example WCT config:
17 
18  misconfig_channel: {
19  policy: "replace",
20  from: {gain: 4.7*wc.mV/wc.fC, shaping: 1.1*wc.us},
21  to: {gain: 14.0*wc.mV/wc.fC, shaping: 2.2*wc.us},
22  }
23 
24 
25  Fixme: original noise filter also used the following and needs to
26  be handled somewhere:
27 
28  - DetPedestalService: to learn and restore a per-channel baseline.
29 
30 */
31 
32 #include "ChannelNoiseDB.h"
33 
39 
40 
41 #include "WireCellUtil/NamedFactory.h"
42 
43 WIRECELL_FACTORY(wclsChannelNoiseDB, wcls::ChannelNoiseDB,
44  wcls::IArtEventVisitor, WireCell::IChannelNoiseDatabase)
45 
46 
47 using namespace WireCell;
48 
50  : OmniChannelNoiseDB()
51  , m_bad_channel_policy(kNothing)
52  , m_misconfig_channel_policy(kNothing)
53 {
54 }
55 
57 {
58 }
59 
61 {
63  return; // no override
64  }
65 
66  // FIXME: the current assumption in this code is that LS channel
67  // numbers are identified with WCT channel IDs. For MicroBooNE
68  // this holds but in general some translation is needed here.
69  auto const& gc = *lar::providerFrom<geo::Geometry>();
70  auto nchans = gc.Nchannels();
71 
72 
74  auto const& csvc = art::ServiceHandle<lariov::ChannelStatusService const>()->GetProvider();
75 
76  std::vector<int> bad_channels;
77  for(size_t ich=0; ich<nchans; ++ich) {
78  if (csvc.IsBad(ich)) {
79  bad_channels.push_back(ich);
80  }
81  }
82  OmniChannelNoiseDB::set_bad_channels(bad_channels);
83  }
84 
86  const auto& esvc = art::ServiceHandle<lariov::ElectronicsCalibService const>()->GetProvider();
87 
88  std::vector<int> mc_channels;
89  for(size_t ich=0; ich<nchans; ++ich) {
90  if (esvc.ExtraInfo(ich).GetBoolData("is_misconfigured")) {
91  mc_channels.push_back(ich);
92  }
93  }
94  OmniChannelNoiseDB::set_misconfigured(mc_channels, m_fgstgs[0], m_fgstgs[1], m_fgstgs[2], m_fgstgs[3]);
95  }
96 }
97 
98 
100 {
101  if (jpol.empty()) {
102  THROW(ValueError() << errmsg{"ChannelNoiseDB: empty override policy given"});
103  }
104 
105  std::string pol = jpol.asString();
106 
107  if (pol == "union") {
108  return kUnion;
109  }
110 
111  if (pol == "replace") {
112  return kReplace;
113  }
114 
115  THROW(ValueError() << errmsg{"ChannelNoiseDB: unknown override policy given: " + pol});
116 }
117 
119 {
120  // forward
121  OmniChannelNoiseDB::configure(cfg);
122 
123  auto jbc = cfg["bad_channel"];
124  if (!jbc.empty()) {
125  m_bad_channel_policy = parse_policy(jbc["policy"]);
126  }
127 
128  auto jmc = cfg["misconfig_channel"];
129  if (!jmc.empty()) {
130  m_misconfig_channel_policy = parse_policy(jmc["policy"]);
131 
132  // stash this for later
133  m_fgstgs[0] = jmc["from"]["gain"].asDouble();
134  m_fgstgs[1] = jmc["from"]["shaping"].asDouble();
135  m_fgstgs[2] = jmc["to"]["gain"].asDouble();
136  m_fgstgs[3] = jmc["to"]["shaping"].asDouble();
137  }
138 }
139 
140 
141 
142 // Local Variables:
143 // mode: c++
144 // c-basic-offset: 4
145 // End:
OverridePolicy_t m_bad_channel_policy
virtual void configure(const WireCell::Configuration &config)
IConfigurable.
std::string string
Definition: nybbler.cc:12
OverridePolicy_t m_misconfig_channel_policy
art framework interface to geometry description
OverridePolicy_t
All IChannelNoiseDatabase interface is defered to parent.
Interface for experiment-specific service for pmt gain info.
OverridePolicy_t parse_policy(const WireCell::Configuration &jpol)
WIRECELL_FACTORY(wclsChannelNoiseDB, wcls::ChannelNoiseDB, wcls::IArtEventVisitor, WireCell::IChannelNoiseDatabase) using namespace WireCell
Interface for experiment-specific channel quality info provider.
Interface for experiment-specific service for channel quality info.
virtual void visit(art::Event &event)
IArtEventVisitor.
Event finding and building.