Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JAcousticsMonitorRateSummary.cc File Reference

Example program to monitor acoustic events rate per emitter and receiver and run. More...

#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TGraph.h"
#include "TGraphErrors.h"
#include "JTools/JHashCollection.hh"
#include "JTools/JHashMap.hh"
#include "JTools/JRange.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JROOT/JRootToolkit.hh"
#include "JROOT/JManager.hh"
#include "JLang/JPredicate.hh"
#include "JAcoustics/JEvent.hh"
#include "JAcoustics/JSupport.hh"
#include "Jeep/JContainer.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 rate per emitter and receiver and run.

Output: histogram of the acoustic event rate per emitter and run.

Author
mdejong, cgatius

Definition in file JAcousticsMonitorRateSummary.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 44 of file JAcousticsMonitorRateSummary.cc.

45{
46 using namespace std;
47 using namespace JPP;
48
49 JMultipleFileScanner<> inputFile;
50 JLimit_t& numberOfEvents = inputFile.getLimit();
51 string outputFile;
52 string detectorFile;
53 int debug;
54 double lifetime_s;
55
56 try {
57
58 JParser<> zap("Example program to monitor acoustic events.");
59
60 zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
61 zap['n'] = make_field(numberOfEvents) = JLimit::max();
62 zap['o'] = make_field(outputFile) = "monitor.root";
63 zap['a'] = make_field(detectorFile);
64 zap['d'] = make_field(debug) = 2;
65 zap['l'] = make_field(lifetime_s, "run lifetime in seconds");
66 zap(argc, argv);
67 }
68 catch(const exception &error) {
69 FATAL(error.what() << endl);
70 }
71
73
74 try {
75 load(detectorFile, detector);
76 }
77 catch(const JException& error) {
78 FATAL(error);
79 }
80
82
83 for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) {
84
85 receivers[i->getID()] = i->getLocation();
86 }
87
89 const JRange <int> floor (make_array(detector.begin(), detector.end(), &JModule::getFloor));
90
91 JManager<int, TH2D> H2(new TH2D("H[%].event", NULL,
92 string.size(), -0.5, string.size() - 0.5,
93 floor.getUpperLimit() + 1, - 0.5, floor.getUpperLimit() + 0.5));
94
95 for (Int_t i = 1; i <= H2->GetXaxis()->GetNbins(); ++i) {
96 H2->GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
97 }
98
99 for (Int_t i = 1; i <= H2->GetYaxis()->GetNbins(); ++i) {
100 H2->GetYaxis()->SetBinLabel(i, MAKE_CSTRING(i-1));
101 }
102
104
105 JTreeScanner_t in(inputFile);
106
107 for (JTreeScanner_t::iterator event = in.begin(); event != in.end(); ++event) {
108
109 TH2D* h2 = H2[event->getID()];
110
111 map<int, set<double> > buffer;
112
113 for (JEvent::const_iterator i = event->begin(); i != event->end(); ++i) {
114 buffer[i->getID()].insert(i->getQ());
115 }
116
117 for (map<int, set<double> >::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
118
119 if (receivers.has(i->first)) {
120
121 const JLocation& location = receivers[i->first];
122
123 h2->Fill((double) string.getIndex(location.getString()), (double) location.getFloor(), 1.0/lifetime_s);
124 }
125 }
126 }
127 STATUS(endl);
128
129 TFile out(outputFile.c_str(), "recreate");
130
131 out << H2;
132
133 out.Write();
134 out.Close();
135}
string outputFile
#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
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:72
Detector data structure.
Definition JDetector.hh:96
Logical location of module.
Definition JLocation.hh:40
int getFloor() const
Get floor number.
Definition JLocation.hh:146
int getString() const
Get string number.
Definition JLocation.hh:135
General exception.
Definition JException.hh:24
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
Base class for JTreeScanner.
Template definition for direct access of elements in ROOT TChain.
General purpose class for hash collection of unique elements.
bool has(const T &value) const
Test whether given value is present.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Definition JVectorize.hh:54
int getIndex()
Get index for user I/O manipulation.
Definition JManip.hh:26
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227
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
General purpose class for hash map of unique keys.
Definition JHashMap.hh:75