File indexing completed on 2025-08-05 08:12:07
0001
0002 int makePlot_EtaDistribution(
0003 const TString infile = "data/pythia.ep.100.test.root"
0004 )
0005 {
0006 gStyle->SetOptStat(kFALSE);
0007
0008 TFile *f_pyth = new TFile( infile, "OPEN");
0009 TTree* T_pyth = (TTree*)f_pyth->Get("tree");
0010 tree->Print();
0011
0012 TCut electron_cut = "p.fKF == 11";
0013 TCut Pion_cut = "abs(p.fKF) == 211 || p.fKF == 111";
0014
0015 TH1F *h_eta = new TH1F("h_eta", "", 60, -6, 6);
0016 TH1F *h_eta_e = (TH1F*)h_eta->Clone();
0017 TCanvas *c_eta = new TCanvas("c_eta");
0018
0019 tree->Draw("TMath::ASinH(p.fPz/sqrt(((p.fPx)**2 + (p.fPy)**2)))>>h_eta", Pion_cut);
0020 h_eta->SetLineStyle(2);
0021 tree->Draw("TMath::ASinH(p.fPz/sqrt(((p.fPx)**2 + (p.fPy)**2)))>>h_eta_e", electron_cut && "p.fParent == 0", "same");
0022
0023 h_eta->GetXaxis()->SetTitle("Pseudorapidity #eta");
0024 h_eta->GetYaxis()->SetTitle("dN/d#eta");
0025
0026 TLegend* leg_eta = new TLegend( 0.25, 0.70, 0.45, 0.90);
0027 leg_eta->AddEntry(h_eta, "Pions", "L");
0028 leg_eta->AddEntry(h_eta_e, "Electrons", "L");
0029 leg_eta->Draw();
0030
0031 c_eta->Print("EtaDistributions.eps");
0032 c_eta->Print("EtaDistributions.png");
0033
0034 return 0;
0035 }