|
HepMC Reference DocumentationHepMC |
00001 00002 // Matt.Dobbs@Cern.CH, December 1999 00003 // November 2000, updated to use Pythia 6.1 00004 // example of generating events with Pythia 00005 // using HepMC/PythiaWrapper.h 00006 // Events are read into the HepMC event record from the FORTRAN HEPEVT 00007 // common block using the IO_HEPEVT strategy and then output to file in 00008 // ascii format using the IO_Ascii strategy. 00020 00021 #include <iostream> 00022 #include "HepMC/PythiaWrapper.h" 00023 #include "HepMC/IO_HEPEVT.h" 00024 #include "HepMC/IO_Ascii.h" 00025 #include "HepMC/IO_ExtendedAscii.h" 00026 #include "HepMC/GenEvent.h" 00027 #include "PythiaHelper.h" 00028 00029 int main() { 00030 // 00031 //........................................HEPEVT 00032 // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point 00033 // numbers. We need to explicitly pass this information to the 00034 // HEPEVT_Wrapper. 00035 // 00036 HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); 00037 HepMC::HEPEVT_Wrapper::set_sizeof_real(8); 00038 // 00039 //........................................PYTHIA INITIALIZATIONS 00040 initPythia(); 00041 00042 //........................................HepMC INITIALIZATIONS 00043 // 00044 // Instantiate an IO strategy for reading from HEPEVT. 00045 HepMC::IO_HEPEVT hepevtio; 00046 // 00047 { // begin scope of ascii_io 00048 // Instantiate an IO strategy to write the data to file 00049 HepMC::IO_Ascii ascii_io("example_MyPythia.dat",std::ios::out); 00050 // declare an IO_ExtendedAscii for output 00051 HepMC::IO_ExtendedAscii xout("example_MyPythia.exdat",std::ios::out); 00052 // 00053 //........................................EVENT LOOP 00054 for ( int i = 1; i <= 100; i++ ) { 00055 if ( i%50==1 ) std::cout << "Processing Event Number " 00056 << i << std::endl; 00057 call_pyevnt(); // generate one event with Pythia 00058 // pythia pyhepc routine converts common PYJETS in common HEPEVT 00059 call_pyhepc( 1 ); 00060 HepMC::GenEvent* evt = hepevtio.read_next_event(); 00061 // add some information to the event 00062 evt->set_event_number(i); 00063 evt->set_signal_process_id(20); 00064 // set number of multi parton interactions 00065 evt->set_mpi( pypars.msti[31-1] ); 00066 // write the event out to the ascii files 00067 ascii_io << evt; 00068 xout << evt; 00069 // we also need to delete the created event from memory 00070 delete evt; 00071 } 00072 //........................................TERMINATION 00073 // write out some information from Pythia to the screen 00074 call_pystat( 1 ); 00075 } // end scope of ascii_io 00076 00077 return 0; 00078 } 00079 00080 00081
1.5.1-3