AliPhysics  db95e02 (db95e02)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CompareMuon.C
Go to the documentation of this file.
1 //====================================================================
2 TCanvas* MakeCanvas(const char* name, const char* title,
3  const char* img=0)
4 {
5  TImage* dimg = 0;
6  if (img) {
7  TImage* dimg = TImage::Open(img);
8  if (!dimg) {
9  Error("Failed to open image file: %s", img);
10  return 0;
11  }
12  }
13  UInt_t w = (dimg ? dimg->GetWidth() : 1000);
14  UInt_t h = (dimg ? dimg->GetHeight() : 900);
15  Printf("Canvas size: (%dx%d)", w, h);
16  TCanvas* c = new TCanvas(name, title, w, h);
17  c->SetTopMargin(0.01);
18  c->SetRightMargin(0.01);
19 
20  if (dimg) {
21  c->SetTopMargin(0);
22  c->SetRightMargin(0);
23  c->SetLeftMargin(0);
24  c->SetRightMargin(0);
25  c->cd();
26  // dimg->Scale(c->GetWw(), c->GetWh());
27  dimg->Draw("x");
28  // dimg->SetDrawOption("X");
29 
30  TPad* p = new TPad("overlay", "Overlay", 0, 0, 1, 1, 0, 0, 0);
31  p->SetFillStyle(0);
32  p->SetFillColor(0);
33  p->SetLineColor(0);
34  p->SetTopMargin(0.01);
35  p->SetRightMargin(0.01);
36  p->SetNumber(10);
37  c->cd();
38  p->Draw();
39  }
40 
41  c->Modified();
42  c->Update();
43  c->cd();
44 
45  return c;
46 }
47 
48 TPair*
49 GetMine(const TString& trigger,
50  Bool_t rebinned=true,
51  Bool_t empirical=true)
52 {
53  gROOT->SetMacroPath(Form("%s:%s", gROOT->GetMacroPath(),
54  "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta"));
55 
56  if (!gROOT->GetClass("Drawer")) gROOT->LoadMacro("Drawer.C++");
57 
58  TString system("pPb");
59  TString system2("Pbp");
60  UShort_t sNN = 5023;
61 
62  TString t1(trigger); t1.ReplaceAll("X", "A");
63  TString t2(trigger); t2.ReplaceAll("X", "C");
64  THStack* s1 = Drawer::GetStack(0, system, sNN, t1, rebinned, empirical);
65  THStack* s2 = Drawer::GetStack(0, system2, sNN, t2, rebinned, empirical);
66 
67  if (!s1 || !s2) return 0;
68 
69  THStack* res = Drawer::Symmetrice(s1, s2);
70  TPair* ret = new TPair(res, 0);
71 
72  TMultiGraph* other = Drawer::GetOther(system, sNN, t1);
73  if (!other)
74  Warning("", "No other data for %s,%d,%s",
75  system.Data(),sNN,trigger.Data());
76  else
77  ret->SetValue(other);
78 
79  return ret;
80 }
81 
82 void CompareMuonDensity(const char* trig)
83 {
84  gStyle->SetFrameLineStyle(0);
85 
86  const char* png
87  = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta/dNdeta_muon.png";
88  TCanvas* c = MakeCanvas("CompareMuonDensity", "Muon",
89  gSystem->ExpandPathName(png));
90 
91  TPair* mine = GetMine(trig);
92  if (!mine) {
93  Warning("", "Didn't get mine");
94  return;
95  }
96  mine->Print();
97 
98  TVirtualPad* p = c->GetPad(10);
99  if (!p) {
100  Error("CompareMuon", "No overlay pad");
101  return;
102  }
103  p->SetTopMargin(0.08);
104  p->SetRightMargin(0.06);
105  p->SetBottomMargin(0.16);
106  p->SetLeftMargin(0.18);
107  // p->SetFillStyle(1001);
108  // p->SetFillColor(kRed);
109  p->Modified();
110  p->Update();
111 
112  p->cd();
113  THStack* data = static_cast<THStack*>(mine->Key());
114  data->SetTitle(Form("1/N dN_{ch}/d#eta (%s) and 1/#deltac dN_{#mu}/d#eta",
115  trig));
116  data->Draw("nostack y+");
117  data->GetHistogram()->GetXaxis()->SetRangeUser(-4.5,4.5);
118  data->GetHistogram()->GetXaxis()->SetLabelSize(0);
119  data->GetHistogram()->GetYaxis()->SetNdivisions(305);
120  data->GetHistogram()->GetXaxis()->SetNdivisions(305);
121  // data->SetMaximum(30);
122  if (mine->Value()) {
123  mine->Value()->Draw("p");
124  }
125  TFrame* f =
126  static_cast<TFrame*>(p->GetListOfPrimitives()->FindObject("TFrame"));
127  if (!f) {
128  Warning("", "No frame");
129  }
130  else {
131  f->SetFillStyle(0);
132  }
133 
134  c->Modified();
135  c->Update();
136  c->cd();
137 
138  c->Print(Form("plots/CompareMuonDensity%s.png",trig));
139 }
140 
141 
142 void CompareMuonRatio(const char* trig)
143 {
144  gStyle->SetFrameLineStyle(0);
145 
146  const char* png
147  = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/dndeta/dNdeta_muon_ratio.png";
148  TCanvas* c = MakeCanvas("CompareMuonRatio", "Muon",
149  gSystem->ExpandPathName(png));
150 
151  TPair* mine = GetMine(trig);
152  if (!mine) {
153  Warning("", "Didn't get mine");
154  return;
155  }
156  mine->Print();
157 
158  TVirtualPad* p = c->GetPad(10);
159  if (!p) {
160  Error("CompareMuon", "No overlay pad");
161  return;
162  }
163  p->SetTopMargin(0.08);
164  p->SetRightMargin(0.06);
165  p->SetBottomMargin(0.16);
166  p->SetLeftMargin(0.18);
167  // p->SetFillStyle(1001);
168  // p->SetFillColor(kRed);
169  p->Modified();
170  p->Update();
171 
172  p->cd();
173 
174  THStack* data = static_cast<THStack*>(mine->Key());
175  THStack* ratios = new THStack(*data);
176  TList* dlist = ratios->GetHists();
177  TH1* dperif = static_cast<TH1*>(dlist->Last());
178  dlist->Remove(dperif);
179  TIter dnext(dlist);
180  TH1* dh = 0;
181  while ((dh = static_cast<TH1*>(dnext()))) {
182  dh->Divide(dperif);
183  dh->SetMaximum(37.3);
184  }
185  ratios->SetTitle(Form("R_{cp} for 1/N dN_{ch}/d#eta (%s) "
186  "and 1/#deltac dN_{#mu}/d#eta", trig));
187  ratios->Draw("nostack y+");
188  ratios->GetHistogram()->GetXaxis()->SetRangeUser(-4.5,4.5);
189  ratios->GetHistogram()->GetYaxis()->SetNdivisions(305);
190  ratios->GetHistogram()->GetXaxis()->SetLabelSize(0);
191  ratios->GetHistogram()->GetXaxis()->SetNdivisions(305);
192  // ratios->GetHistogram()->SetMaximum(39);
193 
194  if (mine->Value()) {
195  TMultiGraph* odata = static_cast<TMultiGraph*>(mine->Value());
196  TMultiGraph* oratios = new TMultiGraph;
197  TList* olist = odata->GetListOfGraphs();
198  olist->Sort();
199  TGraphAsymmErrors* operif = static_cast<TGraphAsymmErrors*>(olist->Last());
200  olist->Remove(operif);
201 
202  TIter onext(olist);
203  TGraphAsymmErrors* og = 0;
204  while ((og = static_cast<TGraphAsymmErrors*>(onext())))
205  oratios->Add(Drawer::GOverG(og, operif, 0, 0), "p");
206 
207  oratios->Draw("p");
208  }
209  TFrame* f =
210  static_cast<TFrame*>(p->GetListOfPrimitives()->FindObject("TFrame"));
211  if (!f) {
212  Warning("", "No frame");
213  }
214  else {
215  f->SetFillStyle(0);
216  }
217 
218  c->Modified();
219  c->Update();
220  c->cd();
221 
222  c->Print(Form("plots/CompareMuonRatio%s.png",trig));
223 }
224 
225 void
226 CompareMuon(const char* trig="CENTZNX")
227 {
228  CompareMuonDensity(trig);
229  CompareMuonRatio(trig);
230 }
TPair * GetMine(const TString &trigger, Bool_t rebinned=true, Bool_t empirical=true)
Definition: CompareMuon.C:49
const char * title
Definition: MakeQAPdf.C:26
void CompareMuonRatio(const char *trig)
Definition: CompareMuon.C:142
TSystem * gSystem
TCanvas * c
Definition: TestFitELoss.C:172
void CompareMuonDensity(const char *trig)
Definition: CompareMuon.C:82
static THStack * GetStack(TLegend *legend, const TString &system, UShort_t sNN, const TString &trigger, Bool_t rebinned=true, Bool_t empirical=true, Int_t marker=20)
Definition: Drawer.C:554
static TGraph * GOverG(const TGraph *num, const TGraph *den, const TGraph *dlow, const TGraph *dup, Double_t dx=0)
Definition: Drawer.C:467
unsigned int UInt_t
Definition: External.C:33
static TMultiGraph * GetOther(UShort_t sys, UShort_t sNN, UShort_t trg, UShort_t exps=0xf, Int_t verbose=3)
Definition: Drawer.C:81
void CompareMuon(const char *trig="CENTZNX")
Definition: CompareMuon.C:226
TCanvas * MakeCanvas(const char *name, const char *title, const char *img=0)
Definition: CompareMuon.C:2
static THStack * Symmetrice(THStack *s1, THStack *s2)
Definition: Drawer.C:1040
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
Definition: External.C:196