20{
23
25
26 string transmitterFile_a;
27 string transmitterFile_b;
28 double precision;
30
31 try {
32
33 JParser<> zap(
"Auxiliary program to compare two transmitter files.");
34
35 zap[
'a'] =
make_field(transmitterFile_a,
"transmitter file A");
36 zap[
'b'] =
make_field(transmitterFile_b,
"transmitter file B (reference)");
37 zap[
'p'] =
make_field(precision,
"precision on radius comparison [m]") = 0.01;
39
40 zap(argc, argv);
41 }
42 catch(const exception &error) {
43 FATAL(error.what() << endl);
44 }
45
46 container_type data_a;
47 container_type data_b;
48
49 data_a.
load(transmitterFile_a.c_str());
50 data_b.load(transmitterFile_b.c_str());
51
52 cout << "Comparing " << transmitterFile_a << " (A) to " << transmitterFile_b << " (B)." << endl;
53 cout << endl;
54
55 cout << setw(4) << "id"
56 << setw(4) << "DU"
57 << setw(12) << "R_A [m]"
58 << setw(12) << "R_B [m]"
59 << setw(14) << "phi [rad]"
60 << " status" << endl;
61
62 for (container_type::const_iterator ia = data_a.begin(); ia != data_a.end(); ++ia) {
63
64 for (container_type::const_iterator ib = data_b.begin(); ib != data_b.end(); ++ib) {
65
66 if (ia->getID() == ib->getID() &&
67 ia->getString() == ib->getString()) {
68
69 const double xa = ia->getX();
70 const double ya = ia->getY();
71 const double xb = ib->getX();
72 const double yb = ib->getY();
73
74 const double ra = sqrt(xa*xa + ya*ya);
75 const double rb = sqrt(xb*xb + yb*yb);
76
77 const double phi = atan2(ya, xa) - atan2(yb, xb);
78
79
80 cout << setw(4) << ia->getID()
81 << setw(4) << ia->getString()
82 << setw(12) << fixed << setprecision(4) << ra
83 << setw(12) << fixed << setprecision(4) << rb;
84
85 if (fabs(ra - rb) <= precision) {
86
87 cout << setw(14) << fixed << setprecision(2) << phi
88 << " OK" << endl;
89
90 } else {
91
92 cout << setw(14) << "-"
93 << " WARNING: not a pure rotation (|dR| = " << fabs(ra - rb) << " m)" << endl;
94 }
95 }
96 }
97 }
98
99 return 0;
100}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary wrapper for I/O of container with optional comment (see JComment).
void load(const char *file_name)
Load from input file.