Functions
test_empnomo.cxx File Reference
#include "WireCellUtil/Persist.h"
#include "WireCellUtil/String.h"
#include "WireCellUtil/Units.h"
#include "WireCellUtil/PluginManager.h"
#include "WireCellUtil/NamedFactory.h"
#include "WireCellIface/IChannelStatus.h"
#include "WireCellIface/IChannelSpectrum.h"
#include <cstdlib>
#include <string>
#include "anode_loader.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 17 of file test_empnomo.cxx.

18 {
19  std::string detector = "uboone";
20 
21 
22  // In the real WCT this is done by wire-cell and driven by user
23  // configuration.
24  auto anode_tns = anode_loader(detector);
25 
26  cerr << "Using AnodePlane: \"" << anode_tns[0] << "\"\n";
27 
28  {
29  {
30  auto icfg = Factory::lookup<IConfigurable>("StaticChannelStatus");
31  // In the real app this would be in a JSON or Jsonnet config
32  // file in wire-cell-cfg. Here, just to avoid an external
33  // file we define a couple hard-coded deviant values somewhat
34  // laboriously
35  auto cfg = icfg->default_configuration();
36  cfg["anode"] = anode_tns[0];
37  // cfg["deviants"] = Json::arrayValue;
38  // cfg["deviants"][0]["chid"] = 100;
39  // cfg["deviants"][0]["gain"] = 4.7*units::mV/units::fC;
40  // cfg["deviants"][0]["shaping"] = 1.0*units::us;
41  // cfg["deviants"][1]["chid"] = 200;
42  // cfg["deviants"][1]["gain"] = 4.7*units::mV/units::fC;
43  // cfg["deviants"][1]["shaping"] = 1.0*units::us;
44  icfg->configure(cfg);
45  }
46  {
47  auto icfg = Factory::lookup<IConfigurable>("EmpiricalNoiseModel");
48  auto cfg = icfg->default_configuration();
49  cfg["anode"] = anode_tns[0];
50  cfg["spectra_file"] = "microboone-noise-spectra-v2.json.bz2";
51  icfg->configure(cfg);
52  }
53  }
54  auto anode = Factory::find_tn<IAnodePlane>(anode_tns[0]);
55 
56  cerr << "Creating EmpiricalNoiseModel...\n";
57 
58  auto empnomo = Factory::find_tn<IChannelSpectrum>("EmpiricalNoiseModel");
59 
60  auto chids = anode->channels();
61  cerr << "Got " << chids.size() << " channels\n";
62  for (auto chid : chids) {
63  const auto& amp = (*empnomo)(chid);
64  double tot = 0;
65  for (auto v : amp) {
66  tot += v;
67  }
68  cerr << "ch:" << chid << " " << amp.size()
69  << " tot=" << tot
70  << endl;
71  }
72 
73 
74  return 0;
75 }
std::string string
Definition: nybbler.cc:12
cfg
Definition: dbjson.py:29
std::vector< std::string > anode_loader(std::string detector)
Definition: anode_loader.h:35
QTextStream & endl(QTextStream &s)