00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "Pythia.h"
00011
00012 #include "LHAFortran.h"
00013
00014 #include "HepMCInterface.h"
00015
00016 #include "HepMC/GenEvent.h"
00017
00018
00019 #include <stdlib.h>
00020 #include <time.h>
00021
00022 #include <iostream>
00023 #include <stdio.h>
00024 #include "HepMC/IO_GenEvent.h"
00025 #include "HepMC/GenEvent.h"
00026 #include "HepMC/IO_AsciiParticles.h"
00027 #include "HepMC/SimpleVector.h"
00028
00029 #include "TH1.h"
00030 #include "TFile.h"
00031 #include "TMath.h"
00032 #include <TCanvas.h>
00033
00034 #include "TF1.h"
00035 #include <TH2.h>
00036 #include <TStyle.h>
00037 #include "TLegend.h"
00038 #include <TTree.h>
00039 #include <TString.h>
00040
00041 using namespace Pythia8;
00042 using namespace std;
00043
00044 #include "../../include/Configuration.h"
00045 #include "../../include/JetFinder.h"
00046 #include "../../include/DiJetAnalysis.h"
00047 #include "../../include/WplusJetAnalysis.h"
00048 #include "../../include/ZAnalysis.h"
00049 #include "../../include/TauAnalysis.h"
00050 #include "../../include/TopAnalysis.h"
00051 #include "../../include/UEAnalysis.h"
00052 #include "../../include/EtMissAnalysis.h"
00053 #include "../../include/UserAnalysis.h"
00054
00055
00056
00057 int main(int argc, const char* argv[]) {
00058
00059 if(argc <= 1 ) {
00060 std::cout << "Usage: " << argv[0] << " <Configuration File>" << std::endl;
00061 return 0;
00062 }
00063
00064
00065 Configuration* currentconfig = new Configuration();
00066 if(currentconfig->read(argv[1]))
00067 {
00068 std::cout << " ... skip !" << std::endl;
00069 return 0;
00070 }
00071
00072
00073
00074 JetFinder FindJet;
00075 FindJet.Init(currentconfig->max_eta,currentconfig->min_pt);
00076 FindJet.InitJetFinder(currentconfig->coneRadius,currentconfig->overlapThreshold,currentconfig->jet_ptmin,currentconfig->lepton_ptmin,currentconfig->DeltaR_lepton_track);
00077
00078 std::vector<baseAnalysis*> analysis;
00079
00080
00081 if (currentconfig->dijet) {
00082 std::cout << "Adding module DiJetAnalysis" << std::endl;
00083 analysis.push_back(new DiJetAnalysis);
00084 }
00085 if (currentconfig->wplusjet) {
00086 std::cout << "Adding module WplusJetAnalysis" << std::endl;
00087 analysis.push_back(new WplusJetAnalysis);
00088 }
00089 if(currentconfig->z){
00090 std::cout << "Adding module ZAnalysis" << std::endl;
00091 analysis.push_back(new ZAnalysis);
00092 }
00093 if(currentconfig->tau){
00094 std::cout << "Adding module TauAnalysis" << std::endl;
00095 analysis.push_back(new TauAnalysis);
00096 }
00097 if(currentconfig->top){
00098 std::cout << "Adding module TopAnalysis" << std::endl;
00099 analysis.push_back(new TopAnalysis);
00100 }
00101 if(currentconfig->ue){
00102 std::cout << "Adding module UEAnalysis" << std::endl;
00103 analysis.push_back(new UEAnalysis);
00104 }
00105 if(currentconfig->etmiss){
00106 std::cout << "Adding module EtMissAnalysis" << std::endl;
00107 analysis.push_back(new EtMissAnalysis);
00108 }
00109 if(currentconfig->user){
00110 std::cout << "Adding module UserAnalysis" << std::endl;
00111 analysis.push_back(new UserAnalysis);
00112 }
00113
00114
00115 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00116 (*i)->Init(currentconfig->max_eta,currentconfig->min_pt);
00117 (*i)->InitJetFinder(currentconfig->coneRadius,currentconfig->overlapThreshold,currentconfig->jet_ptmin,currentconfig->lepton_ptmin,currentconfig->DeltaR_lepton_track);
00118 }
00119
00120
00121 HepMC::I_Pythia8 ToHepMC;
00122
00123
00124
00125 Pythia pythia(std::getenv("Pythia8DATA"));
00126
00127 char processline[64];
00128
00129 for (unsigned int files=0; files<currentconfig->ConfigFileNames.size(); files++)
00130 {
00131 std::cout << "pythia8: Will use settings from file " << currentconfig->ConfigFileNames[files].c_str() << std::endl;
00132 pythia.readFile(currentconfig->ConfigFileNames[files].c_str());
00133 }
00134
00135
00136 pythia.readString("Random:setSeed = on");
00137 sprintf(processline,"Random:seed = %ld",currentconfig->rseed);
00138 pythia.readString(processline);
00139
00140
00141 sprintf(processline,"PartonLevel:FSR = %d",int(currentconfig->FSR));
00142 pythia.readString(processline);
00143
00144 sprintf(processline,"PartonLevel:ISR = %d",int(currentconfig->ISR));
00145 pythia.readString(processline);
00146
00147 sprintf(processline,"PartonLevel:MI = %d",int(currentconfig->MI));
00148 pythia.readString(processline);
00149
00150
00151
00152
00153 pythia.init( 2212, 2212, 14000.);
00154
00155
00156 Event& event = pythia.event;
00157 Settings& settings = pythia.settings;
00158
00159
00160 int nEvent = currentconfig->nevents;
00161
00162 int nList = settings.mode("Main:numberToList");
00163 int nShow = settings.mode("Main:timesToShow");
00164 int nAbort = settings.mode("Main:timesAllowErrors");
00165 bool showChangedSettings = settings.flag("Main:showChangedSettings");
00166 bool showAllSettings = settings.flag("Main:showAllSettings");
00167 bool showAllParticleData = settings.flag("Main:showAllParticleData");
00168
00169
00170 if (showChangedSettings) settings.listChanged();
00171 if (showAllSettings) settings.listAll();
00172
00173
00174 if (showAllParticleData) ParticleDataTable::listAll();
00175
00176
00177 int nShowPace = max(1,nEvent/nShow);
00178 int iAbort = 0;
00179 for (int iEvent = 0; iEvent < nEvent; ++iEvent) {
00180
00181 if (iEvent%nShowPace == 0)
00182 cout << "pythia8: Now begin event " << iEvent << endl;
00183
00184
00185 if (!pythia.next()) {
00186 if (++iAbort < nAbort) continue;
00187 cout << "pythia8: Event generation aborted prematurely, owing to error!\n";
00188 break;
00189 }
00190
00191
00192
00193
00194
00195
00196
00197
00198 HepMC::GenEvent* hepmcevt = new HepMC::GenEvent();
00199 ToHepMC.fill_next_event( event, hepmcevt );
00200
00201
00202
00203
00204 vector<fastjet::PseudoJet> inclusive_jets = FindJet.GetJet(hepmcevt);
00205
00206
00207 int ret_all = true;
00208 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00209 (*i)->SetJet(&inclusive_jets);
00210 int ret = (*i)->Process(hepmcevt);
00211 if (ret == false) ret_all = false;
00212 }
00213
00214 if (ret_all==false) {
00215 std::cout << "Processing event number " << iEvent << std::endl;
00216 std::cout << "throw FAILURE"<<std::endl;
00217
00218
00219
00220 std::cout<<std::endl;
00221 }
00222
00223
00224 FindJet.ClearEvent(hepmcevt);
00225
00226
00227 delete hepmcevt;
00228
00229
00230 }
00231
00232
00233 pythia.statistics();
00234
00235 pythia.settings.writeFile("allSettings.cmnd",true);
00236
00237 TFile* f = new TFile(currentconfig->OutputFileName.c_str(),"RECREATE");
00238 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00239 (*i)->Finalize(f);
00240 }
00241
00242
00243 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00244 delete (*i);
00245 }
00246 analysis.resize(0);
00247
00248
00249 delete currentconfig;
00250
00251
00252 std::cout<<"pythia8: program ends"<<std::endl;
00253 f->Close();
00254
00255 std::cout<<"Run successfully!"<<std::endl;
00256 return 0;
00257 }
00258