00001
00002
00003
00004
00005
00006
00008
00009
00010
00011
00012 #include "HepMC/IO_GenEvent.h"
00013 #include "HepMC/GenEvent.h"
00014
00016
00020 class IsEventGood {
00021 public:
00023 bool operator()( const HepMC::GenEvent* evt ) {
00024 for ( HepMC::GenEvent::particle_const_iterator p
00025 = evt->particles_begin(); p != evt->particles_end(); ++p ){
00026 if ( (*p)->pdg_id() == 22 && (*p)->momentum().perp() > 25. ) {
00027
00028
00029
00030 return 1;
00031 }
00032 }
00033 return 0;
00034 }
00035 };
00036
00037 int main() {
00038
00039
00040 {
00041 HepMC::IO_GenEvent ascii_in("example_MyPythia.dat",std::ios::in);
00042
00043 HepMC::IO_GenEvent ascii_out("example_EventSelection.dat",std::ios::out);
00044
00045 IsEventGood is_good_event;
00046
00047 int icount=0;
00048 int num_good_events=0;
00049 HepMC::GenEvent* evt = ascii_in.read_next_event();
00050 while ( evt ) {
00051 icount++;
00052 if ( icount%50==1 ) std::cout << "Processing Event Number " << icount
00053 << " its # " << evt->event_number()
00054 << std::endl;
00055 if ( is_good_event(evt) ) {
00056 ascii_out << evt;
00057 ++num_good_events;
00058 }
00059 delete evt;
00060 ascii_in >> evt;
00061 }
00062
00063 std::cout << num_good_events << " out of " << icount
00064 << " processed events passed the cuts. Finished." << std::endl;
00065 }
00066 return 0;
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077