source: HiSusy/trunk/hepmc/x86_64-slc5-gcc41-opt/share/HepMC/examples/fio/testPythiaCopies.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: 2.6 KB
Line 
1//////////////////////////////////////////////////////////////////////////
2// testPythiaCopies.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/PythiaWrapper.h"
11#include "HepMC/IO_HEPEVT.h"
12#include "HepMC/GenEvent.h"
13#include "HepMC/CompareGenEvent.h"
14#include "PythiaHelper.h"
15
16int main() {   
17    //
18    //........................................HEPEVT
19    // Pythia 6.1 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    //........................................PYTHIA INITIALIZATIONS
27    initPythia();
28    //
29    //........................................HepMC INITIALIZATIONS
30    //
31    // Instantiate an IO strategy for reading from HEPEVT.
32    HepMC::IO_HEPEVT hepevtio;
33    //
34    // open some output files
35    std::ofstream out1( "testPythiaOriginals.dat" );
36    std::ofstream out2( "testPythiaCopies1.dat" );
37    std::ofstream out3( "testPythiaCopies2.dat" );
38    //
39    //........................................EVENT LOOP
40    for ( int i = 1; i <= 50; i++ ) {
41        if ( i%50==1 ) std::cout << "Processing Event Number " 
42                                 << i << std::endl;
43        call_pyevnt();      // generate one event with Pythia
44        // pythia pyhepc routine convert common PYJETS in common HEPEVT
45        call_pyhepc( 1 );
46        HepMC::GenEvent* evt = hepevtio.read_next_event();
47        // pythia uses GeV and mm
48        evt->use_units( HepMC::Units::GEV, HepMC::Units::MM);
49        // set a couple of arbitrary weights
50        evt->weights().push_back(0.456);
51        evt->weights()["test2"] = 0.8956;
52        // set number of multi parton interactions
53        evt->set_mpi( pypars.msti[31-1] );
54        // set cross section information
55        evt->set_cross_section( HepMC::getPythiaCrossSection() );
56        //
57        //.......................make some copies
58        evt->print(out1);
59        HepMC::GenEvent ec = (*evt);
60        ec.print(out2);
61        HepMC::GenEvent* evt4 = new HepMC::GenEvent(*evt);
62        evt4->print(out3);
63        if( !compareGenEvent(evt,evt4) ) { 
64           std::cerr << "testPythiaCopies: GenEvent comparison fails at event "
65                     << evt->event_number() << std::endl;
66           return -1; 
67        }
68        //
69        // now delete the created events from memory
70        delete evt;
71        delete evt4;
72    }
73    //........................................TERMINATION
74    // write out some information from Pythia to the screen
75    call_pystat( 1 );   
76    std::cout << "testPythiaCopies: event comparison is successful" << std::endl;
77
78    return 0;
79}
80
81
82 
Note: See TracBrowser for help on using the repository browser.