HepMC Reference Documentation

HepMC

example_PythiaParticle.cc

Go to the documentation of this file.
00001 
00002 // garren@fnal.gov, July 2006
00003 // example of generating events with Pythia
00004 // using HepMC/PythiaWrapper.h 
00005 // Events are read into the HepMC event record from the FORTRAN HEPEVT 
00006 // common block using the IO_HEPEVT strategy and then output to file in
00007 // ascii format using the IO_AsciiParticles strategy.
00008 //
00009 // This is identical to example_MyPythia.cc except that it uses IO_AsciiParticles.
00011 // To Compile: go to the examples directory and type:
00012 // gmake example_PythiaParticle.exe
00013 //
00014 // In this example the precision and number of entries for the HEPEVT 
00015 // fortran common block are explicitly defined to correspond to those 
00016 // used in the Pythia version of the HEPEVT common block. 
00017 //
00018 // If you get funny output from HEPEVT in your own code, probably you have
00019 // set these values incorrectly!
00020 //
00021 
00022 #include <iostream>
00023 #include "HepMC/PythiaWrapper.h"
00024 #include "HepMC/IO_HEPEVT.h"
00025 #include "HepMC/IO_AsciiParticles.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_AsciiParticles ascii_io("example_PythiaParticle.dat",std::ios::out);
00050         //
00051         //........................................EVENT LOOP
00052         for ( int i = 1; i <= 100; i++ ) {
00053             if ( i%50==1 ) std::cout << "Processing Event Number " 
00054                                      << i << std::endl;
00055             call_pyevnt();      // generate one event with Pythia
00056             // pythia pyhepc routine converts common PYJETS in common HEPEVT
00057             call_pyhepc( 1 );
00058             HepMC::GenEvent* evt = hepevtio.read_next_event();
00059             // add some information to the event
00060             evt->set_event_number(i);
00061             evt->set_signal_process_id(20);
00062             // write the event out to the ascii file
00063             ascii_io << evt;
00064             // we also need to delete the created event from memory
00065             delete evt;
00066         }
00067         //........................................TERMINATION
00068         // write out some information from Pythia to the screen
00069         call_pystat( 1 );    
00070     } // end scope of ascii_io
00071 
00072     return 0;
00073 }
00074 
00075 
00076  

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