Jpp  17.1.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMergeFit.cc File Reference

Program to merge different files with JFIT::JEvt data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <iterator>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JDAQ/JDAQEvaluator.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JReconstruction/JEvt.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to merge different files with JFIT::JEvt data.

Author
mdejong

Definition in file JMergeFit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 89 of file JMergeFit.cc.

90 {
91  using namespace std;
92  using namespace JPP;
93  using namespace KM3NETDAQ;
94 
95  typedef JParallelFileScanner< JTypeList<JDAQEvent, JEvt> > JParallelFileScanner_t;
96  typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
97 
99 
100  vector<std::string> inputFile;
102  int debug;
103 
104  try {
105 
106  JParser<> zap("Program to merge different files with JFIT::JEvt data " \
107  "(e.g. from JMuonXXX[.sh] and JShowerXXX[.sh] applied to the same input data)." \
108  "\nThe input files should be event-by-event synchronised.");
109 
110  zap['f'] = make_field(inputFile, "list of JEvt compatible files");
111  zap['o'] = make_field(outputFile, "single file with merged JEvt data");
112  zap['d'] = make_field(debug) = 1;
113 
114  zap(argc, argv);
115  }
116  catch(const exception& error) {
117  FATAL(error.what() << endl);
118  }
119 
120  cout.tie(&cerr);
121 
122  if (inputFile.empty()) {
123  FATAL("No input files." << endl);
124  }
125 
126  outputFile.open();
127 
128  outputFile.put(JMeta(argc, argv));
129 
130  JParallelFileScanner_t in(inputFile[0]);
131 
132  vector<JTreeRouter_t> buffer(1); // skip one entry
133 
134  for (size_t i = 1; i != inputFile.size(); ++i) {
135  buffer.push_back(JTreeRouter_t(inputFile[i]));
136  }
137 
138  while (in.hasNext()) {
139 
140  STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl);
141 
142  multi_pointer_type ps = in.next();
143 
144  const JDAQEvent* tev = ps;
145  const JEvt* evt = ps;
146 
147  JEvt out(*evt);
148 
149  for (size_t i = 1; i != inputFile.size(); ++i) {
150 
151  const JEvt* p = buffer[i].get(*tev);
152 
153  if (p != NULL) {
154 
155  copy(p->begin(), p->end(), back_inserter(out));
156 
157  } else {
158 
159  FATAL("Inconsistent data at " << in.getFilename() << ":" << in.getCounter() << endl);
160  }
161  }
162 
163  outputFile.put(out);
164  }
165  STATUS(endl);
166 
167  {
169 
170  io >> outputFile;
171  }
172  {
174 
175  io >> outputFile;
176  }
177 
178  outputFile.close();
179 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Object writing to file.
Utility class to parse command line options.
Definition: JParser.hh:1517
#define STATUS(A)
Definition: JMessage.hh:63
General purpose class for parallel reading of objects from a single file or multiple files...
string outputFile
Type list.
Definition: JTypeList.hh:22
Acoustic event fit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:161
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62