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