]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/scripts/SummarydNdetaDrawer.C
0ae7de11edaaacf9a70f46190226a1ab7b67326a
[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     kLandscape = 0x20,
15     kPause     = 0x40,
16     kMC        = 0x80,
17     kNormal    = 0xF
18   };
19   SummarydNdetaDrawer() 
20     : SummaryDrawer()
21   {}
22   //____________________________________________________________________
23   void Run(const char* fname="forward_dndeta.root", UShort_t flags=kNormal)
24   {
25     // --- Open the file -----------------------------------------------
26     TString filename(fname);
27     TFile* file = TFile::Open(filename.Data(), "READ");
28     if (!file) { 
29       Error("Run", "Failed to open \"%s\"", filename.Data());
30       return;
31     }
32     // Options 
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;
40     
41     // --- Force MB for pp ---------------------------------------------
42     UShort_t     sys = 0;
43     TCollection* c   = GetCollection(file, "ForwardSums");
44     GetParameter(c, "sys", sys); 
45     if (sys == 1) onlyMB = true;
46
47     // --- Test of MC --------------------------------------------------
48     TCollection* mcC = GetCollection(file, "MCTruthSums");
49     if (mcC) { 
50       TCollection* mcAll = GetCollection(mcC, "all");
51       if (mcAll && GetObject(mcAll, "MCTruth"))
52         mc = true;
53     }
54     // --- Make our canvas ---------------------------------------------
55     TString pdfName(filename);
56     pdfName.ReplaceAll(".root", ".pdf");
57     CreateCanvas(pdfName, flags & kLandscape);
58
59     // --- Make a Title page -------------------------------------------
60     DrawTitlePage(file, mc, onlyMB);
61
62     // --- Do each sub-algorithm ---------------------------------------
63     THStack* rF = 0;
64     if (forward && sums)    DrawSums(file, "Forward", onlyMB);
65     if (forward && results) rF = DrawRes(file, "Forward", onlyMB);
66     
67     THStack* rC = 0;
68     if (central && sums)    DrawSums(file, "Central", onlyMB);
69     if (central && results) rC = DrawRes(file, "Central", onlyMB);
70
71     THStack* rM = 0;
72     if (mc && sums)    DrawSums(file, "MCTruth", onlyMB);
73     if (mc && results) rM = DrawRes(file, "MCTruth", onlyMB);
74
75     if (rC && rF && results) DrawBoth(rC, rF, rM, file, onlyMB);
76   
77     CloseCanvas();
78   }
79
80 protected:
81   //____________________________________________________________________
82   TCollection* GetCentCollection(const TCollection* sums, 
83                                  const TString&     base, 
84                                  Int_t              cLow, 
85                                  Int_t              cHigh,
86                                  TString&           title)
87   {
88     TString folder; 
89     title = TString::Format("%s %s: ", base.Data(), title.Data());
90     if (cLow < 0 || cHigh < 0 || cLow >= cHigh) {
91       folder = "all";
92       title.Append("All selected events");
93       cHigh  *= -1;
94     }
95     else {
96       folder.Form("cent%03d_%03d", cLow, cHigh);
97       title.Append(Form("%3d%% - %3d%%", cLow, cHigh));
98     }
99     
100     return GetCollection(sums, folder);
101     
102   }
103   //____________________________________________________________________
104   void DrawTitlePage(TFile* file, Bool_t mc, Bool_t onlyMB)
105   {
106     TCollection* c   = GetCollection(file, "ForwardResults");
107
108     fBody->cd();
109     
110     Double_t y = .9;
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);
117     ltx->SetNDC();
118     ltx->Draw();
119     y -= .075;
120     
121     if (mc) {
122       ltx = new TLatex(.5, y, "Simulation input");
123       ltx->SetNDC();
124       ltx->SetTextAlign(23);
125       ltx->SetTextFont(42);
126       ltx->SetTextSize(.03);
127       ltx->Draw();
128       y -= .035;
129     }
130     if (onlyMB) {
131       ltx = new TLatex(.5, y, "No centrality");
132       ltx->SetNDC();
133       ltx->SetTextAlign(23);
134       ltx->SetTextFont(42);
135       ltx->SetTextSize(.03);
136       ltx->Draw();
137       y -= .035;
138     }
139     
140     DrawResTitle(c, y, onlyMB);
141
142     PrintCanvas("1/N dN/d#eta");
143   }
144   //____________________________________________________________________
145   void DrawBoth(THStack* rC, THStack* rF, THStack* rM, 
146                 TFile* file, Bool_t onlyMB)
147   {
148     fBody->cd();
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);
155
156     fBody->cd();
157     p1->Draw();
158     p1->cd();
159
160     TH1*  h  = 0;
161     if (rM) { 
162       TIter nextM(rM->GetHists());
163       while ((h = static_cast<TH1*>(nextM()))) rC->Add(h);
164     }
165
166     TIter next(rF->GetHists());
167     while ((h = static_cast<TH1*>(next()))) rC->Add(h);
168
169
170     rC->Draw("nostack");
171
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); 
177     TAxis* centAxis = 
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;
181
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);
187     TMultiGraph* other = 
188       reinterpret_cast<TMultiGraph*>(gROOT->ProcessLine(oC));
189     if (other) {
190       // p1->Clear();
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");
196       TObject* g = 0;
197       TIter    nextG(other->GetListOfGraphs());
198       while ((g = nextG()))
199         g->DrawClone("same p");
200     }
201
202     fBody->cd();
203     p2->Draw();
204     p2->cd();
205
206
207     TLegend* l = new TLegend(0.01, 0.1, 0.99, 0.99, 
208                              onlyMB || !centAxis ? "" : "Centralities");
209     l->SetNColumns(fLandscape ? 1 : 2);
210     l->SetFillStyle(0);
211     l->SetBorderSize(0);
212     CleanStack(rC, l, onlyMB ? 0 : centAxis);
213     if (other) { 
214       TIter nextG(other->GetListOfGraphs());
215       TObject* g = 0;
216       while ((g = nextG())) 
217         l->AddEntry(g, g->GetTitle(), "p");
218     }
219     l->Draw();
220
221     PrintCanvas("Both");
222   }
223   //____________________________________________________________________
224   void DrawSums(TDirectory* top, const TString& base, bool onlyMB)
225   {
226     TCollection* c = GetCollection(top, Form("%sSums", base.Data()));
227     if (!c) return;
228     
229     TAxis* centAxis = static_cast<TAxis*>(GetObject(c, "centAxis"));
230
231     Int_t   txtPad = 0;
232     Double_t save  = fParName->GetTextSize();
233     Double_t xSave = fParVal->GetX();
234     fParName->SetTextSize(0.03);
235     fParVal->SetTextSize(0.03);
236     fParVal->SetX(.45);
237     Double_t y = .8;
238     
239     if (!onlyMB && centAxis) {
240       fBody->Divide(1, 2);
241       txtPad = 1;
242     
243       fBody->cd(1);
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))));
249       }
250     
251       TH1* cent = GetH1(c, "cent");
252       cent->SetFillColor(kRed+1);
253       cent->SetFillStyle(3001);
254       cent->SetXTitle("Centrality [%]");
255       cent->SetYTitle("Events");
256       
257       DrawInPad(fBody, 2, cent);
258     }
259     fBody->cd(txtPad);
260     
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); 
266
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");
274
275     TString trigString;
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 ");
290
291     DrawParameter(y, "Collision system", (sys == 1 ? "pp" : 
292                                           (sys == 2 ? "PbPb" : 
293                                            (sys == 3 ? "pPb" : 
294                                             "unknown"))));
295     DrawParameter(y, "#sqrt{s_{NN}}",        Form("%4dGeV", sNN));
296     DrawParameter(y, "Normalization scheme", schemeString);
297     DrawParameter(y, "Triggers",             trigString);
298     
299     fParName->SetTextSize(save);
300     fParVal->SetTextSize(save);
301     fParVal->SetX(xSave);
302
303     PrintCanvas(Form("%s sums", base.Data()));
304
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;
309
310     for (Int_t i = 1; i <= centAxis->GetNbins(); i++) 
311       DrawCentSum(c, base, centAxis->GetBinLowEdge(i), 
312                   centAxis->GetBinUpEdge(i));
313   }
314   //____________________________________________________________________
315   void DrawCentSum(const TCollection* sums, const TString& base, 
316                    Int_t cLow, Int_t cHigh)
317   {
318     TString title("sums");
319     TCollection* c = GetCentCollection(sums, base, cLow, cHigh, title);
320     if (!c) return;
321     
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;
327
328     type->SetFillStyle(3001);
329     type->SetFillColor(kGreen+1);
330
331     fBody->Divide(2, 2);
332
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");
337     
338     if (bin0->GetEntries() <= 0) {
339       fBody->cd(4);
340       TLatex* l = new TLatex(0.5, 0.5, "No 0-bin events");
341       l->SetNDC();
342       l->SetTextAlign(22);
343       l->Draw();
344     }
345     PrintCanvas(title);
346   }
347   //____________________________________________________________________
348   void DrawResTitle(TCollection* c, Double_t& y, Bool_t onlyMB)
349   {
350     Double_t save  = fParName->GetTextSize();
351     Double_t xSave = fParVal->GetX();
352     fParName->SetTextSize(0.03);
353     fParVal->SetTextSize(0.03);
354     fParVal->SetX(.5);
355     // Double_t y = .9;
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))));
363       }
364     }
365     TObject* oSNN  = GetObject(c,"sNN");
366     TString  tSNN  = "";
367     UShort_t sNN   = oSNN->GetUniqueID(); 
368     if (sNN > 1000) {
369       if ((sNN % 1000) == 0) 
370         tSNN = TString::Format("%dTeV", sNN/1000);
371       else 
372         tSNN = TString::Format("%-5.2fTeV", float(sNN) / 1000);
373     }
374     else 
375       tSNN = TString::Format("%dGeV", sNN);
376
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);
384     
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));
390
391     TObject*    options = GetObject(c, "options");
392     TString     opts(options->GetTitle());
393     TObjArray*  tokens = opts.Tokenize(",");
394     TObjString* opt = 0;;
395     TIter       oNext(tokens);
396     Bool_t      first  = true;
397     while ((opt = static_cast<TObjString*>(oNext()))) { 
398       DrawParameter(y, (first ? "options" : ""), 
399                     opt->String().Strip(TString::kBoth));
400       first = false;
401     }
402     fParName->SetTextSize(save);
403     fParVal->SetTextSize(save);
404     fParVal->SetX(xSave);      
405   }
406
407   //____________________________________________________________________
408   THStack* DrawRes(TDirectory* top, const TString& base, Bool_t onlyMB)
409   {
410     TCollection* c = GetCollection(top, Form("%sResults", base.Data()));
411     if (!c) return 0;
412
413     fBody->cd();
414     Double_t y = .9;
415     DrawResTitle(c, y, onlyMB);
416     PrintCanvas(Form("%s results", base.Data()));
417
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");
421     l->SetNColumns(2);
422     l->SetFillStyle(0);
423     l->SetBorderSize(0);
424
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);
429
430     if (!onlyMB) {
431       fBody->Divide(1, 3, 0, 0);
432       
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();
438       
439       PrintCanvas(Form("%s results - stacks", base.Data()));
440     }
441
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);
448       return dndeta;
449     }
450
451     for (Int_t i = 1; i <= centAxis->GetNbins(); i++) 
452       DrawCentRes(c, base, centAxis->GetBinLowEdge(i), 
453                   centAxis->GetBinUpEdge(i));
454     
455     return dndeta;
456   }
457   //____________________________________________________________________
458   THStack* MakeMBStack(const TCollection* sums, const TString& base)
459   {
460     TString title("results");
461     TCollection* c = GetCentCollection(sums, base, 0, -1, title);
462     if (!c) return 0;
463
464     TH1* dndeta      = GetH1(c, Form("dndeta%s",base.Data()));
465     if (!dndeta) return 0;
466
467     THStack* ret = new THStack("dndetaMB", title);
468     ret->Add(dndeta);
469
470     if (base.EqualTo("MCTruth")) {
471       dndeta      = GetH1(c, "dndetaTruth");
472       if (dndeta) ret->Add(dndeta);
473     }
474     return ret;
475   }
476       
477   //____________________________________________________________________
478   void DrawCentRes(const TCollection* sums, const TString& base, 
479                    Int_t cLow, Int_t cHigh)
480   {
481     TString title("results");
482     TCollection* c = GetCentCollection(sums, base, cLow, cHigh, title);
483     if (!c) return;
484
485
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;
491
492     norm->SetFillColor(kGreen+1);
493     norm->SetFillStyle(3001);
494
495     fBody->Divide(2, 3, 0.05, 0);
496
497     Int_t        trP = 1;
498     TVirtualPad* p   = fBody->GetPad(trP);
499     p->SetBottomMargin(0.15);
500     p->SetLeftMargin(0.15);
501     if (trP > 2) p->SetTopMargin(0.05);
502     
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");
508   
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);
512
513     TObject*   normCalc = GetObject(c, "normCalc");
514     TString    calc     = normCalc ? normCalc->GetTitle() : "?";
515
516     // Beautify the text
517     calc.ReplaceAll("beta", "#beta");
518     calc.ReplaceAll("eps", "#epsilon");
519     const char* sufs[] = { "all", "acc", "trg", "vtx", "B", "A", "C", "E", 
520                            "V", "T", 0 };
521     const char** suf = sufs;
522     while (*suf) { 
523       calc.ReplaceAll(Form("_%s", *suf), Form("_{%s}", *suf));
524       suf++;
525     }
526
527     fBody->cd(3);
528     TObjArray* lines    = calc.Tokenize("\n");
529     // TPaveText* disp     = new TPaveText(.1,.1,.9,.9, "NDC");
530     TIter       next(lines);
531     TObjString* sline     = 0;
532     Double_t y = .95;
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('=');
541       if (eq == kNPOS) { 
542         DrawParameter(y, line, "");
543         continue;
544       }
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));
549       
550     }
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);
557     // fBody->cd();
558
559     PrintCanvas(title);
560
561     DrawCentResDetails(c, title);
562   }  
563   //____________________________________________________________________
564   void DrawCentResDetails(const TCollection* sums, const TString& base)
565   {
566     TString title = TString::Format("%s - details: ", base.Data());
567
568     TCollection* c = GetCollection(sums, "partial");
569     if (!c) {
570       Warning("", "Collection partical not found in %s", sums->GetName());
571       sums->ls();
572       return;
573     }
574
575     fBody->Divide(3, 1, 0.05, 0);
576     
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);
583
584       TLatex* ltx = new TLatex(0.5, .99, tits[i-1]);
585       ltx->SetNDC();
586       ltx->SetTextAlign(23);
587       ltx->SetTextSize(0.05);
588       ltx->Draw();
589
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));
593     
594       norm->SetFillColor(kGreen+1);
595       norm->SetFillStyle(3002);
596       phi->SetFillColor(kBlue+1);
597       phi->SetFillStyle(3001);
598       
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);      
604     }
605     PrintCanvas(title);
606   }
607
608   //____________________________________________________________________
609   THStack* CleanStack(const THStack* stack, TLegend* l, const TAxis* axis)
610   {
611     THStack* ret   = new THStack(stack->GetName(), stack->GetTitle());
612     TList*   hists = stack->GetHists();
613     TIter    next(hists);
614     TH1*     h     = 0;
615     Int_t    j     = 0;
616     Bool_t   ok    = false;
617     while ((h = static_cast<TH1*>(next()))) {
618       TString name(h->GetTitle());
619       if (name.Contains("_mirror")) continue;
620       if (l && !ok) { 
621         j++;
622         if (axis) 
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());
630       }
631       ret->Add(h);
632     }
633     return ret;
634   }
635 };
636 //
637 // EOF
638 //