HepMC Reference Documentation

HepMC

fio/example_MyHerwig.cc

00001 
00002 // Matt.Dobbs@Cern.CH, October 2002
00003 // example of generating events with Herwig using HepMC/HerwigWrapper.h 
00004 // Events are read into the HepMC event record from the FORTRAN HEPEVT 
00005 // common block using the IO_HERWIG strategy.
00016 
00017 #include <iostream>
00018 #include "HepMC/HerwigWrapper.h"
00019 #include "HepMC/IO_HERWIG.h"
00020 #include "HepMC/IO_GenEvent.h"
00021 #include "HepMC/GenEvent.h"
00022 #include "HepMC/HEPEVT_Wrapper.h"
00023 
00024 int main() { 
00025     //
00026     //........................................HEPEVT
00027     // Herwig 6.4 uses HEPEVT with 4000 entries and 8-byte floating point
00028     //  numbers. We need to explicitly pass this information to the 
00029     //  HEPEVT_Wrapper.
00030     //
00031     HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
00032     HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00033     //
00034     //.......................................INITIALIZATIONS
00035 
00036     hwproc.PBEAM1 = 7000.; // energy of beam1
00037     hwproc.PBEAM2 = 7000.; // energy of beam2
00038     // 1610 = gg->H--> WW, 1706 = qq-->ttbar, 2510 = ttH -> ttWW
00039     hwproc.IPROC = 1706; // qq -> ttbar production 
00040     hwproc.MAXEV = 100; // number of events
00041     // tell it what the beam particles are:
00042     for ( unsigned int i = 0; i < 8; ++i ) {
00043         hwbmch.PART1[i] = (i < 1) ? 'P' : ' ';
00044         hwbmch.PART2[i] = (i < 1) ? 'P' : ' ';
00045     }
00046     hwigin();    // INITIALISE OTHER COMMON BLOCKS
00047     hwevnt.MAXPR = 1; // number of events to print
00048     hwuinc(); // compute parameter-dependent constants
00049     hweini(); // initialise elementary process
00050 
00051     //........................................HepMC INITIALIZATIONS
00052     //
00053     // Instantiate an IO strategy for reading from HEPEVT.
00054     HepMC::IO_HERWIG hepevtio;
00055     // Instantiate an IO strategy to write the data to file 
00056     HepMC::IO_GenEvent ascii_io("example_MyHerwig.dat",std::ios::out);
00057     //
00058     //........................................EVENT LOOP
00059     for ( int i = 1; i <= hwproc.MAXEV; i++ ) {
00060         if ( i%50==1 ) std::cout << "Processing Event Number " 
00061                                  << i << std::endl;
00062         // initialise event
00063         hwuine();
00064         // generate hard subprocess
00065         hwepro();
00066         // generate parton cascades
00067         hwbgen();
00068         // do heavy object decays
00069         hwdhob();
00070         // do cluster formation
00071         hwcfor();
00072         // do cluster decays
00073         hwcdec();
00074         // do unstable particle decays
00075         hwdhad();
00076         // do heavy flavour hadron decays
00077         hwdhvy();
00078         // add soft underlying event if needed
00079         hwmevt();
00080         // finish event
00081         hwufne();
00082         HepMC::GenEvent* evt = hepevtio.read_next_event();
00083         // define the units (Herwig uses GeV and mm)
00084         evt->use_units(HepMC::Units::GEV, HepMC::Units::MM);
00085         // set cross section information
00086         evt->set_cross_section( HepMC::getHerwigCrossSection(i) );
00087         // add some information to the event
00088         evt->set_event_number(i);
00089         evt->set_signal_process_id(20);
00090         if (i<=hwevnt.MAXPR) {
00091             std::cout << "\n\n This is the FIXED version of HEPEVT as "
00092                       << "coded in IO_HERWIG " << std::endl;
00093             HepMC::HEPEVT_Wrapper::print_hepevt();
00094             evt->print();
00095         }
00096         // write the event to the ascii file
00097         ascii_io << evt;
00098 
00099         // we also need to delete the created event from memory
00100         delete evt;
00101     }
00102     //........................................TERMINATION
00103     hwefin();
00104 
00105     return 0;
00106 }

Generated on Fri Feb 17 00:31:25 2012 for HepMC by  doxygen 1.4.7