pythia8.C

Go to the documentation of this file.
00001 // pythia8 basic example
00002 //Author: Andreas Morsch
00003 //
00004 // to run, do
00005 //  root > .x pythia8.C
00006 //
00007 // Note that before executing this script, 
00008 //   -the env variable PYTHIA8 must point to the pythia8100 (or newer) directoryDATA
00009 //   -the env variable PYTHIA8DATA must be defined and it must point to $PYTHIA8/xmldoc
00010 //
00011 void pythia8(Int_t nev  = 100, Int_t ndeb = 1) {
00012     
00013    char* path = gSystem->ExpandPathName("$PYTHIA8DATA");
00014    if (gSystem->AccessPathName(path)) {
00015       Warning("pythia8.C", 
00016               "Environment variable PYTHIA8DATA must contain path to pythi8100/xmldoc directory !");
00017       return;
00018    }
00019     
00020 // Load libraries
00021    gSystem->Load("$PYTHIA8/lib/libpythia8");
00022    gSystem->Load("libEG");
00023    gSystem->Load("libEGPythia8");
00024 // Histograms
00025    TH1F* etaH = new TH1F("etaH", "Pseudorapidity", 120, -12., 12.);
00026    TH1F* ptH  = new TH1F("ptH",  "pt",              50,   0., 10.);
00027     
00028 
00029 // Array of particles
00030    TClonesArray* particles = new TClonesArray("TParticle", 1000);
00031 // Create pythia8 object
00032    TPythia8* pythia8 = new TPythia8();
00033     
00034 // Configure    
00035    pythia8->ReadString("SoftQCD:minBias = on");
00036    pythia8->ReadString("SoftQCD:singleDiffractive = on");
00037    pythia8->ReadString("SoftQCD:doubleDiffractive = on");
00038 
00039 // Initialize 
00040     
00041    pythia8->Initialize(2212 /* p */, 2212 /* p */, 14000. /* TeV */);
00042     
00043 // Event loop
00044    for (Int_t iev = 0; iev < nev; iev++) {
00045       pythia8->GenerateEvent();
00046       if (iev < ndeb) pythia8->EventListing();
00047       pythia8->ImportParticles(particles,"All");
00048       Int_t np = particles->GetEntriesFast();
00049 // Particle loop
00050       for (Int_t ip = 0; ip < np; ip++) {
00051          TParticle* part = (TParticle*) particles->At(ip);
00052          Int_t ist = part->GetStatusCode();
00053          // Positive codes are final particles.
00054          if (ist <= 0) continue;
00055          Int_t pdg = part->GetPdgCode();
00056          Float_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
00057          if (charge == 0.) continue;
00058          Float_t eta = part->Eta();
00059          Float_t pt  = part->Pt();
00060     
00061          etaH->Fill(eta);
00062          if (pt > 0.) ptH->Fill(pt, 1./(2. * pt));
00063       }
00064    }
00065 
00066    pythia8->PrintStatistics();
00067     
00068    TCanvas* c1 = new TCanvas("c1","Pythia8 test example",800,800);
00069    c1->Divide(1, 2);
00070    c1->cd(1);
00071    etaH->Scale(5./Float_t(nev));
00072    etaH->Draw();
00073    etaH->SetXTitle("#eta");
00074    etaH->SetYTitle("dN/d#eta");
00075 
00076    c1->cd(2);
00077    gPad->SetLogy();
00078    ptH->Scale(5./Float_t(nev));
00079    ptH->Draw();
00080    ptH->SetXTitle("p_{t} [GeV/c]");
00081    ptH->SetYTitle("dN/dp_{t}^{2} [GeV/c]^{-2}");
00082  }

Generated on Tue Jul 5 15:44:53 2011 for ROOT_528-00b_version by  doxygen 1.5.1