00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <stdlib.h>
00018 #include <time.h>
00019
00020 #include <stdio.h>
00021 #include <iostream>
00022 #include <fstream>
00023 #include <sstream>
00024 #include "HepMC/PythiaWrapper.h"
00025 #include "HepMC/IO_HEPEVT.h"
00026 #include "HepMC/IO_Ascii.h"
00027 #include "HepMC/GenEvent.h"
00028 #include "HepMC/SimpleVector.h"
00029 #include "MyPythia6Wrapper.h"
00030
00031 #include "TH1.h"
00032 #include "TFile.h"
00033 #include "TMath.h"
00034 #include <TCanvas.h>
00035
00036 #include "TF1.h"
00037 #include <TH2.h>
00038 #include <TStyle.h>
00039 #include "TLegend.h"
00040 #include <TTree.h>
00041 #include <TString.h>
00042
00043 using namespace std;
00044
00045
00046 #include "../../include/Configuration.h"
00047 #include "../../include/JetFinder.h"
00048 #include "../../include/TopAnalysis.h"
00049 #include "../../include/TauAnalysis.h"
00050 #include "../../include/DiJetAnalysis.h"
00051 #include "../../include/WplusJetAnalysis.h"
00052 #include "../../include/ZAnalysis.h"
00053 #include "../../include/UEAnalysis.h"
00054 #include "../../include/EtMissAnalysis.h"
00055 #include "../../include/ElasScatAnalysis.h"
00056 #include "../../include/UserAnalysis.h"
00057 #include "readpythiaConfigFile.h"
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 pyjets.n=0;
00133 call_pyhepc(1);
00134
00135 HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);
00136 HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 pydatr.mrpy[1-1] = currentconfig->rseed ;
00148
00149
00150
00151
00152 std::cout << "Configuration Parameter List:" << std::endl;
00153
00154 for (unsigned int files=0; files<(currentconfig->ConfigFileNames).size(); files++)
00155 readConfigFile((currentconfig->ConfigFileNames)[files]);
00156
00157
00158
00159
00160
00161
00162
00163
00164 call_pyinit("CMS", "p", "p", 14000.);
00165
00166
00167
00168
00169 HepMC::IO_HEPEVT hepevtio;
00170
00171
00172
00173
00174
00175
00176
00177 int nShow = 50;
00178 int nShowPace = max(1,int(currentconfig->nevents)/nShow);
00179
00180 for (unsigned int iEvent = 1 ; iEvent <= currentconfig->nevents; iEvent++) {
00181
00182
00183 if (iEvent%nShowPace == 0) cout << "pythia6: Now begin event "
00184 << iEvent << endl;
00185
00186 call_pyevnt();
00187
00188 call_pyhepc(1);
00189 HepMC::GenEvent* evt = hepevtio.read_next_event();
00190
00191 evt->set_event_number(iEvent);
00192 evt->set_signal_process_id(20);
00193
00194
00195
00196
00197 vector<fastjet::PseudoJet> inclusive_jets = FindJet.GetJet(evt);
00198
00199
00200 int ret_all = true;
00201 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00202 (*i)->SetJet(&inclusive_jets);
00203 int ret = (*i)->Process(evt);
00204 if (ret == false) ret_all = false;
00205 }
00206
00207 if (ret_all==false) {
00208 std::cout << "Processing event number " << iEvent << std::endl;
00209 std::cout << "throw FAILURE"<<std::endl;
00210
00211
00212
00213
00214
00215 std::cout<<std::endl;
00216 }
00217
00218
00219 FindJet.ClearEvent(evt);
00220
00221
00222 delete evt;
00223 }
00224
00225
00226
00227 call_pystat(1);
00228
00229 TFile* f = new TFile(currentconfig->OutputFileName.c_str(),"RECREATE");
00230 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00231 (*i)->Finalize(f);
00232 }
00233
00234
00235 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00236 delete (*i);
00237 }
00238 analysis.resize(0);
00239
00240
00241 delete currentconfig;
00242
00243 std::cout<<"pythia6: program ends"<<std::endl;
00244 f->Close();
00245
00246 std::cout<<"Run successfully!"<<std::endl;
00247 return 0;
00248
00249 }
00250