Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JDiffToAshort.cc File Reference

Program to compare toashort data. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include "TROOT.h"
#include "TFile.h"
#include "JDB/JToAshort.hh"
#include "JDB/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 toashort data.

Author
mdejong

Definition in file JDiffToAshort.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 104 of file JDiffToAshort.cc.

105 {
106  using namespace std;
107  using namespace JPP;
108 
109  vector<string> inputFile;
110  JLimit numberOfEvents;
111  int debug;
112 
113  try {
114 
115  JParser<> zap("Program to compare toashort data.");
116 
117  zap['f'] = make_field(inputFile, "two outputs of JConvertDB -q toashort");
118  zap['n'] = make_field(numberOfEvents) = JLimit::max();
119  zap['d'] = make_field(debug) = 2;
120 
121  zap(argc, argv);
122  }
123  catch(const exception &error) {
124  FATAL(error.what() << endl);
125  }
126 
127  if (inputFile.size() != 2u) {
128  FATAL("Wrong number of input files " << inputFile.size() << endl);
129  }
130 
131  const size_t width = max(inputFile[0].size(), inputFile[1].size());
132 
133  vector<JToAshort> buffer[2];
134 
135  for (int i = 0; i != 2; ++i) {
136 
137  for (JSingleFileScanner<JToAshort> in(inputFile[i], numberOfEvents); in.hasNext(); ) {
138  buffer[i].push_back(*in.next());
139  }
140 
141  sort(buffer[i].begin(), buffer[i].end(), compare);
142  }
143 
144  int count[] = { 0, 0 };
145 
147  p0 = buffer[0].begin(),
148  p1 = buffer[1].begin(); p0 != buffer[0].end() && p1 != buffer[1].end(); ) {
149 
150  for ( ; p0 != buffer[0].end() && p1 != buffer[1].end() && compare(*p0,*p1); ++p0, ++count[1]) {
151  DEBUG(">> " << setw(width) << left << inputFile[0] << right << ' ' << *p0 << endl);
152  }
153 
154  for ( ; p0 != buffer[0].end() && p1 != buffer[1].end() && compare(*p1,*p0); ++p1, ++count[1]) {
155  DEBUG("<< " << setw(width) << left << inputFile[1] << right << ' ' << *p1 << endl);
156  }
157 
158  if (p0 != buffer[0].end() && p1 != buffer[1].end() && !compare(*p0,*p1) && !compare(*p1,*p0)) {
159 
160  ++count[0];
161 
162  DEBUG(setw(width) << left << inputFile[0] << right << ' ' << *p0 << " \\" << endl);
163  DEBUG(setw(width) << left << inputFile[1] << right << ' ' << *p1 << " / " << endl);
164 
165  ++p0;
166  ++p1;
167  }
168  }
169 
170  STATUS("Number of differences / events: " << count[1] << " / " << count[0] << endl);
171 
172  if (count[1] != 0) {
173  FATAL("Number of differences " << count[1] << endl);
174  }
175 }
Utility class to parse command line options.
Definition: JParser.hh:1500
TPaveText * p1
#define STATUS(A)
Definition: JMessage.hh:63
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:1961
int debug
debug level
Definition: JSirene.cc:68
#define FATAL(A)
Definition: JMessage.hh:67
std::vector< int > count
Definition: JAlgorithm.hh:180
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
Object reading from a list of files.
double u[N+1]
Definition: JPolint.hh:755
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42