00001
00002
00003
00004
00005
00006
00007
00008 #include <stdlib.h>
00009 #include <time.h>
00010
00011 #include <stdio.h>
00012 #include <iostream>
00013 #include <fstream>
00014 #include <sstream>
00015
00016 #include "MyHerwigWrapper.h"
00017 #include "HepMC/IO_HERWIG.h"
00018
00019 #include "HepMC/GenEvent.h"
00020 #include "HepMC/HEPEVT_Wrapper.h"
00021 #include "HepMC/SimpleVector.h"
00022 #include "HepMC/IO_GenEvent.h"
00023
00024
00025
00026 #include "Configuration.h"
00027 #include "readherwigConfigFile.h"
00028
00029 using namespace std;
00030
00031
00032 extern "C" void hwaend_ (void);
00033 extern "C" {
00034 int hwgethepevtsize_(void);
00035 void hwsetmodbos_(int& i, int& ivalue);
00036 double hwgetcs(void);
00037 double hwgetcserr(void);
00038 }
00039
00040
00041 int main(int argc, const char* argv[])
00042 {
00043 if(argc <= 2 ) {
00044 std::cout << "Usage: " << argv[0] << " <Configuration File>" << " <name of file to generate to>"<< std::endl;
00045 return 0;
00046 }
00047
00048 Configuration* currentconfig = new Configuration();
00049 if ( currentconfig->read( argv[ 1 ] ) ) {
00050 cout << " ... skip !" << endl;
00051 return 0;
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 HepMC::HEPEVT_Wrapper::set_max_number_entries(hwgethepevtsize_());
00063 HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00064
00065
00066 hwevnt.nrn[0] = currentconfig->rseed;
00067
00068
00069 hwproc.maxev = int(currentconfig->nevents);
00070
00071
00072 for ( unsigned int i = 0; i < 8; ++i ) {
00073 hwbmch.part1[i] = (i < 1) ? 'P' : ' ';
00074 hwbmch.part2[i] = (i < 1) ? 'P' : ' ';
00075 }
00076
00077
00078 hwigin();
00079 jimmin();
00080
00081 cout << "Configuration Parameter List:" << endl;
00082 for (unsigned int files=0; files<(currentconfig->ConfigFileNames).size(); files++)
00083 readConfigFile((currentconfig->ConfigFileNames)[files]);
00084
00085
00086
00087
00088
00089
00090 hwevnt.maxpr = 1;
00091
00092 hwuinc();
00093
00094 hweini();
00095
00096 jminit();
00097
00098
00099
00100 HepMC::IO_HERWIG hepevtio;
00101
00102
00103 HepMC::IO_GenEvent ascii_out(argv[2],std::ios::out);
00104 for ( int iEvent = 1; iEvent <= hwproc.maxev; iEvent++ ) {
00105 if ( iEvent%50==1 ) cout << "Processing Event Number "
00106 << iEvent << endl;
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 hwuine();
00130
00131 hwepro();
00132
00133 hwbgen();
00134
00135
00136 int abort = 0;
00137 hwmsct(&abort);
00138 if (abort != 0) {
00139 cout << "Event aborted by hwmsct." << endl;
00140 hwufne();
00141 continue;
00142 }
00143
00144
00145 hwdhob();
00146 hwcfor();
00147 hwcdec();
00148 hwdhad();
00149 hwdhvy();
00150 hwmevt();
00151 hwufne();
00152
00153 if (hwevnt.ierror==-1 || hwevnt.ierror>99) {
00154 cout << "Event Error, Number: " << " Code: " << hwevnt.ierror << endl;
00155 continue;
00156 }
00157
00158
00159
00160
00161 HepMC::GenEvent* evt = hepevtio.read_next_event();
00162
00163 evt->set_event_number(iEvent);
00164 evt->set_signal_process_id(20);
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 ascii_out << evt;
00177
00178
00179 delete evt;
00180
00181 }
00182
00183 hwefin();
00184
00185
00186
00187 delete currentconfig;
00188
00189
00190 cout<<"Run successfully!"<<endl;
00191 return 0;
00192 }
00193
00194
00195 void hwaend_ (void) { return; }