Jpp
Functions
JMergeFit.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <iterator>
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JDAQ/JDAQEventIO.hh"
#include "JDAQ/JDAQTimesliceIO.hh"
#include "JDAQ/JDAQSummarysliceIO.hh"
#include "JTrigger/JTriggerParameters.hh"
#include "JSupport/JParallelFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.hh"
#include "JFit/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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 33 of file JMergeFit.cc.

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 }
KM3NETDAQ::JDAQEvent
DAQ Event.
Definition: JDAQEvent.hh:30
JSUPPORT::JLimit
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
KM3NETDAQ::JDAQEventHeader::is_same
bool is_same(const JDAQEventHeader &header) const
Check if header is same.
Definition: JDAQEventHeader.hh:73
std::vector
Definition: JSTDTypes.hh:12
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JFIT::JEvt
Data structure for set of track fit results.
Definition: JEvt.hh:293
JAANET::copy
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:152
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
KM3NETDAQ::JDAQEventHeader::getDAQEventHeader
const JDAQEventHeader & getDAQEventHeader() const
Get DAQ event header.
Definition: JDAQEventHeader.hh:61
JEEP::getFilename
std::string getFilename(const std::string &file_name)
Get file name part, i.e.
Definition: JeepToolkit.hh:86
JLANG::JTypeList
Type list.
Definition: JTypeList.hh:22
STATUS
#define STATUS(A)
Definition: JMessage.hh:63
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
JSUPPORT::JParallelFileScanner
General purpose class for parallel reading of objects from a single file or multiple files.
Definition: JParallelFileScanner.hh:31
JSUPPORT::JMultipleFileScanner
General purpose class for object reading from a list of file names.
Definition: JMultipleFileScanner.hh:167
JSUPPORT::JMeta
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:71
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
KM3NETDAQ
KM3NeT DAQ data structures and auxiliaries.
Definition: DataQueue.cc:39
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37
JSUPPORT::JFileRecorder
Object writing to file.
Definition: JFileRecorder.hh:41