raygrid_dump.h
Go to the documentation of this file.
1 
2 #include <json/json.h>
3 
4 class JsonEvent {
7 
8 public:
9  JsonEvent(const WireCell::RayGrid::Coordinates& coords) : coords(coords) {}
10 
11  void operator()(const Point& pt, double charge=1.0) {
12  Json::Value jpt;
13  jpt[0] = pt.x();
14  jpt[1] = pt.y();
15  jpt[2] = pt.z();
16  Json::Value jpv;
17  jpv["point"] = jpt;
18  jpv["values"]["charge"] = charge;
19  points.append(jpv);
20  }
21 
22 
24  double x) {
25  Json::Value jcorner = Json::arrayValue;
26  auto pt = coords.ray_crossing(corner.first, corner.second);
27  jcorner.append(x);
28  jcorner.append(pt.y());
29  jcorner.append(pt.z());
30  return jcorner;
31  }
32 
34  double x) {
35  Json::Value jcorners = Json::arrayValue;
36  for (const auto& corner : corners) {
37  jcorners.append(convert(corner, x));
38  }
39  return jcorners;
40  }
41 
43  double x, double charge=1.0, int slice = 1, int number=0) {
44  Json::Value jblob;
45  jblob["points"] = convert(blob.corners(), x);
46  jblob["values"]["charge"] = charge;
47  jblob["values"]["slice"] = slice;
48  jblob["values"]["number"] = number;
49  blobs.append(jblob);
50  }
51 
52  void dump(const std::string& filename) {
54  top["points"] = points;
55  top["blobs"] = blobs;
56  ofstream fstr(filename);
57  fstr << top;
58  }
59 };
void dump(const std::string &filename)
Definition: raygrid_dump.h:52
std::string string
Definition: nybbler.cc:12
Json::Value blobs
Definition: raygrid_dump.h:6
const WireCell::RayGrid::Coordinates & coords
Definition: raygrid_dump.h:5
Json::Value convert(const WireCell::RayGrid::crossings_t &corners, double x)
Definition: raygrid_dump.h:33
string filename
Definition: train.py:213
Json::Value points
Definition: raygrid_dump.h:6
void operator()(const Point &pt, double charge=1.0)
Definition: raygrid_dump.h:11
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: document.h:2106
Vector ray_crossing(const coordinate_t &one, const coordinate_t &two) const
Definition: RayGrid.cxx:122
void operator()(const WireCell::RayGrid::Blob &blob, double x, double charge=1.0, int slice=1, int number=0)
Definition: raygrid_dump.h:42
std::vector< crossing_t > crossings_t
Definition: RayGrid.h:62
std::pair< coordinate_t, coordinate_t > crossing_t
Definition: RayGrid.h:61
JsonEvent(const WireCell::RayGrid::Coordinates &coords)
Definition: raygrid_dump.h:9
Json::Value convert(const WireCell::RayGrid::crossing_t &corner, double x)
Definition: raygrid_dump.h:23
list x
Definition: train.py:276
const crossings_t & corners() const
Definition: RayTiling.cxx:202