test_staticchannelstatus.cxx
Go to the documentation of this file.
2 #include "WireCellUtil/Units.h"
3 #include "WireCellUtil/Testing.h"
6 
7 #include <iostream>
8 
9 using namespace std;
10 using namespace WireCell;
11 
12 // These are supposed to be the hard-coded defaults in the class.
13 const double nominal_gain = 14.0*units::mV/units::fC;
14 const double nominal_shaping = 2.0*units::us;
15 
16 const double other_gain = 4.7*units::mV/units::fC;
17 const double other_shaping = 1.0*units::us;
18 
20 {
26  return deviants;
27 }
28 
30 {
31  auto deviants = make_deviants();
32 
34 
35  for (int chid=0; chid<10; ++chid) {
36  Assert(scs.preamp_gain(chid) == nominal_gain);
38  }
39 
40  for (int chid=11; chid<=14; ++chid) {
41  Assert(scs.preamp_gain(chid) == deviants[chid].gain);
42  Assert(scs.preamp_shaping(chid) == deviants[chid].shaping);
43  }
44 }
45 
47 {
49  pm.add("WireCellGen");
50 
51  auto cs = Factory::lookup<IChannelStatus>("StaticChannelStatus");
52  auto cscfg = Factory::lookup<IConfigurable>("StaticChannelStatus");
53 
54  auto deviants = make_deviants();
55 
56  Configuration cfg = cscfg->default_configuration();
57  cfg["deviants"] = Json::arrayValue;
58  for (auto it : deviants) {
59  Json::Value jone(Json::objectValue);
60  jone["chid"] = it.first;
61  jone["gain"] = it.second.gain;
62  jone["shaping"] = it.second.shaping;
63  cfg["deviants"].append(jone);
64  }
65  cscfg->configure(cfg);
66 
67  for (int chid=0; chid<10; ++chid) {
68  Assert(cs->preamp_gain(chid) == nominal_gain);
69  Assert(cs->preamp_shaping(chid) == nominal_shaping);
70  }
71 
72  for (int chid=11; chid<=14; ++chid) {
73  // cerr << chid << ": "
74  // << " want gain: " << deviants[chid].gain
75  // << " got gain: " << cs->preamp_gain(chid)
76  // << endl;
77  Assert(cs->preamp_gain(chid) == deviants[chid].gain);
78  Assert(cs->preamp_shaping(chid) == deviants[chid].shaping);
79  }
80 
81 }
82 
83 int main()
84 {
85  test_hardcode();
86  test_config();
87  return 0;
88 }
const double other_shaping
const std::string instance
STL namespace.
cfg
Definition: dbjson.py:29
void test_hardcode()
void test_config()
#define Assert
Definition: Testing.h:7
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2106
float fC
Definition: units.py:113
virtual double preamp_gain(int chid) const
Definition: Main.h:22
std::unordered_map< int, ChannelStatus > channel_status_map_t
static const double us
Definition: Units.h:101
const double nominal_shaping
virtual double preamp_shaping(int chid) const
Json::Value Configuration
Definition: Configuration.h:50
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
const char * cs
const double other_gain
const double nominal_gain
Gen::StaticChannelStatus::channel_status_map_t make_deviants()