95int main(
int argc,
char **argv)
100 vector<string> inputFile;
101 JLimit numberOfEvents;
106 JParser<> zap(
"Program to compare toa data.");
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;
114 catch(
const exception &error) {
115 FATAL(error.what() << endl);
118 if (inputFile.size() != 2u) {
119 FATAL(
"Wrong number of input files " << inputFile.size() << endl);
122 const size_t width = max(inputFile[0].size(), inputFile[1].size());
124 vector<JToA> buffer[2];
126 for (
int i = 0; i != 2; ++i) {
128 for (JSingleFileScanner<JToA> in(inputFile[i], numberOfEvents); in.hasNext(); ) {
129 buffer[i].push_back(*in.next());
132 sort(buffer[i].begin(), buffer[i].end(), compare);
135 int count[] = { 0, 0 };
137 for (vector<JToA>::const_iterator
138 p0 = buffer[0].begin(),
139 p1 = buffer[1].begin(); p0 != buffer[0].end() && p1 != buffer[1].end(); ) {
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);
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);
149 if (p0 != buffer[0].end() && p1 != buffer[1].end() && !compare(*p0,*p1) && !compare(*p1,*p0)) {
153 DEBUG(setw(width) << left << inputFile[0] << right <<
' ' << *p0 <<
" \\" << endl);
154 DEBUG(setw(width) << left << inputFile[1] << right <<
' ' << *p1 <<
" / " << endl);
161 STATUS(
"Number of differences / events: " << count[1] <<
" / " << count[0] << endl);
163 if (buffer[0].size() != buffer[1].size()) {
164 FATAL(
"Different size " << buffer[0].size() <<
' ' << buffer[1].size() << endl);
168 FATAL(
"Number of differences " << count[1] << endl);