source: HiSusy/trunk/hepmc/x86_64-slc5-gcc41-opt/share/HepMC/examples/fio/testHerwigCopies.cc @ 1

Last change on this file since 1 was 1, checked in by zerwas, 11 years ago

first import of structure, PYTHIA8 and DELPHES

File size: 3.3 KB
Line 
1//////////////////////////////////////////////////////////////////////////
2// testHerwigCopies.cc
3//
4// garren@fnal.gov, January 2008
5// Multiple events in memory at the same time
6//////////////////////////////////////////////////////////////////////////
7
8#include <fstream>
9#include <iostream>
10#include "HepMC/HerwigWrapper.h"
11#include "HepMC/IO_HERWIG.h"
12#include "HepMC/GenEvent.h"
13#include "HepMC/CompareGenEvent.h"
14#include "HepMC/HEPEVT_Wrapper.h"
15
16int main() { 
17    //
18    //........................................HEPEVT
19    // Herwig 6.4 uses HEPEVT with 4000 entries and 8-byte floating point
20    //  numbers. We need to explicitly pass this information to the
21    //  HEPEVT_Wrapper.
22    //
23    HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
24    HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
25    //
26    //.......................................INITIALIZATIONS
27
28    hwproc.PBEAM1 = 7000.; // energy of beam1
29    hwproc.PBEAM2 = 7000.; // energy of beam2
30    // 1610 = gg->H--> WW, 1706 = qq-->ttbar, 2510 = ttH -> ttWW
31    hwproc.IPROC = 1706; // qq -> ttbar production
32    hwproc.MAXEV = 50; // number of events
33    // tell it what the beam particles are:
34    for ( unsigned int i = 0; i < 8; ++i ) {
35        hwbmch.PART1[i] = (i < 1) ? 'P' : ' ';
36        hwbmch.PART2[i] = (i < 1) ? 'P' : ' ';
37    }
38    hwigin();    // INITIALISE OTHER COMMON BLOCKS
39    hwevnt.MAXPR = 0; // number of events to print
40    hwuinc(); // compute parameter-dependent constants
41    hweini(); // initialise elementary process
42
43    //........................................HepMC INITIALIZATIONS
44    //
45    // Instantiate an IO strategy for reading from HEPEVT.
46    HepMC::IO_HERWIG hepevtio;
47    //
48    // open some output files
49    std::ofstream out1( "testHerwigOriginals.dat" );
50    std::ofstream out2( "testHerwigCopies1.dat" );
51    std::ofstream out3( "testHerwigCopies2.dat" );
52    //
53    //........................................EVENT LOOP
54    for ( int i = 1; i <= hwproc.MAXEV; i++ ) {
55        if ( i%50==1 ) std::cout << "Processing Event Number " 
56                                 << i << std::endl;
57        // initialise event
58        hwuine();
59        // generate hard subprocess
60        hwepro();
61        // generate parton cascades
62        hwbgen();
63        // do heavy object decays
64        hwdhob();
65        // do cluster formation
66        hwcfor();
67        // do cluster decays
68        hwcdec();
69        // do unstable particle decays
70        hwdhad();
71        // do heavy flavour hadron decays
72        hwdhvy();
73        // add soft underlying event if needed
74        hwmevt();
75        // finish event
76        hwufne();
77        HepMC::GenEvent* evt = hepevtio.read_next_event();
78        // herwig uses GeV and mm
79        evt->use_units( HepMC::Units::GEV, HepMC::Units::MM);
80        // set cross section information
81        evt->set_cross_section( HepMC::getHerwigCrossSection(i) );
82        // add some information to the event
83        evt->set_event_number(i);
84        evt->set_signal_process_id(20);
85        //
86        //.......................make some copies
87        evt->print(out1);
88        HepMC::GenEvent ec = (*evt);
89        ec.print(out2);
90        HepMC::GenEvent* evt4 = new HepMC::GenEvent(*evt);
91        evt4->print(out3);
92        if( !compareGenEvent(evt,evt4) ) { 
93           std::cerr << "testHerwigCopies: GenEvent comparison fails at event "
94                     << evt->event_number() << std::endl;
95           return -1; 
96        }
97
98        // we also need to delete the created event from memory
99        delete evt;
100        delete evt4;
101    }
102    //........................................TERMINATION
103    hwefin();
104    std::cout << "testHerwigCopies: event comparison is successful" << std::endl;
105
106    return 0;
107}
Note: See TracBrowser for help on using the repository browser.