00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <iostream>
00012 #include <stdio.h>
00013 #include "HepMC/IO_GenEvent.h"
00014 #include "HepMC/GenEvent.h"
00015 #include "HepMC/IO_AsciiParticles.h"
00016 #include "HepMC/SimpleVector.h"
00017
00018 #include "TH1.h"
00019 #include "TFile.h"
00020 #include "TMath.h"
00021 #include <TCanvas.h>
00022
00023 #include "TF1.h"
00024 #include <TH2.h>
00025 #include <TStyle.h>
00026 #include "TLegend.h"
00027 #include <TTree.h>
00028 #include <TString.h>
00029
00030 using namespace std;
00031
00032 #include "../include/Configuration.h"
00033 #include "../include/JetFinder.h"
00034 #include "../include/ttbarAnalysis.h"
00035 #include "../include/ZtautauAnalysis.h"
00036 #include "../include/WtaunuAnalysis.h"
00037 #include "../include/bbbarAnalysis.h"
00038 #include "../include/JetAnalysis.h"
00039 #include "../include/WplusJetAnalysis.h"
00040 #include "../include/ZAnalysis.h"
00041 #include "../include/UEAnalysis.h"
00042 #include "../include/EtMissAnalysis.h"
00043 #include "../include/ElasScatAnalysis.h"
00044 #include "../include/UserAnalysis.h"
00045
00046
00047
00048 int main(int argc, const char* argv[]) {
00049
00050 if(argc <= 2 ) {
00051 std::cout << "Usage: " << argv[0] << " <Configuration File>" << " <name of file to read from>"<< std::endl;
00052 return 0;
00053 }
00054
00055 Configuration* currentconfig = new Configuration();
00056 if(currentconfig->read(argv[1]))
00057 {
00058 std::cout << " ... skip !" << std::endl;
00059 return 0;
00060 }
00061
00062
00063
00064 JetFinder FindJet;
00065 FindJet.Init(currentconfig->max_eta,currentconfig->min_pt);
00066 FindJet.InitJetFinder( currentconfig->coneRadius, currentconfig->overlapThreshold, currentconfig->jet_ptmin,
00067 currentconfig->lepton_ptmin, currentconfig->DeltaR_lepton_track, currentconfig->jetalgorithm );
00068
00069
00070 std::vector<baseAnalysis*> analysis;
00071
00072
00073 if (currentconfig->jet) {
00074 cout << "Adding module JetAnalysis" << endl;
00075 analysis.push_back(new JetAnalysis);
00076 }
00077 if (currentconfig->wplusjet) {
00078 cout << "Adding module WplusJetAnalysis" << endl;
00079 analysis.push_back(new WplusJetAnalysis);
00080 }
00081 if(currentconfig->z){
00082 cout << "Adding module ZAnalysis" << endl;
00083 analysis.push_back(new ZAnalysis);
00084 }
00085 if(currentconfig->ztautau){
00086 cout << "Adding module ZtautauAnalysis" << endl;
00087 analysis.push_back(new ZtautauAnalysis);
00088 }
00089 if(currentconfig->wtaunu){
00090 cout << "Adding module WtaunuAnalysis" << endl;
00091 analysis.push_back(new WtaunuAnalysis);
00092 }
00093 if(currentconfig->bbbar){
00094 cout << "Adding module bbbarAnalysis" << endl;
00095 analysis.push_back(new bbbarAnalysis);
00096 }
00097 if(currentconfig->ttbar){
00098 cout << "Adding module ttbarAnalysis" << endl;
00099 analysis.push_back(new ttbarAnalysis);
00100 }
00101 if(currentconfig->ue){
00102 cout << "Adding module UEAnalysis" << endl;
00103 analysis.push_back(new UEAnalysis);
00104 }
00105 if(currentconfig->etmiss){
00106 cout << "Adding module EtMissAnalysis" << endl;
00107 analysis.push_back(new EtMissAnalysis);
00108 }
00109 if(currentconfig->elasScat){
00110 cout << "Adding module ElasScatAnalysis" << endl;
00111 analysis.push_back(new ElasScatAnalysis);
00112 }
00113 if(currentconfig->user){
00114 cout << "Adding module UserAnalysis" << endl;
00115 analysis.push_back(new UserAnalysis);
00116 }
00117
00118
00119
00120 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00121 (*i)->Init(currentconfig->max_eta,currentconfig->min_pt);
00122 (*i)->InitJetFinder( currentconfig->coneRadius, currentconfig->overlapThreshold, currentconfig->jet_ptmin,
00123 currentconfig->lepton_ptmin, currentconfig->DeltaR_lepton_track, currentconfig->jetalgorithm );
00124 }
00125
00126
00127
00128
00129 int iEvent =0;
00130
00131
00132
00133
00134 HepMC::IO_GenEvent ascii_in(argv[2],std::ios::in);
00135 HepMC::GenEvent* hepmcevt = ascii_in.read_next_event();
00136 while ( hepmcevt) {
00137
00138
00139 vector<fastjet::PseudoJet> inclusive_jets = FindJet.GetJet(hepmcevt);
00140
00141
00142 int ret_all = true;
00143 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00144 (*i)->SetJet(&inclusive_jets);
00145 int ret = (*i)->Process(hepmcevt);
00146 if (ret == false) ret_all = false;
00147 }
00148 iEvent++;
00149 if (ret_all==false) {
00150 std::cout << "Processing event number " << iEvent << std::endl;
00151 std::cout << "throw FAILURE"<<std::endl;
00152 std::cout<<std::endl;
00153 std::cout<<"HepMC Output"<<std::endl;
00154
00155 std::cout<<std::endl;
00156 }
00157
00158
00159 FindJet.ClearEvent(hepmcevt);
00160
00161
00162 delete hepmcevt;
00163
00164 ascii_in >> hepmcevt;
00165 }
00166
00167 TFile* f = new TFile(currentconfig->OutputFileName.c_str(),"RECREATE");
00168 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00169 (*i)->Finalize(f);
00170 }
00171
00172
00173 for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00174 delete (*i);
00175 }
00176 analysis.resize(0);
00177
00178
00179 delete currentconfig;
00180
00181
00182 std::cout<<" program ends"<<std::endl;
00183 f->Close();
00184
00185 std::cout<<"Run successfully!"<<std::endl;
00186 return 0;
00187 }
00188