Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ProofPythia.C File Reference

Detailed Description

Selector to generate Monte Carlo events with Pythia8.

#define ProofPythia_cxx
#include <TCanvas.h>
#include <TFrame.h>
#include <TPaveText.h>
#include <TFormula.h>
#include <TF1.h>
#include <TH1F.h>
#include <TMath.h>
#include <TString.h>
#include <TStyle.h>
#include <TSystem.h>
#include <TParameter.h>
#include "TClonesArray.h"
#include "TParticle.h"
#include "TDatabasePDG.h"
#include "ProofPythia.h"
#include "TPythia8.h"
//_____________________________________________________________________________
ProofPythia::ProofPythia()
{
// Constructor
fHist = 0;
fPt = 0;
fEta = 0;
fPythia = 0;
fP = 0;
}
//_____________________________________________________________________________
ProofPythia::~ProofPythia()
{
// Destructor
SafeDelete(fPythia);
}
//_____________________________________________________________________________
void ProofPythia::Begin(TTree * /*tree*/)
{
// The Begin() function is called at the start of the query.
// When running with PROOF Begin() is only called on the client.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
Info("Begin", "starting a simple exercise with process option: %s", option.Data());
}
//_____________________________________________________________________________
void ProofPythia::SlaveBegin(TTree * /*tree*/)
{
// The SlaveBegin() function is called after the Begin() function.
// When running with PROOF SlaveBegin() is called on each slave server.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
// Histograms
fTot = new TH1F("histo1", "total multiplicity", 25, 0.5, 2500.5);
fHist = new TH1F("histo2", "charged multiplicity", 20, 0.5, 500.5);
fPt = new TH1F("histo3", "particles pT", 100, 0., 10);
fEta = new TH1F("histo4", "particles Eta", 100, -10., 10);
fTot->SetFillColor(kBlue);
fHist->SetFillColor(kRed);
fOutput->Add(fTot);
fOutput->Add(fHist);
fOutput->Add(fPt);
fOutput->Add(fEta);
fPythia = new TPythia8();
// Configure
fPythia->SetName("pythia8");
fPythia->ReadConfigFile("pythia8/main03.cmnd");
// Initialize
fPythia->Initialize( 2212, 2212, 14000.);
fP = new TClonesArray("TParticle", 1000);
}
//_____________________________________________________________________________
Bool_t ProofPythia::Process(Long64_t entry)
{
// Main event loop
fPythia->GenerateEvent();
if (entry < 2)
fPythia->EventListing();
fPythia->ImportParticles(fP, "All");
Int_t nTot = fPythia->GetN();
fPythia->ImportParticles(fP, "All");
Int_t np = fP->GetEntriesFast();
// Particle loop
Int_t nCharged = 0;
for (Int_t ip = 0; ip < np; ip++) {
TParticle* part = (TParticle*) fP->At(ip);
Int_t ist = part->GetStatusCode();
Int_t pdg = part->GetPdgCode();
if (ist != 1) continue;
if (charge == 0.) continue;
nCharged++;
Float_t eta = part->Eta();
Float_t pt = part->Pt();
if (pt > 0.) fPt->Fill(pt);
if ((eta > -10) && (eta < 10)) fEta->Fill(eta);
}
fHist->Fill(nCharged);
fTot->Fill(nTot);
return kTRUE;
}
//_____________________________________________________________________________
void ProofPythia::SlaveTerminate()
{
// The SlaveTerminate() function is called after all entries or objects
// have been processed. When running with PROOF SlaveTerminate() is called
// on each slave server.
}
//_____________________________________________________________________________
void ProofPythia::Terminate()
{
// The Terminate() function is the last function to be called during
// a query. It always runs on the client, it can be used to present
// the results graphically or save the results to file.
//
// Create canvas
//
TCanvas *c1 = new TCanvas("c1","Proof ProofPythia canvas",200,10,700,700);
c1->Divide(2, 2);
if ((fTot = dynamic_cast<TH1F *>(fOutput->FindObject("histo1")))) {
c1->cd(1);
fTot->Draw("h");
}
if ((fHist = dynamic_cast<TH1F *>(fOutput->FindObject("histo2")))) {
c1->cd(2);
fHist->Draw("h");
}
if ((fPt = dynamic_cast<TH1F *>(fOutput->FindObject("histo3")))) {
c1->cd(3);
fPt->Draw("h");
}
if ((fEta = dynamic_cast<TH1F *>(fOutput->FindObject("histo4")))) {
c1->cd(4);
fEta->Draw("h");
}
// Final update
c1->cd();
c1->Update();
}
Selector to generate Monte Carlo events with Pythia8.
#define SafeDelete(p)
Definition RConfig.hxx:547
int Int_t
Definition RtypesCore.h:45
bool Bool_t
Definition RtypesCore.h:63
long long Long64_t
Definition RtypesCore.h:73
float Float_t
Definition RtypesCore.h:57
const Bool_t kTRUE
Definition RtypesCore.h:91
@ kRed
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:220
The Canvas class.
Definition TCanvas.h:23
An array of clone (identical) objects.
static TDatabasePDG * Instance()
static function
TParticlePDG * GetParticle(Int_t pdgCode) const
Get a pointer to the particle object according to the MC code number.
1-D histogram with a float per channel (see TH1 documentation)}
Definition TH1.h:575
Double_t Charge() const
Description of the dynamic properties of a particle.
Definition TParticle.h:26
Int_t GetStatusCode() const
Definition TParticle.h:82
Int_t GetPdgCode() const
Definition TParticle.h:83
Double_t Pt() const
Definition TParticle.h:135
Double_t Eta() const
Definition TParticle.h:137
TPythia8 is an interface class to C++ version of Pythia 8.1 event generators, written by T....
Definition TPythia8.h:77
Basic string class.
Definition TString.h:136
const char * Data() const
Definition TString.h:369
A TTree represents a columnar dataset.
Definition TTree.h:79
TPaveText * pt
return c1
Definition legend1.C:41
Author
Gerardo Ganis (gerar.nosp@m.do.g.nosp@m.anis@.nosp@m.cern.nosp@m..ch)

Definition in file ProofPythia.C.