#include #include "HepMC/GenEvent.h" #include "HepMC/IO_GenEvent.h" using namespace std; int main(int argc, char** argv) { if (argc < 2) { cerr << "needs file name!" << endl; return 1; } char* fname = argv[1]; cout << "reading event from " << fname << endl; istream *infile = new fstream(fname, ios::in); HepMC::IO_GenEvent io(*infile); HepMC::GenEvent *evt = new HepMC::GenEvent(); unsigned int cnt(0); while (cnt < 1000000) { if (io.rdstate() != 0) { cerr << "io.rdstate() != 0" << endl; return 1; } if (!io.fill_next_event(evt)) { cerr << "io.fill_next_event(evt) failed!" << endl; cerr << " error: " << io.error_message() << " (type: " << io.error_type() << ")" << endl; return 2; } else { cout << "read event #" << cnt << endl; cnt++; } } cout << "read " << cnt << " events in total"; return 0; }