Classes | Typedefs | Functions
WireCell::WireSchema Namespace Reference

Classes

struct  Anode
 
struct  Detector
 
struct  Face
 
struct  Plane
 
class  Store
 
struct  StoreDB
 
struct  Wire
 

Typedefs

typedef std::shared_ptr< const StoreDBStoreDBPtr
 

Functions

Store load (const char *filename)
 

Typedef Documentation

typedef std::shared_ptr<const StoreDB> WireCell::WireSchema::StoreDBPtr

Definition at line 59 of file WireSchema.h.

Function Documentation

Store WireCell::WireSchema::load ( const char *  filename)

Definition at line 14 of file WireSchema.cxx.

15 {
16  // turn into absolute real path
18  auto maybe = gStoreCache.find(realpath);
19  if (maybe != gStoreCache.end()) {
20  return Store(maybe->second);
21  }
22 
23 
25  Json::Value jstore = jtop["Store"];
26 
27  StoreDB* store = new StoreDB;
28 
29 
30 
31  std::vector<Point> points;
32  {
33  Json::Value jpoints = jstore["points"];
34  const int npoints = jpoints.size();
35  points.resize(npoints);
36  for (int ipoint=0; ipoint<npoints; ++ipoint) {
37  Json::Value jp = jpoints[ipoint]["Point"];
38  points[ipoint].set(get<double>(jp,"x"), get<double>(jp,"y"), get<double>(jp,"z"));
39  }
40  }
41 
42  {// wires
43  Json::Value jwires = jstore["wires"];
44  const int nwires = jwires.size();
45  std::vector<Wire>& wires = store->wires;
46  wires.resize(nwires);
47  for (int iwire=0; iwire<nwires; ++iwire) {
48  Json::Value jwire = jwires[iwire]["Wire"];
49  Wire& wire = wires[iwire];
50  wire.ident = get<int>(jwire, "ident");
51  wire.channel = get<int>(jwire, "channel");
52  wire.segment = get<int>(jwire, "segment");
53 
54  int itail = get<int>(jwire,"tail");
55  int ihead = get<int>(jwire,"head");
56  wire.tail = points[itail];
57  wire.head = points[ihead];
58  }
59  }
60 
61 
62  {// planes
63  Json::Value jplanes = jstore["planes"];
64  const int nplanes = jplanes.size();
65  std::vector<Plane>& planes = store->planes;
66  planes.resize(nplanes);
67  for (int iplane=0; iplane<nplanes; ++iplane) {
68  Json::Value jplane = jplanes[iplane]["Plane"];
69  Plane& plane = planes[iplane];
70  plane.ident = get<int>(jplane, "ident");
71  Json::Value jwires = jplane["wires"];
72  const int nwires = jwires.size();
73  plane.wires.resize(nwires);
74  for (int iwire=0; iwire<nwires; ++iwire) {
75  plane.wires[iwire] = convert<int>(jwires[iwire]);
76  }
77  }
78  }
79 
80  {// faces
81  Json::Value jfaces = jstore["faces"];
82  const int nfaces = jfaces.size();
83  std::vector<Face>& faces = store->faces;
84  faces.resize(nfaces);
85  for (int iface=0; iface<nfaces; ++iface) {
86  Json::Value jface = jfaces[iface]["Face"];
87  Face& face = faces[iface];
88  face.ident = get<int>(jface, "ident");
89  Json::Value jplanes = jface["planes"];
90  const int nplanes = jplanes.size();
91  face.planes.resize(nplanes);
92  for (int iplane=0; iplane<nplanes; ++iplane) {
93  face.planes[iplane] = convert<int>(jplanes[iplane]);
94  }
95  }
96  }
97 
98  {// anodes
99  Json::Value janodes = jstore["anodes"];
100  const int nanodes = janodes.size();
101  std::vector<Anode>& anodes = store->anodes;
102  anodes.resize(nanodes);
103  for (int ianode=0; ianode<nanodes; ++ianode) {
104  Json::Value janode = janodes[ianode]["Anode"];
105  Anode& anode = anodes[ianode];
106  anode.ident = get<int>(janode, "ident");
107  Json::Value jfaces = janode["faces"];
108  const int nfaces = jfaces.size();
109  anode.faces.resize(nfaces);
110  for (int iface=0; iface<nfaces; ++iface) {
111  anode.faces[iface] = convert<int>(jfaces[iface]);
112  }
113  }
114  }
115 
116  {// detectors
117  Json::Value jdets = jstore["detectors"];
118  const int ndets = jdets.size();
119  std::vector<Detector>& dets = store->detectors;
120  dets.resize(ndets);
121  for (int idet=0; idet<ndets; ++idet) {
122  Json::Value jdet = jdets[idet]["Detector"];
123  Detector& det = dets[idet];
124  det.ident = get<int>(jdet, "ident");
125  Json::Value janodes = jdet["anodes"];
126  const int nanodes = janodes.size();
127  det.anodes.resize(nanodes);
128  for (int ianode=0; ianode<nanodes; ++ianode) {
129  det.anodes[ianode] = convert<int>(janodes[ianode]);
130  }
131  }
132  }
133  gStoreCache[realpath] = StoreDBPtr(store);
134  return Store(gStoreCache[realpath]);
135 }
const int nwires
std::shared_ptr< const StoreDB > StoreDBPtr
Definition: WireSchema.h:59
std::string string
Definition: nybbler.cc:12
static std::map< std::string, StoreDBPtr > gStoreCache
Definition: WireSchema.cxx:10
string filename
Definition: train.py:213
std::vector< Anode > anodes
Definition: WireSchema.h:51
std::vector< Face > faces
Definition: WireSchema.h:52
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2106
std::vector< int > planes
Definition: WireSchema.h:36
Json::Value load(const std::string &filename, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t())
Definition: Persist.cxx:121
std::vector< int > wires
Definition: WireSchema.h:31
std::vector< int > faces
Definition: WireSchema.h:41
std::vector< Wire > wires
Definition: WireSchema.h:54
int convert< int >(const Configuration &cfg, const int &def)
Definition: Configuration.h:74
std::vector< Plane > planes
Definition: WireSchema.h:53
std::vector< Detector > detectors
Definition: WireSchema.h:50
std::vector< int > anodes
Definition: WireSchema.h:46
std::string resolve(const std::string &filename)
Definition: Persist.cxx:99
def points(jdat)
Definition: rendertvtk.py:105