Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
makePlot_truth_EtaDistribution.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file makePlot_truth_EtaDistribution.C
2  const TString infile = "../../data/Sample_DISReco_ep.root",
3  //const TString infile = "../../data/EventGenAna_Pythia6_DIS_10x250_100k.root",
4  const bool save_figures = true
5  )
6 {
7  gStyle->SetOptStat(kFALSE);
8 
9  TFile *f_truth = new TFile( infile, "OPEN");
10  TTree* t_truth = (TTree*)f_truth->Get("event_truth");
11  t_truth->Print();
12 
13  TCut electron_cut = "em_evtgen_pid == 11";
14  TCut Pion_cut = "abs( em_evtgen_pid ) == 211";
15 
16  TH1F *h_eta = new TH1F("h_eta", "", 60, -6, 6);
17  TH1F *h_eta_e = (TH1F*)h_eta->Clone();
18 
19  TCanvas *c_eta = new TCanvas("c_eta");
20 
21  t_truth->Draw("-1 * log( tan( em_evtgen_theta / 2.0 ) ) >> h_eta", Pion_cut);
22  h_eta->SetLineStyle(2);
23  t_truth->Draw("-1 * log( tan( em_evtgen_theta / 2.0 ) ) >> h_eta_e", electron_cut, "sames");
24 
25  h_eta->GetXaxis()->SetTitle("Pseudorapidity #eta");
26  h_eta->GetYaxis()->SetTitle("dN/d#eta");
27 
28  TLegend* leg_eta = new TLegend( 0.25, 0.70, 0.45, 0.90);
29  leg_eta->AddEntry(h_eta, "Charged Pions", "L");
30  leg_eta->AddEntry(h_eta_e, "Electrons", "L");
31  leg_eta->Draw();
32 
33  if ( save_figures )
34  {
35  c_eta->Print("plots/truth_EtaDistribution.eps");
36  c_eta->Print("plots/truth_EtaDistribution.png");
37  }
38 
39  return 0;
40 }