Subversion Repositories hepmc

Rev

Rev 103 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //////////////////////////////////////////////////////////////////////////
  2. // Matt.Dobbs@Cern.CH, December 1999
  3. // November 2000, updated to use Pythia 6.1
  4. // example of generating events with Pythia
  5. // using HepMC/PythiaWrapper.h
  6. // Events are read into the HepMC event record from the FORTRAN HEPEVT
  7. // common block using the IO_HEPEVT strategy and then output to file in
  8. // ascii format using the IO_Ascii strategy.
  9. //////////////////////////////////////////////////////////////////////////
  10. /// To Compile: go to the HepMC directory and type:
  11. /// gmake examples/example_MyPythia.exe
  12. ///
  13. /// In this example the precision and number of entries for the HEPEVT
  14. /// fortran common block are explicitly defined to correspond to those
  15. /// used in the Pythia version of the HEPEVT common block.
  16. ///
  17. /// If you get funny output from HEPEVT in your own code, probably you have
  18. /// set these values incorrectly!
  19. ///
  20.  
  21. #include <iostream>
  22. #include "HepMC/PythiaWrapper.h"
  23. #include "HepMC/IO_HEPEVT.h"
  24. #include "HepMC/IO_Ascii.h"
  25. #include "HepMC/IO_ExtendedAscii.h"
  26. #include "HepMC/GenEvent.h"
  27. #include "PythiaHelper.h"
  28.  
  29. int main() {
  30.     //
  31.     //........................................HEPEVT
  32.     // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point
  33.     //  numbers. We need to explicitly pass this information to the
  34.     //  HEPEVT_Wrapper.
  35.     //
  36.     HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
  37.     HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
  38.     //
  39.     //........................................PYTHIA INITIALIZATIONS
  40.     initPythia();
  41.  
  42.     //........................................HepMC INITIALIZATIONS
  43.     //
  44.     // Instantiate an IO strategy for reading from HEPEVT.
  45.     HepMC::IO_HEPEVT hepevtio;
  46.     //
  47.     { // begin scope of ascii_io
  48.         // Instantiate an IO strategy to write the data to file
  49.         HepMC::IO_Ascii ascii_io("example_MyPythia.dat",std::ios::out);
  50.         // declare an IO_ExtendedAscii for output
  51.         HepMC::IO_ExtendedAscii xout("example_MyPythia.exdat",std::ios::out);
  52.         //
  53.         //........................................EVENT LOOP
  54.         for ( int i = 1; i <= 100; i++ ) {
  55.             if ( i%50==1 ) std::cout << "Processing Event Number "
  56.                                      << i << std::endl;
  57.             call_pyevnt();      // generate one event with Pythia
  58.             // pythia pyhepc routine converts common PYJETS in common HEPEVT
  59.             call_pyhepc( 1 );
  60.             HepMC::GenEvent* evt = hepevtio.read_next_event();
  61.             // add some information to the event
  62.             evt->set_event_number(i);
  63.             evt->set_signal_process_id(20);
  64.             // set number of multi parton interactions
  65.             evt->set_mpi( pypars.msti[31-1] );
  66.             // write the event out to the ascii files
  67.             ascii_io << evt;
  68.             xout << evt;
  69.             // we also need to delete the created event from memory
  70.             delete evt;
  71.         }
  72.         //........................................TERMINATION
  73.         // write out some information from Pythia to the screen
  74.         call_pystat( 1 );    
  75.     } // end scope of ascii_io
  76.  
  77.     return 0;
  78. }
  79.  
  80.  
  81.  
  82.