// main85.cc is a part of the PYTHIA event generator. // Copyright (C) 2011 Torbjorn Sjostrand. // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details. // Please respect the MCnet Guidelines, see GUIDELINES for details. // This program is written by Stefan Prestel. // It illustrates how to do CKKW-L merging, // see the Matrix Element Merging page in the online manual. #include "Pythia.h" #include "HepMCInterface.h" #include "HepMC/GenEvent.h" #include "HepMC/IO_GenEvent.h" // Following line to be used with HepMC 2.04 onwards. #include "HepMC/Units.h" using namespace Pythia8; //========================================================================== // Example main programm to illustrate merging int main( int argc, char* argv[] ){ // Check that correct number of command-line arguments if (argc != 4) { cerr << " Unexpected number of command-line arguments ("< xsecLO; vector nAcceptLO; cout << endl << endl << endl; cout << "Start estimating ckkwl tree level cross section" << endl; while(njetcounterLO >= 0) { // From njet, choose LHE file stringstream in; in << "_" << njetcounterLO << ".lhe"; string LHEfile = iPathTree + in.str(); pythia.settings.mode("Merging:nRequested", njetcounterLO); pythia.readString("Beams:frameType = 4"); pythia.settings.word("Beams:LHEF", LHEfile); pythia.init(); // Start generation loop for( int iEvent=0; iEvent 0 ) njetcounterLO--; else break; } // end loop over different jet multiplicities //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Switch off cross section estimation. pythia.settings.flag("Merging:doXSectionEstimate", false); // Switch showering and multiple interaction back on. pythia.settings.flag("PartonLevel:FSR",fsr); pythia.settings.flag("PartonLevel:ISR",isr); pythia.settings.flag("HadronLevel:all",had); pythia.settings.flag("PartonLevel:MPI",mpi); int sizeLO = int(xsecLO.size()); njetcounterLO = nMaxLO; iPathTree = iPath + "_tree"; // Cross section an error. double sigmaTotal = 0.; double errorTotal = 0.; while(njetcounterLO >= 0){ // From njet, choose LHE file stringstream in; in << "_" << njetcounterLO << ".lhe"; string LHEfile = iPathTree + in.str(); cout << endl << endl << endl << "Start tree level treatment for " << njetcounterLO << " jets" << endl; pythia.settings.mode("Merging:nRequested", njetcounterLO); pythia.readString("Beams:frameType = 4"); pythia.settings.word("Beams:LHEF", LHEfile); pythia.init(); // Remember position in vector of cross section estimates. int iNow = sizeLO-1-njetcounterLO; // Start generation loop for( int iEvent=0; iEventweights().push_back(weight*normhepmc); // Fill HepMC event ToHepMC.fill_next_event( pythia, hepmcevt ); // Add the weight of the current event to the cross section. sigmaTotal += weight*normhepmc; errorTotal += pow2(weight*normhepmc); // Report cross section to hepmc HepMC::GenCrossSection xsec; xsec.set_cross_section( sigmaTotal*1e9, pythia.info.sigmaErr()*1e9 ); hepmcevt->set_cross_section( xsec ); // Write the HepMC event to file. Done with it. ascii_io << hepmcevt; delete hepmcevt; } // end loop over events to generate // print cross section, errors pythia.stat(); // Restart with ME of a reduced the number of jets if( njetcounterLO > 0 ) njetcounterLO--; else break; } cout << endl << endl << endl; cout << "CKKWL merged cross section: " << scientific << setprecision(8) << sigmaTotal << " +- " << sqrt(errorTotal) << " mb " << endl; cout << "LO inclusive cross section: " << scientific << setprecision(8) << xsecLO.back() << " mb " << endl; cout << endl << endl << endl; // Done return 0; }