Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JRootComparator.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3
11
13
14#include "Jeep/JParser.hh"
15#include "Jeep/JMessage.hh"
16
17
18/**
19 * Example application to test comparison of objects using ROOT dictionary.
20 */
21int main(int argc, char **argv)
22{
23 using namespace std;
24 using namespace JPP;
25
26 int debug;
27
28 try {
29
30 JParser<> zap;
31
32 zap['d'] = make_field(debug) = 1;
33
34 zap(argc, argv);
35 }
36 catch(const exception &error) {
37 FATAL(error.what() << endl);
38 }
39
40
41 JRootComparator comparator;
42
43 if (debug >= debug_t) {
44 cout << "comparator:" << endl;
45 for (const auto& i : comparator) {
46 cout << i.first << endl;
47 }
48 cout << endl;
49 }
50
51 comparator.debug = debug;
52
53 {
54 Trk a1;
55 Trk a2;
56
57 a1.hit_ids.push_back(1);
58
59 a2.hit_ids.push_back(1);
60 a2.hit_ids.push_back(2);
61
62 ASSERT(comparator(a1, a1) == true, "comparison of equal objects");
63 ASSERT(comparator(a2, a2) == true, "comparison of equal objects");
64 ASSERT(comparator(a1, a2) == false, "comparison of different objects");
65 }
66 {
67 Trk a1;
68 Trk a2;
69
70 a1.hit_ids.push_back(1);
71 a1.hit_ids.push_back(1);
72
73 a2.hit_ids.push_back(2);
74 a2.hit_ids.push_back(2);
75
76 ASSERT(comparator(a1, a1) == true, "comparison of equal objects");
77 ASSERT(comparator(a2, a2) == true, "comparison of equal objects");
78 ASSERT(comparator(a1, a2) == false, "comparison of different objects");
79 }
80 {
81 Evt a1;
82 Evt a2;
83
84 Trk t1;
85 Trk t2;
86
87 t1.id = 1;
88 t2.id = 2;
89
90 a1.trks.push_back(t1);
91 a2.trks.push_back(t2);
92
93 ASSERT(comparator(a1, a1) == true, "comparison of equal objects");
94 ASSERT(comparator(a2, a2) == true, "comparison of equal objects");
95 ASSERT(comparator(a1, a2) == false, "comparison of different objects");
96 }
97 {
98 Head a1;
99 Head a2;
100
101 a2["aa"] = "aa";
102
103 ASSERT(comparator(a1, a1) == true, "comparison of equal objects");
104 ASSERT(comparator(a2, a2) == true, "comparison of equal objects");
105 ASSERT(comparator(a1, a2) == false, "comparison of different objects");
106 }
107}
General purpose messaging.
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
Example application to test comparison of objects using ROOT dictionary.
Utility class to parse command line options.
Definition JParser.hh:1698
@ debug_t
debug
Definition JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
std::vector< Trk > trks
list of reconstructed tracks (can be several because of prefits,showers, etc).
Definition Evt.hh:39
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition Head.hh:65
The Trk class represents a Monte Carlo (MC) particle as well as a reconstructed track/shower.
Definition Trk.hh:15
std::vector< int > hit_ids
list of associated hit-ids (corresponds to Hit::id).
Definition Trk.hh:33
int id
track identifier
Definition Trk.hh:16