]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/esdTrackCuts/draw.C
Background subraction disabled since not correct. (Elena Bruna)
[u/mrichter/AliRoot.git] / PWG0 / esdTrackCuts / draw.C
1 void draw()
2 {
3   //const char* files[] = { "trackCuts_normal.root", "trackCuts_increased.root", "trackCuts_decreased.root" };
4   const char* files[] =
5     { "Material-normal/trackCuts.root",
6       "Material-increased-mcvtx/trackCuts.root",
7       "Material-decreased-mcvtx/trackCuts.root" };
8   const char* titles[] = { "default geometry", "+ 10% material", "- 10% material" };
9   Int_t colors[] = { 1, 2, 4 };
10   Int_t markers[] = {24, 25, 26, 27 };
11
12   TCanvas* c = new TCanvas;
13   TCanvas* c2 = new TCanvas;
14
15   TLegend* legend = new TLegend(0.6, 0.5, 0.9, 0.9);
16   TLegend* legend2 = new TLegend(0.7, 0.7, 0.9, 0.9);
17
18   for (Int_t i=0; i<3; i++) {
19     if (!TFile::Open(files[i]))
20       return;
21
22     TH1* ptPrim = gFile->Get("fTrackCutsPrimaries/before_cuts/pt");
23     TH1* ptPrimCut = gFile->Get("fTrackCutsPrimaries/after_cuts/pt_cut");
24
25     TH1* ptSec = gFile->Get("fTrackCutsSecondaries/before_cuts/pt");
26     TH1* ptSecCut = gFile->Get("fTrackCutsSecondaries/after_cuts/pt_cut");
27
28     TH1* vertex = gFile->Get("fVertex");
29     Int_t nEvents = vertex->GetEntries();
30
31     ptPrim->Add(ptSec);
32     ptPrimCut->Add(ptSecCut);
33
34     ptPrim->Sumw2();
35     ptPrimCut->Sumw2();
36     ptSec->Sumw2();
37     ptSecCut->Sumw2();
38
39     Printf("%s", titles[i]);
40     Printf("Total particles: %d", (Int_t) (ptPrim->GetEntries() + ptSec->GetEntries()));
41     Printf("Total particles/event: %.2f", (ptPrim->GetEntries() + ptSec->GetEntries()) / nEvents);
42     Printf("Primaries/event: %.2f", ptPrim->GetEntries() / nEvents);
43     Printf("Secondaries/event: %.2f", ptSec->GetEntries() / nEvents);
44     Printf("Primaries > 0.2 GeV/c/event: %.2f", ptPrim->Integral(ptPrim->GetXaxis()->FindBin(0.21), ptPrim->GetNbinsX()) / nEvents);
45     Printf("Secondaries > 0.2 GeV/c/event: %.2f", ptSec->Integral(ptSec->GetXaxis()->FindBin(0.21), ptSec->GetNbinsX()) / nEvents);
46     Printf("Primaries after cuts > 0.2 GeV/c/event: %.2f +- %.2f", ptPrimCut->Integral(ptPrimCut->GetXaxis()->FindBin(0.21), ptPrimCut->GetNbinsX()) / nEvents, TMath::Sqrt(ptPrimCut->Integral(ptPrimCut->GetXaxis()->FindBin(0.21), ptPrimCut->GetNbinsX())) / nEvents);
47     Printf("Secondaries after cuts > 0.2 GeV/c/event: %.2f +- %.2f", ptSecCut->Integral(ptSecCut->GetXaxis()->FindBin(0.21), ptSecCut->GetNbinsX()) / nEvents, TMath::Sqrt(ptSecCut->Integral(ptSecCut->GetXaxis()->FindBin(0.21), ptSecCut->GetNbinsX())) / nEvents);
48     Printf("%.2f %% secondaries before cuts", 100.0 * ptSec->GetEntries() / ptPrim->GetEntries());
49     Printf("%.2f %% secondaries after cuts", 100.0 * ptSecCut->GetEntries() / ptPrimCut->GetEntries());
50     Printf("");
51
52     ptPrim->SetLineColor(colors[i]);
53     ptPrimCut->SetLineColor(colors[i]);
54     ptSec->SetLineColor(colors[i]);
55     ptSecCut->SetLineColor(colors[i]);
56
57     ptPrim->SetMarkerColor(colors[i]);
58     ptPrimCut->SetMarkerColor(colors[i]);
59     ptSec->SetMarkerColor(colors[i]);
60     ptSecCut->SetMarkerColor(colors[i]);
61
62     ptPrim->SetStats(kFALSE);
63     ptPrim->SetTitle("");
64     ptPrim->GetYaxis()->SetTitle("N");
65     ptSec->SetStats(kFALSE);
66     ptSec->SetTitle("");
67
68     ptPrim->SetMarkerStyle(markers[0]);
69     ptPrimCut->SetMarkerStyle(markers[1]);
70     ptSec->SetMarkerStyle(markers[2]);
71     ptSecCut->SetMarkerStyle(markers[3]);
72
73     if (i == 0) {
74       legend->AddEntry(ptPrim->Clone(), "Primaries");
75       legend->AddEntry(ptPrimCut->Clone(), "Primaries after cuts");
76       legend->AddEntry(ptSec->Clone(), "Secondaries");
77       legend->AddEntry(ptSecCut->Clone(), "Secondaries after cuts");
78     }
79
80     ptPrim->GetXaxis()->SetRangeUser(0, 2);
81     ptSec->GetXaxis()->SetRangeUser(0, 2);
82     //ptPrim->GetYaxis()->SetRangeUser(1e-5, ptSec->GetMaximum() * 1.1);
83
84     c->cd();
85     ptPrim->DrawCopy((i > 0) ? "SAME" : "");
86     ptPrimCut->DrawCopy("SAME");
87     ptSec->DrawCopy("SAME");
88     ptSecCut->DrawCopy("SAME");
89
90     ptSec->Divide(ptSec, ptPrim, 1, 1, "B");
91     ptSecCut->Divide(ptSecCut, ptPrimCut, 1, 1, "B");
92
93     ptSec->SetMarkerStyle(1);
94     ptSecCut->SetMarkerStyle(1);
95
96     ptSec->GetYaxis()->SetRangeUser(0, 1);
97
98     ptSec->GetYaxis()->SetTitle("N_{Secondaries} / N_{All}");
99
100     c2->cd();
101     ptSec->DrawCopy((i > 0) ? "SAME" : "");
102     ptSecCut->DrawCopy("SAME");
103
104     legend->AddEntry(ptSec, titles[i]);
105     legend2->AddEntry(ptSec, titles[i]);
106   }
107
108   c->cd();
109   legend->Draw();
110   c->SaveAs("changedmaterial_absolute.gif");
111
112   c2->cd();
113   legend2->Draw();
114   c2->SaveAs("changedmaterial_relative.gif");
115 }
116
117 void drawStats(const char* fileName = "trackCuts.root")
118 {
119   TFile::Open(fileName);
120
121   TH1* stat1 = gFile->Get("fTrackCutsPrimaries/cut_statistics");
122   TH1* stat2 = gFile->Get("fTrackCutsSecondaries/cut_statistics");
123   
124   new TCanvas;
125   stat1->Draw();
126   stat2->SetLineColor(2);
127   stat2->Draw("SAME");
128 }