Jpp 20.0.0-27-g39925593c-D
the software that should make you happy
Loading...
Searching...
No Matches
JConvert.cc
Go to the documentation of this file.
1
2#include <string>
3#include <iostream>
4#include <iomanip>
5#include <type_traits>
6
12
14#include "JDAQ/JDAQEventIO.hh"
16
18
23#include "JSupport/JMeta.hh"
24#include "JSupport/JSupport.hh"
25#include "JLang/JPipe.hh"
28#include "JTools/JRange.hh"
29
30#include "Jeep/JParser.hh"
31#include "Jeep/JMessage.hh"
32
33namespace {
34
35 using namespace KM3NETDAQ;
36 using namespace JLANG;
37
38 /**
39 * Type definition for DAQ UTC time range.
40 */
42
43 /**
44 * Default implementation for selection of objects based on UTC time range.
45 */
47 struct JSelector :
48 public virtual JObjectSelector<T>,
49 public virtual JDAQUTCTimeRange
50 {
51 virtual bool accept(const T& object) const override
52 {
53 return true;
54 }
55 };
56
57 /**
58 * Custom implementation for selection of objects based on UTC time range.
59 */
60 template<>
61 struct JSelector<Evt, false> :
62 public virtual JObjectSelector<Evt>,
63 public virtual JDAQUTCTimeRange
64 {
65 virtual bool accept(const Evt& object) const override
66 {
67 return (*this)(JDAQUTCExtended(object.t.GetSec(), object.t.GetNanoSec() / 16));
68 }
69 };
70
71 /**
72 * Common implementation for selection of objects based on UTC time range.
73 */
74 template<class T>
75 struct JSelector<T, true> :
76 public virtual JObjectSelector<T>,
77 public virtual JDAQUTCTimeRange
78 {
79 virtual bool accept(const T& object) const override
80 {
81 return (*this)(object.getTimesliceStart());
82 }
83 };
84
85 /**
86 * Implementation for multiple selection of objects based on UTC time range.
87 */
88 template<class JHead_t, class JTail_t>
89 struct JSelector< JTypeList<JHead_t, JTail_t>, false > :
90 public virtual JObjectSelector< JTypeList<JHead_t, JTail_t> >,
91 public JSelector<JHead_t>,
92 public JSelector<JTail_t>
93 {};
94
95 /**
96 * Terminator class of recursive JSelector class.
97 */
98 template<class JHead_t>
99 struct JSelector< JTypeList<JHead_t, JNullType>, false > :
100 public JSelector<JHead_t>
101 {};
102}
103
104
105/**
106 * \file
107 * Auxiliary program to convert data formats and/or to select data.
108 * Possible file name extensions include ".evt" (ASCII), ".root" (ROOT) and ".dat" (binary).\n
109 * The following data structures and file name extensions are supported:
110 *
111 * <table>
112 * <tr><th> type </th><th> evt </th><th> root </th><th> dat </th></tr>
113 * <tr><td> KM3NETDAQ::JDAQEvent </td><td> </td><td> I/O </td><td> I/O </td></tr>
114 * <tr><td> KM3NETDAQ::JDAQTimeslice </td><td> </td><td> I/O </td><td> I/O </td></tr>
115 * <tr><td> KM3NETDAQ::JDAQSummaryslice </td><td> </td><td> I/O </td><td> I/O </td></tr>
116 * <tr><td> Head </td><td> I </td><td> I/O </td><td> </td></tr>
117 * <tr><td> Evt </td><td> I </td><td> I/O </td><td> </td></tr>
118 * </table>
119 *
120 * The name of the data structure following option -C should be preceded by a '+' or '-'
121 * to add or remove data types in the output, respectively.\n
122 * In this, ROOT wildcards are accepted (e.g. <tt>-C -\\\.\\*</tt> will remove all data types).
123 *
124 * \author mdejong
125 */
126int main(int argc, char **argv)
127{
128 using namespace std;
129 using namespace JPP;
130
131 typedef JAllTypes_t typelist;
132
135 JLimit_t& numberOfEvents = inputFile.getLimit();
138 JSelector<typelist> selector;
139 int debug;
140
141 try {
142
143 JParser<> zap("Auxiliary program to convert data formats and/or to select data.");
144
145 zap['f'] = make_field(inputFile);
146 zap['o'] = make_field(outputFile);
147 zap['n'] = make_field(numberOfEvents) = JLimit::max();
148 zap['C'] = make_field(selection,
149 "Precede name of data structure by a '+' or '-' "
150 "to add or remove data types in the output, respectively."
151 "\nROOT wildcards are accepted.") = JPARSER::initialised();
152 zap['m'] = make_field(merge, "Allow merging of files w/o Monte Carlo headers");
153 zap['r'] = make_field(selector) = JPARSER::initialised();
154 zap['d'] = make_field(debug) = 1;
155
156 zap(argc, argv);
157 }
158 catch(const exception& error) {
159 FATAL(error.what() << endl);
160 }
161
162
163 outputFile.open();
164
166
167 inputFile | JValve<typelist>(selection) | selector | outputFile;
168
169 outputFile.close();
170}
int main(int argc, char **argv)
Definition JConvert.cc:126
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:72
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:2142
Implementation of pipe operation for object iterators.
Auxiliary class to define a range between two values.
ROOT TTree parameter settings of various packages.
Auxiliary class for specifying selection of database data.
Interface for selection of objects.
Template definition of a multi-dimensional oscillation probability interpolation table.
General purpose class for object reading from a list of file names.
Range of values.
Definition JRange.hh:42
Data structure for UTC time.
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JTOOLS::JRange< JDAQUTCExtended > JDAQUTCTimeRange
Type definition for DAQ UTC time range.
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition Evt.hh:21
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:68
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