Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JDiffToA.cc File Reference

Program to compare toa data. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include "TROOT.h"
#include "TFile.h"
#include "JAcoustics/JToA.hh"
#include "JAcoustics/JSupport.hh"
#include "JSupport/JSingleFileScanner.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to compare toa data.

Author
mdejong

Definition in file JDiffToA.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 95 of file JDiffToA.cc.

96{
97 using namespace std;
98 using namespace JPP;
99
100 vector<string> inputFile;
101 JLimit numberOfEvents;
102 int debug;
103
104 try {
105
106 JParser<> zap("Program to compare toa data.");
107
108 zap['f'] = make_field(inputFile, "two outputs of JToA");
109 zap['n'] = make_field(numberOfEvents) = JLimit::max();
110 zap['d'] = make_field(debug) = 2;
111
112 zap(argc, argv);
113 }
114 catch(const exception &error) {
115 FATAL(error.what() << endl);
116 }
117
118 if (inputFile.size() != 2u) {
119 FATAL("Wrong number of input files " << inputFile.size() << endl);
120 }
121
122 const size_t width = max(inputFile[0].size(), inputFile[1].size());
123
124 vector<JToA> buffer[2];
125
126 for (int i = 0; i != 2; ++i) {
127
128 for (JSingleFileScanner<JToA> in(inputFile[i], numberOfEvents); in.hasNext(); ) {
129 buffer[i].push_back(*in.next());
130 }
131
132 sort(buffer[i].begin(), buffer[i].end(), compare);
133 }
134
135 int count[] = { 0, 0 };
136
137 for (vector<JToA>::const_iterator
138 p0 = buffer[0].begin(),
139 p1 = buffer[1].begin(); p0 != buffer[0].end() && p1 != buffer[1].end(); ) {
140
141 for ( ; p0 != buffer[0].end() && p1 != buffer[1].end() && compare(*p0,*p1); ++p0, ++count[1]) {
142 DEBUG(">> " << setw(width) << left << inputFile[0] << right << ' ' << *p0 << endl);
143 }
144
145 for ( ; p0 != buffer[0].end() && p1 != buffer[1].end() && compare(*p1,*p0); ++p1, ++count[1]) {
146 DEBUG("<< " << setw(width) << left << inputFile[1] << right << ' ' << *p1 << endl);
147 }
148
149 if (p0 != buffer[0].end() && p1 != buffer[1].end() && !compare(*p0,*p1) && !compare(*p1,*p0)) {
150
151 ++count[0];
152
153 DEBUG(setw(width) << left << inputFile[0] << right << ' ' << *p0 << " \\" << endl);
154 DEBUG(setw(width) << left << inputFile[1] << right << ' ' << *p1 << " / " << endl);
155
156 ++p0;
157 ++p1;
158 }
159 }
160
161 STATUS("Number of differences / events: " << count[1] << " / " << count[0] << endl);
162
163 if (buffer[0].size() != buffer[1].size()) {
164 FATAL("Different size " << buffer[0].size() << ' ' << buffer[1].size() << endl);
165 }
166
167 if (count[1] != 0) {
168 FATAL("Number of differences " << count[1] << endl);
169 }
170}
TPaveText * p1
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Utility class to parse command line options.
Definition JParser.hh:1698
Object reading from a list of files.
virtual bool hasNext() override
Check availability of next element.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128