1 // --- Get a single histogram ----------------------------------------
3 GetOne(const TList* list, const char* which, bool mirror)
6 Error("GetOne", "No list passed");
9 TString n(Form("dndeta%s_rebin05", which));
10 if (mirror) n.Append("_mirror");
12 TObject* o = list->FindObject(n);
14 Error("GetOne", "Object %s not found in %s", n.Data(), list->GetName());
17 TH1* ret = static_cast<TH1*>(o);
18 ret->SetLineColor(ret->GetMarkerColor());
23 // --- Make point-to-point systematic errors -------------------------
25 MakeSysError(TH1* h, Double_t sysErr)
27 TString n(h->GetName());
29 TH1* ret = static_cast<TH1*>(h->Clone(n));
30 ret->SetMarkerStyle(1);
31 ret->SetMarkerSize(0);
32 ret->SetMarkerColor(kBlue-10);
33 ret->SetFillColor(kBlue-10);
34 ret->SetFillStyle(1001);
35 ret->SetLineColor(kBlue-10);
39 for (Int_t i = 1; i <= ret->GetNbinsX(); i++) {
40 Double_t c = ret->GetBinContent(i);
42 ret->SetBinContent(i,0);
43 ret->SetBinError(i,0);
45 Double_t e = c * sysErr/100;
46 ret->SetBinError(i,e);
52 // --- Turn a TGraphAsymmErrors into a histogram ---------------------
53 TH1* Graph2Hist(const TGraphAsymmErrors* g)
55 Int_t nBins = g->GetN();
56 TArrayF bins(nBins+1);
60 Double_t xmin = 10000;
61 Double_t xmax = -10000;
62 for (Int_t i = 0; i < nBins; i++) {
63 Double_t x = g->GetX()[i];
64 Double_t exl = g->GetEXlow()[i];
65 Double_t exh = g->GetEXhigh()[i];
66 xmin = TMath::Min(x-exl, xmin);
67 xmax = TMath::Max(x+exh, xmax);
68 bins.fArray[i] = x-exl;
69 bins.fArray[i+1] = x+exh;
70 Double_t dxi = exh+exl;
71 if (dxi == 0 && i != 0) dxi = bins.fArray[i]-bins.fArray[i-1];
72 if (dx == 0) dx = dxi;
73 else if (dxi != dx) dx = 0;
75 y.fArray[i] = g->GetY()[i];
76 ey.fArray[i] = TMath::Max(g->GetEYlow()[i],g->GetEYhigh()[i]);
79 TString name(g->GetName());
80 TString title(g->GetTitle());
83 h = new TH1D(name.Data(), title.Data(), nBins,
84 bins[0]-dx/2, bins[nBins]+dx/2);
87 h = new TH1D(name.Data(), title.Data(), nBins, bins.fArray);
89 for (Int_t i = 1; i <= nBins; i++) {
90 h->SetBinContent(i, y.fArray[i-1]);
91 h->SetBinError(i, ey.fArray[i-1]);
93 h->SetMarkerStyle(g->GetMarkerStyle());
94 h->SetMarkerColor(g->GetMarkerColor());
95 h->SetMarkerSize(g->GetMarkerSize());
101 // --- Set Histogram properties --------------------------------------
102 void SetAttributes(TH1* h, UShort_t sNN, Int_t which, Bool_t mirror)
104 Int_t marker = (sNN == 900 ? 20 : 21) + (mirror ? 4 : 0);
105 Int_t color = (which == 0 ? kRed+2 :
106 which == 1 ? kMagenta+2 :
108 h->SetMarkerColor(color);
109 h->SetLineColor(color);
110 h->SetMarkerStyle(marker);
114 // --- Get publlished data via script --------------------------------
115 TH1* GetPublished(UShort_t sNN, Bool_t isNSD)
118 Int_t typ = (isNSD ? 4 : 1);
120 ptr = gROOT->ProcessLine(Form("GetSingle(2,1,%d,%d)", sNN, typ));
123 TGraphAsymmErrors* g = reinterpret_cast<TGraphAsymmErrors*>(ptr);
124 TH1* h = Graph2Hist(g);
125 h->SetLineColor(h->GetMarkerColor());
130 // --- Add points to stack -------------------------------------------
132 AddToStack(THStack* stack, UShort_t sNN, Bool_t isNSD,
133 TList* forward, TList* central,
134 Double_t fwdSysErr, Double_t cenSysErr,
135 Double_t strangeCorr)
137 TH1* fd1 = GetOne(forward, "Forward", false);
138 TH1* fd2 = GetOne(forward, "Forward", true);
139 fd1->Scale(1-strangeCorr/100);
140 fd2->Scale(1-strangeCorr/100);
141 TH1* fs1 = MakeSysError(fd1, fwdSysErr);
142 TH1* fs2 = MakeSysError(fd2, fwdSysErr);
147 cd = GetOne(central, "Central", false);
148 cs = MakeSysError(cd, cenSysErr);
151 cd = GetPublished(sNN, isNSD);
153 SetAttributes(fd1, sNN, 0, false);
154 SetAttributes(fd2, sNN, 0, true);
155 if (cd) SetAttributes(cd, sNN, central ? 1 : 2, false);
157 if (cs) stack->Add(cs, "e2");
158 stack->Add(fs1, "e2");
159 stack->Add(fs2, "e2");
160 if (cd) stack->Add(cd, "ep");
161 stack->Add(fd1, "ep");
162 stack->Add(fd2, "ep");
164 Double_t mcd = (cd ? cd->GetMaximum() : 0);
165 Double_t mfs = fs1->GetMaximum();
167 return TMath::Max(mcd, mfs);
170 // --- Find a list in directory --------------------------------------
172 GetList(const TDirectory* d, const char* what)
175 Error("GetList", "No diretory passed");
178 TList* p = static_cast<TList*>(d->Get(Form("%sResults", what)));
180 Error("GetList", "%sResults not found in %s", what, d->GetName());
183 TList* r = static_cast<TList*>(p->FindObject("all"));
185 Error("GetList", "all not found in %s", p->GetName());
194 a->SetTitleFont(132);
195 a->SetLabelFont(132);
196 a->SetTitleSize(0.08);
197 a->SetLabelSize(0.08);
198 a->SetTitleOffset(0.5);
199 a->SetNdivisions(10);
202 // --- Make a stack for a single plot --------------------------------
204 MakeStack(Bool_t isNSD, Bool_t showClusters,
205 Double_t strangeCorr, Double_t maxFactor=1.1)
207 const char* trg = isNSD ? "nsd" : "inel";
208 TFile* f0900 =TFile::Open(Form("forward_dndeta_%s%04d.root",trg,900, "READ"));
209 TFile* f7000 =TFile::Open(Form("forward_dndeta_%s%04d.root",trg,7000,"READ"));
210 if (!f0900 || !f7000) {
211 Error("MakeStack", "Failed to open one or more files (%p, %p)",
215 TList* forward0900 = GetList(f0900, "Forward");
216 TList* forward7000 = GetList(f7000, "Forward");
217 TList* central0900 = 0;
218 TList* central7000 = showClusters ? GetList(f7000, "Central") : 0;
220 THStack* stack = new THStack("stack", "Stack");
226 Double_t fwdSys = TMath::Sqrt(sysDen * sysDen +
231 Info("", "Forward systematic error: %4.1f", fwdSys);
233 AddToStack(stack, 900, isNSD, forward0900, central0900,
234 fwdSys, 5, strangeCorr);
236 AddToStack(stack, 7000, isNSD, forward7000, central7000,
237 fwdSys, 5, strangeCorr);
239 stack->SetMaximum(maxFactor * TMath::Max(m0900, m7000));
247 // --- Draw one stack ------------------------------------------------
249 DrawStack(Bool_t isNSD, Bool_t showClusters,
250 Double_t strangeCorr, Double_t maxFactor=1.1)
252 THStack* stack = MakeStack(isNSD, showClusters, strangeCorr, maxFactor);
253 stack->Draw("nostack ep");
254 stack->GetHistogram()->SetXTitle("#eta");
256 stack->GetHistogram()->SetYTitle("#frac{1}{N} #frac{dN_{ch}}{d#eta}");
258 stack->SetMinimum(.0001);
259 AdjustAxis(stack->GetHistogram()->GetXaxis());
260 AdjustAxis(stack->GetHistogram()->GetYaxis());
261 stack->GetHistogram()->GetXaxis()->SetTitleOffset(1);
263 stack->Draw("nostack ep");
265 TLatex* title = new TLatex(1-gPad->GetRightMargin()-.01,
266 1-gPad->GetTopMargin()-.01,
267 (isNSD ? "NSD" : "INEL"));
269 title->SetTextSize(0.1);
270 title->SetTextFont(132);
271 title->SetTextAlign(33);
272 title->SetTextColor(kBlue+2);
275 return stack->GetMaximum();
278 // --- Draw one stack ------------------------------------------------
280 ExtractData(Bool_t showClusters = true)
282 gROOT->LoadMacro("OtherData.C");
283 gStyle->SetOptTitle(0);
284 gStyle->SetGridColor(kGray);
285 TCanvas* c = new TCanvas("c", "C", 1200, 850);
286 c->SetRightMargin(0.01);
287 c->SetLeftMargin(0.1);
288 c->SetTopMargin(0.02);
289 c->SetBottomMargin(0.15);
295 c->Divide(1, 2, 0, 0);
297 TVirtualPad* p = c->cd(1);
299 p->SetRightMargin(0.02);
302 DrawStack(false, showClusters, 1.5);
306 TLegend* l = new TLegend(.33, .01, .53, .35);
311 TLegendEntry* e = l->AddEntry("", "900GeV", "p");
312 e->SetMarkerStyle(20);
313 e->SetMarkerSize(ms+.1);
314 e = l->AddEntry("", " 7TeV", "p");
315 e->SetMarkerStyle(21);
316 e->SetMarkerSize(ms);
317 e = l->AddEntry("", "Mirrored data", "p");
318 e->SetMarkerStyle(24);
319 e->SetMarkerSize(ms);
322 TLegend* l2 = new TLegend(.5, .01, .8, .35);
323 l2->SetBorderSize(0);
325 l2->SetTextFont(132);
327 l2->SetColumnSeperation(-.05);
328 e = l2->AddEntry("", "Forward", "p");
329 e->SetMarkerStyle(20);
330 e->SetMarkerColor(kRed+2);
331 e->SetLineColor(kRed+2);
332 e->SetMarkerSize(ms);
334 e = l2->AddEntry("", "Central", "p");
335 e->SetMarkerStyle(20);
336 e->SetMarkerColor(kMagenta+2);
337 e->SetLineColor(kMagenta+2);
338 e->SetMarkerSize(ms);
340 e = l2->AddEntry("", "#splitline{Eur.Phys.J.#font[22]{C68}:89-108}"
341 "{Eur.Phys.J.#font[22]{C68}:345--354}", "p");
342 e->SetMarkerStyle(20);
343 e->SetMarkerColor(kBlue+2);
344 e->SetLineColor(kBlue+2);
345 e->SetMarkerSize(ms);
353 p->SetRightMargin(0.02);
354 DrawStack(true, showClusters, 1.5);
356 // TPad, x1, y1, x2, y2, ts, t1, t2, prel
357 gROOT->LoadMacro("AddLogo.C");
358 AddLogo((TPad*)p, .4, p->GetBottomMargin()+.05,
359 .5, .44, 0.08, "", "pp data", true);
362 TString out("dndeta_pp_forward");
363 if (!showClusters) out.Append("_noclusters");
364 c->SaveAs(Form("%s.png", out.Data()));
365 c->SaveAs(Form("%s.eps", out.Data()));