Subversion Repositories hepmc

Rev

Rev 76 | Details | Compare with Previous | Last modification | View Log | RSS feed

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"
76 garren 26
#include "PythiaHelper.h"
27
 
2 garren 28
int main() {
29
    //
30
    //........................................HEPEVT
31
    // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point
32
    //  numbers. We need to explicitly pass this information to the 
33
    //  HEPEVT_Wrapper.
34
    //
35
    HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
36
    HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
37
    //
38
    //........................................PYTHIA INITIALIZATIONS
76 garren 39
    initPythia();
2 garren 40
 
41
    //........................................HepMC INITIALIZATIONS
42
    //
43
    // Instantiate an IO strategy for reading from HEPEVT.
44
    HepMC::IO_HEPEVT hepevtio;
45
    //
63 garren 46
    { // begin scope of ascii_io
47
        // Instantiate an IO strategy to write the data to file 
48
        HepMC::IO_Ascii ascii_io("example_MyPythia.dat",std::ios::out);
49
        //
50
        //........................................EVENT LOOP
51
        for ( int i = 1; i <= 100; i++ ) {
52
            if ( i%50==1 ) std::cout << "Processing Event Number "
53
                                     << i << std::endl;
54
            call_pyevnt();      // generate one event with Pythia
55
            // pythia pyhepc routine converts common PYJETS in common HEPEVT
56
            call_pyhepc( 1 );
57
            HepMC::GenEvent* evt = hepevtio.read_next_event();
58
            // add some information to the event
59
            evt->set_event_number(i);
60
            evt->set_signal_process_id(20);
103 garren 61
            // set number of multi parton interactions
62
            evt->set_mpi( pypars.msti[31-1] );
63 garren 63
            // write the event out to the ascii file
64
            ascii_io << evt;
65
            // we also need to delete the created event from memory
66
            delete evt;
67
        }
68
        //........................................TERMINATION
69
        // write out some information from Pythia to the screen
70
        call_pystat( 1 );    
71
    } // end scope of ascii_io
2 garren 72
 
73
    return 0;
74
}
75
 
76
 
77