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