]>
Commit | Line | Data |
---|---|---|
2970d087 | 1 | /** |
2 | * @file DrawOccupancy.C | |
3 | * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk> | |
4 | * @date Thu Jul 7 10:24:58 2011 | |
5 | * | |
6 | * @brief A script to draw the Poisson vs Energy Loss correlation | |
7 | * | |
8 | * | |
9 | * @ingroup pwg2_forward_scripts_qa | |
10 | * | |
11 | */ | |
12 | ||
13 | /** | |
14 | * Draw the poisson @f$N_{ch}@f$ estimate against the @f$\Delta@f$ | |
15 | * @f$N_{ch}@f$ estimate and do a regression line between the two | |
16 | * | |
17 | * @param p List | |
18 | * @param d Detector | |
19 | * @param r Ring | |
20 | * @param xmin Minimum | |
21 | * @param xmax Maximum | |
22 | * | |
23 | * @return The regression coefficient | |
24 | * | |
25 | * @ingroup pwg2_forward_scripts_qa | |
26 | */ | |
27 | Double_t | |
28 | DrawRingOccupancy(TList* p, UShort_t d, Char_t r) | |
29 | { | |
30 | if (!p) return; | |
31 | ||
32 | TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r))); | |
33 | if (!ring) { | |
34 | Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName()); | |
35 | return; | |
36 | } | |
37 | ||
38 | TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy")); | |
39 | if (!corr) { | |
40 | Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c", | |
41 | d, r); | |
42 | return; | |
43 | } | |
44 | TPad* pad = static_cast<TPad*>(gPad); | |
45 | pad->SetGridy(); | |
46 | pad->SetGridx(); | |
47 | pad->SetLogy(); | |
48 | pad->SetFillColor(0); | |
49 | pad->SetRightMargin(0.01); | |
50 | #if 0 | |
51 | if (d == 3) { | |
52 | pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99, | |
53 | pad->GetYlowNDC()+pad->GetHNDC()); | |
54 | pad->SetRightMargin(0.15); | |
55 | } | |
56 | #endif | |
57 | ||
58 | corr->Draw("hist"); | |
59 | ||
60 | TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r)); | |
61 | ltx->SetNDC(); | |
62 | ltx->SetTextAlign(33); | |
63 | ltx->SetTextSize(.08); | |
64 | ltx->Draw(); | |
65 | ||
66 | return corr->GetMean(); | |
67 | } | |
68 | ||
69 | /** | |
70 | * Draw the correlation between the Poisson @f$N_{ch}@f$ estimate | |
71 | * and the @f$\Delta@f$ @f$N_{ch}@f$ estimate and do a regression | |
72 | * line between the two for each ring | |
73 | * | |
74 | * @param filename File to read | |
75 | * @param xmax Minimum X | |
76 | * @param xmin Maximum X | |
77 | * | |
78 | * @ingroup pwg2_forward_scripts_qa | |
79 | */ | |
80 | void | |
81 | DrawOccupancy(const char* filename="forward.root", | |
82 | Double_t xmax=-1, | |
83 | Double_t xmin=-1) | |
84 | { | |
85 | gStyle->SetPalette(1); | |
86 | gStyle->SetOptFit(0); | |
87 | gStyle->SetOptStat(0); | |
88 | gStyle->SetOptTitle(0); | |
89 | gStyle->SetTitleW(.4); | |
90 | gStyle->SetTitleH(.1); | |
91 | gStyle->SetTitleX(.4); | |
92 | // gStyle->SetTitleY(.1); | |
93 | gStyle->SetTitleColor(0); | |
94 | gStyle->SetTitleStyle(0); | |
95 | gStyle->SetTitleBorderSize(0); | |
96 | ||
97 | TFile* file = TFile::Open(filename, "READ"); | |
98 | if (!file) { | |
99 | Error("DrawOccupancy", "failed to open %s", filename); | |
100 | return; | |
101 | } | |
102 | ||
103 | TList* forward = static_cast<TList*>(file->Get("Forward")); | |
104 | if (!forward) { | |
105 | Error("DrawOccupancy", "List Forward not found in %s", filename); | |
106 | return; | |
107 | } | |
108 | ||
109 | TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator")); | |
110 | if (!dc) { | |
111 | Error("DrawOccupancy", "List fmdDensityCalculator not found in Forward"); | |
112 | return; | |
113 | } | |
114 | ||
115 | TCanvas* c = new TCanvas("occupancy", | |
116 | "Mean Occupancy", 900, 700); | |
117 | c->SetFillColor(0); | |
118 | c->SetBorderSize(0); | |
119 | c->SetBorderMode(0); | |
120 | c->SetHighLightColor(0); | |
121 | c->SetBottomMargin(.15); | |
122 | c->SetTopMargin(.02); | |
123 | c->SetRightMargin(.02); | |
124 | c->SetLeftMargin(.15); | |
125 | c->Divide(3, 2, 0, 0); | |
126 | ||
127 | ||
128 | Double_t corrs[5]; | |
129 | c->cd(1); corrs[0] = DrawRingOccupancy(dc, 1, 'I'); | |
130 | c->cd(2); corrs[1] = DrawRingOccupancy(dc, 2, 'I'); | |
131 | c->cd(5); corrs[2] = DrawRingOccupancy(dc, 2, 'O'); | |
132 | c->cd(3); corrs[3] = DrawRingOccupancy(dc, 3, 'I'); | |
133 | c->cd(6); corrs[4] = DrawRingOccupancy(dc, 3, 'O'); | |
134 | ||
135 | TVirtualPad* p = c->cd(4); | |
136 | p->SetTopMargin(0.05); | |
137 | p->SetRightMargin(0.10); | |
138 | p->SetLeftMargin(0.15); | |
139 | p->SetBottomMargin(0.15); | |
140 | p->SetFillColor(0); | |
141 | ||
142 | TH1D* hc = new TH1D("occ", "Mean occupancy", 5, .5, 5.5); | |
143 | hc->SetFillColor(kRed+1); | |
144 | hc->SetFillStyle(3001); | |
145 | hc->SetMinimum(0.0); | |
146 | hc->GetXaxis()->SetBinLabel(1,"FMD1i"); hc->SetBinContent(1,corrs[0]); | |
147 | hc->GetXaxis()->SetBinLabel(2,"FMD2i"); hc->SetBinContent(2,corrs[1]); | |
148 | hc->GetXaxis()->SetBinLabel(3,"FMD2o"); hc->SetBinContent(3,corrs[2]); | |
149 | hc->GetXaxis()->SetBinLabel(4,"FMD3i"); hc->SetBinContent(4,corrs[3]); | |
150 | hc->GetXaxis()->SetBinLabel(5,"FMD3o"); hc->SetBinContent(5,corrs[4]); | |
151 | hc->GetXaxis()->SetLabelSize(0.08); | |
152 | hc->GetYaxis()->SetTitle("#bar{occupancy}"); | |
153 | hc->SetMarkerSize(1.5); | |
154 | hc->Draw("text hist"); | |
155 | hc->SetMaximum(hc->GetMaximum()*1.5); | |
156 | ||
157 | // TH2D* highCuts = static_cast<TH2D*>(dc->FindObject("highCuts")); | |
158 | // if (highCuts) highCuts->Draw("colz"); | |
159 | c->cd(); | |
160 | c->SaveAs("occupancy.png"); | |
161 | } | |
162 | // | |
163 | // EOF | |
164 | // |