Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMergeFit.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 #include <vector>
6 #include <algorithm>
7 #include <iterator>
8 
11 #include "JDAQ/JDAQEventIO.hh"
12 #include "JDAQ/JDAQTimesliceIO.hh"
15 
18 #include "JSupport/JSupport.hh"
19 #include "JSupport/JMeta.hh"
20 
21 #include "JReconstruction/JEvt.hh"
22 
23 #include "Jeep/JParser.hh"
24 #include "Jeep/JMessage.hh"
25 
26 
27 /**
28  * \file
29  *
30  * Program to merge different files with JFIT::JEvt data.
31  * \author mdejong
32  */
33 int main(int argc, char **argv)
34 {
35  using namespace std;
36  using namespace JPP;
37  using namespace KM3NETDAQ;
38 
39  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
40  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
42 
45  JLimit_t numberOfEvents;
46  int debug;
47 
48  try {
49 
50  JParser<> zap("Program to merge different files with JFIT::JEvt data.");
51 
52  zap['f'] = make_field(inputFile, "list of JEvt compatible files");
53  zap['o'] = make_field(outputFile, "single file with merged JEvt data");
54  zap['n'] = make_field(numberOfEvents) = JLimit::max();
55  zap['d'] = make_field(debug) = 1;
56 
57  zap(argc, argv);
58  }
59  catch(const exception& error) {
60  FATAL(error.what() << endl);
61  }
62 
63  cout.tie(&cerr);
64 
65  if (inputFile.empty()) {
66  FATAL("No input files." << endl);
67  }
68 
69  outputFile.open();
70 
71  outputFile.put(JMeta(argc, argv));
72 
73  for (inputFile[0].setLimit(numberOfEvents); inputFile[0].hasNext(); ) {
74 
75  STATUS("event: " << setw(10) << inputFile[0].getCounter() << '\r'); DEBUG(endl);
76 
77  multi_pointer_type ps = inputFile[0].next();
78 
79  const JDAQEvent* tev = ps;
80  const JEvt* evt = ps;
81 
82  JEvt out(*evt);
83 
84  for (size_t i = 1; i != inputFile.size(); ++i) {
85 
86  if (inputFile[i].hasNext()) {
87 
88  multi_pointer_type __ps = inputFile[i].next();
89 
90  const JDAQEvent* __tev = __ps;
91  const JEvt* __evt = __ps;
92 
93  if (tev->getDAQEventHeader().is_same(__tev->getDAQEventHeader())) {
94 
95  copy(__evt->begin(), __evt->end(), back_inserter(out));
96 
97  } else {
98 
99  FATAL("Inconsistent data at "
100  << inputFile[0].getFilename() << ":" << inputFile[0].getCounter() << " != "
101  << inputFile[i].getFilename() << ":" << inputFile[i].getCounter() << endl);
102  }
103  }
104  }
105 
106  outputFile.put(out);
107  }
108  STATUS(endl);
109 
111 
112  io >> outputFile;
113 
114  outputFile.close();
115 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1493
ROOT TTree parameter settings.
#define STATUS(A)
Definition: JMessage.hh:63
Recording of objects on file according a format that follows from the file name extension.
General purpose class for parallel reading of objects from a single file or multiple files...
string outputFile
Type list.
Definition: JTypeList.hh:22
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
ROOT I/O of application specific meta data.
int debug
debug level
Definition: JSirene.cc:61
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Data structure for set of track fit results.
Definition: JEvt.hh:294
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:153
bool is_same(const JDAQEventHeader &header) const
Check if header is same.
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:88
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
int main(int argc, char *argv[])
Definition: Main.cpp:15