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

Example program to monitor acoustic events. More...

#include <iostream>
#include <iomanip>
#include "JAcoustics/JEvent.hh"
#include "JAcoustics/JSupport.hh"
#include "JTools/JQuantile.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.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 monitor acoustic events.

Author
mdejong

Definition in file JAcousticsEventMonitor.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 54 of file JAcousticsEventMonitor.cc.

55 {
56  using namespace std;
57  using namespace JPP;
58 
59  JMultipleFileScanner<> inputFile;
60  JLimit_t& numberOfEvents = inputFile.getLimit();
61  double Tmax_s;
62  int debug;
63 
64  try {
65 
66  JParser<> zap("Example program to monitor acoustic events.");
67 
68  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
69  zap['n'] = make_field(numberOfEvents) = JLimit::max();
70  zap['p'] = make_field(compare.waveform_s, "wavefrom duration [s]") = 5.0e-3;
71  zap['D'] = make_field(Tmax_s, "time difference between events [s]") = 20.0e-3;
72  zap['d'] = make_field(debug) = 2;
73 
74  zap(argc, argv);
75  }
76  catch(const exception &error) {
77  FATAL(error.what() << endl);
78  }
79 
80 
82 
83  JEvent* p0 = new JEvent();
84 
85  counter_type events = 0;
86 
87  JQuantile Q;
88 
89  for (JMultipleFileScanner<>::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) {
90 
92 
93  for (JTreeScanner_t::iterator p1 = in.begin(); p1 != in.end() && events != inputFile.getLimit(); ++p1, ++events) {
94 
95  STATUS("event " << setw(8) << events << '\r'); DEBUG(endl);
96 
97  if (!p1->empty() && !p0->empty()) {
98 
99  if (p1->begin()->getToE() < p0->rbegin()->getToE() + Tmax_s) {
100 
101  if (debug >= debug_t) {
102 
103  cout << endl;
104 
105  cout << p0->getOID() << endl
106  << FIXED(20,6) << p0-> begin()->getToE() << ' '
107  << FIXED(20,6) << p0->rbegin()->getToE() << endl
108  << FIXED(20,6) << p1-> begin()->getToE() << ' '
109  << FIXED(20,6) << p1->rbegin()->getToE() << endl;
110  }
111 
112  JEvent evt[] = { *p0, *p1 };
113 
114  for (int i = 0; i != 2; ++i) {
115  sort(evt[i].begin(), evt[i].end(), compare);
116  }
117 
118  size_t n = 0;
119 
120  for (JEvent::const_iterator
121  i0 = evt[0].begin(),
122  i1 = evt[1].begin(); i0 != evt[0].end() && i1 != evt[1].end(); ) {
123 
124  if (compare(*i0, *i1))
125  ++i0;
126  else if (compare(*i1, *i0))
127  ++i1;
128 
129  else {
130 
131  n += 1;
132 
133  if (debug >= debug_t) {
134 
135  cout << setw(2) << p0->getID() << ' '
136  << setw(10) << i0->getID() << ' '
137  << FIXED(20,6) << i0->getToA() << ' '
138  << FIXED( 8,0) << i0->getQ() << ' ';
139 
140  cout << setw(2) << p1->getID() << ' '
141  << setw(10) << i1->getID() << ' '
142  << FIXED(20,6) << i1->getToA() << ' '
143  << FIXED( 8,0) << i1->getQ() << ' ';
144 
145  cout << FIXED( 9,6) << (i1->getToA() - i0->getToA()) << endl;
146  }
147 
148  if (i0->getToA() < i1->getToA())
149  ++i0;
150  else if (i1->getToA() < i0->getToA())
151  ++i1;
152  else {
153  ++i0;
154  ++i1;
155  }
156  }
157  }
158 
159  if (n != 0) {
160  Q.put(n);
161  }
162  }
163  }
164 
165  new (p0) JEvent(*p1);
166  }
167  }
168  STATUS(endl);
169 
170  delete p0;
171 
172  cout << "Number of errors / events: " << Q.getCount() << " / " << events << endl;
173 
174  Q.print(cout);
175 }
Utility class to parse command line options.
Definition: JParser.hh:1514
Q(UTCMax_s-UTCMin_s)-livetime_s
debug
Definition: JMessage.hh:29
TPaveText * p1
#define STATUS(A)
Definition: JMessage.hh:63
Long64_t counter_type
Type definition for counter.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
Template definition for direct access of elements in ROOT TChain.
JFIT::JEvent JEvent
Definition: JHistory.hh:353
const int n
Definition: JPolint.hh:742
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:1989
#define FATAL(A)
Definition: JMessage.hh:67
Base class for JTreeScanner.
Definition: JTreeScanner.hh:54
Auxiliary data structure for average.
Definition: JKatoomba_t.hh:76
Acoustic event.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
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 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:46
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62