00001
00002
00003
00004
00005
00006
00007
00008
00010
00011
00012 #include "HepMC/IO_Ascii.h"
00013 #include "HepMC/GenEvent.h"
00014
00015
00016 #include "IsGoodEvent.h"
00017
00018 int main() {
00019
00020 IsGoodEvent is_good_event;
00021 {
00022
00023
00024 HepMC::IO_Ascii ascii_in("@srcdir@/testAscii.input",std::ios::in);
00025 if ( ascii_in.rdstate() == std::ios::failbit ) {
00026 std::cerr << "ERROR input file @srcdir@/testAscii.input is needed "
00027 << "and does not exist. Exit." << std::endl;
00028 return 1;
00029 }
00030
00031 HepMC::IO_Ascii ascii_out("testAscii.dat",std::ios::out);
00032 if ( ascii_out.rdstate() == std::ios::failbit ) {
00033 std::cerr << "ERROR opening output file testAscii.dat. Exit."
00034 << std::endl;
00035 return 1;
00036 }
00037
00038 int icount=0;
00039 int num_good_events=0;
00040 HepMC::GenEvent* evt = ascii_in.read_next_event();
00041 while ( evt ) {
00042 icount++;
00043 if ( icount%50==1 ) std::cout << "Processing Event Number " << icount
00044 << " its # " << evt->event_number()
00045 << std::endl;
00046 if ( is_good_event(evt) ) {
00047 ascii_out << evt;
00048 ++num_good_events;
00049 }
00050
00051
00052 delete evt;
00053 ascii_in >> evt;
00054 }
00055
00056 std::cout << num_good_events << " out of " << icount
00057 << " processed events passed the cuts. Finished." << std::endl;
00058 }
00059
00060 }