generator.cc

Go to the documentation of this file.
00001 /***********************************************************************
00002 *                                                                      *
00003 * File: pythia6_jet.cc                                                 *
00004 * This is a simple test program.                                       *
00005 * Copyright \ufffd 2005 Torbj\ufffdrn Sj\ufffdstrand                   *
00006 *                                                                      *
00007 * Modified by sj and ca                                                *
00008 *                                                                      *
00009 ***********************************************************************/
00010 //#include "Pythia.h"
00011 
00012 //#include "LHAFortran.h"
00013 
00014 //#include "HepMCInterface.h"
00015 
00016 // this is needed to generate some random numbers
00017 #include <stdlib.h>
00018 #include <time.h>
00019 
00020 #include <stdio.h>
00021 #include <iostream>
00022 #include <fstream>
00023 #include <sstream>
00024 #include "HepMC/PythiaWrapper.h"
00025 #include "HepMC/IO_HEPEVT.h"
00026 // #include "HepMC/IO_Ascii.h"
00027 #include "HepMC/IO_BaseClass.h"
00028 #include "HepMC/GenEvent.h"
00029 #include "HepMC/SimpleVector.h"
00030 #include "MyPythia6Wrapper.h"
00031 
00032 #include "HepMC/IO_GenEvent.h"  //ap add
00033 
00034 // include our own classes
00035 #include "Configuration.h"
00036 #include "readpythiaConfigFile.h"
00037 
00038 using namespace std;
00039 
00040 // ---------------------------------------------------------------------- 
00041 int main(int argc, const char* argv[]) 
00042 {
00043   if(argc <= 2 ) { //ap
00044     std::cout << "Usage: " << argv[0] << " <Configuration File>" << " <name of file to generate to>"<< std::endl; //ap
00045     return 0;
00046   }
00047   
00048   
00049   Configuration* currentconfig = new Configuration();
00050   if(currentconfig->read(argv[1]))
00051     {
00052       cout << " ... skip !" << endl;
00053       return 0;
00054     }
00055   
00056 
00057 
00058   //........................................HEPEVT
00059   //  Standard Pythia >6.1 uses HEPEVT with NMXHEP=4000 entries and 8-byte
00060   //  floating point numbers. We need to explicitly pass this information
00061   //  to the HEPEVT_Wrapper.
00062   pyjets.n=0; // ensure dummyness of the next call
00063   call_pyhepc(1); // mstu(8) is set to NMXHEP in this dummy call (version >=6.404)
00064   //HepMC::HEPEVT_Wrapper::set_max_number_entries(pydat1.mstu[8-1]);
00065   HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);
00066   HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00067   
00068   //
00069   //........................................PYTHIA INITIALIZATIONS
00070   // (Some platforms may require the initialization of pythia PYDATA block
00071   //  data as external - if you get pythia initialization errors try
00072   //  commenting in/out the below call to initpydata() )
00073   // initpydata();
00074   //
00075   
00076   // set random number seed (mandatory!) ... this may be overwritten by function readConfigFile
00077   pydatr.mrpy[1-1] = currentconfig->rseed ;
00078   
00079   //int tunemode=300;
00080   //pytune( &tunemode );
00081   
00082   cout << "Configuration Parameter List:" << endl;
00083   
00084   for (unsigned int files=0; files<(currentconfig->ConfigFileNames).size(); files++)
00085     readConfigFile((currentconfig->ConfigFileNames)[files]);
00086 
00087   // these three lines are set in the config file Pythia6_Common.config
00088   //   // master switches for FSR, ISR and MI
00089   //   pypars.mstp[61-1]=int(currentconfig->ISR); 
00090   //   pypars.mstp[71-1]=int(currentconfig->FSR); 
00091   //   pypars.mstp[81-1]=int(currentconfig->MI); 
00092 
00093   // Call pythia initialization
00094   call_pyinit("CMS", "p", "p", 14000.);
00095   
00096   //........................................HepMC INITIALIZATIONS
00097   //
00098   // Instantiate an IO strategy for reading from HEPEVT.
00099   HepMC::IO_HEPEVT hepevtio;
00100   //
00101   // Instantiate an IO strategy to write the data to file - it uses the 
00102   //  same ParticleDataTable
00103   //HepMC::IO_Ascii ascii_io("test_pythia_hepmc.dat",ios::out);
00104   
00105   //.......EVENT LOOP:
00106   
00107   int nShow = 50;
00108   int nShowPace = max(1,int(currentconfig->nevents)/nShow);
00109   
00110   HepMC::IO_GenEvent ascii_out(argv[2],std::ios::out);  //ap add
00111   
00112   for (unsigned int iEvent = 1 ; iEvent <= currentconfig->nevents; iEvent++) {
00113     
00114     // Begin event loop. 
00115     if (iEvent%nShowPace == 0) cout << "pythia6:  Now begin event "
00116                                     << iEvent << endl;
00117     
00118     call_pyevnt();      // generate one event with Pythia
00119     // pythia pyhepc routine converts common PYJETS in common HEPEVT
00120     call_pyhepc(1);
00121     HepMC::GenEvent* evt = hepevtio.read_next_event();
00122     // add some information to the event
00123     evt->set_event_number(iEvent);
00124     evt->set_signal_process_id(20);
00125     // write the event out to the ascii file
00126     //    ascii_io << evt;
00127     
00128     
00129     // OUTPUT
00130     ascii_out << evt;   //ap add 
00131 
00132     // we also need to delete the created event from memory
00133     delete evt;
00134   } // end of event loop
00135   
00136   
00137   // write out some information from Pythia to the screen
00138   call_pystat(1);    
00139 
00140   // clean up config object
00141   delete currentconfig;
00142   
00143   cout<<"pythia6:  program ends"<<endl;
00144 
00145   cout<<"Run successfully!"<<endl;
00146   return 0;
00147 }
00148 

Generated on Wed Aug 31 09:44:48 2011 for HepMCAnalysis by  doxygen 1.4.7