Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
JCompareTransmitter.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <cmath>
5
7
8#include "Jeep/JContainer.hh"
9#include "Jeep/JParser.hh"
10#include "Jeep/JMessage.hh"
11
12
13/**
14 * \file
15 *
16 * Auxiliary program to compare two transmitter files.\n
17 * \author lvoorend
18 */
19int main(int argc, char **argv)
20{
21 using namespace std;
22 using namespace JPP;
23
24 typedef JContainer< vector<JTransmitter> > container_type;
25
26 string transmitterFile_a;
27 string transmitterFile_b;
28 double precision;
29 int debug;
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;
38 zap['d'] = make_field(debug) = 1;
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}
Container I/O.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2140
Data structure for transmitter.
Utility class to parse command line options.
Definition JParser.hh:1697
int main()
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).
Definition JContainer.hh:42
void load(const char *file_name)
Load from input file.