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