Jpp  17.3.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintAcousticsEvent.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <vector>
5 #include <map>
6 #include <algorithm>
7 
8 #include "TROOT.h"
9 #include "TFile.h"
10 
11 #include "JLang/JPredicate.hh"
12 #include "JLang/JComparator.hh"
13 #include "JLang/JComparison.hh"
14 
15 #include "JTools/JQuantile.hh"
16 
19 #include "JSupport/JMeta.hh"
20 
21 #include "JAcoustics/JEvent.hh"
22 #include "JAcoustics/JSupport.hh"
23 
24 #include "Jeep/JContainer.hh"
25 #include "Jeep/JParser.hh"
26 #include "Jeep/JMessage.hh"
27 
28 
29 /**
30  * \file
31  *
32  * Example application to print acoustics event.
33  * \author mdejong
34  */
35 int main(int argc, char **argv)
36 {
37  using namespace std;
38  using namespace JPP;
39 
41  JLimit_t& numberOfEvents = inputFile.getLimit();
42  int debug;
43 
44  try {
45 
46  JParser<> zap("Example application to print acoustics event.");
47 
48  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
49  zap['n'] = make_field(numberOfEvents) = JLimit::max();
50  zap['d'] = make_field(debug) = 3;
51 
52  zap(argc, argv);
53  }
54  catch(const exception &error) {
55  FATAL(error.what() << endl);
56  }
57 
58  JQuantile Q0("size ");
59  JQuantile Q1("duplicates");
60 
61  while (inputFile.hasNext()) {
62 
63  STATUS("event: " << setw(8) << inputFile.getCounter() << '\r' << flush); DEBUG(endl);
64 
65  const JEvent* evt = inputFile.next();
66 
68 
69  for (JEvent::const_iterator hit = evt->begin(); hit != evt->end(); ++hit) {
70  buffer[hit->getID()].push_back(*hit);
71  }
72 
73  size_t duplicates = 0;
74 
75  for (map<int, vector<JTransmission> >::iterator ps = buffer.begin(); ps != buffer.end(); ++ps) {
76 
77  sort(ps->second.begin(), ps->second.end(), make_comparator(&JTransmission::getQ, JComparison::gt()));
78 
79  if (ps->second.size() >= 2u) {
80 
81  duplicates += 1;
82 
83  if (debug >= debug_t) {
84 
85  cout << endl;
86 
87  for (vector<JTransmission>::const_iterator i = ps->second.begin(); i != ps->second.end(); ++i) {
88 
89  cout << setw (8) << i->getRunNumber() << ' '
90  << setw (2) << evt->getID() << ' '
91  << setw (10) << i->getID() << ' '
92  << FIXED(10,0) << i->getQ() << ' '
93  << FIXED(15,6) << i->getToA() << ' ';
94 
95  size_t n = 0;
96 
97  for (vector<JTransmission>::const_iterator j = ps->second.begin(); j != ps->second.end(); ++j) {
98  if (i != j) {
99  if (i->getQ() == j->getQ()) {
100  n += 1;
101  }
102  }
103  }
104 
105  cout << (n == 0 ? "" : "*") << endl;
106  }
107  }
108  }
109  }
110 
111  Q0.put(evt->size());
112  Q1.put(duplicates);
113  }
114 
115  for (const auto& Q : { Q0, Q1 }) {
116  if (Q.getCount() > 0) {
117  Q.print(cout);
118  }
119  }
120 }
Utility class to parse command line options.
Definition: JParser.hh:1517
Q(UTCMax_s-UTCMin_s)-livetime_s
debug
Definition: JMessage.hh:29
int main(int argc, char *argv[])
Definition: Main.cc:15
Greater than.
Definition: JComparison.hh:73
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
Auxiliary data structure for running average, standard deviation and quantiles.
Definition: JQuantile.hh:43
#define STATUS(A)
Definition: JMessage.hh:63
ROOT TTree parameter settings.
Recording of objects on file according a format that follows from the file name extension.
Acoustic event.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
const int n
Definition: JPolint.hh:697
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:1993
ROOT I/O of application specific meta data.
void put(const double x, const double w=1.0)
Put value.
Definition: JQuantile.hh:133
double getQ(const double D_m, const double f_kHz, const double d_m)
Get relative quality for given frequency at given distance.
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
Acoustic event.
int j
Definition: JPolint.hh:703
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
int getID() const
Get identifier.
double u[N+1]
Definition: JPolint.hh:776
Container I/O.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62