1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | ////////////////////////////////////////////////////////////////////////// |
---|
28 | // Matt.Dobbs@Cern.CH, December 1999 |
---|
29 | // November 2000, updated to use Pythia 6.1 |
---|
30 | // example of generating events with Pythia |
---|
31 | // using HepMC/PythiaWrapper.h |
---|
32 | // Events are read into the HepMC event record from the FORTRAN HEPEVT |
---|
33 | // common block using the IO_HEPEVT strategy and then output to file in |
---|
34 | // ascii format using the IO_Ascii strategy. |
---|
35 | ////////////////////////////////////////////////////////////////////////// |
---|
36 | // To Compile: go to the HepMC directory and type: |
---|
37 | // gmake examples/example_MyPythia.exe |
---|
38 | // |
---|
39 | // In this example the precision and number of entries for the HEPEVT |
---|
40 | // fortran common block are explicitly defined to correspond to those |
---|
41 | // used in the Pythia version of the HEPEVT common block. |
---|
42 | // |
---|
43 | // If you get funny output from HEPEVT in your own code, probably you have |
---|
44 | // set these values incorrectly! |
---|
45 | // |
---|
46 | |
---|
47 | #include <iostream> |
---|
48 | #include "HepMC/PythiaWrapper.h" |
---|
49 | #include "HepMC/IO_HEPEVT.h" |
---|
50 | #include "HepMC/IO_Ascii.h" |
---|
51 | #include "HepMC/GenEvent.h" |
---|
52 | |
---|
53 | int main() { |
---|
54 | // |
---|
55 | //........................................HEPEVT |
---|
56 | // Pythia 6.1 uses HEPEVT with 4000 entries and 8-byte floating point |
---|
57 | // numbers. We need to explicitly pass this information to the |
---|
58 | // HEPEVT_Wrapper. |
---|
59 | // |
---|
60 | HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
---|
61 | HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
---|
62 | // |
---|
63 | //........................................PYTHIA INITIALIZATIONS |
---|
64 | // (Some platforms may require the initialization of pythia PYDATA block |
---|
65 | // data as external - if you get pythia initialization errors try |
---|
66 | // commenting in/out the below call to initpydata() ) |
---|
67 | // initpydata(); |
---|
68 | // |
---|
69 | // Select W+gamma process (process number 20) |
---|
70 | // (here we have to be careful of C/F77 differences: arrays in C |
---|
71 | // start at 0, F77 at 1, so we need to subtract 1 from the process #) |
---|
72 | pysubs.msel=0; |
---|
73 | pysubs.msub[20-1] = 1; |
---|
74 | // set random number seed (mandatory!) |
---|
75 | pydatr.mrpy[0]=55122 ; |
---|
76 | // Tell Pythia not to write multiple copies of particles in event record. |
---|
77 | pypars.mstp[128-1] = 2; |
---|
78 | // Example of setting a Pythia parameter: set the top mass |
---|
79 | pydat2.pmas[1-1][6-1]= 175; |
---|
80 | // |
---|
81 | // Call pythia initialization |
---|
82 | call_pyinit( "CMS", "p", "p", 14000. ); |
---|
83 | |
---|
84 | //........................................HepMC INITIALIZATIONS |
---|
85 | // |
---|
86 | // Instantiate an IO strategy for reading from HEPEVT. |
---|
87 | HepMC::IO_HEPEVT hepevtio; |
---|
88 | // |
---|
89 | // Instantial an IO strategy to write the data to file - it uses the |
---|
90 | // same ParticleDataTable |
---|
91 | HepMC::IO_Ascii ascii_io("example_MyPythia.dat",std::ios::out); |
---|
92 | // |
---|
93 | //........................................EVENT LOOP |
---|
94 | for ( int i = 1; i <= 10; i++ ) { |
---|
95 | if ( i%50==1 ) std::cout << "Processing Event Number " |
---|
96 | << i << std::endl; |
---|
97 | call_pyevnt(); // generate one event with Pythia |
---|
98 | // pythia pyhepc routine converts common PYJETS in common HEPEVT |
---|
99 | call_pyhepc( 1 ); |
---|
100 | HepMC::GenEvent* evt = hepevtio.read_next_event(); |
---|
101 | // add some information to the event |
---|
102 | evt->set_event_number(i); |
---|
103 | evt->set_signal_process_id(20); |
---|
104 | // write the event out to the ascii file |
---|
105 | ascii_io << evt; |
---|
106 | // we also need to delete the created event from memory |
---|
107 | delete evt; |
---|
108 | } |
---|
109 | //........................................TERMINATION |
---|
110 | // write out some information from Pythia to the screen |
---|
111 | call_pystat( 1 ); |
---|
112 | |
---|
113 | return 0; |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | |
---|