Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JAcousticsTriggerMonitor.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <limits>
4#include <map>
5
6#include "TROOT.h"
7#include "TFile.h"
8#include "TGraph.h"
9
11
12#include "JTools/JQuantile.hh"
13#include "JTools/JRange.hh"
14
15#include "JROOT/JRootToolkit.hh"
16#include "JROOT/JManager.hh"
17
18#include "JAcoustics/JEvent.hh"
20
21#include "Jeep/JPrint.hh"
22#include "Jeep/JParser.hh"
23#include "Jeep/JMessage.hh"
24
25
26/**
27 * \file
28 *
29 * Example program to monitor acoustic events.
30 * \author mdejong
31 */
32int main(int argc, char **argv)
33{
34 using namespace std;
35 using namespace JPP;
36
38 JLimit_t& numberOfEvents = inputFile.getLimit();
39 string outputFile;
40 double Q;
41 int debug;
42
43 try {
44
45 JParser<> zap("Example program to monitor acoustic events.");
46
47 zap['f'] = make_field(inputFile, "output of JAcousticTriggerProcessor[.sh]");
48 zap['n'] = make_field(numberOfEvents) = JLimit::max();
49 zap['o'] = make_field(outputFile) = "monitor.root";
50 zap['Q'] = make_field(Q) = 0.9;
51 zap['d'] = make_field(debug) = 2;
52
53 zap(argc, argv);
54 }
55 catch(const exception &error) {
56 FATAL(error.what() << endl);
57 }
58
59 JManager<int, TGraph> GA(new TGraph(), "G[%].size");
60 JManager<int, TGraph> GD(new TGraph(), "G[%].rms");
61 JManager<int, TGraph> GQ(new TGraph(), "G[%].quality");
62 JManager<int, TGraph> G1(new TGraph(), "G[%].quantile");
63 JManager<int, TGraph> GN(new TGraph(), "G[%].overlays");
64
66
68
69 map<int, size_t> summary;
70
71 while (inputFile.hasNext()) {
72
73 if (inputFile.getCounter()%100 == 0) {
74 STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
75 }
76
77 const JEvent* event = inputFile.next();
78
79 if (event->empty()) { // due to emptying of overlapping events
80 continue;
81 }
82
83 const double t1 = event->begin()->getToE();
84
85 T_s.include(t1);
86
87 summary[event->getID()] += 1;
88
89 JQuantile Q1, Q2;
90
91 for (JEvent::const_iterator i = event->begin(); i != event->end(); ++i) {
92 Q1.put(i->getToE());
93 Q2.put(log10(i->getQ()));
94 }
95
96 AddPoint(GA[event->getID()], t1, event->size());
97 AddPoint(GD[event->getID()], t1, Q1.getSTDev());
98 AddPoint(GQ[event->getID()], t1, Q2.getMean());
99 AddPoint(G1[event->getID()], t1, Q1.getQuantile(Q, JQuantile::symmetric_t));
100 AddPoint(GN[event->getID()], t1, event->getOverlays());
101 }
102 STATUS(endl);
103
104 if (T_s.getUpperLimit() > T_s.getLowerLimit()) {
105
106 size_t N = 0;
107
108 for (const auto& i : summary) {
109 N += i.second;
110 }
111
112 for (const auto& i : summary) {
113 STATUS(setw(4) << i.first << ' ' << FIXED(5,2) << 60 * i.second / (T_s.getUpperLimit() - T_s.getLowerLimit()) << " [min^-1]" << endl);
114 }
115 {
116 STATUS(setw(4) << " " << ' ' << FIXED(5,2) << 60 * N / (T_s.getUpperLimit() - T_s.getLowerLimit()) << " [min^-1]" << endl);
117 }
118 }
119
120 TFile out(outputFile.c_str(), "recreate");
121
122 out << GA << GD << GQ << G1 << GN;
123
124 out.Write();
125 out.Close();
126}
int main(int argc, char **argv)
Acoustic event.
ROOT TTree parameter settings.
string outputFile
Dynamic ROOT object management.
General purpose messaging.
#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
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
Double_t G1(const Double_t x)
Integral of method g1.
Definition JQuantiles.cc:37
Auxiliary class to define a range between two values.
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Definition JManager.hh:47
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition JManager.hh:304
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.
Range of values.
Definition JRange.hh:42
static JRange< int, std::less< int > > DEFAULT_RANGE()
Definition JRange.hh:555
range_type & include(argument_type x)
Include given value to range.
Definition JRange.hh:397
T getLowerLimit() const
Get lower limit.
Definition JRange.hh:202
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void AddPoint(TGraph *g1, const Double_t x, const Double_t y)
Add point to TGraph.
JRange< int > range_type
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
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:41
double getQuantile(const double Q, const Quantile_t option=forward_t) const
Get quantile.
Definition JQuantile.hh:147
@ symmetric_t
symmatric
Definition JQuantile.hh:135
void put(const double x, const double w=1.0)
Put value.
Definition JQuantile.hh:106
double getMean() const
Get mean value.
Definition JStats.hh:234
double getSTDev() const
Get standard deviation.
Definition JStats.hh:263