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

Example program to add MultiHead. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "km3net-dataformat/offline/Head.hh"
#include "km3net-dataformat/offline/MultiHead.hh"
#include "km3net-dataformat/offline/Evt.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JFileRecorder.hh"
#include "JSupport/JMonteCarloFileSupportkit.hh"
#include "JSupport/JSupport.hh"
#include "JSupport/JMeta.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

Example program to add MultiHead.

Author
mdejong

Definition in file JMultiHead.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file JMultiHead.cc.

31 {
32  using namespace std;
33  using namespace JPP;
34 
35  JMultipleFileScanner<Evt> inputFile;
37  JLimit_t& numberOfEvents = inputFile.getLimit();
38  int debug;
39 
40  try {
41 
42  JParser<> zap("Example program to add MultiHead.");
43 
44  zap['f'] = make_field(inputFile);
45  zap['n'] = make_field(numberOfEvents) = JLimit::max();
46  zap['o'] = make_field(outputFile);
47  zap['d'] = make_field(debug) = 2;
48 
49  zap(argc, argv);
50  }
51  catch(const exception& error) {
52  FATAL(error.what() << endl);
53  }
54 
55 
56  outputFile.open();
57 
58  outputFile.put(JMeta(argc, argv));
59 
60  Head header;
61 
62  try {
63 
64  header = getHeader(inputFile);
65 
66  MultiHead buffer;
67 
68  buffer.push_back(header);
69 
70  outputFile.put(header);
71  outputFile.put(buffer);
72 
73  } catch(const exception& error) {
74  FATAL("Missing header." << endl);
75  }
76 
77  while (inputFile.hasNext()) {
78 
79  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
80 
81  const Evt* evt = inputFile.next();
82 
83  outputFile.put(*evt);
84  }
85  STATUS(endl);
86 
87  outputFile.close();
88 }
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
string outputFile
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
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:1993
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition: Head.hh:65
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
int debug
debug level
The Evt class respresent a Monte Carlo (MC) event as well as an offline event.
Definition: Evt.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62