AliPhysics  a4b41ad (a4b41ad)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DrawOccupancy.C
Go to the documentation of this file.
1 
12 #ifndef __CINT__
13 # include <TH1.h>
14 # include <TH2.h>
15 # include <TList.h>
16 # include <TFile.h>
17 # include <TString.h>
18 # include <TError.h>
19 # include <TPad.h>
20 # include <TCanvas.h>
21 # include <TLine.h>
22 # include <TLatex.h>
23 # include <TStyle.h>
24 #else
25 class TList;
26 #endif
27 
42 {
43  if (!p) return 0;
44 
45  TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
46  if (!ring) {
47  Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
48  return 0;
49  }
50 
51  TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
52  if (!corr) {
53  Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
54  d, r);
55  return 0;
56  }
57  corr->Rebin(4);
58 
59  TPad* pad = static_cast<TPad*>(gPad);
60  pad->SetGridy();
61  pad->SetGridx();
62  pad->SetLogy();
63  pad->SetFillColor(0);
64  pad->SetRightMargin(0.01);
65 #if 0
66  if (d == 3) {
67  pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
68  pad->GetYlowNDC()+pad->GetHNDC());
69  pad->SetRightMargin(0.15);
70  }
71 #endif
72 
73  corr->Draw("hist");
74 
75  TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
76  ltx->SetNDC();
77  ltx->SetTextAlign(33);
78  ltx->SetTextSize(.08);
79  ltx->Draw();
80 
81  return corr->GetMean();
82 }
83 
93 void
94 DrawOccupancy(const char* filename="forward.root",
95  const char* folder="ForwardResults")
96 {
97  gStyle->SetPalette(1);
98  gStyle->SetOptFit(0);
99  gStyle->SetOptStat(0);
100  gStyle->SetOptTitle(0);
101  gStyle->SetTitleW(.4);
102  gStyle->SetTitleH(.1);
103  gStyle->SetTitleX(.4);
104  // gStyle->SetTitleY(.1);
105  gStyle->SetTitleColor(0);
106  gStyle->SetTitleStyle(0);
107  gStyle->SetTitleBorderSize(0);
108 
109  TFile* file = TFile::Open(filename, "READ");
110  if (!file) {
111  Error("DrawOccupancy", "failed to open %s", filename);
112  return;
113  }
114 
115  TList* forward = static_cast<TList*>(file->Get(folder));
116  if (!forward) {
117  Error("DrawOccupancy", "List %s not found in %s", folder, filename);
118  return;
119  }
120 
121  TList* dc = static_cast<TList*>(forward->FindObject("fmdDensityCalculator"));
122  if (!dc) {
123  Error("DrawOccupancy", "List fmdDensityCalculator not found in Forward");
124  return;
125  }
126 
127  TCanvas* c = new TCanvas("occupancy",
128  "Mean Occupancy", 900, 700);
129  c->SetFillColor(0);
130  c->SetBorderSize(0);
131  c->SetBorderMode(0);
132  c->SetHighLightColor(0);
133  c->SetBottomMargin(.15);
134  c->SetTopMargin(.02);
135  c->SetRightMargin(.02);
136  c->SetLeftMargin(.15);
137  c->Divide(3, 2, 0, 0);
138 
139 
140  Double_t corrs[5];
141  c->cd(1); corrs[0] = DrawRingOccupancy(dc, 1, 'I');
142  c->cd(2); corrs[1] = DrawRingOccupancy(dc, 2, 'I');
143  c->cd(5); corrs[2] = DrawRingOccupancy(dc, 2, 'O');
144  c->cd(3); corrs[3] = DrawRingOccupancy(dc, 3, 'I');
145  c->cd(6); corrs[4] = DrawRingOccupancy(dc, 3, 'O');
146 
147  TVirtualPad* p = c->cd(4);
148  p->SetTopMargin(0.05);
149  p->SetRightMargin(0.10);
150  p->SetLeftMargin(0.15);
151  p->SetBottomMargin(0.15);
152  p->SetFillColor(0);
153 
154  TH1D* hc = new TH1D("occ", "Mean occupancy", 5, .5, 5.5);
155  hc->SetFillColor(kRed+1);
156  hc->SetFillStyle(3001);
157  hc->SetMinimum(0.0);
158  hc->GetXaxis()->SetBinLabel(1,"FMD1i"); hc->SetBinContent(1,corrs[0]);
159  hc->GetXaxis()->SetBinLabel(2,"FMD2i"); hc->SetBinContent(2,corrs[1]);
160  hc->GetXaxis()->SetBinLabel(3,"FMD2o"); hc->SetBinContent(3,corrs[2]);
161  hc->GetXaxis()->SetBinLabel(4,"FMD3i"); hc->SetBinContent(4,corrs[3]);
162  hc->GetXaxis()->SetBinLabel(5,"FMD3o"); hc->SetBinContent(5,corrs[4]);
163  hc->GetXaxis()->SetLabelSize(0.08);
164  hc->GetYaxis()->SetTitle("#bar{occupancy}");
165  hc->SetMarkerSize(1.5);
166  hc->Draw("text hist");
167  hc->SetMaximum(hc->GetMaximum()*1.5);
168 
169  // TH2D* highCuts = static_cast<TH2D*>(dc->FindObject("highCuts"));
170  // if (highCuts) highCuts->Draw("colz");
171  c->cd();
172  c->SaveAs("occupancy.png");
173 }
174 //
175 // EOF
176 //
const char * filename
Definition: TestFCM.C:1
double Double_t
Definition: External.C:58
Double_t DrawRingOccupancy(TList *p, UShort_t d, Char_t r)
Definition: DrawOccupancy.C:41
char Char_t
Definition: External.C:18
TCanvas * c
Definition: TestFitELoss.C:172
Definition: External.C:212
void DrawOccupancy(const char *filename="forward.root", const char *folder="ForwardResults")
Definition: DrawOccupancy.C:94
TFile * file
unsigned short UShort_t
Definition: External.C:28
Definition: External.C:196