Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

cascade.cc

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/UserAnalysis.h"
00059 #include "readCascadeConfigFile.h"
00060 
00061 extern "C" {
00062   extern struct {
00063     int Nevent;
00064   } steer1_;
00065 }
00066 #define steer1 steer1_
00067 
00068 int main(int argc, const char* argv[]) { 
00069 
00070   if(argc <= 1 ) {
00071     std::cout << "Usage: " << argv[0] << " <Configuration File>" << std::endl;
00072     return 0;
00073   }
00074 
00075 
00076   Configuration* currentconfig = new Configuration();
00077   if(currentconfig->read(argv[1]))
00078     {
00079       std::cout << " ... skip !" << std::endl;
00080       return 0;
00081     }   
00082 
00083   JetFinder FindJet;
00084   FindJet.Init(currentconfig->max_eta,currentconfig->min_pt);
00085   FindJet.InitJetFinder(currentconfig->coneRadius,currentconfig->overlapThreshold,currentconfig->jet_ptmin,currentconfig->lepton_ptmin,currentconfig->DeltaR_lepton_track);
00086 
00087 
00088   std::vector<baseAnalysis*> analysis;
00089 
00090   // create analysis Objects and initialize them                                                                                          
00091   if (currentconfig->dijet) {
00092     std::cout << "Adding module DiJetAnalysis" << std::endl;
00093     analysis.push_back(new DiJetAnalysis);
00094   }
00095   if (currentconfig->wplusjet) {
00096     std::cout << "Adding module WplusJetAnalysis" << std::endl;
00097     analysis.push_back(new WplusJetAnalysis);
00098   }
00099   if(currentconfig->z){
00100     std::cout << "Adding module ZAnalysis" << std::endl;
00101     analysis.push_back(new ZAnalysis);
00102   }
00103   if(currentconfig->tau){
00104     std::cout << "Adding module TauAnalysis" << std::endl;
00105     analysis.push_back(new TauAnalysis);
00106   }
00107   if(currentconfig->top){
00108     std::cout << "Adding module TopAnalysis" << std::endl;
00109     analysis.push_back(new TopAnalysis);
00110   }
00111   if(currentconfig->ue){
00112     std::cout << "Adding module UEAnalysis" << std::endl;
00113     analysis.push_back(new UEAnalysis);
00114   }  
00115   if(currentconfig->etmiss){
00116     std::cout << "Adding module EtMissAnalysis" << std::endl;
00117     analysis.push_back(new EtMissAnalysis);
00118   }
00119   if(currentconfig->user){
00120     std::cout << "Adding module UserAnalysis" << std::endl;
00121     analysis.push_back(new UserAnalysis);
00122   }
00123   
00124 
00125   // init requested analysis modules and jet finder
00126   for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00127     (*i)->Init(currentconfig->max_eta,currentconfig->min_pt);
00128     (*i)->InitJetFinder(currentconfig->coneRadius,currentconfig->overlapThreshold,currentconfig->jet_ptmin,currentconfig->lepton_ptmin,currentconfig->DeltaR_lepton_track);
00129   }
00130 
00131   //
00132   //........................................HEPEVT
00133   // CASCADE (via PYTHIA6) uses HEPEVT with 10000 entries and 
00134   // 8-byte floating point numbers. We need to explicitly pass
00135   // this information to the HEPEVT_Wrapper.
00136   //
00137   //    HepMC::HEPEVT_Wrapper::set_sizeof_int(4);
00138   //    HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00139   //    HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);
00140   //
00141   pyjets.n=0;     // ensure dummyness of the next call
00142   call_pyhepc(1); // mstu(8) is set to NMXHEP in this dummy call (version >=6.404)
00143   //HepMC::HEPEVT_Wrapper::set_max_number_entries(pydat1.mstu[8-1]);
00144   HepMC::HEPEVT_Wrapper::set_max_number_entries(10000);
00145   HepMC::HEPEVT_Wrapper::set_sizeof_real(8);
00146   
00147   //    
00148   //    initPythia();
00149   //........................................CASCADE INITIALIZATIONS
00150   //  call_rluxgo(lux,iseed,k1,k2)
00151   // lux = luxory level
00152   // iseed = seed for random number generator
00153   //    call_rluxgo(4,87777886,0,0);
00154   //--initialise CASCADE parameters
00155 
00156   call_casini();
00157 
00158   //call steering
00159   //call_steer();
00160 
00161   //-- change standard parameters of CASCADE
00162   call_cascha();
00163   
00164   //change cascade parameters
00165   std::vector< std::string > cascade_commands;
00166   // read in commandlines
00167   for (unsigned int files=0; files<(currentconfig->ConfigFileNames).size(); files++)
00168     readConfigFile((currentconfig->ConfigFileNames)[files]);
00169 
00170   //-- change standard parameters of JETSET/PYTHIA
00171   call_pytcha();
00172 
00173   //-- set up for running CASCADE  
00174   call_cascade();
00175 
00176   //-- print result from integration
00177   call_caend(1);   
00178 
00179   //
00180   //........................................HepMC INITIALIZATIONS
00181   //
00182   // Instantiate an IO strategy for reading from HEPEVT.
00183   HepMC::IO_HEPEVT hepevtio;
00184   //
00185   // Instantial an IO strategy to write the data to file - it uses the 
00186   //  same ParticleDataTable
00187   //HepMC::IO_GenEvent ascii_io("example_MyCASCADE.dat",std::ios::out);
00188   //
00189   //........................................EVENT LOOP
00190   //int Nevent = steer1.Nevent;
00191   int Nevent = currentconfig->nevents;
00192 
00193   for ( int iEvent = 1; iEvent <= Nevent; iEvent++ ) {
00194     if ( iEvent==1 || iEvent%100==0 ) std::cout << "Processing Event Number " 
00195                                       << iEvent << std::endl;
00196     call_event();      // generate one event with CASCADE
00197 
00198     // pythia pyhepc routine convert common PYJETS in common HEPEVT
00199     call_pyhepc( 1 );
00200     HepMC::GenEvent* hepmcevt = hepevtio.read_next_event();
00201     //
00202     // add some information to the event
00203     hepmcevt->set_event_number(iEvent);
00204     hepmcevt->set_signal_process_id(11);
00205 
00206     //call the Jetfinder
00207     vector<fastjet::PseudoJet> inclusive_jets = FindJet.GetJet(hepmcevt);
00208 
00209     //call analysis
00210     int ret_all = true;
00211     for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00212       (*i)->SetJet(&inclusive_jets);
00213       int ret = (*i)->Process(hepmcevt);
00214       if (ret == false) ret_all = false;
00215     }
00216     
00217     if (ret_all==false) {
00218       std::cout << "Processing event number " << iEvent << std::endl;    
00219       std::cout << "throw FAILURE"<<std::endl;
00220       //std::cout<<std::endl;
00221       //std::cout<<"HepMC Output"<<std::endl;
00222       //hepmcevt->print();
00223       std::cout<<std::endl;
00224     }
00225     
00226     //// write the event out to the ascii file
00227     //ascii_io << hepmcevt;
00228     
00229     //delete all the jet objects, missingEt etc. to be free for the next event
00230     FindJet.ClearEvent(hepmcevt);
00231 
00232     // we also need to delete the created event from memory
00233     delete hepmcevt;
00234 
00235   }
00236   //........................................TERMINATION
00237   //  Print out of generated event summary
00238   call_caend(2);
00239   // write out some information from Pythia to the screen
00240   //    call_pystat( 1 );    
00241   
00242   TFile* f = new TFile(currentconfig->OutputFileName.c_str(),"RECREATE");
00243   for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00244     (*i)->Finalize(f);
00245   }
00246 
00247   // clean up analysis modules
00248   for (std::vector<baseAnalysis*>::const_iterator i(analysis.begin()); i != analysis.end(); ++i) {
00249     delete (*i);
00250   }
00251   analysis.resize(0);
00252 
00253   // clean up config object
00254   delete currentconfig;
00255 
00256   std::cout<<"cascade: program ends"<<std::endl;
00257   f->Close();
00258 
00259   std::cout<<"Run successfully!"<<std::endl;
00260   return 0;
00261 }

Generated on Thu Jul 23 14:57:35 2009 for HepMCAnalysis by  doxygen 1.3.9.1