Basic example of use of root I/O: reading events from file
- Author
- Witold Pokorski
- Date
- 16/10/14
#include <iostream>
int main(
int argc,
char **argv) {
if( argc<3 ) {
std::cout << "Usage: " << argv[0] << " <input_root_file> <output_hepmc3_file>" << std::endl;
exit(-1);
}
ReaderRoot root_input (argv[1]);
WriterAscii text_output(argv[2]);
int events_parsed = 0;
while( !root_input.failed() ) {
GenEvent evt;
root_input.read_event(evt);
if( root_input.failed() ) break;
if( events_parsed == 0 ) {
std::cout << "First event: " << std::endl;
}
text_output.write_event(evt);
++events_parsed;
if( events_parsed%100 == 0 ) {
std::cout << "Event: " << events_parsed << std::endl;
}
}
root_input.close();
text_output.close();
std::cout << "Events parsed and written: " << events_parsed << std::endl;
return 0;
}
Definition of class GenEvent.
Definition of static class Print.
Definition of class ReaderRoot.
Definition of class WriterAscii.
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
int main(int argc, char **argv)