00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <stdlib.h>
00016 #include <time.h>
00017 #include <stdio.h>
00018
00019 #include <iostream>
00020 #include <vector>
00021 #include <fstream>
00022 #include <sstream>
00023
00024 #include "HepMC/PythiaWrapper.h"
00025 #include "HepMC/IO_HEPEVT.h"
00026
00027 #include "HepMC/IO_BaseClass.h"
00028 #include "HepMC/GenEvent.h"
00029 #include "HepMC/SimpleVector.h"
00030 #include "MyPythia6Wrapper.h"
00031
00032 #include "TH1.h"
00033 #include "TFile.h"
00034 #include "TMath.h"
00035 #include <TCanvas.h>
00036
00037 #include "TF1.h"
00038 #include <TH2.h>
00039 #include <TStyle.h>
00040 #include "TLegend.h"
00041 #include <TTree.h>
00042 #include <TString.h>
00043
00044
00045 #include "../../include/Configuration.h"
00046 #include "../../include/JetFinder.h"
00047 #include "../../include/ttbarAnalysis.h"
00048 #include "../../include/ZtautauAnalysis.h"
00049 #include "../../include/WtaunuAnalysis.h"
00050 #include "../../include/bbbarAnalysis.h"
00051 #include "../../include/JetAnalysis.h"
00052 #include "../../include/WplusJetAnalysis.h"
00053 #include "../../include/ZAnalysis.h"
00054 #include "../../include/UEAnalysis.h"
00055 #include "../../include/EtMissAnalysis.h"
00056 #include "../../include/ElasScatAnalysis.h"
00057 #include "../../include/UserAnalysis.h"
00058
00059 #include "readpythiaConfigFile.h"
00060 #include "alpgen_spec.h"
00061 #include "test_hepmc.h"
00062
00063 using namespace std;
00064
00065 extern "C" {
00066
00067 void pyupev_();
00068 };
00069
00070
00071 int main( int argc, const char *argv[] )
00072 {
00073 if ( argc <= 1 ) {
00074 cout << "Usage: " << argv[ 0 ] << " <Configuration File>" << endl;
00075 return 0;
00076 }
00077
00078
00079 Configuration *currentconfig = new Configuration;
00080 if ( currentconfig->read( argv[ 1 ] ) ) {
00081 cout << " ... skip !" << endl;
00082 return 0;
00083 }
00084
00085
00086 JetFinder FindJet;
00087 FindJet.Init( currentconfig->max_eta, currentconfig->min_pt );
00088 FindJet.InitJetFinder( currentconfig->coneRadius, currentconfig->overlapThreshold,
00089 currentconfig->jet_ptmin, currentconfig->lepton_ptmin, currentconfig->DeltaR_lepton_track, currentconfig->jetalgorithm );
00090
00091
00092 vector< baseAnalysis* > analysis;
00093
00094 if ( currentconfig->jet ) {
00095 cout << "Adding module JetAnalysis" << endl;
00096 analysis.push_back( new JetAnalysis );
00097 }
00098 if ( currentconfig->wplusjet ) {
00099 cout << "Adding module WplusJetAnalysis" << endl;
00100 analysis.push_back( new WplusJetAnalysis );
00101 }
00102 if ( currentconfig->z ) {
00103 cout << "Adding module ZAnalysis" << endl;
00104 analysis.push_back( new ZAnalysis );
00105 }
00106 if ( currentconfig->ztautau ) {
00107 cout << "Adding module ZtautauAnalysis" << endl;
00108 analysis.push_back( new ZtautauAnalysis );
00109 }
00110 if ( currentconfig->wtaunu ) {
00111 cout << "Adding module WtaunuAnalysis" << endl;
00112 analysis.push_back( new WtaunuAnalysis );
00113 }
00114 if ( currentconfig->bbbar ) {
00115 cout << "Adding module bbbarAnalysis" << endl;
00116 analysis.push_back( new bbbarAnalysis );
00117 }
00118 if ( currentconfig->ttbar ) {
00119 cout << "Adding module ttbarAnalysis" << endl;
00120 analysis.push_back( new ttbarAnalysis );
00121 }
00122 if ( currentconfig->ue ) {
00123 cout << "Adding module UEAnalysis" << endl;
00124 analysis.push_back( new UEAnalysis );
00125 }
00126 if( currentconfig->etmiss ) {
00127 cout << "Adding module EtMissAnalysis" << endl;
00128 analysis.push_back( new EtMissAnalysis );
00129 }
00130 if ( currentconfig->elasScat ) {
00131 cout << "Adding module ElasScatAnalysis" << endl;
00132 analysis.push_back( new ElasScatAnalysis );
00133 }
00134 if ( currentconfig->user ) {
00135 cout << "Adding module UserAnalysis" << endl;
00136 analysis.push_back( new UserAnalysis );
00137 }
00138
00139
00140 for ( vector< baseAnalysis* >::const_iterator i( analysis.begin() ); i != analysis.end(); ++i ) {
00141 (*i)->Init( currentconfig->max_eta, currentconfig->min_pt );
00142 (*i)->InitJetFinder( currentconfig->coneRadius, currentconfig->overlapThreshold, currentconfig->jet_ptmin,
00143 currentconfig->lepton_ptmin, currentconfig->DeltaR_lepton_track, currentconfig->jetalgorithm );
00144 }
00145
00146
00147
00148
00149
00150 pyjets.n = 0;
00151 call_pyhepc( 1 );
00152
00153
00154 HepMC::HEPEVT_Wrapper::set_max_number_entries( 10000 );
00155 HepMC::HEPEVT_Wrapper::set_sizeof_real( 8 );
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 pydatr.mrpy[ 1 - 1 ] = currentconfig->rseed;
00166
00167
00168
00169
00170 cout << "Configuration Parameter List:" << endl;
00171
00172 for ( size_t iFile = 0; iFile < currentconfig->ConfigFileNames.size(); ++iFile ) {
00173 readConfigFile( currentconfig->ConfigFileNames.at( iFile ) );
00174 }
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 call_pyinit( "USER", "", "", 0. );
00185
00186
00187 evstat_.nvpass = 0;
00188 evstat_.nvcall = 0;
00189 evstat_.nvfail = 0;
00190
00191
00192
00193
00194 HepMC::IO_HEPEVT hepevtio;
00195 HepMC::GenEvent *evt = 0;
00196
00197
00198
00199
00200
00201
00202
00203
00204 int pylistMode = 1;
00205 int pystatMode = 1;
00206
00207 bool doFillEvWeight = true;
00208 bool doFillEvXsec = true;
00209
00210
00211 pyupev_();
00212
00213
00214 int nShow = 50;
00215 int nShowPace = max( 1, static_cast< int >( currentconfig->nevents ) / nShow );
00216
00217 HepMC::IO_GenEvent ascii_io( "myexample_alpgen.dat", std::ios::out );
00218
00219 for ( size_t iEvent = 1; iEvent <= currentconfig->nevents; ++iEvent ) {
00220 if ( iEvent % nShowPace == 0) {
00221 cout << "pythia6: Now begin event " << iEvent << endl;
00222 }
00223
00224
00225 call_pyevnt();
00226
00227 call_pylist( pylistMode );
00228
00229
00230
00231 call_pyhepc( 1 );
00232 hepevtio.print();
00233
00234
00235 if ( hepeup_.NUP == 0 ) {
00236 cout << "end of ER after " << iEvent - 1 << " events." << endl;
00237 break;
00238 }
00239
00240
00241 evt = hepevtio.read_next_event();
00242 evt->print();
00243
00244 if ( !( evt->is_valid() ) ) {
00245 cerr << "got invalid HepMC event after " << iEvent << " events." << endl;
00246 cerr << "exit the generation loop now. " << endl;
00247 break;
00248 }
00249
00250 if ( !testHepMC( evt ) ) {
00251 cerr << "ERROR: Invalid HepMC event! Event #: " << iEvent << endl;
00252 cerr << ">> Exit the generation loop now." << endl;
00253
00254 }
00255
00256
00257
00258
00259
00260 evt->set_event_number( iEvent );
00261 evt->set_signal_process_id( 20 );
00262
00263 ascii_io << evt;
00264
00265
00266 if ( doFillEvWeight ) {
00267 fill_eweight( evt );
00268 }
00269
00270
00271 if ( doFillEvXsec ) {
00272 fill_exsec( evt );
00273 }
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 vector< fastjet::PseudoJet > inclusiveJets = FindJet.GetJet( evt );
00293
00294
00295 int retAll = true;
00296 for ( vector< baseAnalysis* >::const_iterator i( analysis.begin() ); i != analysis.end(); ++i ) {
00297 (*i)->SetJet( &inclusiveJets );
00298 if ( !( (*i)->Process( evt ) ) ) {
00299 retAll = false;
00300 }
00301 }
00302
00303 if ( !retAll ) {
00304 cerr << "Processing event number " << iEvent << endl;
00305 cerr << "throw FAILURE" << endl;
00306 cout << ">>> pylist output: " << endl;
00307 call_pylist( 2 );
00308
00309
00310 cerr << endl;
00311 }
00312
00313
00314 FindJet.ClearEvent( evt );
00315
00316
00317
00318 delete evt;
00319 evt = 0;
00320 }
00321
00322
00323 call_pystat( pystatMode );
00324
00325 TFile *f = new TFile( currentconfig->OutputFileName.c_str(), "RECREATE" );
00326 for ( vector< baseAnalysis* >::const_iterator i( analysis.begin() ); i != analysis.end(); ++i ) {
00327 (*i)->Finalize( f );
00328 }
00329
00330
00331 for ( vector< baseAnalysis* >::iterator i( analysis.begin() ); i != analysis.end(); ++i ) {
00332 if ( *i ) {
00333 delete *i;
00334 *i = 0;
00335 }
00336 }
00337 analysis.clear();
00338
00339
00340 delete currentconfig;
00341 currentconfig = 0;
00342
00343 cout << "alpgen_pythia6: program ends" << endl;
00344 f->Close();
00345
00346 cout << "Successfull run!" << endl;
00347 return 0;
00348 }
00349