// main89.cc is a part of the PYTHIA event generator. // Copyright (C) 2017 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 run PYTHIA with LHEF input, allowing a // sample-by-sample generation of // a) Non-matched/non-merged events // b) MLM jet-matched events (kT-MLM, shower-kT, FxFx) // c) CKKW-L and UMEPS-merged events // d) UNLOPS NLO merged events // see the respective sections in the online manual for details. #include "Pythia8/Pythia.h" #include "Pythia8Plugins/HepMC2.h" #include // Include UserHooks for Jet Matching. #include "Pythia8Plugins/CombineMatchingInput.h" // Include UserHooks for randomly choosing between integrated and // non-integrated treatment for unitarised merging. #include "Pythia8Plugins/aMCatNLOHooks.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 != 3) { cerr << " Unexpected number of command-line arguments ("< nAbort) {doAbort = true; break;} else continue; } // Get event weight(s). double evtweight = pythia.info.weight(); // Additional PDF/alphaS weight for internal merging. if (doMerge) evtweight *= pythia.info.mergingWeightNLO() // Additional weight due to random choice of reclustered/non-reclustered // treatment. Also contains additional sign for subtractive samples. *setting->getNormFactor(); // Do not print zero-weight events. if ( evtweight == 0. ) continue; // Construct new empty HepMC event. HepMC::GenEvent* hepmcevt = new HepMC::GenEvent(); // Work with weighted (LHA strategy=-4) events. double normhepmc = 1.; if (abs(pythia.info.lhaStrategy()) == 4) normhepmc = 1. / double(1e9*nEvent); // Work with unweighted events. else normhepmc = xs / double(1e9*nEvent); // Set event weight hepmcevt->weights().push_back(evtweight*normhepmc); // Fill HepMC event ToHepMC.fill_next_event( pythia, hepmcevt ); // Add the weight of the current event to the cross section. sigmaTotal += evtweight*normhepmc; sigmaSample += evtweight*normhepmc; errorTotal += pow2(evtweight*normhepmc); errorSample += pow2(evtweight*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. if (doAbort) break; // print cross section, errors pythia.stat(); cout << endl << " Contribution of sample " << iMerge << " to the inclusive cross section : " << scientific << setprecision(8) << sigmaSample << " +- " << sqrt(errorSample) << endl; } cout << endl << endl << endl; if (doAbort) cout << " Run was not completed owing to too many aborted events" << endl; else cout << "Inclusive cross section: " << scientific << setprecision(8) << sigmaTotal << " +- " << sqrt(errorTotal) << " mb " << endl; cout << endl << endl << endl; // Clean-up if ( doMerge ) delete setting; if ( doMatch ) delete matching; // Done return 0; }