HepMC Reference Documentation

HepMC

testHerwigCopies.cc

Go to the documentation of this file.
00001 
00002 // testHerwigCopies.cc
00003 //
00004 // garren@fnal.gov, January 2008
00005 // Multiple events in memory at the same time
00007 
00008 #include <fstream>
00009 #include <iostream>
00010 #include "HepMC/HerwigWrapper.h"
00011 #include "HepMC/IO_HERWIG.h"
00012 #include "HepMC/GenEvent.h"
00013 #include "HepMC/CompareGenEvent.h"
00014 #include "HepMC/HEPEVT_Wrapper.h"
00015 #include "HerwigHelper.h"
00016 
00017 int main() { 
00018     //
00019     //........................................HEPEVT
00020     // Herwig 6.4 uses HEPEVT with 4000 entries and 8-byte floating point
00021     //  numbers. We need to explicitly pass this information to the 
00022     //  HEPEVT_Wrapper.
00023     //
00024     HepMC::HEPEVT_Wrapper::set_max_number_entries(4000);
00025     HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00026     //
00027     //.......................................INITIALIZATIONS
00028 
00029     hwproc.PBEAM1 = 7000.; // energy of beam1
00030     hwproc.PBEAM2 = 7000.; // energy of beam2
00031     // 1610 = gg->H--> WW, 1706 = qq-->ttbar, 2510 = ttH -> ttWW
00032     hwproc.IPROC = 1706; // qq -> ttbar production 
00033     hwproc.MAXEV = 50; // number of events
00034     // tell it what the beam particles are:
00035     for ( unsigned int i = 0; i < 8; ++i ) {
00036         hwbmch.PART1[i] = (i < 1) ? 'P' : ' ';
00037         hwbmch.PART2[i] = (i < 1) ? 'P' : ' ';
00038     }
00039     hwigin();    // INITIALISE OTHER COMMON BLOCKS
00040     hwevnt.MAXPR = 0; // number of events to print
00041     hwuinc(); // compute parameter-dependent constants
00042     hweini(); // initialise elementary process
00043 
00044     //........................................HepMC INITIALIZATIONS
00045     //
00046     // Instantiate an IO strategy for reading from HEPEVT.
00047     HepMC::IO_HERWIG hepevtio;
00048     //
00049     // open some output files
00050     std::ofstream out1( "testHerwigOriginals.dat" );
00051     std::ofstream out2( "testHerwigCopies1.dat" );
00052     std::ofstream out3( "testHerwigCopies2.dat" );
00053     //
00054     //........................................EVENT LOOP
00055     for ( int i = 1; i <= hwproc.MAXEV; i++ ) {
00056         if ( i%50==1 ) std::cout << "Processing Event Number " 
00057                                  << i << std::endl;
00058         // initialise event
00059         hwuine();
00060         // generate hard subprocess
00061         hwepro();
00062         // generate parton cascades
00063         hwbgen();
00064         // do heavy object decays
00065         hwdhob();
00066         // do cluster formation
00067         hwcfor();
00068         // do cluster decays
00069         hwcdec();
00070         // do unstable particle decays
00071         hwdhad();
00072         // do heavy flavour hadron decays
00073         hwdhvy();
00074         // add soft underlying event if needed
00075         hwmevt();
00076         // finish event
00077         hwufne();
00078         HepMC::GenEvent* evt = hepevtio.read_next_event();
00079         // herwig uses GeV and mm 
00080         evt->use_units( HepMC::Units::GEV, HepMC::Units::MM);
00081         // set cross section information
00082         evt->set_cross_section( getHerwigCrossSection(i) );
00083         // add some information to the event
00084         evt->set_event_number(i);
00085         evt->set_signal_process_id(20);
00086         //
00087         //.......................make some copies
00088         evt->print(out1);
00089         HepMC::GenEvent ec = (*evt);
00090         ec.print(out2);
00091         HepMC::GenEvent* evt4 = new HepMC::GenEvent(*evt);
00092         evt4->print(out3);
00093         if( !compareGenEvent(evt,evt4) ) { 
00094            std::cerr << "testHerwigCopies: GenEvent comparison fails at event "
00095                      << evt->event_number() << std::endl;
00096            return -1; 
00097         }
00098 
00099         // we also need to delete the created event from memory
00100         delete evt;
00101         delete evt4;
00102     }
00103     //........................................TERMINATION
00104     hwefin();
00105     std::cout << "testHerwigCopies: event comparison is successful" << std::endl;
00106 
00107     return 0;
00108 }

Generated on Thu Jan 7 13:10:16 2010 for HepMC by  doxygen 1.4.7