00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "Pythia.h"
00013
00014 #include "LHAFortran.h"
00015
00016 #include "HepMCInterface.h"
00017
00018 #include "HepMC/GenEvent.h"
00019
00020
00021 #include <stdlib.h>
00022 #include <time.h>
00023
00024 #include <iostream>
00025 #include <stdio.h>
00026 #include "HepMC/IO_GenEvent.h"
00027 #include "HepMC/GenEvent.h"
00028 #include "HepMC/IO_AsciiParticles.h"
00029 #include "HepMC/SimpleVector.h"
00030
00031 using namespace Pythia8;
00032 using namespace std;
00033
00034 #include "Configuration.h"
00035
00036
00037
00038
00039 int main(int argc, const char* argv[]) {
00040
00041 if(argc <= 2 ) {
00042 std::cout << "Usage: " << argv[0] << " <Configuration File>" << " <name of file to generate to>"<< std::endl;
00043 return 0;
00044 }
00045
00046 Configuration* currentconfig = new Configuration();
00047 if(currentconfig->read(argv[1]))
00048 {
00049
00050 return 0;
00051 }
00052
00053
00054 HepMC::I_Pythia8 ToHepMC;
00055
00056
00057
00058 Pythia pythia(std::getenv("Pythia8DATA"));
00059
00060 char processline[64];
00061
00062 for (unsigned int files=0; files<currentconfig->ConfigFileNames.size(); files++)
00063 {
00064
00065 pythia.readFile(currentconfig->ConfigFileNames[files].c_str());
00066 }
00067
00068
00069 pythia.readString("Random:setSeed = on");
00070
00071 pythia.readString(processline);
00072
00073
00074
00075 pythia.readString(processline);
00076
00077
00078 pythia.readString(processline);
00079
00080
00081 pythia.readString(processline);
00082
00083
00084
00085
00086 pythia.init( 2212, 2212, 14000.);
00087
00088
00089 Event& event = pythia.event;
00090 Settings& settings = pythia.settings;
00091
00092
00093 int nEvent = currentconfig->nevents;
00094
00095
00096 int nShow = settings.mode("Main:timesToShow");
00097 int nAbort = settings.mode("Main:timesAllowErrors");
00098 bool showChangedSettings = settings.flag("Main:showChangedSettings");
00099 bool showAllSettings = settings.flag("Main:showAllSettings");
00100 bool showAllParticleData = settings.flag("Main:showAllParticleData");
00101
00102
00103 if (showChangedSettings) settings.listChanged();
00104 if (showAllSettings) settings.listAll();
00105
00106
00107
00108
00109 if (showAllParticleData) pythia.particleData.listAll();
00110
00111
00112 int nShowPace = max(1,nEvent/nShow);
00113 int iAbort = 0;
00114 HepMC::IO_GenEvent ascii_out(argv[2],std::ios::out);
00115 for (int iEvent = 0; iEvent < nEvent; ++iEvent) {
00116
00117 if (iEvent%nShowPace == 0)
00118
00119
00120
00121 if (!pythia.next()) {
00122 if (++iAbort < nAbort) continue;
00123
00124 break;
00125 }
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 HepMC::GenEvent* hepmcevt = new HepMC::GenEvent();
00136
00137 ToHepMC.fill_next_event( event, hepmcevt );
00138
00139
00140
00141
00142
00143 ascii_out << hepmcevt;
00144
00145
00146 delete hepmcevt;
00147
00148 }
00149
00150
00151
00152 pythia.statistics();
00153
00154 pythia.settings.writeFile("allSettings.cmnd",true);
00155
00156
00157
00158 delete currentconfig;
00159
00160
00161 std::cout<<"pythia8: program ends"<<std::endl;
00162 std::cout<<"Run successfully!"<<std::endl;
00163
00164 return 0;
00165 }
00166