generator.cc

Go to the documentation of this file.
00001 /***********************************************************************
00002 *                                                                      *
00003 * File: cascade.cc                                                     *
00004 * This is a simple test program.                                       *
00005 * based on the example cascade program                                 *
00006 * from the MC School at DESY in April 2008                             *
00007 *                                                                      *
00008 * Modified by sj                                                       *
00009 *                                                                      *
00010 ***********************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 // Events are read into the HepMC event record from the FORTRAN HEPEVT 
00014 // common block using the IO_HEPEVT strategy -- nothing is done with them.
00015 // This program is just used to find the total time required to transfer
00016 // from HEPEVT into the HepMC event record.
00017 //////////////////////////////////////////////////////////////////////////
00018 
00019 #include <iostream>
00020 #include "HepMC/PythiaWrapper.h"
00021 #include "CascadeWrapper.h"
00022 #include "MyCascadeWrapper.h"
00023 #include "HepMC/IO_HEPEVT.h"
00024 //#include "HepMC/IO_Ascii.h"
00025 #include "HepMC/IO_GenEvent.h"
00026 #include "HepMC/GenEvent.h"
00027 #include "PythiaHelper.h"
00028 
00029 #include <stdio.h>
00030 #include "HepMC/IO_AsciiParticles.h"
00031 #include "HepMC/SimpleVector.h"
00032 
00033 #include "TH1.h"
00034 #include "TFile.h"
00035 #include "TMath.h"
00036 #include <TCanvas.h>
00037 
00038 #include "TF1.h"
00039 #include <TH2.h>
00040 #include <TStyle.h>
00041 #include "TLegend.h"
00042 #include <TTree.h>
00043 #include <TString.h>
00044 
00045 // include our own classes
00046 #include "Configuration.h"
00047 #include "readCascadeConfigFile.h"
00048 
00049 extern "C" {
00050   extern struct {
00051     int Nevent;
00052   } steer1_;
00053 }
00054 #define steer1 steer1_
00055 
00056 using namespace std;
00057 
00058 // ---------------------------------------------------------------------- 
00059 int main( int argc, const char* argv[] ) 
00060 { 
00061   if(argc <= 2 ) { //ap
00062     std::cout << "Usage: " << argv[0] << " <Configuration File>" << " <name of file to generate to>"<< std::endl; //ap
00063     return 0;
00064   }
00065 
00066   Configuration* currentconfig = new Configuration();
00067   if ( currentconfig->read( argv[1] ) ) {
00068     cout << " ... skip !" << endl;
00069     return 0;
00070   }     
00071 
00072   
00073   //
00074   //........................................HEPEVT
00075   // CASCADE (via PYTHIA6) uses HEPEVT with 10000 entries and 
00076   // 8-byte floating point numbers. We need to explicitly pass
00077   // this information to the HEPEVT_Wrapper.
00078   //
00079   //    HepMC::HEPEVT_Wrapper::set_sizeof_int(4);
00080   //    HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00081   //    HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);
00082   //
00083   pyjets.n=0;     // ensure dummyness of the next call
00084   call_pyhepc(1); // mstu(8) is set to NMXHEP in this dummy call (version >=6.404)
00085   //HepMC::HEPEVT_Wrapper::set_max_number_entries(pydat1.mstu[8-1]);
00086   HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);
00087   HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00088   
00089   //    
00090   //    initPythia();
00091   //........................................CASCADE INITIALIZATIONS
00092   //  call_rluxgo(lux,iseed,k1,k2)
00093   // lux = luxory level
00094   // iseed = seed for random number generator
00095   //    call_rluxgo(4,87777886,0,0);
00096   //--initialise CASCADE parameters
00097 
00098   call_casini();
00099 
00100   //call steering
00101   //call_steer();
00102 
00103   //-- change standard parameters of CASCADE
00104   call_cascha();
00105   
00106   //change cascade parameters
00107   vector< string > cascade_commands;
00108   // read in commandlines
00109   for (unsigned int files=0; files<(currentconfig->ConfigFileNames).size(); files++)
00110     readConfigFile((currentconfig->ConfigFileNames)[files]);
00111 
00112   //-- change standard parameters of JETSET/PYTHIA
00113   call_pytcha();
00114 
00115   //-- set up for running CASCADE  
00116   call_cascade();
00117 
00118   //-- print result from integration
00119   call_caend(1);   
00120 
00121   //
00122   //........................................HepMC INITIALIZATIONS
00123   //
00124   // Instantiate an IO strategy for reading from HEPEVT.
00125   HepMC::IO_HEPEVT hepevtio;
00126   //
00127   HepMC::IO_GenEvent ascii_out(argv[2],std::ios::out);  //add ap
00128   // Instantial an IO strategy to write the data to file - it uses the 
00129   //  same ParticleDataTable
00130   //HepMC::IO_GenEvent ascii_io("example_MyCASCADE.dat",ios::out);
00131   //
00132   //........................................EVENT LOOP
00133   //int Nevent = steer1.Nevent;
00134   int Nevent = currentconfig->nevents;
00135 
00136   for ( int iEvent = 1; iEvent <= Nevent; iEvent++ ) {
00137     if ( iEvent == 1 || iEvent % 100 == 0 ) {
00138       cout << "Processing Event Number "  << iEvent << endl;
00139     }
00140     call_event();      // generate one event with CASCADE
00141 
00142     // pythia pyhepc routine convert common PYJETS in common HEPEVT
00143     call_pyhepc( 1 );
00144     HepMC::GenEvent* hepmcevt = hepevtio.read_next_event();
00145     //
00146     // add some information to the event
00147     hepmcevt->set_event_number(iEvent);
00148     hepmcevt->set_signal_process_id(11);
00149 
00150 
00151     ascii_out << hepmcevt;    //add ap
00152     // we also need to delete the created event from memory
00153     delete hepmcevt;
00154 
00155   }
00156   //........................................TERMINATION
00157   //  Print out of generated event summary
00158   call_caend(2);
00159   // write out some information from Pythia to the screen
00160   //    call_pystat( 1 );    
00161   
00162 
00163   // clean up config object
00164   delete currentconfig;
00165 
00166   cout << "cascade: program ends" << endl;
00167 
00168   cout << "Run successfully!" << endl;
00169   return 0;
00170 }
00171 

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