cascade.cc.svn-base

Go to the documentation of this file.
00001 /***********************************************************************
00002 *                                                                      *
00003 * File: cascade.cc                                                     *
00004 * This is a simple test program.                                       *
00005 * based on the example cascade program                                 *
00006 * from the MC School at DESY in April 2008                             *
00007 *                                                                      *
00008 * Modified by sj                                                       *
00009 *                                                                      *
00010 ***********************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 // Events are read into the HepMC event record from the FORTRAN HEPEVT 
00014 // common block using the IO_HEPEVT strategy -- nothing is done with them.
00015 // This program is just used to find the total time required to transfer
00016 // from HEPEVT into the HepMC event record.
00017 //////////////////////////////////////////////////////////////////////////
00018 
00019 
00020 #include <iostream>
00021 #include "HepMC/PythiaWrapper.h"
00022 #include "CascadeWrapper.h"
00023 #include "MyCascadeWrapper.h"
00024 #include "HepMC/IO_HEPEVT.h"
00025 #include "HepMC/IO_Ascii.h"
00026 #include "HepMC/IO_GenEvent.h"
00027 #include "HepMC/GenEvent.h"
00028 #include "PythiaHelper.h"
00029 
00030 #include <stdio.h>
00031 #include "HepMC/IO_AsciiParticles.h"
00032 #include "HepMC/SimpleVector.h"
00033 
00034 #include "TH1.h"
00035 #include "TFile.h"
00036 #include "TMath.h"
00037 #include <TCanvas.h>
00038 
00039 #include "TF1.h"
00040 #include <TH2.h>
00041 #include <TStyle.h>
00042 #include "TLegend.h"
00043 #include <TTree.h>
00044 #include <TString.h>
00045 
00046 using namespace std;
00047 
00048 // include our own classes
00049 #include "../../include/Configuration.h"
00050 #include "../../include/JetFinder.h"
00051 #include "../../include/TopAnalysis.h"
00052 #include "../../include/TauAnalysis.h"
00053 #include "../../include/DiJetAnalysis.h"
00054 #include "../../include/WplusJetAnalysis.h"
00055 #include "../../include/ZAnalysis.h"
00056 #include "../../include/UEAnalysis.h"
00057 #include "../../include/EtMissAnalysis.h"
00058 #include "../../include/ElasScatAnalysis.h"
00059 #include "../../include/UserAnalysis.h"
00060 #include "readCascadeConfigFile.h"
00061 
00062 extern "C" {
00063   extern struct {
00064     int Nevent;
00065   } steer1_;
00066 }
00067 #define steer1 steer1_
00068 
00069 int main(int argc, const char* argv[]) { 
00070 
00071   if(argc <= 1 ) {
00072     std::cout << "Usage: " << argv[0] << " <Configuration File>" << std::endl;
00073     return 0;
00074   }
00075 
00076 
00077   Configuration* currentconfig = new Configuration();
00078   if(currentconfig->read(argv[1]))
00079     {
00080       std::cout << " ... skip !" << std::endl;
00081       return 0;
00082     }   
00083 
00084   JetFinder FindJet;
00085   FindJet.Init(currentconfig->max_eta,currentconfig->min_pt);
00086   FindJet.InitJetFinder(currentconfig->coneRadius,currentconfig->overlapThreshold,currentconfig->jet_ptmin,currentconfig->lepton_ptmin,currentconfig->DeltaR_lepton_track);
00087 
00088 
00089   std::vector<baseAnalysis*> analysis;
00090 
00091   // create analysis Objects and initialize them                                                                                          
00092   if (currentconfig->dijet) {
00093     std::cout << "Adding module DiJetAnalysis" << std::endl;
00094     analysis.push_back(new DiJetAnalysis);
00095   }
00096   if (currentconfig->wplusjet) {
00097     std::cout << "Adding module WplusJetAnalysis" << std::endl;
00098     analysis.push_back(new WplusJetAnalysis);
00099   }
00100   if(currentconfig->z){
00101     std::cout << "Adding module ZAnalysis" << std::endl;
00102     analysis.push_back(new ZAnalysis);
00103   }
00104   if(currentconfig->tau){
00105     std::cout << "Adding module TauAnalysis" << std::endl;
00106     analysis.push_back(new TauAnalysis);
00107   }
00108   if(currentconfig->top){
00109     std::cout << "Adding module TopAnalysis" << std::endl;
00110     analysis.push_back(new TopAnalysis);
00111   }
00112   if(currentconfig->ue){
00113     std::cout << "Adding module UEAnalysis" << std::endl;
00114     analysis.push_back(new UEAnalysis);
00115   }  
00116   if(currentconfig->etmiss){
00117     std::cout << "Adding module EtMissAnalysis" << std::endl;
00118     analysis.push_back(new EtMissAnalysis);
00119   }
00120   if(currentconfig->elasScat){
00121     std::cout << "Adding module ElasScatAnalysis" << std::endl;
00122     analysis.push_back(new ElasScatAnalysis);
00123   }
00124   if(currentconfig->user){
00125     std::cout << "Adding module UserAnalysis" << std::endl;
00126     analysis.push_back(new UserAnalysis);
00127   }
00128   
00129 
00130   // init requested analysis modules and jet finder
00131   for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00132     (*i)->Init(currentconfig->max_eta,currentconfig->min_pt);
00133     (*i)->InitJetFinder(currentconfig->coneRadius,currentconfig->overlapThreshold,currentconfig->jet_ptmin,currentconfig->lepton_ptmin,currentconfig->DeltaR_lepton_track);
00134   }
00135 
00136   //
00137   //........................................HEPEVT
00138   // CASCADE (via PYTHIA6) uses HEPEVT with 10000 entries and 
00139   // 8-byte floating point numbers. We need to explicitly pass
00140   // this information to the HEPEVT_Wrapper.
00141   //
00142   //    HepMC::HEPEVT_Wrapper::set_sizeof_int(4);
00143   //    HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00144   //    HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);
00145   //
00146   pyjets.n=0;     // ensure dummyness of the next call
00147   call_pyhepc(1); // mstu(8) is set to NMXHEP in this dummy call (version >=6.404)
00148   //HepMC::HEPEVT_Wrapper::set_max_number_entries(pydat1.mstu[8-1]);
00149   HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);
00150   HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00151   
00152   //    
00153   //    initPythia();
00154   //........................................CASCADE INITIALIZATIONS
00155   //  call_rluxgo(lux,iseed,k1,k2)
00156   // lux = luxory level
00157   // iseed = seed for random number generator
00158   //    call_rluxgo(4,87777886,0,0);
00159   //--initialise CASCADE parameters
00160 
00161   call_casini();
00162 
00163   //call steering
00164   //call_steer();
00165 
00166   //-- change standard parameters of CASCADE
00167   call_cascha();
00168   
00169   //change cascade parameters
00170   std::vector< std::string > cascade_commands;
00171   // read in commandlines
00172   for (unsigned int files=0; files<(currentconfig->ConfigFileNames).size(); files++)
00173     readConfigFile((currentconfig->ConfigFileNames)[files]);
00174 
00175   //-- change standard parameters of JETSET/PYTHIA
00176   call_pytcha();
00177 
00178   //-- set up for running CASCADE  
00179   call_cascade();
00180 
00181   //-- print result from integration
00182   call_caend(1);   
00183 
00184   //
00185   //........................................HepMC INITIALIZATIONS
00186   //
00187   // Instantiate an IO strategy for reading from HEPEVT.
00188   HepMC::IO_HEPEVT hepevtio;
00189   //
00190   // Instantial an IO strategy to write the data to file - it uses the 
00191   //  same ParticleDataTable
00192   //HepMC::IO_GenEvent ascii_io("example_MyCASCADE.dat",std::ios::out);
00193   //
00194   //........................................EVENT LOOP
00195   //int Nevent = steer1.Nevent;
00196   int Nevent = currentconfig->nevents;
00197 
00198   for ( int iEvent = 1; iEvent <= Nevent; iEvent++ ) {
00199     if ( iEvent==1 || iEvent%100==0 ) std::cout << "Processing Event Number " 
00200                                       << iEvent << std::endl;
00201     call_event();      // generate one event with CASCADE
00202 
00203     // pythia pyhepc routine convert common PYJETS in common HEPEVT
00204     call_pyhepc( 1 );
00205     HepMC::GenEvent* hepmcevt = hepevtio.read_next_event();
00206     //
00207     // add some information to the event
00208     hepmcevt->set_event_number(iEvent);
00209     hepmcevt->set_signal_process_id(11);
00210 
00211     //call the Jetfinder
00212     vector<fastjet::PseudoJet> inclusive_jets = FindJet.GetJet(hepmcevt);
00213 
00214     //call analysis
00215     int ret_all = true;
00216     for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00217       (*i)->SetJet(&inclusive_jets);
00218       int ret = (*i)->Process(hepmcevt);
00219       if (ret == false) ret_all = false;
00220     }
00221     
00222     if (ret_all==false) {
00223       std::cout << "Processing event number " << iEvent << std::endl;    
00224       std::cout << "throw FAILURE"<<std::endl;
00225       //std::cout<<std::endl;
00226       //std::cout<<"HepMC Output"<<std::endl;
00227       //hepmcevt->print();
00228       std::cout<<std::endl;
00229     }
00230     
00231     //// write the event out to the ascii file
00232     //ascii_io << hepmcevt;
00233     
00234     //delete all the jet objects, missingEt etc. to be free for the next event
00235     FindJet.ClearEvent(hepmcevt);
00236     
00237     // we also need to delete the created event from memory
00238     delete hepmcevt;
00239 
00240   }
00241   //........................................TERMINATION
00242   //  Print out of generated event summary
00243   call_caend(2);
00244   // write out some information from Pythia to the screen
00245   //    call_pystat( 1 );    
00246   
00247   TFile* f = new TFile(currentconfig->OutputFileName.c_str(),"RECREATE");
00248   for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00249     (*i)->Finalize(f);
00250   }
00251 
00252   // clean up analysis modules
00253   for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00254     delete (*i);
00255   }
00256   analysis.resize(0);
00257 
00258   // clean up config object
00259   delete currentconfig;
00260 
00261   std::cout<<"cascade: program ends"<<std::endl;
00262   f->Close();
00263 
00264   std::cout<<"Run successfully!"<<std::endl;
00265   return 0;
00266 }

Generated on Mon Jan 4 15:22:33 2010 for HepMCAnalysis by  doxygen 1.4.7