00001 #define ProofPythia_cxx
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <TCanvas.h>
00013 #include <TFrame.h>
00014 #include <TPaveText.h>
00015 #include <TFormula.h>
00016 #include <TF1.h>
00017 #include <TH1F.h>
00018 #include <TMath.h>
00019 #include <TString.h>
00020 #include <TStyle.h>
00021 #include <TSystem.h>
00022 #include <TParameter.h>
00023 #include "TClonesArray.h"
00024 #include "TParticle.h"
00025 #include "TDatabasePDG.h"
00026
00027 #include "ProofPythia.h"
00028 #include "TPythia8.h"
00029
00030
00031 ProofPythia::ProofPythia()
00032 {
00033
00034
00035 fHist = 0;
00036 fPt = 0;
00037 fEta = 0;
00038 fPythia = 0;
00039 fP = 0;
00040 }
00041
00042
00043 ProofPythia::~ProofPythia()
00044 {
00045
00046
00047 SafeDelete(fPythia);
00048 SafeDelete(fP);
00049 }
00050
00051
00052 void ProofPythia::Begin(TTree * )
00053 {
00054
00055
00056
00057
00058 TString option = GetOption();
00059 }
00060
00061
00062 void ProofPythia::SlaveBegin(TTree * )
00063 {
00064
00065
00066
00067
00068 TString option = GetOption();
00069
00070
00071 fTot = new TH1F("histo1", "total multiplicity", 25, 0.5, 2500.5);
00072 fHist = new TH1F("histo2", "charged multiplicity", 20, 0.5, 500.5);
00073 fPt = new TH1F("histo3", "particles pT", 100, 0., 10);
00074 fEta = new TH1F("histo4", "particles Eta", 100, -10., 10);
00075 fTot->SetFillColor(kBlue);
00076 fHist->SetFillColor(kRed);
00077 fOutput->Add(fTot);
00078 fOutput->Add(fHist);
00079 fOutput->Add(fPt);
00080 fOutput->Add(fEta);
00081
00082 fPythia = new TPythia8();
00083
00084 fPythia->SetName("pythia8");
00085 fPythia->ReadConfigFile("pythia8/main03.cmnd");
00086
00087
00088 fPythia->Initialize( 2212, 2212, 14000.);
00089 fP = new TClonesArray("TParticle", 1000);
00090
00091 }
00092
00093
00094 Bool_t ProofPythia::Process(Long64_t entry)
00095 {
00096
00097
00098 fPythia->GenerateEvent();
00099 if (entry < 2)
00100 fPythia->EventListing();
00101 fPythia->ImportParticles(fP, "All");
00102 Int_t nTot = fPythia->GetN();
00103 fPythia->ImportParticles(fP, "All");
00104 Int_t np = fP->GetEntriesFast();
00105
00106 Int_t nCharged = 0;
00107 for (Int_t ip = 0; ip < np; ip++) {
00108 TParticle* part = (TParticle*) fP->At(ip);
00109 Int_t ist = part->GetStatusCode();
00110 Int_t pdg = part->GetPdgCode();
00111 if (ist != 1) continue;
00112 Float_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
00113 if (charge == 0.) continue;
00114 nCharged++;
00115 Float_t eta = part->Eta();
00116 Float_t pt = part->Pt();
00117 if (pt > 0.) fPt->Fill(pt);
00118 if ((eta > -10) && (eta < 10)) fEta->Fill(eta);
00119 }
00120 fHist->Fill(nCharged);
00121 fTot->Fill(nTot);
00122
00123 return kTRUE;
00124 }
00125
00126
00127 void ProofPythia::SlaveTerminate()
00128 {
00129
00130
00131
00132 }
00133
00134
00135 void ProofPythia::Terminate()
00136 {
00137
00138
00139
00140
00141
00142
00143
00144 TCanvas *c1 = new TCanvas("c1","Proof ProofPythia canvas",200,10,700,700);
00145 c1->Divide(2, 2);
00146
00147 if ((fTot = dynamic_cast<TH1F *>(fOutput->FindObject("histo1")))) {
00148 c1->cd(1);
00149 fTot->Draw("h");
00150 }
00151
00152 if ((fHist = dynamic_cast<TH1F *>(fOutput->FindObject("histo2")))) {
00153 c1->cd(2);
00154 fHist->Draw("h");
00155 }
00156
00157 if ((fPt = dynamic_cast<TH1F *>(fOutput->FindObject("histo3")))) {
00158 c1->cd(3);
00159 fPt->Draw("h");
00160 }
00161
00162 if ((fEta = dynamic_cast<TH1F *>(fOutput->FindObject("histo4")))) {
00163 c1->cd(4);
00164 fEta->Draw("h");
00165 }
00166
00167
00168 c1->cd();
00169 c1->Update();
00170 }