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

Example application to print acoustics event. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include "TROOT.h"
#include "TFile.h"
#include "JLang/JPredicate.hh"
#include "JLang/JComparator.hh"
#include "JLang/JComparison.hh"
#include "JTools/JQuantile.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMeta.hh"
#include "JAcoustics/JEvent.hh"
#include "JAcoustics/JSupport.hh"
#include "Jeep/JContainer.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 application to print acoustics event.

Author
mdejong

Definition in file JPrintAcousticsEvent.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 35 of file JPrintAcousticsEvent.cc.

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
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
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
double getQ(const double D_m, const double f_kHz, const double d_m)
Get relative quality for given frequency at given distance.
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
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
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62