Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

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}
#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.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
@ debug_t
debug
Definition JMessage.hh:29
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
const int n
Definition JPolint.hh:791
int j
Definition JPolint.hh:801
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
int getID() const
Get emitter identifier.
double getQ() const
Get quality.
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 running average, standard deviation and quantiles.
Definition JQuantile.hh:46