HepMC Reference Documentation

HepMC

example_MyPythia.cc

Go to the documentation of this file.
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_GenEvent strategy.
00020 
00021 #include <iostream>
00022 #include "HepMC/PythiaWrapper.h"
00023 #include "HepMC/IO_HEPEVT.h"
00024 #include "HepMC/IO_GenEvent.h"
00025 #include "HepMC/GenEvent.h"
00026 #include "PythiaHelper.h"
00027 
00028 int main() { 
00029     //
00030     //........................................HEPEVT
00031     // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point
00032     //  numbers. We need to explicitly pass this information to the 
00033     //  HEPEVT_Wrapper.
00034     //
00035     HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
00036     HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00037     //
00038     //........................................PYTHIA INITIALIZATIONS
00039     initPythia();
00040 
00041     //........................................HepMC INITIALIZATIONS
00042     //
00043     // Instantiate an IO strategy for reading from HEPEVT.
00044     HepMC::IO_HEPEVT hepevtio;
00045     //
00046     { // begin scope of ascii_io
00047         // Instantiate an IO strategy to write the data to file 
00048         HepMC::IO_GenEvent ascii_io("example_MyPythia.dat",std::ios::out);
00049         //
00050         //........................................EVENT LOOP
00051         for ( int i = 1; i <= 100; i++ ) {
00052             if ( i%50==1 ) std::cout << "Processing Event Number " 
00053                                      << i << std::endl;
00054             call_pyevnt();      // generate one event with Pythia
00055             // pythia pyhepc routine converts common PYJETS in common HEPEVT
00056             call_pyhepc( 1 );
00057             HepMC::GenEvent* evt = hepevtio.read_next_event();
00058             // add some information to the event
00059             evt->set_event_number(i);
00060             evt->set_signal_process_id(20);
00061             // set number of multi parton interactions
00062             evt->set_mpi( pypars.msti[31-1] );
00063             // write the event out to the ascii files
00064             ascii_io << evt;
00065             // we also need to delete the created event from memory
00066             delete evt;
00067         }
00068         //........................................TERMINATION
00069         // write out some information from Pythia to the screen
00070         call_pystat( 1 );    
00071     } // end scope of ascii_io
00072 
00073     return 0;
00074 }
00075 
00076 
00077  

Generated on Wed Mar 12 13:08:08 2008 for HepMC by  doxygen 1.5.1-3