ROOT
Version v6.32
master
v6.34
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
▼
ROOT
ROOT Reference Documentation
Tutorials
▼
Functional Parts
►
Core ROOT classes
►
std Extension classes
►
Parallelized classes
►
The Geometry Package
►
Graphics
►
Event display with ROOT7
►
GUI
►
Web Widgets
►
Web Display
►
Histogram Library
►
Input/Output Library
►
Math
►
N-D parametric functions
►
VecOps
►
Monte Carlo
►
HTTP server
►
PROOF
►
TMVA
►
RooFit
►
Dataframe
►
ROOT7 classes
►
NTuple-related classes
►
Tree Library
►
TreePlayer Library
▼
Tutorials
►
Histograms tutorials
►
Tree tutorials
►
Dataframe tutorials
►
ROOT 7 tutorials
►
FOAM tutorials
►
Containers tutorials
►
Event display tutorials
►
Event display ROOT7 tutorials
►
Geometry tutorials
►
Fast Fourier Transforms tutorials
►
Fit Tutorials
►
RooFit Tutorials
►
Graphs tutorials
►
Graphics tutorials
►
OpenGL tutorials
►
Tutorials specific to Mac/Cocoa
►
GUI tutorials
►
HistFactory Tutorials
►
HTTP tutorials
►
Image tutorials
►
IO tutorials
►
Math tutorials
►
Matrix tutorials
►
Monte Carlo tutorials
►
Multicore tutorials
►
Net tutorials
►
Physics tutorials
►
PyRoot tutorials
▼
Pythia tutorials
pythia8.C
►
Quadratic programming package.
►
R tutorials
►
RooStats Tutorials
►
Spectrum tutorials
►
TSPlot tutorials
►
SQL tutorials
►
TMVA tutorials
►
TUnfold tutorials
►
Unuran tutorials
►
VecOps tutorials
►
FITS files interface tutorials
►
XML tutorials
►
Proof tutorials
►
Webgui tutorials
►
Legacy tutorials
demos.C
demoshelp.C
hsimple.C
rootlogoff.C
rootlogon.C
►
R Interface for Statistical Computing
►
Namespaces
►
All Classes
►
Files
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
pythia8.C File Reference
Tutorials
»
Pythia tutorials
Detailed Description
pythia8 basic example
to run, do:
root > .x pythia8.C
#include "
TSystem.h
"
#include "
TH1F.h
"
#include "
TClonesArray.h
"
#include "
TPythia8.h
"
#include "
TParticle.h
"
#include "
TDatabasePDG.h
"
#include "
TCanvas.h
"
void
pythia8(
Int_t
nev
= 100,
Int_t
ndeb
= 1)
{
// Load libraries
gSystem
->
Load
(
"libEG"
);
gSystem
->
Load
(
"libEGPythia8"
);
// Histograms
TH1F
*
etaH
=
new
TH1F
(
"etaH"
,
"Pseudorapidity"
, 120, -12., 12.);
TH1F
*
ptH
=
new
TH1F
(
"ptH"
,
"pt"
, 50, 0., 10.);
// Array of particles
TClonesArray
*
particles
=
new
TClonesArray
(
"TParticle"
, 1000);
// Create pythia8 object
TPythia8
* pythia8 =
new
TPythia8
();
#if PYTHIA_VERSION_INTEGER == 8235
// Pythia 8.235 is known to cause crashes:
printf
(
"ABORTING PYTHIA8 TUTORIAL!\n"
);
printf
(
"The version of Pythia you use is known to case crashes due to memory errors.\n"
);
printf
(
"They have been reported to the authors; the Pythia versions 8.1... are known to work.\n"
);
return
;
#endif
// Configure
pythia8->
ReadString
(
"HardQCD:all = on"
);
pythia8->
ReadString
(
"Random:setSeed = on"
);
// use a reproducible seed: always the same results for the tutorial.
pythia8->
ReadString
(
"Random:seed = 42"
);
// Initialize
pythia8->
Initialize
(2212
/* p */
, 2212
/* p */
, 14000.
/* TeV */
);
// Event loop
for
(
Int_t
iev
= 0;
iev
<
nev
;
iev
++) {
pythia8->
GenerateEvent
();
if
(
iev
<
ndeb
) pythia8->
EventListing
();
pythia8->
ImportParticles
(
particles
,
"All"
);
Int_t
np
=
particles
->GetEntriesFast();
// Particle loop
for
(
Int_t
ip
= 0;
ip
<
np
;
ip
++) {
TParticle
*
part
= (
TParticle
*)
particles
->At(
ip
);
Int_t
ist
=
part
->GetStatusCode();
// Positive codes are final particles.
if
(
ist
<= 0)
continue
;
Int_t
pdg
=
part
->GetPdgCode();
Float_t
charge
=
TDatabasePDG::Instance
()->GetParticle(
pdg
)->Charge();
if
(
charge
== 0.)
continue
;
Float_t
eta =
part
->Eta();
Float_t
pt
=
part
->Pt();
etaH
->Fill(eta);
if
(
pt
> 0.)
ptH
->Fill(
pt
, 1./(2. *
pt
));
}
}
pythia8->
PrintStatistics
();
TCanvas
*
c1
=
new
TCanvas
(
"c1"
,
"Pythia8 test example"
,800,800);
c1
->Divide(1, 2);
c1
->cd(1);
etaH
->Scale(5./
Float_t
(
nev
));
etaH
->Draw();
etaH
->SetXTitle(
"#eta"
);
etaH
->SetYTitle(
"dN/d#eta"
);
c1
->cd(2);
gPad
->SetLogy();
ptH
->Scale(5./
Float_t
(
nev
));
ptH
->Draw();
ptH
->SetXTitle(
"p_{t} [GeV/c]"
);
ptH
->SetYTitle(
"dN/dp_{t}^{2} [GeV/c]^{-2}"
);
}
Int_t
int Int_t
Definition
RtypesCore.h:45
Float_t
float Float_t
Definition
RtypesCore.h:57
TCanvas.h
TClonesArray.h
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TDatabasePDG.h
np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Definition
TGWin32VirtualXProxy.cxx:222
TH1F.h
TParticle.h
TPythia8.h
TSystem.h
gSystem
R__EXTERN TSystem * gSystem
Definition
TSystem.h:566
gPad
#define gPad
Definition
TVirtualPad.h:305
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TClonesArray
An array of clone (identical) objects.
Definition
TClonesArray.h:29
TDatabasePDG::Instance
static TDatabasePDG * Instance()
static function
Definition
TDatabasePDG.cxx:106
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:621
TParticle
Description of the dynamic properties of a particle.
Definition
TParticle.h:26
TPythia8
TPythia8 is an interface class to C++ version of Pythia 8.1 event generators, written by T....
Definition
TPythia8.h:77
TPythia8::ImportParticles
Int_t ImportParticles(TClonesArray *particles, Option_t *option="") override
Import particles from Pythia stack.
Definition
TPythia8.cxx:194
TPythia8::ReadString
void ReadString(const char *string) const
Configuration.
Definition
TPythia8.cxx:300
TPythia8::Initialize
Bool_t Initialize(Int_t idAin, Int_t idBin, Double_t ecms)
Initialization.
Definition
TPythia8.cxx:147
TPythia8::EventListing
void EventListing() const
Event listing.
Definition
TPythia8.cxx:364
TPythia8::GenerateEvent
void GenerateEvent() override
Generate the next event.
Definition
TPythia8.cxx:185
TPythia8::PrintStatistics
void PrintStatistics() const
Print end of run statistics.
Definition
TPythia8.cxx:356
TSystem::Load
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition
TSystem.cxx:1857
pt
TPaveText * pt
Definition
entrylist_figure1.C:7
c1
return c1
Definition
legend1.C:41
Author
Andreas Morsch
Definition in file
pythia8.C
.
tutorials
pythia
pythia8.C
ROOT v6-32 - Reference Guide Generated on Sun Apr 6 2025 05:41:43 (GVA Time) using Doxygen 1.10.0