HepMC Reference Documentation

HepMC

testPythiaCopies.cc

Multiple events in memory at the same time

00001 
00002 // testPythiaCopies.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/PythiaWrapper.h"
00011 #include "HepMC/IO_HEPEVT.h"
00012 #include "HepMC/GenEvent.h"
00013 #include "HepMC/CompareGenEvent.h"
00014 #include "PythiaHelper.h"
00015 
00016 int main() {    
00017     //
00018     //........................................HEPEVT
00019     // Pythia 6.1 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     //........................................PYTHIA INITIALIZATIONS
00027     initPythia();
00028     //
00029     //........................................HepMC INITIALIZATIONS
00030     //
00031     // Instantiate an IO strategy for reading from HEPEVT.
00032     HepMC::IO_HEPEVT hepevtio;
00033     //
00034     // open some output files
00035     std::ofstream out1( "testPythiaOriginals.dat" );
00036     std::ofstream out2( "testPythiaCopies1.dat" );
00037     std::ofstream out3( "testPythiaCopies2.dat" );
00038     //
00039     //........................................EVENT LOOP
00040     for ( int i = 1; i <= 50; i++ ) {
00041         if ( i%50==1 ) std::cout << "Processing Event Number " 
00042                                  << i << std::endl;
00043         call_pyevnt();      // generate one event with Pythia
00044         // pythia pyhepc routine convert common PYJETS in common HEPEVT
00045         call_pyhepc( 1 );
00046         HepMC::GenEvent* evt = hepevtio.read_next_event();
00047         // pythia uses GeV and mm
00048         evt->use_units( HepMC::Units::GEV, HepMC::Units::MM);
00049         // set number of multi parton interactions
00050         evt->set_mpi( pypars.msti[31-1] );
00051         // set cross section information
00052         evt->set_cross_section( getPythiaCrossSection() );
00053         //
00054         //.......................make some copies
00055         evt->print(out1);
00056         HepMC::GenEvent ec = (*evt);
00057         ec.print(out2);
00058         HepMC::GenEvent* evt4 = new HepMC::GenEvent(*evt);
00059         evt4->print(out3);
00060         if( !compareGenEvent(evt,evt4) ) { 
00061            std::cerr << "testPythiaCopies: GenEvent comparison fails at event "
00062                      << evt->event_number() << std::endl;
00063            return -1; 
00064         }
00065         //
00066         // now delete the created events from memory
00067         delete evt;
00068         delete evt4;
00069     }
00070     //........................................TERMINATION
00071     // write out some information from Pythia to the screen
00072     call_pystat( 1 );    
00073     std::cout << "testPythiaCopies: event comparison is successful" << std::endl;
00074 
00075     return 0;
00076 }
00077 
00078 
00079  

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