void pythia8(Int_t nev = 100, Int_t ndeb = 1) {
char* path = gSystem->ExpandPathName("$PYTHIA8DATA");
if (gSystem->AccessPathName(path)) {
Warning("pythia8.C",
"Environment variable PYTHIA8DATA must contain path to pythi8100/xmldoc directory !");
return;
}
gSystem->Load("$PYTHIA8/lib/libpythia8");
gSystem->Load("libEG");
gSystem->Load("libEGPythia8");
TH1F* etaH = new TH1F("etaH", "Pseudorapidity", 120, -12., 12.);
TH1F* ptH = new TH1F("ptH", "pt", 50, 0., 10.);
TClonesArray* particles = new TClonesArray("TParticle", 1000);
TPythia8* pythia8 = new TPythia8();
pythia8->ReadString("SoftQCD:minBias = on");
pythia8->ReadString("SoftQCD:singleDiffractive = on");
pythia8->ReadString("SoftQCD:doubleDiffractive = on");
pythia8->Initialize(2212 , 2212 , 14000. );
for (Int_t iev = 0; iev < nev; iev++) {
pythia8->GenerateEvent();
if (iev < ndeb) pythia8->EventListing();
pythia8->ImportParticles(particles,"All");
Int_t np = particles->GetEntriesFast();
for (Int_t ip = 0; ip < np; ip++) {
TParticle* part = (TParticle*) particles->At(ip);
Int_t ist = part->GetStatusCode();
Int_t pdg = part->GetPdgCode();
if (ist != 1) continue;
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}");
}
|
|