Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JConvert.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "evt/Head.hh"
7 #include "evt/Evt.hh"
8 
9 #include "JDAQ/JDAQTimeslice.hh"
10 #include "JDAQ/JDAQEvent.hh"
11 #include "JDAQ/JDAQSummaryslice.hh"
12 
14 
19 #include "JSupport/JSupport.hh"
20 #include "JLang/JPipe.hh"
22 
23 #include "Jeep/JParser.hh"
24 #include "Jeep/JMessage.hh"
25 
26 
27 /**
28  * \file
29  * Auxiliary program to convert data formats.
30  * Possible file name extensions include ".evt" (ASCII), ".root" (ROOT), ".dat" (binary) and ".evtx" (ASCII).
31  * The following data structures and file name extension are supported:
32  *
33  * <table border="1" width="500">
34  * <tr> <th> type </th><th> evt </th><th> root </th><th> dat </th><th> evtx </th></tr>
35  * <tr> <td> KM3NETDAQ::JDAQEvent </td><td> </td><td> I/O </td><td> I/O </td><td> </td></tr>
36  * <tr> <td> KM3NETDAQ::JDAQTimeslice </td><td> </td><td> I/O </td><td> I/O </td><td> </td></tr>
37  * <tr> <td> KM3NETDAQ::JDAQSummaryslice </td><td> </td><td> I/O </td><td> I/O </td><td> </td></tr>
38  * <tr> <td> Head </td><td> I </td><td> I/O </td><td> </td><td> I </td></tr>
39  * <tr> <td> Evt </td><td> I </td><td> I/O </td><td> </td><td> I </td></tr>
40  * </table>
41  *
42  * The name of the data structure following option -C should be preceded by a '+' or '-'
43  * to add or remove data types in the output, respectively.\n
44  * In this, ROOT wildcards are accepted (e.g. <pre>-C -\\.\\*</pre> will remove all data types).
45  *
46  * \author mdejong
47  */
48 int main(int argc, char **argv)
49 {
50  using namespace std;
51  using namespace JPP;
52 
53  typedef JAllDataTypes_t typelist;
54 
55  JMultipleFileScanner<typelist> inputFile;
56  JFileRecorder <typelist> outputFile;
57  JLimit_t& numberOfEvents = inputFile.getLimit();
58  JROOTClassSelection selection = getROOTClassSelection<typelist>();
59  int debug;
60 
61  try {
62 
63  JParser<> zap("Auxiliary program to convert data formats.");
64 
65  zap['f'] = make_field(inputFile);
66  zap['o'] = make_field(outputFile);
67  zap['n'] = make_field(numberOfEvents) = JLimit::max();
68  zap['C'] = make_field(selection,
69  "Precede name of data structure by a '+' or '-'"
70  "to add or remove data types in the output, respectively."
71  "\nROOT wildcards are accepted.") = JPARSER::initialised();
72  zap['d'] = make_field(debug) = 1;
73 
74  zap(argc, argv);
75  }
76  catch(const exception& error) {
77  FATAL(error.what() << endl);
78  }
79 
80 
81  outputFile.open();
82 
83  inputFile | JValve<typelist>(selection) | outputFile;
84 
85  outputFile.close();
86 }
Utility class to parse command line options.
Definition: JParser.hh:1410
Recording of objects on file according a format that follows from the file name extension.
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:64
string outputFile
JLimit JLimit_t
Type definition of limit.
Definition: JLimit.hh:214
Type list.
Definition: JTypeList.hh:22
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
Implementation of pipe operation for object iterators.
int debug
debug level
Definition: JSirene.cc:59
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:65
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
ROOT TTree parameter settings.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:72
int main(int argc, char *argv[])
Definition: Main.cpp:15