1 | ////////////////////////////////////////////////////////////////////////// |
---|
2 | // Matt.Dobbs@Cern.CH, October 2002 |
---|
3 | // example of generating events with Herwig using HepMC/HerwigWrapper.h |
---|
4 | // Events are read into the HepMC event record from the FORTRAN HEPEVT |
---|
5 | // common block using the IO_HERWIG strategy. |
---|
6 | ////////////////////////////////////////////////////////////////////////// |
---|
7 | /// To Compile: go to the HepMC directory and type: |
---|
8 | /// gmake examples/example_MyHerwig.exe |
---|
9 | /// |
---|
10 | /// In this example the precision and number of entries for the HEPEVT |
---|
11 | /// fortran common block are explicitly defined to correspond to those |
---|
12 | /// used in the Herwig version of the HEPEVT common block. |
---|
13 | /// If you get funny output from HEPEVT in your own code, probably you have |
---|
14 | /// set these values incorrectly! |
---|
15 | /// |
---|
16 | |
---|
17 | #include <iostream> |
---|
18 | #include "HepMC/HerwigWrapper.h" |
---|
19 | #include "HepMC/IO_HERWIG.h" |
---|
20 | #include "HepMC/IO_GenEvent.h" |
---|
21 | #include "HepMC/GenEvent.h" |
---|
22 | #include "HepMC/HEPEVT_Wrapper.h" |
---|
23 | |
---|
24 | int main() { |
---|
25 | // |
---|
26 | //........................................HEPEVT |
---|
27 | // Herwig 6.4 uses HEPEVT with 4000 entries and 8-byte floating point |
---|
28 | // numbers. We need to explicitly pass this information to the |
---|
29 | // HEPEVT_Wrapper. |
---|
30 | // |
---|
31 | HepMC::HEPEVT_Wrapper::set_max_number_entries(4000); |
---|
32 | HepMC::HEPEVT_Wrapper::set_sizeof_real(8); |
---|
33 | // |
---|
34 | //.......................................INITIALIZATIONS |
---|
35 | |
---|
36 | hwproc.PBEAM1 = 7000.; // energy of beam1 |
---|
37 | hwproc.PBEAM2 = 7000.; // energy of beam2 |
---|
38 | // 1610 = gg->H--> WW, 1706 = qq-->ttbar, 2510 = ttH -> ttWW |
---|
39 | hwproc.IPROC = 1706; // qq -> ttbar production |
---|
40 | hwproc.MAXEV = 100; // number of events |
---|
41 | // tell it what the beam particles are: |
---|
42 | for ( unsigned int i = 0; i < 8; ++i ) { |
---|
43 | hwbmch.PART1[i] = (i < 1) ? 'P' : ' '; |
---|
44 | hwbmch.PART2[i] = (i < 1) ? 'P' : ' '; |
---|
45 | } |
---|
46 | hwigin(); // INITIALISE OTHER COMMON BLOCKS |
---|
47 | hwevnt.MAXPR = 1; // number of events to print |
---|
48 | hwuinc(); // compute parameter-dependent constants |
---|
49 | hweini(); // initialise elementary process |
---|
50 | |
---|
51 | //........................................HepMC INITIALIZATIONS |
---|
52 | // |
---|
53 | // Instantiate an IO strategy for reading from HEPEVT. |
---|
54 | HepMC::IO_HERWIG hepevtio; |
---|
55 | // Instantiate an IO strategy to write the data to file |
---|
56 | HepMC::IO_GenEvent ascii_io("example_MyHerwig.dat",std::ios::out); |
---|
57 | // |
---|
58 | //........................................EVENT LOOP |
---|
59 | for ( int i = 1; i <= hwproc.MAXEV; i++ ) { |
---|
60 | if ( i%50==1 ) std::cout << "Processing Event Number " |
---|
61 | << i << std::endl; |
---|
62 | // initialise event |
---|
63 | hwuine(); |
---|
64 | // generate hard subprocess |
---|
65 | hwepro(); |
---|
66 | // generate parton cascades |
---|
67 | hwbgen(); |
---|
68 | // do heavy object decays |
---|
69 | hwdhob(); |
---|
70 | // do cluster formation |
---|
71 | hwcfor(); |
---|
72 | // do cluster decays |
---|
73 | hwcdec(); |
---|
74 | // do unstable particle decays |
---|
75 | hwdhad(); |
---|
76 | // do heavy flavour hadron decays |
---|
77 | hwdhvy(); |
---|
78 | // add soft underlying event if needed |
---|
79 | hwmevt(); |
---|
80 | // finish event |
---|
81 | hwufne(); |
---|
82 | HepMC::GenEvent* evt = hepevtio.read_next_event(); |
---|
83 | // define the units (Herwig uses GeV and mm) |
---|
84 | evt->use_units(HepMC::Units::GEV, HepMC::Units::MM); |
---|
85 | // set cross section information |
---|
86 | evt->set_cross_section( HepMC::getHerwigCrossSection(i) ); |
---|
87 | // add some information to the event |
---|
88 | evt->set_event_number(i); |
---|
89 | evt->set_signal_process_id(20); |
---|
90 | if (i<=hwevnt.MAXPR) { |
---|
91 | std::cout << "\n\n This is the FIXED version of HEPEVT as " |
---|
92 | << "coded in IO_HERWIG " << std::endl; |
---|
93 | HepMC::HEPEVT_Wrapper::print_hepevt(); |
---|
94 | evt->print(); |
---|
95 | } |
---|
96 | // write the event to the ascii file |
---|
97 | ascii_io << evt; |
---|
98 | |
---|
99 | // we also need to delete the created event from memory |
---|
100 | delete evt; |
---|
101 | } |
---|
102 | //........................................TERMINATION |
---|
103 | hwefin(); |
---|
104 | |
---|
105 | return 0; |
---|
106 | } |
---|