test_configuration2.cxx
Go to the documentation of this file.
2 #include "WireCellUtil/Persist.h"
3 #include "WireCellUtil/Testing.h"
4 #include "WireCellUtil/Point.h"
5 
6 #include <iostream>
7 
8 using namespace WireCell;
9 using namespace std;
10 
11 int main()
12 {
13  string json = R"(
14 [
15  {
16  "data": {
17  "step_size": 1,
18  "tracks": [
19  {
20  "charge": -1,
21  "ray": {
22  "head": {
23  "x": 100,
24  "y": 10,
25  "z": 10
26  },
27  "tail": {
28  "x": 10,
29  "y": 0,
30  "z": 0
31  }
32  },
33  "time": 10
34  },
35  {
36  "charge": -2,
37  "ray": {
38  "head": {
39  "x": 2,
40  "y": -100,
41  "z": 0
42  },
43  "tail": {
44  "x": 1,
45  "y": 0,
46  "z": 0
47  }
48  },
49  "time": 120
50  },
51  {
52  "charge": -3,
53  "ray": {
54  "head": {
55  "x": 11,
56  "y": -50,
57  "z": -30
58  },
59  "tail": {
60  "x": 130,
61  "y": 50,
62  "z": 50
63  }
64  },
65  "time": 99
66  }
67  ]
68  },
69  "type": "TrackDepos"
70  }
71 ]
72 )";
73 
74 
76 
77  for (auto comp: cfg) {
78  Assert(get<string>(comp,"type") == "TrackDepos");
79  Configuration data = comp["data"];
80  Assert(get<double>(data,"step_size") == 1.0);
81  Configuration tracks = data["tracks"];
82  for (auto track : tracks) {
83  Assert(get<double>(track,"charge") < 0);
84  Ray ray = get<Ray>(track,"ray");
85  cerr << ray << endl;
86  }
87  }
88  return 0;
89 }
std::pair< Point, Point > Ray
A line segment running from a first (tail) to a second (head) point.
Definition: Point.h:21
STL namespace.
comp
Definition: dbjson.py:31
cfg
Definition: dbjson.py:29
basic_data data
Definition: format.h:764
#define Assert
Definition: Testing.h:7
Definition: Main.h:22
Json::Value loads(const std::string &text, const externalvars_t &extvar=externalvars_t(), const externalvars_t &extcode=externalvars_t())
Definition: Persist.cxx:152
Json::Value Configuration
Definition: Configuration.h:50
int main()
QTextStream & endl(QTextStream &s)