HepMC Reference Documentation

HepMC

testPythiaCopies.cc

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         // set number of multi parton interactions
00048         evt->set_mpi( pypars.msti[31-1] );
00049         //
00050         //.......................make some copies
00051         evt->print(out1);
00052         HepMC::GenEvent ec = (*evt);
00053         ec.print(out2);
00054         HepMC::GenEvent* evt4 = new HepMC::GenEvent(*evt);
00055         evt4->print(out3);
00056         if( !compareGenEvent(evt,evt4) ) { 
00057            std::cerr << "testPythiaCopies: GenEvent comparison fails at event "
00058                      << evt->event_number() << std::endl;
00059            return -1; 
00060         }
00061         //
00062         // now delete the created events from memory
00063         delete evt;
00064         delete evt4;
00065     }
00066     //........................................TERMINATION
00067     // write out some information from Pythia to the screen
00068     call_pystat( 1 );    
00069     std::cout << "testPythiaCopies: event comparison is successful" << std::endl;
00070 
00071     return 0;
00072 }
00073 
00074 
00075  

Generated on Wed Mar 12 13:08:08 2008 for HepMC by  doxygen 1.5.1-3