AliPhysics  59e0e03 (59e0e03)
DrawCorrCentralSecMap2.C
Go to the documentation of this file.
1 
15 void
16 ClearCanvas(TCanvas* c)
17 {
18  c->SetLeftMargin(.1);
19  c->SetRightMargin(.05);
20  c->SetBottomMargin(.1);
21  c->SetTopMargin(.05);
22  c->Clear();
23 }
24 
29 void
31 {
32  const char* test = gSystem->GetLibraries("PWGLFforward2","D",false);
33  if (test && test[0] != '\0') return;
34  gROOT->Macro("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
35 }
36 
55 void
56 DrawCorrCentralSecMap2(const char* fname, const char* option="colz", bool tracklets=true)
57 {
58  //__________________________________________________________________
59  // Load libraries and object
60  LoadLibraries();
61 
62  TFile* file = TFile::Open(fname, "READ");
63  if (!file) {
64  Error("DrawCorrSecMap", "Failed to open %s", fname);
65  return;
66  }
67  TString pname(fname);
68  pname.ReplaceAll(".root", ".png");
69  pname = gSystem->BaseName(pname);
70 
71  AliCentralMultiplicityTask::Manager* mgr =
72  new AliCentralMultiplicityTask::Manager;
73  const char* objName = mgr->GetObjectName(0);
75  static_cast<AliCentralCorrSecondaryMap*>(file->Get(objName));
76  if (!corr) {
77  Error("DrawCorrCentralSecMap", "Object '%s' not found in %s",
78  objName, fname);
79  file->ls();
80  return;
81  }
82 
83  //__________________________________________________________________
84  // Create a canvas
85  Int_t w = 1200;
86  TCanvas* c = new TCanvas("c", "c", w, w / TMath::Sqrt(2));
87  c->SetFillColor(0);
88  c->SetBorderSize(0);
89  c->SetBorderMode(0);
90  // c->Print(Form("%s[", pname.Data()));
91 
92  gStyle->SetOptStat(0);
93  gStyle->SetTitleColor(0);
94  gStyle->SetTitleStyle(0);
95  gStyle->SetTitleBorderSize(0);
96  gStyle->SetTitleX(.1);
97  gStyle->SetTitleY(1);
98  gStyle->SetTitleW(.8);
99  gStyle->SetTitleH(.09);
100  gStyle->SetFrameFillColor(kWhite);
101  gStyle->SetFrameBorderSize(1);
102  gStyle->SetFrameBorderMode(1);
103  gStyle->SetPalette(1);
104 
105  TString opt(option);
106  opt.ToLower();
107  Bool_t h2d = (opt.Contains("lego") ||
108  opt.Contains("surf") ||
109  opt.Contains("col"));
110  ClearCanvas(c);
111  //__________________________________________________________________
112  // Draw all corrections
113  const TAxis& vtxAxis = corr->GetVertexAxis();
114  Int_t nVtx = vtxAxis.GetNbins();
115  c->Divide((nVtx+2)/3, 3, 0, 0);
116  Int_t ipad = 0;
117  for (UShort_t v=1; v <= nVtx+1; v++) {
118  ipad++;
119  if (ipad == 1) {
120  c->cd(ipad);
121  TLatex* l = new TLatex(.5, .5,
122  "#frac{#sum N_{ch,SPD0}}{#sum N_{ch,primary}}");
123  if (!tracklets)
124  l->SetText(.5,.5,"#frac{dN_{ch}/d#eta}{#sum N_{ch,primary}}");
125  l->SetNDC();
126  l->SetTextAlign(22);
127  l->SetTextSize(.1);
128  l->Draw();
129  ipad++;
130  }
131  if (ipad == 12) {
132  if (!tracklets)
133  continue;
134  c->cd(ipad);
135  TFile* f = TFile::Open("forward_mccorr.root", "READ");
136  if (!f) {
137  Warning("DrawCorrCentralSecMap2", "File forward_mccorr.root not found");
138  continue;
139  }
140  TList* l3 = static_cast<TList*>(f->Get("CentralSums"));
141  if (!l3) {
142  Warning("DrawCorrCentralSecMap2", "No CentralSums list found");
143  f->Close();
144  continue;
145  }
146  TH1* xyz = static_cast<TH1*>(l3->FindObject("xyz"));
147  if (!xyz) {
148  Warning("DrawCorrCentralSecMap2", "no xyz histogram found");
149  f->Close();
150  continue;
151  }
152  xyz = static_cast<TH1*>(xyz->Clone());
153  xyz->SetDirectory(0);
154  xyz->Draw("ISO");
155  f->Close();
156  continue;
157  }
158  TVirtualPad* p = c->cd(ipad);
159  p->SetFillColor(kWhite);
160  p->SetGridx();
161  p->SetGridy();
162 
163  TH2* h1 = corr->GetCorrection(v);
164  if (h2d) {
165  p->SetRightMargin(0.13);
166  h1->SetMaximum(1.9);
167  h1->Draw(option);
168  continue;
169  }
170 
171  TH1D* pr = h1->ProjectionX(Form("vtxbin%02d", v), -1, -1, "e");
172  TH1D* nr = static_cast<TH1D*>(pr->Clone("norm"));
173  nr->SetDirectory(0);
174  pr->SetDirectory(0);
175  pr->SetTitle(Form("%+5.1f<v_{z}<%+5.1f",
176  vtxAxis.GetBinLowEdge(v),
177  vtxAxis.GetBinUpEdge(v)));
178  pr->SetMarkerColor(kRed+1);
179  pr->SetFillColor(kRed+1);
180  pr->SetFillStyle(3001);
181  pr->SetMaximum(1.65);
182  pr->GetXaxis()->SetRangeUser(-3.1,3.1);
183 
184  Int_t nX = h1->GetNbinsX();
185  Int_t nY = h1->GetNbinsY();
186  nr->Reset();
187  for (Int_t i = 1; i <= nX; i++) {
188  Int_t nonZero = 0;
189  for (Int_t j = 1; j <= nY; j++)
190  if (h1->GetBinContent(i,j) > 0.001) nonZero++;
191  nr->SetBinContent(i, nonZero);
192  }
193  // pr->Scale(1. / nY);
194  pr->Divide(nr);
195  pr->Draw("hist");
196  pr->Draw("same");
197 
198  }
199 
200  //__________________________________________________________________
201  // Close output file
202  c->SaveAs(pname.Data());
203 
204 }
205 //
206 // EOF
207 //
TSystem * gSystem
TCanvas * c
Definition: TestFitELoss.C:172
int Int_t
Definition: External.C:63
Definition: External.C:212
TH2D * GetCorrection(Double_t v) const
void LoadLibraries()
void ClearCanvas(TCanvas *c)
Definition: DrawCorrAcc2.C:16
Definition: External.C:220
TFile * file
TList with histograms for a given trigger.
const TAxis & GetVertexAxis() const
unsigned short UShort_t
Definition: External.C:28
void test(int runnumber=195345)
bool Bool_t
Definition: External.C:53
Definition: External.C:196
void DrawCorrCentralSecMap2(const char *fname, const char *option="colz", bool tracklets=true)