Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
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

int main ( int  argc,
char **  argv 
)

Definition at line 117 of file JDiffToA.cc.

118 {
119  using namespace std;
120  using namespace JPP;
121 
122  vector<string> inputFile;
123  JLimit numberOfEvents;
124  int debug;
125 
126  try {
127 
128  JParser<> zap("Program to compare toa data.");
129 
130  zap['f'] = make_field(inputFile, "two outputs of JToA");
131  zap['n'] = make_field(numberOfEvents) = JLimit::max();
132  zap['d'] = make_field(debug) = 2;
133 
134  zap(argc, argv);
135  }
136  catch(const exception &error) {
137  FATAL(error.what() << endl);
138  }
139 
140  if (inputFile.size() != 2u) {
141  FATAL("Wrong number of input files " << inputFile.size() << endl);
142  }
143 
144  const size_t width = max(inputFile[0].size(), inputFile[1].size());
145 
146  vector<JToA> buffer[2];
147 
148  for (int i = 0; i != 2; ++i) {
149 
150  for (JSingleFileScanner<JToA> in(inputFile[i], numberOfEvents); in.hasNext(); ) {
151  buffer[i].push_back(*in.next());
152  }
153 
154  sort(buffer[i].begin(), buffer[i].end(), compare);
155  }
156 
157  int count[] = { 0, 0 };
158 
160  p0 = buffer[0].begin(),
161  p1 = buffer[1].begin(); p0 != buffer[0].end() && p1 != buffer[1].end(); ) {
162 
163  for ( ; p0 != buffer[0].end() && p1 != buffer[1].end() && compare(*p0,*p1); ++p0, ++count[1]) {
164  DEBUG(">> " << setw(width) << left << inputFile[0] << right << ' ' << *p0 << endl);
165  }
166 
167  for ( ; p0 != buffer[0].end() && p1 != buffer[1].end() && compare(*p1,*p0); ++p1, ++count[1]) {
168  DEBUG("<< " << setw(width) << left << inputFile[1] << right << ' ' << *p1 << endl);
169  }
170 
171  if (p0 != buffer[0].end() && p1 != buffer[1].end() && !compare(*p0,*p1) && !compare(*p1,*p0)) {
172 
173  ++count[0];
174 
175  DEBUG(setw(width) << left << inputFile[0] << right << ' ' << *p0 << " \\" << endl);
176  DEBUG(setw(width) << left << inputFile[1] << right << ' ' << *p1 << " / " << endl);
177 
178  ++p0;
179  ++p1;
180  }
181  }
182 
183  STATUS("Number of differences / events: " << count[1] << " / " << count[0] << endl);
184 
185  if (buffer[0].size() != buffer[1].size()) {
186  FATAL("Different size " << buffer[0].size() << ' ' << buffer[1].size() << endl);
187  }
188 
189  if (count[1] != 0) {
190  FATAL("Number of differences " << count[1] << endl);
191  }
192 }
Utility class to parse command line options.
Definition: JParser.hh:1711
TPaveText * p1
#define STATUS(A)
Definition: JMessage.hh:63
then usage $script< input file >[option] nPossible options count
Definition: JVolume1D.sh:31
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define FATAL(A)
Definition: JMessage.hh:67
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Object reading from a list of files.
double u[N+1]
Definition: JPolint.hh:865
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62