// main91.cc is a part of the PYTHIA event generator. // Copyright (C) 2021 Torbjorn Sjostrand. // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details. // Please respect the MCnet Guidelines, see GUIDELINES for details. // Keywords: analysis; root; // This is a simple test program. // to use ROOT for histogramming. // Header file to access Pythia 8 program elements. #include "Pythia8/Pythia.h" // ROOT, for histogramming. #include "TH1.h" // ROOT, for interactive graphics. #include "TStyle.h" #include "TVirtualPad.h" #include "TApplication.h" #include "TLatex.h" // ROOT, for saving file. #include "TFile.h" using namespace Pythia8; int main(int argc, char* argv[]) { // Create the ROOT application environment. TApplication theApp("hist", &argc, argv); // Create Pythia instance and set it up to generate hard QCD processes // above pTHat = 20 GeV for pp collisions at 14 TeV. Pythia pythia; pythia.readString("Top:gg2ttbar = on"); // Switch on process: ttbar production pythia.readString("Beams:eCM = 13000."); // 13 TeV CM energy. pythia.readString("PartonLevel:all = off"); // swith off showering pythia.readString("HadronLevel:all = off"); // switch off hadronization pythia.readString("Next:numberShowProcess = 5"); // print first five events pythia.init(); // Create file on which histogram(s) can be saved. TFile* outFile = new TFile("hist.root", "RECREATE"); gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetPadBottomMargin(gStyle->GetPadBottomMargin()*1.5); gStyle->SetPadLeftMargin(gStyle->GetPadLeftMargin()*1.5); // Book histogram. TH1F *toppt = new TH1F("toppt","top pt", 20, 0, 1000.); // Begin event loop. Generate event; skip if generation aborted. for (int iEvent = 0; iEvent < 1000; ++iEvent) { if (!pythia.next()) continue; // Loop over particles in event. Find last top copy. Fill its pT. int iTop = -1; for (int i = 0; i < pythia.process.size(); ++i) if (pythia.process[i].id() == 6) iTop = i; if (iTop>-1) toppt->Fill( pythia.process[iTop].pT() ); } // Statistics on event generation. pythia.stat(); // Show histogram. Possibility to close it. toppt->Draw(); // Decorate axes toppt->GetXaxis()->SetTitle("p_{T}^{top} [GeV]"); toppt->GetXaxis()->SetTitleSize(toppt->GetXaxis()->GetTitleSize()*1.8); toppt->GetYaxis()->SetTitle("Entries"); toppt->GetYaxis()->SetTitleSize(toppt->GetYaxis()->GetTitleSize()*1.8); // Add some text TLatex *p = new TLatex(); p->DrawLatex(350,350,"Third HEP Graduate Workshop"); p->SetTextFont(52); p->DrawLatex(790,320,"p p #rightarrow t #bar{t}"); p->SetTextFont(42); p->DrawLatex(740,290,"#sqrt{s} = 13 TeV"); std::cout << "\nDouble click on the histogram window to quit.\n"; gPad->WaitPrimitive(); // Save histogram on file and close file. toppt->Write(); delete outFile; // Done. return 0; }