1 #include "SummaryDrawer.C"
3 #include <TMultiGraph.h>
5 class SummarydNdetaDrawer : public SummaryDrawer
22 //____________________________________________________________________
23 void Run(const char* fname="forward_dndeta.root", UShort_t flags=kNormal)
25 // --- Open the file -----------------------------------------------
26 TString filename(fname);
27 TFile* file = TFile::Open(filename.Data(), "READ");
29 Error("Run", "Failed to open \"%s\"", filename.Data());
33 Bool_t forward = flags & kForward;
34 Bool_t central = flags & kCentral;
35 Bool_t sums = flags & kSums;
36 Bool_t results = flags & kResults;
37 Bool_t onlyMB = flags & kMinBias;
38 Bool_t mc = flags & kMC;
39 fPause = flags & kPause;
41 // --- Force MB for pp ---------------------------------------------
43 TCollection* c = GetCollection(file, "ForwardSums");
44 GetParameter(c, "sys", sys);
45 if (sys == 1) onlyMB = true;
47 // --- Test of MC --------------------------------------------------
48 TCollection* mcC = GetCollection(file, "MCTruthSums");
50 TCollection* mcAll = GetCollection(mcC, "all");
51 if (mcAll && GetObject(mcAll, "MCTruth"))
54 // --- Make our canvas ---------------------------------------------
55 TString pdfName(filename);
56 pdfName.ReplaceAll(".root", ".pdf");
57 CreateCanvas(pdfName, flags & kLandscape);
59 // --- Make a Title page -------------------------------------------
60 DrawTitlePage(file, mc, onlyMB);
62 // --- Do each sub-algorithm ---------------------------------------
64 if (forward && sums) DrawSums(file, "Forward", onlyMB);
65 if (forward && results) rF = DrawRes(file, "Forward", onlyMB);
68 if (central && sums) DrawSums(file, "Central", onlyMB);
69 if (central && results) rC = DrawRes(file, "Central", onlyMB);
72 if (mc && sums) DrawSums(file, "MCTruth", onlyMB);
73 if (mc && results) rM = DrawRes(file, "MCTruth", onlyMB);
75 if (rC && rF && results) DrawBoth(rC, rF, rM, file, onlyMB);
81 //____________________________________________________________________
82 TCollection* GetCentCollection(const TCollection* sums,
89 title = TString::Format("%s %s: ", base.Data(), title.Data());
90 if (cLow < 0 || cHigh < 0 || cLow >= cHigh) {
92 title.Append("All selected events");
96 folder.Form("cent%03d_%03d", cLow, cHigh);
97 title.Append(Form("%3d%% - %3d%%", cLow, cHigh));
100 return GetCollection(sums, folder);
103 //____________________________________________________________________
104 void DrawTitlePage(TFile* file, Bool_t mc, Bool_t onlyMB)
106 TCollection* c = GetCollection(file, "ForwardResults");
111 TLatex* ltx = new TLatex(.5, y,
112 "#frac{1}{#it{N}}#kern[.1]"
113 "{#frac{d#it{N_{ch}}}{d#it{#eta}}}");
114 ltx->SetTextSize(0.07);
115 ltx->SetTextFont(42);
116 ltx->SetTextAlign(22);
122 ltx = new TLatex(.5, y, "Simulation input");
124 ltx->SetTextAlign(23);
125 ltx->SetTextFont(42);
126 ltx->SetTextSize(.03);
131 ltx = new TLatex(.5, y, "No centrality");
133 ltx->SetTextAlign(23);
134 ltx->SetTextFont(42);
135 ltx->SetTextSize(.03);
140 DrawResTitle(c, y, onlyMB);
142 PrintCanvas("1/N dN/d#eta");
144 //____________________________________________________________________
145 void DrawBoth(THStack* rC, THStack* rF, THStack* rM,
146 TFile* file, Bool_t onlyMB)
149 Double_t y1 = fLandscape ? 0 : .3;
150 Double_t x2 = fLandscape ? .7 : 1;
151 Double_t x1 = fLandscape ? x2 : 0;
152 Double_t y2 = fLandscape ? 1 : y1;
153 TPad* p1 = new TPad("p1", "p1", 0, y1, x2, 1, 0, 0);
154 TPad* p2 = new TPad("p2", "p2", x1, 0, 1, y2, 0, 0);
162 TIter nextM(rM->GetHists());
163 while ((h = static_cast<TH1*>(nextM()))) rC->Add(h);
166 TIter next(rF->GetHists());
167 while ((h = static_cast<TH1*>(next()))) rC->Add(h);
172 TCollection* fS = GetCollection(file, "ForwardSums");
173 Int_t sys, sNN, trigger;
174 GetParameter(fS, "sNN", sNN);
175 GetParameter(fS, "sys", sys);
176 GetParameter(fS, "trigger", trigger);
178 static_cast<TAxis*>(GetObject(fS, "centAxis"));
179 UShort_t cLow = centAxis && !onlyMB ? centAxis->GetXmin() : 0;
180 UShort_t cHigh = centAxis && !onlyMB ? centAxis->GetXmax() : 100;
182 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/OtherData.C++");
183 // If we have V0AND trigger, get NSD other data
184 Int_t oT = (trigger == 0x2000) ? 0x4 : trigger;
185 TString oC = Form("GetData(%hu,%hu,%hu,%hu,%hu,0xF)",
186 sys, sNN, oT, cLow, cHigh);
188 reinterpret_cast<TMultiGraph*>(gROOT->ProcessLine(oC));
191 // other->Draw("ap");
192 // Double_t oMax = other->GetHistogram()->GetMaximum();
193 // Double_t rMax = rC->GetMaximum("nostack");
194 // other->SetMaximum(1.2*TMath::Max(oMax, rMax));
195 // rC->Draw("same nostack");
197 TIter nextG(other->GetListOfGraphs());
198 while ((g = nextG()))
199 g->DrawClone("same p");
207 TLegend* l = new TLegend(0.01, 0.1, 0.99, 0.99,
208 onlyMB || !centAxis ? "" : "Centralities");
209 l->SetNColumns(fLandscape ? 1 : 2);
212 CleanStack(rC, l, onlyMB ? 0 : centAxis);
214 TIter nextG(other->GetListOfGraphs());
216 while ((g = nextG()))
217 l->AddEntry(g, g->GetTitle(), "p");
223 //____________________________________________________________________
224 void DrawSums(TDirectory* top, const TString& base, bool onlyMB)
226 TCollection* c = GetCollection(top, Form("%sSums", base.Data()));
229 TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis"));
232 Double_t save = fParName->GetTextSize();
233 Double_t xSave = fParVal->GetX();
234 fParName->SetTextSize(0.03);
235 fParVal->SetTextSize(0.03);
239 if (!onlyMB && centAxis) {
244 for (Int_t i = 1; i <= centAxis->GetNbins(); i++) {
245 DrawParameter(y, (i == 1 ? "Centrality classes" : ""),
246 Form("%3d%% - %3d%%",
247 Int_t(centAxis->GetBinLowEdge(i)),
248 Int_t(centAxis->GetBinUpEdge(i))));
251 TH1* cent = GetH1(c, "cent");
252 cent->SetFillColor(kRed+1);
253 cent->SetFillStyle(3001);
254 cent->SetXTitle("Centrality [%]");
255 cent->SetYTitle("Events");
257 DrawInPad(fBody, 2, cent);
261 Int_t sys, sNN, scheme, trigger;
262 GetParameter(c, "sNN", sNN);
263 GetParameter(c, "sys", sys);
264 GetParameter(c, "scheme", scheme);
265 GetParameter(c, "trigger", trigger);
267 TString schemeString;
268 if (scheme == 0) schemeString = "1/N_{accepted}";
269 if (scheme & 0x1) schemeString.Append("1/#epsilon_{V}1/#epsilon_{T}");
270 if (scheme & 0x2) schemeString.Append("Shape ");
271 if (scheme & 0x4) schemeString.Append("A+C-E ");
272 if (scheme & 0x8) schemeString.Append("#epsilon_{T,MC} ");
273 if (scheme & 0x10) schemeString.Append("0-bin");
276 if (trigger & 0x0001) trigString.Append("INEL ");
277 if (trigger & 0x0002) trigString.Append("INEL>0 ");
278 if (trigger & 0x0004) trigString.Append("NSD ");
279 if (trigger & 0x0008) trigString.Append("Empty ");
280 if (trigger & 0x0010) trigString.Append("A ");
281 if (trigger & 0x0020) trigString.Append("B ");
282 if (trigger & 0x0080) trigString.Append("C ");
283 if (trigger & 0x0100) trigString.Append("E ");
284 if (trigger & 0x0200) trigString.Append("Pile-up ");
285 if (trigger & 0x0400) trigString.Append("NSD(MC) ");
286 if (trigger & 0x0800) trigString.Append("Off-line ");
287 if (trigger & 0x1000) trigString.Append("N_{cluster}>0 ");
288 if (trigger & 0x2000) trigString.Append("V0-AND ");
289 if (trigger & 0x4000) trigString.Append("Satellite ");
291 DrawParameter(y, "Collision system", (sys == 1 ? "pp" :
295 DrawParameter(y, "#sqrt{s_{NN}}", Form("%4dGeV", sNN));
296 DrawParameter(y, "Normalization scheme", schemeString);
297 DrawParameter(y, "Triggers", trigString);
299 fParName->SetTextSize(save);
300 fParVal->SetTextSize(save);
301 fParVal->SetX(xSave);
303 PrintCanvas(Form("%s sums", base.Data()));
305 Int_t cLow = centAxis ? centAxis->GetXmin() : 0;
306 Int_t cHigh = centAxis ? -centAxis->GetXmax() : -100;
307 DrawCentSum(c, base, cLow, cHigh);
308 if (onlyMB || !centAxis) return;
310 for (Int_t i = 1; i <= centAxis->GetNbins(); i++)
311 DrawCentSum(c, base, centAxis->GetBinLowEdge(i),
312 centAxis->GetBinUpEdge(i));
314 //____________________________________________________________________
315 void DrawCentSum(const TCollection* sums, const TString& base,
316 Int_t cLow, Int_t cHigh)
318 TString title("sums");
319 TCollection* c = GetCentCollection(sums, base, cLow, cHigh, title);
322 TH1* type = GetH1(c, Form("%sEvents",base.Data()));
323 TH2* bin0 = GetH2(c, Form("%s0", base.Data()));
324 TH1* trig = GetH1(c, "triggers");
325 TH2* bin = GetH2(c, base.Data());
326 if (!bin0 || !bin || !trig || !type) return;
328 type->SetFillStyle(3001);
329 type->SetFillColor(kGreen+1);
333 DrawInPad(fBody, 1, trig, "HIST TEXT");
334 DrawInPad(fBody, 2, type, "HIST TEXT");
335 DrawInPad(fBody, 3, bin, "colz");
336 DrawInPad(fBody, 4, bin0, "colz");
338 if (bin0->GetEntries() <= 0) {
340 TLatex* l = new TLatex(0.5, 0.5, "No 0-bin events");
347 //____________________________________________________________________
348 void DrawResTitle(TCollection* c, Double_t& y, Bool_t onlyMB)
350 Double_t save = fParName->GetTextSize();
351 Double_t xSave = fParVal->GetX();
352 fParName->SetTextSize(0.03);
353 fParVal->SetTextSize(0.03);
356 TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis"));
357 if (!onlyMB && centAxis) {
358 for (Int_t i = 1; i <= centAxis->GetNbins(); i++) {
359 DrawParameter(y, (i == 1 ? "Centrality classes" : ""),
360 Form("%3d%% - %3d%%",
361 Int_t(centAxis->GetBinLowEdge(i)),
362 Int_t(centAxis->GetBinUpEdge(i))));
365 TObject* oSNN = GetObject(c,"sNN");
367 UShort_t sNN = oSNN->GetUniqueID();
369 if ((sNN % 1000) == 0)
370 tSNN = TString::Format("%dTeV", sNN/1000);
372 tSNN = TString::Format("%-5.2fTeV", float(sNN) / 1000);
375 tSNN = TString::Format("%dGeV", sNN);
377 DrawParameter(y, "Collision system", GetObject(c, "sys")->GetTitle());
378 DrawParameter(y, "#sqrt{s_{NN}}",tSNN);
379 DrawParameter(y, "Trigger",GetObject(c,"trigger")->GetTitle());
380 TObject* oscheme = GetObject(c,"scheme");
381 TString scheme = oscheme->GetTitle();
382 if (scheme.IsNull()) scheme = "1/N_{accepted}";
383 DrawParameter(y, "Normalization scheme", scheme);
385 Double_t epsT, epsT0;
386 GetParameter(c, "triggerEff", epsT);
387 GetParameter(c, "triggerEff0", epsT0);
388 DrawParameter(y, "#epsilon_{T}", Form("%5.3f", epsT));
389 DrawParameter(y, "#epsilon_{T,zero bin}", Form("%5.3f", epsT0));
391 TObject* options = GetObject(c, "options");
392 TString opts(options->GetTitle());
393 TObjArray* tokens = opts.Tokenize(",");
394 TObjString* opt = 0;;
397 while ((opt = static_cast<TObjString*>(oNext()))) {
398 DrawParameter(y, (first ? "options" : ""),
399 opt->String().Strip(TString::kBoth));
402 fParName->SetTextSize(save);
403 fParVal->SetTextSize(save);
404 fParVal->SetX(xSave);
407 //____________________________________________________________________
408 THStack* DrawRes(TDirectory* top, const TString& base, Bool_t onlyMB)
410 TCollection* c = GetCollection(top, Form("%sResults", base.Data()));
415 DrawResTitle(c, y, onlyMB);
416 PrintCanvas(Form("%s results", base.Data()));
418 TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis"));
419 TLegend* l = new TLegend(0.1, 0.1, 0.9, 0.9,
420 onlyMB || !centAxis? "" : "Centralities");
425 THStack* dndeta_ = GetStack(c, "dndeta");
426 THStack* dndeta5_ = GetStack(c, "dndeta_rebin05");
427 THStack* dndeta = CleanStack(dndeta_, l, centAxis);
428 THStack* dndeta5 = CleanStack(dndeta5_, 0, 0);
431 fBody->Divide(1, 3, 0, 0);
433 DrawInPad(fBody, 1, l, "");
434 DrawInPad(fBody, 2, dndeta, "nostack");
435 DrawInPad(fBody, 3, dndeta5, "nostack");
436 fBody->GetPad(2)->SetGridx();
437 fBody->GetPad(3)->SetGridx();
439 PrintCanvas(Form("%s results - stacks", base.Data()));
442 Int_t cLow = centAxis ? centAxis->GetXmin() : 0;
443 Int_t cHigh = centAxis ? -centAxis->GetXmax() : -100;
444 DrawCentRes(c, base, cLow, cHigh);
445 if (onlyMB || !centAxis) {
446 Info("", "Returning dndeta for MB");
447 dndeta = MakeMBStack(c, base);
451 for (Int_t i = 1; i <= centAxis->GetNbins(); i++)
452 DrawCentRes(c, base, centAxis->GetBinLowEdge(i),
453 centAxis->GetBinUpEdge(i));
457 //____________________________________________________________________
458 THStack* MakeMBStack(const TCollection* sums, const TString& base)
460 TString title("results");
461 TCollection* c = GetCentCollection(sums, base, 0, -1, title);
464 TH1* dndeta = GetH1(c, Form("dndeta%s",base.Data()));
465 if (!dndeta) return 0;
467 THStack* ret = new THStack("dndetaMB", title);
470 if (base.EqualTo("MCTruth")) {
471 dndeta = GetH1(c, "dndetaTruth");
472 if (dndeta) ret->Add(dndeta);
477 //____________________________________________________________________
478 void DrawCentRes(const TCollection* sums, const TString& base,
479 Int_t cLow, Int_t cHigh)
481 TString title("results");
482 TCollection* c = GetCentCollection(sums, base, cLow, cHigh, title);
486 TH1* trig = GetH1(c, "triggers");
487 TH1* norm = GetH1(c, Form("norm%s",base.Data()));
488 TH1* dndeta = GetH1(c, Form("dndeta%s",base.Data()));
489 TH2* d2ndetadphi = GetH2(c, Form("d2Ndetadphi%s", base.Data()));
490 if (!trig || !norm || !dndeta || !d2ndetadphi) return;
492 norm->SetFillColor(kGreen+1);
493 norm->SetFillStyle(3001);
495 fBody->Divide(2, 3, 0.05, 0);
498 TVirtualPad* p = fBody->GetPad(trP);
499 p->SetBottomMargin(0.15);
500 p->SetLeftMargin(0.15);
501 if (trP > 2) p->SetTopMargin(0.05);
503 DrawInPad(fBody, trP, trig, "HIST TEXT");
504 DrawInPad(fBody, 2, norm);
505 DrawInPad(fBody, 4, dndeta);
506 DrawInPad(fBody, 6, GetH1(c, Form("dndeta%s_rebin05",base.Data())));
507 DrawInPad(fBody, 5, d2ndetadphi, "colz");
509 fBody->GetPad(2)->SetGridx(); fBody->GetPad(2)->SetLeftMargin(0.15);
510 fBody->GetPad(4)->SetGridx(); fBody->GetPad(4)->SetLeftMargin(0.15);
511 fBody->GetPad(6)->SetGridx(); fBody->GetPad(6)->SetLeftMargin(0.15);
513 TObject* normCalc = GetObject(c, "normCalc");
514 TString calc = normCalc ? normCalc->GetTitle() : "?";
517 calc.ReplaceAll("beta", "#beta");
518 calc.ReplaceAll("eps", "#epsilon");
519 const char* sufs[] = { "all", "acc", "trg", "vtx", "B", "A", "C", "E",
521 const char** suf = sufs;
523 calc.ReplaceAll(Form("_%s", *suf), Form("_{%s}", *suf));
528 TObjArray* lines = calc.Tokenize("\n");
529 // TPaveText* disp = new TPaveText(.1,.1,.9,.9, "NDC");
531 TObjString* sline = 0;
533 Double_t xSave = fParName->GetX();
534 Int_t aSave = fParName->GetTextAlign();
535 fParName->SetTextAlign(33);
536 fParName->SetX(fParVal->GetX()-.05);
537 while ((sline = static_cast<TObjString*>(next()))) {
538 // disp->AddText(line->GetName());
539 TString& line = sline->String();
540 Ssiz_t eq = line.Last('=');
542 DrawParameter(y, line, "");
545 TString name = line(0, eq);
546 TString val = line(eq+1,line.Length()-eq-1);
547 DrawParameter(y, name.Strip(TString::kBoth),
548 val.Strip(TString::kBoth));
551 fParName->SetTextAlign(aSave);
552 fParName->SetX(xSave);
553 // disp->SetBorderSize(0);
554 // disp->SetBorderSize(0);
555 // disp->SetFillStyle(0);
556 // DrawInPad(fBody, 3, disp);
561 DrawCentResDetails(c, title);
563 //____________________________________________________________________
564 void DrawCentResDetails(const TCollection* sums, const TString& base)
566 TString title = TString::Format("%s - details: ", base.Data());
568 TCollection* c = GetCollection(sums, "partial");
570 Warning("", "Collection partical not found in %s", sums->GetName());
575 fBody->Divide(3, 1, 0.05, 0);
577 const char* typs[] = { "", "0", "All" };
578 const char* tits[] = { "Non-zero events", "Zero events", "Weighted sum" };
579 for (Int_t i = 1; i <= 3; i++) {
580 const char* suf = typs[i-1];
581 TVirtualPad* p = fBody->cd(i);
582 p->SetTopMargin(0.10);
584 TLatex* ltx = new TLatex(0.5, .99, tits[i-1]);
586 ltx->SetTextAlign(23);
587 ltx->SetTextSize(0.05);
590 TH1* sum = GetH2(c, Form("sum%s", suf));
591 TH1* norm = GetH1(c, Form("norm%s", suf));
592 TH1* phi = GetH1(c, Form("phi%s", suf));
594 norm->SetFillColor(kGreen+1);
595 norm->SetFillStyle(3002);
596 phi->SetFillColor(kBlue+1);
597 phi->SetFillStyle(3001);
599 p->Divide(1, 3, 0, 0);
600 DrawInPad(p, 1, sum, sum->Integral()>0 ? "col" : "");
601 DrawInPad(p, 2, GetH1(c, Form("average%s", suf)), "");
602 DrawInPad(p, 3, norm);
603 DrawInPad(p, 3, phi, "same", 0x10);
608 //____________________________________________________________________
609 THStack* CleanStack(const THStack* stack, TLegend* l, const TAxis* axis)
611 THStack* ret = new THStack(stack->GetName(), stack->GetTitle());
612 TList* hists = stack->GetHists();
617 while ((h = static_cast<TH1*>(next()))) {
618 TString name(h->GetTitle());
619 if (name.Contains("_mirror")) continue;
623 name.Form("%3d%% - %3d%%",
624 Int_t(axis->GetBinLowEdge(j)),
625 Int_t(axis->GetBinUpEdge(j)));
626 ok = axis && axis->GetBinUpEdge(j) > 100;
627 TLegendEntry* e = l->AddEntry("dummy", name, "f");
628 e->SetFillStyle(1001);
629 e->SetFillColor(h->GetMarkerColor());