]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/scripts/SummarydNdetaDrawer.C
c39f5524f9c133eebeb3e956c417880c717a2ff4
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / scripts / SummarydNdetaDrawer.C
1 #include "SummaryDrawer.C"
2 #include <TPaveText.h>
3 #include <TMultiGraph.h>
4
5 class SummarydNdetaDrawer : public SummaryDrawer
6 {
7 public:
8   enum { 
9     kForward   = 0x01,
10     kCentral   = 0x02, 
11     kSums      = 0x04, 
12     kResults   = 0x08, 
13     kMinBias   = 0x10, 
14     kMC        = 0x80,
15     kNormal    = 0x0F
16   };
17   SummarydNdetaDrawer() 
18     : SummaryDrawer()
19   {}
20   const char* ColName(const char* prefix, bool results=false)
21   {
22     return Form("%sdNdeta%s", prefix, results ? "Results" : "Sums");
23   }
24   //____________________________________________________________________
25   void Run(const char* fname="forward_dndeta.root", UShort_t flags=kNormal)
26   {
27     // --- Open the file -----------------------------------------------
28     TString filename(fname);
29     TFile* file = TFile::Open(filename.Data(), "READ");
30     if (!file) { 
31       Error("Run", "Failed to open \"%s\"", filename.Data());
32       return;
33     }
34     // Options 
35     Bool_t forward = flags & kForward;
36     Bool_t central = flags & kCentral;
37     Bool_t sums    = flags & kSums;
38     Bool_t results = flags & kResults;
39     Bool_t onlyMB  = flags & kMinBias;
40     Bool_t mc      = flags & kMC;
41     fPause         = flags & kPause;
42     
43     // --- Force MB for pp ---------------------------------------------
44     UShort_t     sys = 0;
45     TCollection* c   = GetCollection(file, ColName("Forward", false));
46     GetParameter(c, "sys", sys); 
47     if (sys == 1) {
48       onlyMB = true;
49       Info("Run", "Found sys==1 -> Forcing MB");
50     }
51
52     // --- Test of MC --------------------------------------------------
53     TCollection* mcC = GetCollection(file, ColName("MCTruth"), false);
54     if (mcC) { 
55       TCollection* mcAll = GetCollection(mcC, "all");
56       if (mcAll && GetObject(mcAll, "sum")) {
57         Info("Run", "Found MC truth output");
58         mc = true;
59       }
60     }
61     // --- Make our canvas ---------------------------------------------
62     TString pdfName(filename);
63     pdfName.ReplaceAll(".root", ".pdf");
64     CreateCanvas(pdfName, flags & kLandscape);
65
66     // --- Make a Title page -------------------------------------------
67     DrawTitlePage(file, mc, onlyMB);
68
69     // --- Do each sub-algorithm ---------------------------------------
70     THStack* rF = 0;
71     if (forward && sums)    DrawSums(file, "Forward", onlyMB);
72     if (forward && results) rF = DrawRes(file, "Forward", onlyMB);
73     
74     THStack* rC = 0;
75     if (central && sums)    DrawSums(file, "Central", onlyMB);
76     if (central && results) rC = DrawRes(file, "Central", onlyMB);
77
78     THStack* rM = 0;
79     if (mc && sums)    DrawSums(file, "MCTruth", onlyMB);
80     if (mc && results) rM = DrawRes(file, "MCTruth", onlyMB);
81
82     if (rC && rF && results) DrawBoth(rC, rF, rM, file, onlyMB);
83   
84     CloseCanvas();
85   }
86
87 protected:
88   //____________________________________________________________________
89   TCollection* GetCentCollection(const TCollection* sums, 
90                                  const TString&     base, 
91                                  Int_t              cLow, 
92                                  Int_t              cHigh,
93                                  TString&           title)
94   {
95     TString folder; 
96     title = TString::Format("%s %s: ", base.Data(), title.Data());
97     if (cLow < 0 || cHigh < 0 || cLow >= cHigh) {
98       folder = "all";
99       title.Append("All selected events");
100       cHigh  *= -1;
101     }
102     else {
103       folder.Form("cent%03d_%03d", cLow, cHigh);
104       title.Append(Form("%3d%% - %3d%%", cLow, cHigh));
105     }
106     
107     return GetCollection(sums, folder);
108     
109   }
110   //____________________________________________________________________
111   void DrawTitlePage(TFile* file, Bool_t mc, Bool_t onlyMB)
112   {
113     TCollection* c   = GetCollection(file, ColName("Forward", true));
114
115     fBody->cd();
116     
117     Double_t y = .9;
118     TLatex* ltx = new TLatex(.5, y, 
119                              "#frac{1}{#it{N}}#kern[.1]"
120                              "{#frac{d#it{N_{ch}}}{d#it{#eta}}}");
121     ltx->SetTextSize(0.07);
122     ltx->SetTextFont(42);
123     ltx->SetTextAlign(22);
124     ltx->SetNDC();
125     ltx->Draw();
126     y -= .075;
127     
128     if (mc) {
129       ltx = new TLatex(.5, y, "Simulation input");
130       ltx->SetNDC();
131       ltx->SetTextAlign(23);
132       ltx->SetTextFont(42);
133       ltx->SetTextSize(.03);
134       ltx->Draw();
135       y -= .035;
136     }
137     if (onlyMB) {
138       ltx = new TLatex(.5, y, "No centrality");
139       ltx->SetNDC();
140       ltx->SetTextAlign(23);
141       ltx->SetTextFont(42);
142       ltx->SetTextSize(.03);
143       ltx->Draw();
144       y -= .035;
145     }
146     
147     DrawResTitle(c, y, onlyMB);
148
149     PrintCanvas("1/N dN/d#eta");
150   }
151   //____________________________________________________________________
152   void DrawBoth(THStack* rC, THStack* rF, THStack* rM, 
153                 TFile* file, Bool_t onlyMB)
154   {
155     fBody->cd();
156     Double_t y1 = fLandscape ? 0  : .3;
157     Double_t x2 = fLandscape ? .7 : 1;
158     Double_t x1 = fLandscape ? x2 : 0;
159     Double_t y2 = fLandscape ? 1  : y1;
160     TPad* p1 = new TPad("p1", "p1", 0,  y1, x2, 1,  0, 0);
161     TPad* p2 = new TPad("p2", "p2", x1, 0,  1,  y2, 0, 0);
162
163     fBody->cd();
164     p1->Draw();
165     p1->cd();
166
167     TH1*  h  = 0;
168     if (rM) { 
169       TIter nextM(rM->GetHists());
170       while ((h = static_cast<TH1*>(nextM()))) rC->Add(h);
171     }
172
173     TIter next(rF->GetHists());
174     while ((h = static_cast<TH1*>(next()))) rC->Add(h);
175
176
177     rC->Draw("nostack");
178
179     TCollection* fS = GetCollection(file, ColName("Forward", false));
180     UShort_t sys, sNN;
181     ULong_t trigger;
182     GetParameter(fS, "sNN",     sNN); 
183     GetParameter(fS, "sys",     sys); 
184     GetParameter(fS, "trigger", trigger); 
185     TAxis* centAxis = 
186       static_cast<TAxis*>(GetObject(fS, "centAxis", false));
187     UShort_t cLow  = centAxis && !onlyMB ? centAxis->GetXmin() : 0;
188     UShort_t cHigh = centAxis && !onlyMB ? centAxis->GetXmax() : 100;
189
190     CompileScript("OtherData.C", "", "RefData", false);
191
192     // If we have V0AND trigger, get NSD other data
193     TMultiGraph* other = 0;
194     if (!centAxis) {
195       Int_t   oT = (trigger == 0x2000) ? 0x4 : trigger;
196       TString oC = Form("RefData::GetData(%hu,%hu,%hu,%hu,%hu,0xF)", 
197                         sys, sNN, oT, cLow, cHigh);
198       other = reinterpret_cast<TMultiGraph*>(gROOT->ProcessLine(oC));
199     }
200     else { 
201       other = new TMultiGraph("other", "");
202       Int_t nCent = centAxis->GetNbins();
203       for (Int_t i = 1; i <= nCent; i++) { 
204         TString oC = Form("RefData::GetData(%hu,%hu,%hu,%hu,%hu,0xF)", 
205                           sys, sNN, 0, UShort_t(centAxis->GetBinLowEdge(i)),
206                           UShort_t(centAxis->GetBinUpEdge(i)));
207         TMultiGraph* oM = 
208           reinterpret_cast<TMultiGraph*>(gROOT->ProcessLine(oC));
209         if (oM) other->Add(oM);
210       }
211     }
212     if (other) {
213       // p1->Clear();
214       // other->Draw("ap");
215       // Double_t oMax = other->GetHistogram()->GetMaximum();
216       // Double_t rMax = rC->GetMaximum("nostack");
217       // other->SetMaximum(1.2*TMath::Max(oMax, rMax));
218       // rC->Draw("same nostack");
219       TObject* g = 0;
220       TIter    nextG(other->GetListOfGraphs());
221       while ((g = nextG())) {
222         // Printf("Drawing %s/%s", g->GetName(), g->GetTitle());
223         g->DrawClone("same p");
224       }
225     }
226     
227
228     fBody->cd();
229     p2->Draw();
230     p2->cd();
231
232
233     TLegend* l = new TLegend(0.01, 0.1, 0.99, 0.99, 
234                              onlyMB || !centAxis ? "" : "Centralities");
235     l->SetNColumns(fLandscape ? 1 : 2);
236     l->SetFillStyle(0);
237     l->SetBorderSize(0);
238     CleanStack(rC, l, onlyMB ? 0 : centAxis);
239     TString seen;
240     if (other) { 
241       TIter nextG(other->GetListOfGraphs());
242       TObject* g = 0;
243       while ((g = nextG())) {
244         if (seen.Index(g->GetTitle()) != kNPOS) continue;
245         seen.Append(Form("|%s", g->GetTitle()));
246         TLegendEntry* e = l->AddEntry("dummy", g->GetTitle(), "p");
247         TGraph* gg = static_cast<TGraph*>(g);
248         e->SetMarkerStyle(gg->GetMarkerStyle());
249         e->SetMarkerSize(gg->GetMarkerSize());
250         e->SetMarkerColor(kBlack);
251       }
252     }
253     l->Draw();
254
255     PrintCanvas("Both");
256   }
257   //____________________________________________________________________
258   void DrawSums(TDirectory* top, const TString& base, bool onlyMB)
259   {
260     TCollection* c = GetCollection(top, ColName(base));
261     if (!c) return;
262     
263     TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis", false));
264     if (centAxis->GetNbins() < 1) centAxis = 0;
265
266     Int_t   txtPad = 0;
267     Double_t save  = fParName->GetTextSize();
268     Double_t xSave = fParVal->GetX();
269     fParName->SetTextSize(0.03);
270     fParVal->SetTextSize(0.03);
271     fParVal->SetX(.45);
272     Double_t y = .8;
273     
274     if (!onlyMB && centAxis) {
275       fBody->Divide(1, 2);
276       txtPad = 1;
277     
278       fBody->cd(1);
279       for (Int_t i = 1; i <= centAxis->GetNbins(); i++) { 
280         DrawParameter(y, (i == 1 ? "Centrality classes" : ""),
281                       Form("%3d%% - %3d%%", 
282                            Int_t(centAxis->GetBinLowEdge(i)), 
283                            Int_t(centAxis->GetBinUpEdge(i))));
284       }
285     
286       TH1* cent = GetH1(c, "cent");
287       cent->SetFillColor(kRed+1);
288       cent->SetFillStyle(3001);
289       cent->SetXTitle("Centrality [%]");
290       cent->SetYTitle("Events");
291       
292       DrawInPad(fBody, 2, cent);
293     }
294     fBody->cd(txtPad);
295     
296     UShort_t sys, sNN, scheme;
297     ULong_t trigger;
298     GetParameter(c, "sNN",     sNN); 
299     GetParameter(c, "sys",     sys); 
300     GetParameter(c, "scheme",  scheme); 
301     GetParameter(c, "trigger", trigger); 
302
303     TString schemeString;
304     if (scheme == 0)   schemeString = "1/N_{accepted}";
305     if (scheme & 0x1)  schemeString.Append("1/#epsilon_{V}1/#epsilon_{T}");
306     if (scheme & 0x2)  schemeString.Append("Shape ");
307     if (scheme & 0x4)  schemeString.Append("A+C-E ");
308     if (scheme & 0x8)  schemeString.Append("#epsilon_{T,MC} ");
309     if (scheme & 0x10) schemeString.Append("0-bin");
310
311     TString trigString;   TriggerString(trigger, trigString);
312     TString sysString;    SysString(sys, sysString);
313     TString sNNString;    SNNString(sNN, sNNString);
314     
315     DrawParameter(y, "Collision system",     sysString);
316     DrawParameter(y, "#sqrt{s_{NN}}",        sNNString);
317     DrawParameter(y, "Normalization scheme", schemeString);
318     DrawParameter(y, "Triggers",             trigString);
319     
320     fParName->SetTextSize(save);
321     fParVal->SetTextSize(save);
322     fParVal->SetX(xSave);
323
324     PrintCanvas(Form("%s sums", base.Data()));
325
326     Int_t cLow = centAxis  ?  centAxis->GetXmin() : 0;
327     Int_t cHigh = centAxis ? -centAxis->GetXmax() : -100;
328     DrawCentSum(c, base, cLow, cHigh);
329     if (onlyMB || !centAxis) return;
330
331     for (Int_t i = 1; i <= centAxis->GetNbins(); i++) 
332       DrawCentSum(c, base, centAxis->GetBinLowEdge(i), 
333                   centAxis->GetBinUpEdge(i));
334   }
335   //____________________________________________________________________
336   void DrawCentSum(const TCollection* sums, const TString& base, 
337                    Int_t cLow, Int_t cHigh)
338   {
339     TString title("sums");
340     TCollection* c = GetCentCollection(sums, base, cLow, cHigh, title);
341     if (!c) return;
342     
343     TH2* bin  = GetH2(c, "sum");
344     TH2* bin0 = GetH2(c, "sum0");
345     TH1* type = GetH1(c, "events");
346     TH1* trig = GetH1(c, "triggers");
347     if (!bin0 || !bin || !trig || !type) return;
348
349     type->SetFillStyle(3001);
350     type->SetFillColor(kGreen+1);
351
352     fBody->Divide(2, 2);
353
354     DrawInPad(fBody, 1, trig, "HIST TEXT");
355     DrawInPad(fBody, 2, type, "HIST TEXT");
356     DrawInPad(fBody, 3, bin,  "colz");
357     DrawInPad(fBody, 4, bin0, "colz");
358     
359     if (bin0->GetEntries() <= 0) {
360       fBody->cd(4);
361       TLatex* l = new TLatex(0.5, 0.5, "No 0-bin events");
362       l->SetNDC();
363       l->SetTextAlign(22);
364       l->Draw();
365     }
366     PrintCanvas(title);
367   }
368   //____________________________________________________________________
369   void DrawResTitle(TCollection* c, Double_t& y, Bool_t onlyMB)
370   {
371     Double_t save  = fParName->GetTextSize();
372     Double_t xSave = fParVal->GetX();
373     fParName->SetTextSize(0.03);
374     fParVal->SetTextSize(0.03);
375     fParVal->SetX(.5);
376     // Double_t y = .9;
377     TAxis*   centAxis = static_cast<TAxis*>(GetObject(c, "centAxis", false));
378     if (!onlyMB && centAxis) {
379       for (Int_t i = 1; i <= centAxis->GetNbins(); i++) { 
380         DrawParameter(y, (i == 1 ? "Centrality classes" : ""),
381                       Form("%3d%% - %3d%%", 
382                            Int_t(centAxis->GetBinLowEdge(i)), 
383                            Int_t(centAxis->GetBinUpEdge(i))));
384       }
385     }
386     TObject* oSNN = GetObject(c, "sNN");
387     TString  tSNN; SNNString(oSNN->GetUniqueID(), tSNN);
388
389     DrawParameter(y, "Collision system", GetObject(c, "sys")->GetTitle());
390     DrawParameter(y, "#sqrt{s_{NN}}",tSNN);
391     DrawParameter(y, "Trigger",GetObject(c,"trigger")->GetTitle());
392     TObject* oscheme = GetObject(c,"scheme");
393     TString  scheme  = oscheme ? oscheme->GetTitle() : "";
394     if (scheme.IsNull()) scheme = "1/N_{accepted}";
395     DrawParameter(y, "Normalization scheme", scheme);
396     
397     Double_t epsT, epsT0;
398     GetParameter(c, "triggerEff",  epsT);
399     GetParameter(c, "triggerEff0", epsT0);
400     DrawParameter(y, "#epsilon_{T}", Form("%5.3f", epsT));
401     DrawParameter(y, "#epsilon_{T,zero bin}", Form("%5.3f", epsT0));
402
403     TObject*    options = GetObject(c, "options");
404     TString     opts(options->GetTitle());
405     TObjArray*  tokens = opts.Tokenize(",");
406     TObjString* opt = 0;;
407     TIter       oNext(tokens);
408     Bool_t      first  = true;
409     while ((opt = static_cast<TObjString*>(oNext()))) { 
410       DrawParameter(y, (first ? "options" : ""), 
411                     opt->String().Strip(TString::kBoth));
412       first = false;
413     }
414     fParName->SetTextSize(save);
415     fParVal->SetTextSize(save);
416     fParVal->SetX(xSave);      
417   }
418
419   //____________________________________________________________________
420   THStack* DrawRes(TDirectory* top, const TString& base, Bool_t onlyMB)
421   {
422     TCollection* c = GetCollection(top, ColName(base, true));
423     if (!c) return 0;
424
425     fBody->cd();
426     Double_t y = .9;
427     DrawResTitle(c, y, onlyMB);
428     PrintCanvas(Form("%s results", base.Data()));
429
430     TAxis*   centAxis = static_cast<TAxis*>(GetObject(c, "centAxis", false));
431     if (centAxis->GetNbins() < 1) centAxis = 0;
432
433     TLegend* l = new TLegend(0.1, 0.1, 0.9, 0.9, 
434                              onlyMB || !centAxis? "" : "Centralities");
435     l->SetNColumns(fLandscape ? 1 : 2);
436     l->SetFillStyle(0);
437     l->SetBorderSize(0);
438
439     THStack* dndeta_  = GetStack(c, "dndeta");
440     THStack* dndeta5_ = GetStack(c, "dndeta_rebin05");
441     THStack* dndeta   = CleanStack(dndeta_, l, centAxis);
442     THStack* dndeta5  = CleanStack(dndeta5_, 0, 0);
443
444     if (!onlyMB) {
445       Double_t y1 = fLandscape ? 0  : .3;
446       Double_t x2 = fLandscape ? .7 : 1;
447       Double_t x1 = fLandscape ? x2 : 0;
448       Double_t y2 = fLandscape ? 1  : y1;
449       TPad* p1 = new TPad("p1", "p1", 0,  y1, x2, 1,  0, 0);
450       TPad* p2 = new TPad("p2", "p2", x1, 0,  1,  y2, 0, 0);
451       fBody->cd();
452       p1->Draw();
453       p1->cd();
454       fBody->cd();
455       p2->Draw();
456       p2->cd();
457       p1->Divide(1,2,0,0);
458
459       // fBody->Divide(1, 3, 0, 0);
460       
461       DrawInPad(p2, 0, l, "");
462       DrawInPad(p1, 1, dndeta,  "nostack");
463       DrawInPad(p1, 2, dndeta5, "nostack");
464       p1->GetPad(1)->SetGridx();
465       p1->GetPad(2)->SetGridx();
466       
467       PrintCanvas(Form("%s results - stacks", base.Data()));
468     }
469
470     Int_t cLow = centAxis  ?  centAxis->GetXmin() : 0;
471     Int_t cHigh = centAxis ? -centAxis->GetXmax() : -100;
472     DrawCentRes(c, base, cLow, cHigh);
473     if (onlyMB || !centAxis) {
474       Info("", "Returning dndeta for MB");
475       dndeta = MakeMBStack(c, base);
476       return dndeta;
477     }
478
479     for (Int_t i = 1; i <= centAxis->GetNbins(); i++) 
480       DrawCentRes(c, base, centAxis->GetBinLowEdge(i), 
481                   centAxis->GetBinUpEdge(i));
482     
483     return dndeta;
484   }
485   //____________________________________________________________________
486   THStack* MakeMBStack(const TCollection* sums, const TString& base)
487   {
488     TString title("results");
489     TCollection* c = GetCentCollection(sums, base, 0, -1, title);
490     if (!c) return 0;
491
492     TH1* dndeta      = GetH1(c, Form("dndeta%s",base.Data()));
493     if (!dndeta) return 0;
494
495     THStack* ret = new THStack("dndetaMB", title);
496     ret->Add(dndeta);
497
498     if (base.EqualTo("MCTruth")) {
499       dndeta      = GetH1(c, "dndetaTruth");
500       if (dndeta) ret->Add(dndeta);
501     }
502     return ret;
503   }
504       
505   //____________________________________________________________________
506   void DrawCentRes(const TCollection* sums, const TString& base, 
507                    Int_t cLow, Int_t cHigh)
508   {
509     TString title("results");
510     TCollection* c = GetCentCollection(sums, base, cLow, cHigh, title);
511     if (!c) return;
512
513
514     TH1* trig        = GetH1(c, "triggers");
515     TH1* norm        = GetH1(c, Form("norm%s",base.Data()));
516     TH1* dndeta      = GetH1(c, Form("dndeta%s",base.Data()));
517     TH2* d2ndetadphi = GetH2(c, Form("d2Ndetadphi%s", base.Data()));
518     if (!trig || !norm || !dndeta || !d2ndetadphi) return;
519
520     norm->SetFillColor(kGreen+1);
521     norm->SetFillStyle(3001);
522
523
524     fBody->Divide(2, 3, 0.05, 0);
525
526     Int_t        trP = 1;
527     TVirtualPad* p   = fBody->GetPad(trP);
528     p->SetBottomMargin(0.15);
529     p->SetLeftMargin(0.15);
530     if (trP > 2) p->SetTopMargin(0.05);
531     
532     DrawInPad(fBody, trP, trig,   "HIST TEXT");
533     DrawInPad(fBody, 2,   norm,   "", 0, "Normalization");
534     DrawInPad(fBody, 4,   dndeta, "", 0, "d#it{N}_{ch}/d#it{#eta}");
535     DrawInPad(fBody, 6,   GetH1(c, Form("dndeta%s_rebin05",base.Data())),
536               "", 0, "d#it{N}_{ch}/d#it{#eta} (rebinned by 5)");
537     DrawInPad(fBody, 5,   d2ndetadphi, "colz");
538   
539     fBody->GetPad(2)->SetGridx(); fBody->GetPad(2)->SetLeftMargin(0.15);
540     fBody->GetPad(4)->SetGridx(); fBody->GetPad(4)->SetLeftMargin(0.15);
541     fBody->GetPad(6)->SetGridx(); fBody->GetPad(6)->SetLeftMargin(0.15);
542
543     TObject*   normCalc = GetObject(c, "normCalc");
544     TString    calc     = normCalc ? normCalc->GetTitle() : "?";
545
546     // Beautify the text
547     calc.ReplaceAll("beta", "#beta");
548     calc.ReplaceAll("eps", "#epsilon");
549     const char* sufs[] = { "all", "acc", "trg", "vtx", "B", "A", "C", "E", 
550                            "V", "T", 0 };
551     const char** suf = sufs;
552     while (*suf) { 
553       calc.ReplaceAll(Form("_%s", *suf), Form("_{%s}", *suf));
554       suf++;
555     }
556
557     fBody->cd(3);
558     TObjArray* lines    = calc.Tokenize("\n");
559     // TPaveText* disp     = new TPaveText(.1,.1,.9,.9, "NDC");
560     TIter       next(lines);
561     TObjString* sline     = 0;
562     Double_t y = .95;
563     Double_t xSave = fParName->GetX();
564     Int_t    aSave = fParName->GetTextAlign();
565     fParName->SetTextAlign(33);
566     fParName->SetX(fParVal->GetX()-.05);
567     while ((sline = static_cast<TObjString*>(next()))) {
568       // disp->AddText(line->GetName());
569       TString& line = sline->String();
570       Ssiz_t   eq   = line.Last('=');
571       if (eq == kNPOS) { 
572         DrawParameter(y, line, "");
573         continue;
574       }
575       TString name = line(0, eq);
576       TString val  = line(eq+1,line.Length()-eq-1);
577       DrawParameter(y, name.Strip(TString::kBoth), 
578                     val.Strip(TString::kBoth));
579       
580     }
581     fParName->SetTextAlign(aSave);
582     fParName->SetX(xSave);
583     // disp->SetBorderSize(0);
584     // disp->SetBorderSize(0);
585     // disp->SetFillStyle(0);
586     // DrawInPad(fBody, 3, disp);
587     // fBody->cd();
588
589     PrintCanvas(title);
590
591     DrawCentResDetails(c, title);
592   }  
593   //____________________________________________________________________
594   void DrawCentResDetails(const TCollection* sums, const TString& base)
595   {
596     TString title = TString::Format("%s - details: ", base.Data());
597
598     TCollection* c = GetCollection(sums, "partial");
599     if (!c) {
600       Warning("", "Collection partical not found in %s", sums->GetName());
601       sums->ls();
602       return;
603     }
604
605     fBody->Divide(3, 1, 0.05, 0);
606     
607     const char* typs[] = { "", "0", "All" };
608     const char* tits[] = { "Non-zero events", "Zero events", "Weighted sum" };
609     for (Int_t i = 1; i <= 3; i++) {
610       const char* suf = typs[i-1];
611       TVirtualPad* p   = fBody->cd(i);
612       p->SetTopMargin(0.10);
613
614       TLatex* ltx = new TLatex(0.5, .99, tits[i-1]);
615       ltx->SetNDC();
616       ltx->SetTextAlign(23);
617       ltx->SetTextSize(0.05);
618       ltx->Draw();
619
620       TH1* sum  = GetH2(c, Form("sum%s",     suf));
621       TH1* norm = GetH1(c, Form("norm%s", suf));
622       TH1* phi  = GetH1(c, Form("phi%s",  suf));
623     
624       norm->SetFillColor(kGreen+1);
625       norm->SetFillStyle(3002);
626       phi->SetFillColor(kBlue+1);
627       phi->SetFillStyle(3001);
628       
629       p->Divide(1, 3, 0, 0);
630       DrawInPad(p, 1, sum, sum->Integral()>0 ? "col" : "", 0, 
631                 "d^{2}#it{N}_{ch}/d#it{#varphi}d#it{#eta}");
632       DrawInPad(p, 2, GetH1(c, Form("average%s", suf)), "", 0, 
633                 "d#it{N}_{ch}/d#it{#eta}");
634       DrawInPad(p, 3, norm, "", 0, "#eta-coverage/#varphi-acceptance");
635       DrawInPad(p, 3, phi, "same", kLegend);      
636     }
637     PrintCanvas(title);
638   }
639
640   //____________________________________________________________________
641   THStack* CleanStack(const THStack* stack, TLegend* l, const TAxis* axis)
642   {
643     THStack* ret   = new THStack(stack->GetName(), stack->GetTitle());
644     TList*   hists = stack->GetHists();
645     TIter    next(hists);
646     TH1*     h     = 0;
647     Int_t    j     = 0;
648     Bool_t   ok    = false;
649     while ((h = static_cast<TH1*>(next()))) {
650       TString name(h->GetTitle());
651       TString nme(h->GetName());
652       if (nme.Contains("_mirror", TString::kIgnoreCase)) {
653         // Printf("Ignore %s/%s in stack", nme.Data(), name.Data());
654         continue;
655       }
656       if (l && !ok) { 
657         j++;
658         if (axis) 
659           name.Form("%3d%% - %3d%%", 
660                     Int_t(axis->GetBinLowEdge(j)), 
661                     Int_t(axis->GetBinUpEdge(j)));
662         else {
663           name.ReplaceAll("ALICE", "");
664           name.ReplaceAll("dNdeta", " - work in progress");
665         }
666         ok = axis && axis->GetBinUpEdge(j) > 100;
667         // Printf("Adding entry %d: %s/%s", j,  nme.Data(), name.Data());
668         TLegendEntry* e = l->AddEntry("dummy", name, "f");
669         e->SetFillStyle(1001);
670         e->SetFillColor(h->GetMarkerColor());
671       }
672       ret->Add(h);
673     }
674     return ret;
675   }
676 };
677 //
678 // EOF
679 //