Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JToA.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 "JLang/JPredicate.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JAcoustics/JToA.hh"
#include "JAcoustics/JSupport.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 examples/JAcoustics/JToA.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 90 of file examples/JAcoustics/JToA.cc.

91{
92 using namespace std;
93 using namespace JPP;
94
96 JLimit_t& numberOfEvents = inputFile.getLimit();
97 double precision;
98 bool allowed;
99 int debug;
100
101 try {
102
103 JParser<> zap("Example program to test acoustic data.");
104
105 zap['f'] = make_field(inputFile);
106 zap['n'] = make_field(numberOfEvents) = JLimit::max();
107 zap['A'] = make_field(allowed);
108 zap['e'] = make_field(precision) = 1.0e-7;
109 zap['d'] = make_field(debug) = 2;
110
111 zap(argc, argv);
112 }
113 catch(const exception &error) {
114 FATAL(error.what() << endl);
115 }
116
117
118 typedef vector<JToA_t> buffer_type; // acoustic data type
119
120 map<int, map< int, buffer_type > > data; // emitter -> receiver -> data
121
122 for (int counter = 0; inputFile.hasNext(); ++counter) {
123
124 STATUS("counter: " << setw(8) << counter << '\r' << flush); DEBUG(endl);
125
126 const JToA* parameters = inputFile.next();
127
128 data[parameters->WAVEFORMID][parameters->DOMID].push_back(JToA_t(*parameters, counter));
129 }
130 STATUS(endl);
131
132 constexpr double s2ns = 1E9;
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 (p->DOMID == q->DOMID &&
146 p->QUALITYFACTOR - q->QUALITYFACTOR <= lrint(s2ns*precision) &&
147 llabs(p->TOA_NS - q->TOA_NS) <= llrint(s2ns*precision)) {
148
149 if (!allowed || (p->TOA_NS < llrint(s2ns*TOAMAX_S) &&
150 q->TOA_NS < llrint(s2ns*TOAMAX_S))) {
151
152 cout << *p << endl;
153 cout << *q << endl;
154
155 cout << "Difference between absolute times "
156 << SCIENTIFIC(12,3) << (p->TOA_NS-q->TOA_NS) << " nanoseconds\n";
157 }
158 }
159 }
160 }
161 }
162 }
163}
#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
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
static const double TOAMAX_S
Maximal allowed time-of-arrival [s].
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< JHitW0 > buffer_type
hits
Definition JPerth.cc:70
Time-of-arrival data from acoustic piezo sensor or hydrophone.
Definition JToA.hh:28
uint32_t DOMID
DAQ run number.
Definition JToA.hh:34
int32_t WAVEFORMID
DOM unique identifeir.
Definition JToA.hh:35
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
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488