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

Example program to test acoustic data. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include "TROOT.h"
#include "TFile.h"
#include "JDB/JToAshort.hh"
#include "JDB/JSupport.hh"
#include "JLang/JPredicate.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JAcoustics/JAcousticsSupportkit.hh"
#include "Jeep/JPrint.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

Example program to test acoustic data.

Author
mdejong

Definition in file JToAshort.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 91 of file JToAshort.cc.

92 {
93  using namespace std;
94  using namespace JPP;
95 
97  JLimit_t& numberOfEvents = inputFile.getLimit();
98  double precision;
99  bool allowed;
100  int debug;
101 
102  try {
103 
104  JParser<> zap("Example program to test acoustic data.");
105 
106  zap['f'] = make_field(inputFile);
107  zap['n'] = make_field(numberOfEvents) = JLimit::max();
108  zap['A'] = make_field(allowed);
109  zap['e'] = make_field(precision) = 1.0e-7;
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 
119  typedef vector<JToAshort_t> buffer_type; // acoustic data type
120 
121  map<int, map< int, buffer_type > > data; // emitter -> receiver -> data
122 
123  for (int counter = 0; inputFile.hasNext(); ++counter) {
124 
125  STATUS("counter: " << setw(8) << counter << '\r' << flush); DEBUG(endl);
126 
127  const JToAshort* parameters = inputFile.next();
128 
129  data[parameters->EMITTERID][parameters->DOMID].push_back(JToAshort_t(*parameters, counter));
130  }
131  STATUS(endl);
132 
133 
134  for (map<int, map< int, buffer_type> >::iterator i = data.begin(); i != data.end(); ++i) {
135 
136  for (map< int, buffer_type>::iterator module = i->second.begin(); module != i->second.end(); ++module) {
137 
138  buffer_type& buffer = module->second;
139 
140  sort(buffer.begin(), buffer.end());
141 
142  for (buffer_type::const_iterator p = buffer.begin(); p != buffer.end(); ++p) {
143  for (buffer_type::const_iterator q = buffer.begin(); q != p; ++q) {
144 
145  if (labs(p->DOMID - q->DOMID) == 0 &&
146  fabs(p->QUALITYFACTOR - q->QUALITYFACTOR) <= precision &&
147  fabs((p->UNIXTIMEBASE + p->TOA_S) -
148  (q->UNIXTIMEBASE + q->TOA_S)) <= precision) {
149 
150  if (!allowed || (p->TOA_S < TOAMAX_S &&
151  q->TOA_S < TOAMAX_S)) {
152 
153  cout << *p << endl;
154  cout << *q << endl;
155 
156  cout << "Difference between absolute times "
157  << SCIENTIFIC(12,3) << ((p->UNIXTIMEBASE + p->TOA_S) -
158  (q->UNIXTIMEBASE + q->TOA_S)) << endl;
159  }
160  }
161  }
162  }
163  }
164  }
165 }
Utility class to parse command line options.
Definition: JParser.hh:1514
#define STATUS(A)
Definition: JMessage.hh:63
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
std::vector< JHitW0 > buffer_type
hits
Definition: JPerth.cc:67
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
static const double TOAMAX_S
Maximal allowed time-of-arrival [s].
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:486
int EMITTERID
waveform identifier
Definition: JToAshort.hh:27
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62