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 #include "HepMC/IO_Ascii.h"
00019 #include "HepMC/GenEvent.h"
00020 #include "HepMC/HEPEVT_Wrapper.h"
00021 #include "HepMC/SimpleVector.h"
00022
00023 #include "TH1.h"
00024 #include "TFile.h"
00025 #include "TMath.h"
00026 #include <TCanvas.h>
00027
00028 #include "TF1.h"
00029 #include <TH2.h>
00030 #include <TStyle.h>
00031 #include "TLegend.h"
00032 #include <TTree.h>
00033 #include <TString.h>
00034
00035 using namespace std;
00036
00037
00038 #include "../../include/Configuration.h"
00039 #include "../../include/JetFinder.h"
00040 #include "../../include/TopAnalysis.h"
00041 #include "../../include/TauAnalysis.h"
00042 #include "../../include/DiJetAnalysis.h"
00043 #include "../../include/WplusJetAnalysis.h"
00044 #include "../../include/ZAnalysis.h"
00045 #include "../../include/UEAnalysis.h"
00046 #include "../../include/EtMissAnalysis.h"
00047 #include "../../include/ElasScatAnalysis.h"
00048 #include "../../include/UserAnalysis.h"
00049 #include "readherwigConfigFile.h"
00050
00051
00052 extern "C" void hwaend_ (void);
00053 extern "C" {
00054 int hwgethepevtsize_(void);
00055 void hwsetmodbos_(int& i, int& ivalue);
00056 double hwgetcs(void);
00057 double hwgetcserr(void);
00058 }
00059
00060
00061 int main(int argc, const char* argv[]) {
00062
00063 if(argc <= 1 ) {
00064 std::cout << "Usage: " << argv[0] << " <Configuration File>" << std::endl;
00065 return 0;
00066 }
00067
00068
00069 Configuration* currentconfig = new Configuration();
00070 if(currentconfig->read(argv[1]))
00071 {
00072 std::cout << " ... skip !" << std::endl;
00073 return 0;
00074 }
00075
00076 JetFinder FindJet;
00077 FindJet.Init(currentconfig->max_eta,currentconfig->min_pt);
00078 FindJet.InitJetFinder(currentconfig->coneRadius,currentconfig->overlapThreshold,currentconfig->jet_ptmin,currentconfig->lepton_ptmin,currentconfig->DeltaR_lepton_track);
00079
00080
00081 std::vector<baseAnalysis*> analysis;
00082
00083
00084 if (currentconfig->dijet) {
00085 std::cout << "Adding module DiJetAnalysis" << std::endl;
00086 analysis.push_back(new DiJetAnalysis);
00087 }
00088 if (currentconfig->wplusjet) {
00089 std::cout << "Adding module WplusJetAnalysis" << std::endl;
00090 analysis.push_back(new WplusJetAnalysis);
00091 }
00092 if(currentconfig->z){
00093 std::cout << "Adding module ZAnalysis" << std::endl;
00094 analysis.push_back(new ZAnalysis);
00095 }
00096 if(currentconfig->tau){
00097 std::cout << "Adding module TauAnalysis" << std::endl;
00098 analysis.push_back(new TauAnalysis);
00099 }
00100 if(currentconfig->top){
00101 std::cout << "Adding module TopAnalysis" << std::endl;
00102 analysis.push_back(new TopAnalysis);
00103 }
00104 if(currentconfig->ue){
00105 std::cout << "Adding module UEAnalysis" << std::endl;
00106 analysis.push_back(new UEAnalysis);
00107 }
00108 if(currentconfig->etmiss){
00109 std::cout << "Adding module EtMissAnalysis" << std::endl;
00110 analysis.push_back(new EtMissAnalysis);
00111 }
00112 if(currentconfig->elasScat){
00113 std::cout << "Adding module ElasScatAnalysis" << std::endl;
00114 analysis.push_back(new ElasScatAnalysis);
00115 }
00116 if(currentconfig->user){
00117 std::cout << "Adding module UserAnalysis" << std::endl;
00118 analysis.push_back(new UserAnalysis);
00119 }
00120
00121
00122
00123 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00124 (*i)->Init(currentconfig->max_eta,currentconfig->min_pt);
00125 (*i)->InitJetFinder(currentconfig->coneRadius,currentconfig->overlapThreshold,currentconfig->jet_ptmin,currentconfig->lepton_ptmin,currentconfig->DeltaR_lepton_track);
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135 HepMC::HEPEVT_Wrapper::set_max_number_entries(hwgethepevtsize_());
00136 HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00137
00138
00139 hwevnt.nrn[0]= currentconfig->rseed;
00140
00141
00142 hwproc.maxev = int(currentconfig->nevents);
00143
00144
00145 for ( unsigned int i = 0; i < 8; ++i ) {
00146 hwbmch.part1[i] = (i < 1) ? 'P' : ' ';
00147 hwbmch.part2[i] = (i < 1) ? 'P' : ' ';
00148 }
00149
00150 std::cout << "Configuration Parameter List:" << std::endl;
00151 for (unsigned int files=0; files<(currentconfig->ConfigFileNames).size(); files++)
00152 readConfigFile((currentconfig->ConfigFileNames)[files]);
00153
00154
00155 hwpram.nospac=int(currentconfig->ISR);
00156
00157
00158 hwigin();
00159
00160 hwevnt.maxpr = 1;
00161
00162 hwuinc();
00163
00164 hweini();
00165
00166 jminit();
00167
00168
00169
00170 HepMC::IO_HERWIG hepevtio;
00171
00172
00173 for ( int iEvent = 1; iEvent <= hwproc.maxev; iEvent++ ) {
00174 if ( iEvent%50==1 ) std::cout << "Processing Event Number "
00175 << iEvent << std::endl;
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 hwuine();
00199
00200 hwepro();
00201
00202 hwbgen();
00203
00204 int abort = 0;
00205 if (abort == 0) {
00206 hwmsct(&abort);
00207 hwdhob();
00208 hwcfor();
00209 hwcdec();
00210 hwdhad();
00211 hwdhvy();
00212 hwmevt();
00213 hwufne();
00214 }
00215
00216
00217
00218
00219 HepMC::GenEvent* evt = hepevtio.read_next_event();
00220
00221 evt->set_event_number(iEvent);
00222 evt->set_signal_process_id(20);
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 std::vector<fastjet::PseudoJet> inclusive_jets = FindJet.GetJet(evt);
00236
00237
00238 int ret_all = true;
00239 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00240 (*i)->SetJet(&inclusive_jets);
00241 int ret = (*i)->Process(evt);
00242 if (ret == false) ret_all = false;
00243 }
00244
00245 if (ret_all==false) {
00246 std::cout << "Processing event number " << iEvent << std::endl;
00247 std::cout << "throw FAILURE"<<std::endl;
00248
00249
00250 std::cout<<std::endl;
00251
00252
00253 std::cout<<std::endl;
00254 }
00255
00256
00257 if (iEvent<=hwevnt.maxpr) {
00258 std::cout << "\n\n This is the FIXED version of HEPEVT as "
00259 << "coded in IO_HERWIG " << std::endl;
00260
00261
00262 }
00263
00264
00265 FindJet.ClearEvent(evt);
00266
00267
00268 delete evt;
00269
00270 }
00271
00272 hwefin();
00273
00274
00275 TFile* f = new TFile(currentconfig->OutputFileName.c_str(),"RECREATE");
00276 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00277 (*i)->Finalize(f);
00278 }
00279
00280
00281 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00282 delete (*i);
00283 }
00284 analysis.resize(0);
00285
00286
00287 delete currentconfig;
00288
00289
00290 std::cout<<"Herwig: program ends"<<std::endl;
00291 f->Close();
00292
00293 std::cout<<"Run successfully!"<<std::endl;
00294 return 0;
00295 }
00296
00297
00298 void hwaend_ (void) { return; }