Jpp 21.0.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JConvertAcoustics.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <memory>
4
5#include "TROOT.h"
6#include "TFile.h"
7
10#include "JSupport/JMeta.hh"
11
12#include "JAcoustics/JEvent.hh"
13#include "JAcoustics/JEvt.hh"
16
17#include "JLang/JPipe.hh"
20#include "JTools/JRange.hh"
21
22#include "Jeep/JContainer.hh"
23#include "Jeep/JParser.hh"
24#include "Jeep/JMessage.hh"
25
26namespace {
27
28 using namespace JLANG;
29 using namespace JACOUSTICS;
30
31 /**
32 * Type definition for UTC time range.
33 */
35
36 /**
37 * Auxiliary data structure for UTC time ranges.
38 */
39 struct veto_type :
40 public std::vector<JTimeRange>
41 {
42 veto_type() {}
43
44 veto_type(const veto_type& veto) :
45 std::vector<JTimeRange>(static_cast<const std::vector<JTimeRange>&>(veto))
46 {}
47
48 // allow use of virtual base class
49 veto_type(veto_type&&) = delete;
50 veto_type& operator=(veto_type&&) = delete;
51 };
52
53
54 /**
55 * Default implementation for veto of acoustics objects based on UTC time ranges.
56 */
57 template<class T>
58 struct JSelector :
59 public virtual JObjectSelector<T>,
60 public virtual veto_type
61 {
62 virtual bool accept(const T& object) const override
63 {
64 return true;
65 }
66 };
67
68 /**
69 * Custom implementation for veto of acoustics objects based on UTC time ranges.
70 */
71 template<>
72 struct JSelector<JEvent> :
73 public virtual JObjectSelector<JEvent>,
74 public virtual veto_type
75 {
76 virtual bool accept(const JEvent& event) const override
77 {
78 if (!event.empty()) {
79 for (veto_type::const_iterator i = this->begin(); i != this->end(); ++i) {
80 for (JEvent::const_iterator hit = event.begin(); hit != event.end(); ++hit) {
81 if ((*i)(hit->getToA())) {
82 return false;
83 }
84 }
85 }
86 }
87
88 return true;
89 }
90 };
91
92 /**
93 * Custom implementation for veto of acoustics objects based on UTC time ranges.
94 */
95 template<>
96 struct JSelector<JEvt> :
97 public virtual JObjectSelector<JEvt>,
98 public virtual veto_type
99 {
100 virtual bool accept(const JEvt& evt) const override
101 {
102 for (veto_type::const_iterator i = this->begin(); i != this->end(); ++i) {
103 if ((*i)(evt.UNIXTimeStart) || (*i)(evt.UNIXTimeStop)) {
104 return false;
105 }
106 }
107
108 return true;
109 }
110 };
111
112 /**
113 * Implementation for multiple veto of acoustics objects based on UTC time ranges.
114 */
115 template<>
116 struct JSelector<JSuperEvt> :
117 public virtual JObjectSelector<JSuperEvt>,
118 public virtual veto_type
119 {
120 virtual bool accept(const JSuperEvt& evt) const override
121 {
122 for (veto_type::const_iterator i = this->begin(); i != this->end(); ++i) {
123 if ((*i)(evt.UNIXTimeStart) || (*i)(evt.UNIXTimeStop)) {
124 return false;
125 }
126 }
127
128 return true;
129 }
130 };
131
132 /**
133 * Implementation for multiple selection of objects based on UTC time range.
134 */
135 template<class JHead_t, class JTail_t>
136 struct JSelector< JTypeList<JHead_t, JTail_t> > :
137 public virtual JObjectSelector< JTypeList<JHead_t, JTail_t> >,
138 public JSelector<JHead_t>,
139 public JSelector<JTail_t>
140 {};
141
142 /**
143 * Terminator class of recursive JSelector class.
144 */
145 template<class JHead_t>
146 struct JSelector< JTypeList<JHead_t, JNullType> > :
147 public JSelector<JHead_t>
148 {};
149}
150
151/**
152 * \file
153 *
154 * Auxiliary program to convert acoustic events.
155 * \author mdejong
156 */
157int main(int argc, char **argv)
158{
159 using namespace std;
160 using namespace JPP;
161
164
166 JFileRecorder <typelist> outputFile;
167 JLimit_t& numberOfEvents = inputFile.getLimit();
169 JSelector_t selector;
170 int debug;
171
172 try {
173
174 JParser<> zap("Auxiliary program to convert acoustic events.");
175
176 zap['f'] = make_field(inputFile);
177 zap['o'] = make_field(outputFile);
178 zap['n'] = make_field(numberOfEvents) = JLimit::max();
179 zap['C'] = make_field(selection,
180 "Precede name of data structure by a '+' or '-' "
181 "to add or remove data types in the output, respectively."
182 "\nROOT wildcards are accepted.") = JPARSER::initialised();
183 zap['r'] = make_field(selector,
184 "veto UTC time ranges [s]") = JPARSER::initialised();
185 zap['d'] = make_field(debug) = 1;
186
187 zap(argc, argv);
188 }
189 catch(const exception &error) {
190 FATAL(error.what() << endl);
191 }
192
193 outputFile.open();
194
195 outputFile.put(JMeta(argc,argv));
196
197 inputFile | JValve<typelist>(selection) | selector | outputFile;
198
199 outputFile.close();
200}
201
Acoustic event.
Acoustic event fit.
ROOT TTree parameter settings.
Container I/O.
int main(int argc, char **argv)
string outputFile
Recording of objects on file according a format that follows from the file name extension.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:74
ROOT I/O of application specific meta data.
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:2140
Implementation of pipe operation for object iterators.
Auxiliary class to define a range between two values.
Acoustic event fit.
Interface for selection of objects.
Auxiliary class for selection of data type.
Definition JValve.hh:23
Utility class to parse command line options.
Definition JParser.hh:1697
General purpose class for object reading from a list of file names.
Range of values.
Definition JRange.hh:42
Auxiliary classes and methods for acoustic position calibration.
JTOOLS::JRange< double > JTimeRange
Type definition for time range (unit [s]).
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
Acoustic event fit.
double UNIXTimeStop
stop time
double UNIXTimeStart
start time
Acoustic super event fit.
Definition JSuperEvt.hh:38
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition JContainer.hh:42
Auxiliary class for no type definition.
Definition JNullType.hh:19
Type list.
Definition JTypeList.hh:23
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition JParser.hh:67
Auxiliary class for ROOT class selection.
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 class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72