Basic example of use of root I/O: writing events to file.
Basic example of use of root I/O: writing events to 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_hepmc3_file> <output_root_file>" << std::endl;
exit(-1);
}
int events_parsed = 0;
while( !text_input.
failed() ) {
if( text_input.
failed() )
break;
if( events_parsed == 0 ) {
std::cout << "First event: " << std::endl;
Print::listing(evt);
}
++events_parsed;
if( events_parsed%100 == 0 ) {
std::cout << "Event: " << events_parsed << std::endl;
}
}
std::cout << "Events parsed and written: " << events_parsed << std::endl;
return 0;
}
Definition of class GenEvent.
Definition of static class Print.
Definition of class ReaderAscii.
Definition of class WriterRoot.
Stores event-related information.
GenEvent I/O parsing for structured text files.
bool read_event(GenEvent &evt) override
Load event from file.
bool failed() override
Return status of the stream.
void close() override
Close file stream.
GenEvent I/O serialization for root files.
void close() override
Close file stream.
void write_event(const GenEvent &evt) override
Write event to file.