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