hepmc - Blame information for rev 65
Subversion Repositories:
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | garren | 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 | ////////////////////////////////////////////////////////////////////////// | ||
| 65 | garren | 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 | /// | ||
| 2 | garren | 20 | |
| 21 | #include <iostream> | ||
| 22 | #include "HepMC/PythiaWrapper.h" | ||
| 23 | #include "HepMC/IO_HEPEVT.h" | ||
| 24 | #include "HepMC/IO_Ascii.h" | ||
| 25 | #include "HepMC/GenEvent.h" | ||
| 26 | |||
| 27 | int main() { | ||
| 28 | // | ||
| 29 | //........................................HEPEVT | ||
| 30 | // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point | ||
| 31 | // numbers. We need to explicitly pass this information to the | ||
| 32 | // HEPEVT_Wrapper. | ||
| 33 | // | ||
| 34 | HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); | ||
| 35 | HepMC::HEPEVT_Wrapper::set_sizeof_real(8); | ||
| 36 | // | ||
| 37 | //........................................PYTHIA INITIALIZATIONS | ||
| 38 | // (Some platforms may require the initialization of pythia PYDATA block | ||
| 39 | // data as external - if you get pythia initialization errors try | ||
| 40 | // commenting in/out the below call to initpydata() ) | ||
| 41 | // initpydata(); | ||
| 42 | // | ||
| 43 | // Select W+gamma process (process number 20) | ||
| 44 | // (here we have to be careful of C/F77 differences: arrays in C | ||
| 45 | // start at 0, F77 at 1, so we need to subtract 1 from the process #) | ||
| 46 | pysubs.msel=0; | ||
| 47 | pysubs.msub[20-1] = 1; | ||
| 48 | // set random number seed (mandatory!) | ||
| 49 | pydatr.mrpy[0]=55122 ; | ||
| 50 | // Tell Pythia not to write multiple copies of particles in event record. | ||
| 51 | pypars.mstp[128-1] = 2; | ||
| 52 | // Example of setting a Pythia parameter: set the top mass | ||
| 53 | pydat2.pmas[1-1][6-1]= 175; | ||
| 54 | // | ||
| 55 | // Call pythia initialization | ||
| 56 | call_pyinit( "CMS", "p", "p", 14000. ); | ||
| 57 | |||
| 58 | //........................................HepMC INITIALIZATIONS | ||
| 59 | // | ||
| 60 | // Instantiate an IO strategy for reading from HEPEVT. | ||
| 61 | HepMC::IO_HEPEVT hepevtio; | ||
| 62 | // | ||
| 63 | garren | 63 | { // begin scope of ascii_io |
| 64 | // Instantiate an IO strategy to write the data to file | ||
| 65 | HepMC::IO_Ascii ascii_io("example_MyPythia.dat",std::ios::out); | ||
| 66 | // | ||
| 67 | //........................................EVENT LOOP | ||
| 68 | for ( int i = 1; i <= 100; i++ ) { | ||
| 69 | if ( i%50==1 ) std::cout << "Processing Event Number " | ||
| 70 | << i << std::endl; | ||
| 71 | call_pyevnt(); // generate one event with Pythia | ||
| 72 | // pythia pyhepc routine converts common PYJETS in common HEPEVT | ||
| 73 | call_pyhepc( 1 ); | ||
| 74 | HepMC::GenEvent* evt = hepevtio.read_next_event(); | ||
| 75 | // add some information to the event | ||
| 76 | evt->set_event_number(i); | ||
| 77 | evt->set_signal_process_id(20); | ||
| 78 | // write the event out to the ascii file | ||
| 79 | ascii_io << evt; | ||
| 80 | // we also need to delete the created event from memory | ||
| 81 | delete evt; | ||
| 82 | } | ||
| 83 | //........................................TERMINATION | ||
| 84 | // write out some information from Pythia to the screen | ||
| 85 | call_pystat( 1 ); | ||
| 86 | } // end scope of ascii_io | ||
| 2 | garren | 87 | |
| 88 | return 0; | ||
| 89 | } | ||
| 90 | |||
| 91 | |||
| 92 |
