Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JDisable.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <limits>
4#include <map>
5
7
8#include "TROOT.h"
9#include "TFile.h"
10
13
15
16#include "JAcoustics/JEvent.hh"
18
19#include "Jeep/JPrint.hh"
20#include "Jeep/JParser.hh"
21#include "Jeep/JMessage.hh"
22
23
24/**
25 * \file
26 *
27 * Auxiliary program to disable acoustic sensors based on acoustic events.
28 * \author mdejong
29 */
30int main(int argc, char **argv)
31{
32 using namespace std;
33 using namespace JPP;
34
36 JLimit_t& numberOfEvents = inputFile.getLimit();
37 string detectorFile;
38 size_t Nmin;
39 bool overwriteDetector;
40 int debug;
41
42 try {
43
44 JParser<> zap("Auxiliary program to disable acoustic sensors based on acoustic events.");
45
46 zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
47 zap['n'] = make_field(numberOfEvents) = JLimit::max();
48 zap['a'] = make_field(detectorFile);
49 zap['N'] = make_field(Nmin, "minimum number of transmissions");
50 zap['A'] = make_field(overwriteDetector, "overwrite detector file provided through '-a' with status of acoustic sensor.");
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
60
61 try {
62 load(detectorFile, detector);
63 }
64 catch(const JException& error) {
65 FATAL(error);
66 }
67
68 map<int, size_t> buffer;
69
70 while (inputFile.hasNext()) {
71
72 if (inputFile.getCounter()%1000 == 0) {
73 STATUS("event " << setw(8) << inputFile.getCounter() << '\r'); DEBUG(endl);
74 }
75
76 const JEvent* evt = inputFile.next();
77
78 for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
79 buffer[i->getID()] += 1;
80 }
81 }
82 STATUS(endl);
83
84 if (inputFile.getCounter() == 0) {
85 FATAL("No events in input." << endl);
86 }
87
88 for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
89
90 if (buffer[module->getID()] < Nmin) {
91
92 if (module->getFloor() == 0) {
93
94 if (!module->has(HYDROPHONE_DISABLE)) {
95
96 NOTICE("Module " << setw(10) << module->getID() << ' ' << getLabel(module->getLocation()) << " disable hydrophone." << endl);
97
98 module->set(HYDROPHONE_DISABLE);
99 }
100
101 } else {
102
103 if (!module->has(PIEZO_DISABLE)) {
104
105 NOTICE("Module " << setw(10) << module->getID() << ' ' << getLabel(module->getLocation()) << " disable piezo." << endl);
106
107 module->set(PIEZO_DISABLE);
108 }
109 }
110 }
111 }
112
113 if (overwriteDetector) {
114
115 NOTICE("Store calibration data on file " << detectorFile << endl);
116
117 store(detectorFile, detector);
118 }
119}
Acoustic event.
ROOT TTree parameter settings.
Data structure for detector geometry and calibration.
int main(int argc, char **argv)
Definition JDisable.cc:30
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define NOTICE(A)
Definition JMessage.hh:64
#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.
Detector data structure.
Definition JDetector.hh:96
General exception.
Definition JException.hh:24
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.
static const int HYDROPHONE_DISABLE
Enable (disable) use of hydrophone if this status bit is 0 (1);.
static const int PIEZO_DISABLE
Enable (disable) use of piezo if this status bit is 0 (1);.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Definition JLocation.hh:247
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
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