added correction for events with vertex but 0 tracks
[u/mrichter/AliRoot.git] / PWG0 / esdTrackCuts / printStats.C
CommitLineData
9c4cc5e7 1void printStats(const char* fileName = "trackCuts.root")
2{
3 TFile::Open(fileName);
4
5 fTriggerStats = (TH1*) gFile->Get("fTriggerStats");
6
7 // !MB1 + MB1
8 Int_t allEvents = fTriggerStats->GetBinContent(1) + fTriggerStats->GetBinContent(2);
9
10 // MB2
11 Int_t triggeredEvents = fTriggerStats->GetBinContent(3);
12
13 Printf("Triggered %d out of %d events (%.2f %%)", triggeredEvents, allEvents, 100.0 * triggeredEvents / allEvents);
14
15 fVertex = (TH1*) gFile->Get("fVertex");
16 Int_t eventsVertex = fVertex->GetEntries();
17
18 Printf("%d events have a vertex out of %d triggered (%.2f %%)", eventsVertex, triggeredEvents, 100.0 * eventsVertex / triggeredEvents);
19
20 fStatsPrim = (TH1*) gFile->Get("fTrackCutsPrimaries/cut_statistics");
21
22 Int_t tracksPrim = fStatsPrim->GetBinContent(1);
23 Int_t tracksPrimAc = tracksPrim - fStatsPrim->GetBinContent(2);
24
25 fStatsSec = (TH1*) gFile->Get("fTrackCutsSecondaries/cut_statistics");
26
27 Int_t tracksSec = fStatsSec->GetBinContent(1);
28 Int_t tracksSecAc = tracksSec - fStatsSec->GetBinContent(2);
29
30 fPrimStats = (TH1*) gFile->Get("fPrimStats");
31
32 if (fPrimStats->GetBinContent(5) + fPrimStats->GetBinContent(7) != fStatsPrim->GetBinContent(2))
33 Printf("UNEXPECTED: %f != %f", fPrimStats->GetBinContent(5) + fPrimStats->GetBinContent(7), fStatsPrim->GetBinContent(2));
34
35 Float_t notLostPrimaries = 100.0 * fPrimStats->GetBinContent(7) / (fPrimStats->GetBinContent(5) + fPrimStats->GetBinContent(7));
3dfa46a4 36
9c4cc5e7 37 Printf("Accepted %d out of %d primary tracks (%.2f %%)", tracksPrimAc, tracksPrim, 100.0 * tracksPrimAc / tracksPrim);
3dfa46a4 38 Printf("Per Event: %.2f out of %.2f", (Float_t) tracksPrimAc / eventsVertex, (Float_t) tracksPrim / eventsVertex);
9c4cc5e7 39
40 Printf("Among the non accepted ones %.2f %% are from primaries that have been found with other tracks", notLostPrimaries);
41
42 Printf("Accepted %d out of %d secondary tracks (%.2f %%)", tracksSecAc, tracksSec, 100.0 * tracksSecAc / tracksSec);
3dfa46a4 43 Printf("Per Event: %.2f out of %.2f", (Float_t) tracksSecAc / eventsVertex, (Float_t) tracksSec / eventsVertex);
9c4cc5e7 44
45 Printf("Before cuts: %.2f %% of the tracks are secondaries", 100.0 * tracksSec / (tracksPrim + tracksSec));
46
47 Printf("After cuts: %.2f %% of the tracks are secondaries", 100.0 * tracksSecAc / (tracksPrimAc + tracksSecAc));
48}
49
3dfa46a4 50void ComparePlots(const char* fileName1, const char* fileName2, const char* dirName1 = "AliESDtrackCuts/before_cuts", const char* dirName2 = 0)
9c4cc5e7 51{
52 file1 = TFile::Open(fileName1);
53 file2 = TFile::Open(fileName2);
54
3dfa46a4 55 if (!dirName2)
56 dirName1 = dirName2;
57
58 dir1 = file1->GetDirectory(dirName1);
59 dir2 = file2->GetDirectory(dirName2);
9c4cc5e7 60
61 keyList = dir1->GetListOfKeys();
62 TIter iter(keyList);
63
64 TKey* key = 0;
65 while ((key = (TKey*) iter())) {
66 TH1* hist1 = (TH1*) dir1->Get(key->GetName());
67 TH1* hist2 = (TH1*) dir2->Get(key->GetName());
68
69 if (hist1->Integral() > 0)
70 hist1->Scale(1.0 / hist1->Integral());
71 if (hist2->Integral())
72 hist2->Scale(1.0 / hist2->Integral());
73
74 TString name(key->GetName());
75
3dfa46a4 76 c = new TCanvas(Form("%s_canvas", key->GetName()), key->GetName(), 600, 400);
77
9c4cc5e7 78 hist1->Draw();
79 hist2->SetLineColor(2);
80 hist2->Draw("SAME");
81
3dfa46a4 82 /* this does not work, although given here: http://pcroot.cern.ch/root/html/THistPainter.html ;-)
83 TPaveStats *st = (TPaveStats*) hist1->FindObject("stats");
84 st->SetTextColor(2);
85 st->SetY1NDC(st->GetY1NDC() - 0.2);
86 st->SetY2NDC(st->GetY2NDC() - 0.2);
87 */
88
9c4cc5e7 89 Float_t min = 0.9 * TMath::Min(hist1->GetMinimum(), hist2->GetMinimum());
90
91 if (name.Contains("cov") || name.Contains("dXY") || name.Contains("dZ")) {
92 min += 1e-6;
93 c->cd(1)->SetLogy();
94 if (name.Contains("cov"))
95 hist1->GetXaxis()->SetRangeUser(0, 5);
96 }
97
98 hist1->GetYaxis()->SetRangeUser(min, 1.1 * TMath::Max(hist1->GetMaximum(), hist2->GetMaximum()));
99
100 c->SaveAs(Form("%s.gif", key->GetName()));
3dfa46a4 101
9c4cc5e7 102 //break;
103 }
104}
105