anode_loader.h
Go to the documentation of this file.
1 // DO NO USE
2 //
3 // This code should not be considered for any user examples. This
4 // reproduces some internal configuration stuff so that units tests
5 // need not specify a configuration file.
6 //
7 
10 #include "WireCellUtil/Units.h"
11 #include "WireCellUtil/String.h"
13 
18 
19 #include <vector>
20 #include <string>
21 
22 using namespace WireCell;
23 using namespace std;
24 
25 std::vector<std::string> known_dets = {
26  "uboone", "apa", "protodune-larsoft"
27 };
29 {
30  for (auto det : known_dets) {
31  if (maybe == det) { return; }
32  }
33  THROW(ValueError() << errmsg{String::format("unknown detector: %s", maybe)});
34 }
35 std::vector<std::string> anode_loader(std::string detector)
36 {
37  known_det(detector);
38 
39  std::vector<std::string> ret;
40  {
41  int nanodes = 1;
42  // Note: these files must be located via WIRECELL_PATH
43  std::string ws_fname = "microboone-celltree-wires-v2.1.json.bz2";
44  std::string fr_fname = "ub-10-half.json.bz2";
45  if (detector == "uboone") {
46  ws_fname = "microboone-celltree-wires-v2.1.json.bz2";
47  fr_fname = "ub-10-half.json.bz2";
48  }
49  if (detector == "apa") {
50  ws_fname = "apa-wires.json.bz2";
51  fr_fname = "garfield-1d-3planes-21wires-6impacts-dune-v1.json.bz2";
52  }
53  if (detector == "protodune-larsoft") {
54  ws_fname = "protodune-wires-larsoft-v1.json.bz2";
55  fr_fname = "garfield-1d-3planes-21wires-6impacts-dune-v1.json.bz2";
56  nanodes = 6;
57  }
58 
60  pm.add("WireCellSigProc");
61  pm.add("WireCellGen");
62 
63  const std::string fr_tn = "FieldResponse";
64  const std::string ws_tn = "WireSchemaFile";
65 
66  {
67  auto icfg = Factory::lookup<IConfigurable>(fr_tn);
68  auto cfg = icfg->default_configuration();
69  cfg["filename"] = fr_fname;
70  icfg->configure(cfg);
71  }
72  {
73  auto icfg = Factory::lookup<IConfigurable>(ws_tn);
74  auto cfg = icfg->default_configuration();
75  cfg["filename"] = ws_fname;
76  icfg->configure(cfg);
77  }
78 
79  for (int ianode = 0; ianode < nanodes; ++ianode) {
80  std::string tn = String::format("AnodePlane:%d", ianode);
81  ret.push_back(tn);
82  cerr << "Configuring: " << tn << "\n";
83  auto icfg = Factory::lookup_tn<IConfigurable>(tn);
84  auto cfg = icfg->default_configuration();
85  cfg["ident"] = ianode;
86  cfg["wire_schema"] = ws_tn;
87  cfg["faces"][0]["response"] = 10*units::cm - 6*units::mm;
88  cfg["faces"][0]["cathode"] = 2.5604*units::m;
89  cerr << cfg<<endl;
90  icfg->configure(cfg);
91  }
92  }
93  return ret;
94 }
static const double m
Definition: Units.h:63
std::string string
Definition: nybbler.cc:12
boost::error_info< struct tag_errmsg, std::string > errmsg
Definition: Exceptions.h:54
STL namespace.
cfg
Definition: dbjson.py:29
static PluginManager & instance()
std::vector< std::string > anode_loader(std::string detector)
Definition: anode_loader.h:35
#define THROW(e)
Definition: Exceptions.h:25
void known_det(std::string maybe)
Definition: anode_loader.h:28
static const double cm
Definition: Units.h:59
Thrown when a wrong value has been encountered.
Definition: Exceptions.h:37
static const double mm
Definition: Units.h:55
std::string format(const std::string &form, TYPES...objs)
Definition: String.h:45
Definition: Main.h:22
std::vector< std::string > known_dets
Definition: anode_loader.h:25
Plugin * add(const std::string &plugin_name, const std::string &libname="")
Add a plugin. If libname is not given, try to derive it.
QTextStream & endl(QTextStream &s)