Functions | Variables
test_staticchannelstatus.cxx File Reference
#include "WireCellGen/StaticChannelStatus.h"
#include "WireCellUtil/Units.h"
#include "WireCellUtil/Testing.h"
#include "WireCellUtil/NamedFactory.h"
#include "WireCellUtil/PluginManager.h"
#include <iostream>

Go to the source code of this file.

Functions

Gen::StaticChannelStatus::channel_status_map_t make_deviants ()
 
void test_hardcode ()
 
void test_config ()
 
int main ()
 

Variables

const double nominal_gain = 14.0*units::mV/units::fC
 
const double nominal_shaping = 2.0*units::us
 
const double other_gain = 4.7*units::mV/units::fC
 
const double other_shaping = 1.0*units::us
 

Function Documentation

int main ( void  )

Definition at line 83 of file test_staticchannelstatus.cxx.

84 {
85  test_hardcode();
86  test_config();
87  return 0;
88 }
void test_hardcode()
void test_config()
void test_config ( )

Definition at line 46 of file test_staticchannelstatus.cxx.

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 }
const std::string instance
cfg
Definition: dbjson.py:29
#define Assert
Definition: Testing.h:7
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2106
const double nominal_shaping
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 nominal_gain
Gen::StaticChannelStatus::channel_status_map_t make_deviants()
void test_hardcode ( )

Definition at line 29 of file test_staticchannelstatus.cxx.

30 {
31  auto deviants = make_deviants();
32 
34 
35  for (int chid=0; chid<10; ++chid) {
36  Assert(scs.preamp_gain(chid) == nominal_gain);
37  Assert(scs.preamp_shaping(chid) == nominal_shaping);
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 }
#define Assert
Definition: Testing.h:7
const double nominal_shaping
const double nominal_gain
Gen::StaticChannelStatus::channel_status_map_t make_deviants()

Variable Documentation

const double nominal_gain = 14.0*units::mV/units::fC

Definition at line 13 of file test_staticchannelstatus.cxx.

const double nominal_shaping = 2.0*units::us

Definition at line 14 of file test_staticchannelstatus.cxx.

const double other_gain = 4.7*units::mV/units::fC

Definition at line 16 of file test_staticchannelstatus.cxx.

const double other_shaping = 1.0*units::us

Definition at line 17 of file test_staticchannelstatus.cxx.