]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/scripts/SummaryAODDrawer.C
Why the h*ll do we make a remote commit when pulling?
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / scripts / SummaryAODDrawer.C
1 #include "SummaryDrawer.C"
2 #ifndef __CINT__
3 # include <TGraph.h>
4 # include <TGraphErrors.h>
5 # include <TF1.h>
6 # include <TArrow.h>
7 #else
8 class TGraph;
9 #endif
10
11 /**
12  * Class to draw a summary of the AOD production
13  *
14  * @par Input: 
15  * - The merged <tt>forward.root</tt> file.
16  *   If the file isn't merged, it should still work. 
17  *
18  * @par Output:
19  * - A PDF file named after the input, but with <tt>.root</tt>
20  *   replaced with <tt>pdf</tt>
21  * 
22  */
23 class SummaryAODDrawer : public SummaryDrawer
24 {
25 public:
26   enum EFlags { 
27     kEventInspector    = 0x001, 
28     kSharingFilter     = 0x002, 
29     kDensityCalculator = 0x004,
30     kCorrector         = 0x008,
31     kHistCollector     = 0x010,
32     kSteps             = 0x020, 
33     kResults           = 0x040, 
34     kCentral           = 0x080,
35     kNormal            = 0x0FF
36   };
37   SummaryAODDrawer() 
38     : SummaryDrawer(),
39       fSums(0),
40       fResults(0)
41   {}
42   
43   //__________________________________________________________________
44   /** 
45    * 
46    * 
47    * @param fname 
48    * @param what 
49    */
50   void Run(const char* fname, UShort_t what=kNormal)
51   {
52     // --- Open the file ---------------------------------------------
53     TString filename(fname);
54     TFile*  file = TFile::Open(filename, "READ");
55     if (!file) { 
56       Error("Run", "Failed to open \"%s\"", filename.Data());
57       return;
58     }
59    
60
61     // --- Get top-level collection ----------------------------------
62     fSums = GetCollection(file, "ForwardSums");
63     if (!fSums) {
64       Info("Run", "Trying old name Forward");
65       fSums = GetCollection(file, "Forward");
66       if (!fSums) return;
67     }
68
69     // --- Do the results ----------------------------------------------
70     fResults = GetCollection(file, "ForwardResults");
71     if (!fResults) fResults = fSums; // Old-style
72
73     // --- Make our canvas -------------------------------------------
74     TString pdfName(filename);
75     pdfName.ReplaceAll(".root", ".pdf");
76     CreateCanvas(pdfName, what & kLandscape);
77     DrawTitlePage(file);
78
79     // --- Possibly make a chapter here ------------------------------
80     TCollection* centralSums = GetCollection(file, "CentralSums", false);
81     if (!centralSums) {
82       Info("Run", "Trying old name \"Central\"");
83       centralSums = GetCollection(file, "Central", false);
84     }
85     if (what & kCentral && centralSums) 
86       MakeChapter("Forward");
87     
88     // --- Set pause flag --------------------------------------------
89     fPause = what & kPause;
90
91     // --- Do each sub-algorithm -------------------------------------
92     if (what & kEventInspector)    DrawEventInspector(fSums);
93     if (what & kSharingFilter)     DrawSharingFilter();
94     if (what & kDensityCalculator) DrawDensityCalculator();
95     if (what & kCorrector)         DrawCorrector();
96     if (what & kHistCollector)     DrawHistCollector();
97   
98     
99     if (what & kSteps) DrawSteps();
100     if (what & kResults) DrawResults();
101
102     // --- SPD clusters ----------------------------------------------
103     if (what & kCentral) { 
104       // --- Get top-level collection --------------------------------
105       fSums = GetCollection(file, "CentralSums");
106       if (!fSums) 
107         fSums = GetCollection(file, "Central");
108       if (fSums) {
109         MakeChapter("Central");
110         DrawCentral();
111         if (what & kEventInspector) DrawEventInspector(fSums);
112       }
113       fResults = GetCollection(file, "CentralResults");
114       if (fResults && (what & kResults)) {
115         DrawCentralResults();
116       }
117
118       if (what & kResults) DrawBoth(file);
119     }
120
121     
122     CloseCanvas();
123   }
124 protected:
125   //____________________________________________________________________
126   void DrawTitlePage(TFile* f)
127   {
128     fBody->cd();
129
130     TLatex* ltx = new TLatex(.5, .7, "ESD #rightarrow AOD filtering");
131     ltx->SetNDC();
132     ltx->SetTextSize(0.07);
133     ltx->SetTextAlign(22);
134     ltx->Draw();
135
136     TCollection* fwd = fSums; // GetCollection(f, "ForwardSums");
137     TCollection* cen = GetCollection(f, "CentralSums");
138     Double_t y = .6;
139     
140     Double_t save = fParName->GetTextSize();
141     fParName->SetTextSize(0.03);
142     fParVal->SetTextSize(0.03);
143
144     DrawParameter(y, "Tasks", (fwd ? "Forward" : ""));
145     DrawParameter(y, "",      (cen ? "Central" : ""));
146
147     if (fwd) { 
148       TCollection* ei = GetCollection(fwd, "fmdEventInspector");
149       if (ei) { 
150
151         UShort_t sys=0, sNN=0;
152         Int_t field=0;
153         ULong_t runNo=0;
154         Bool_t mc=false;
155         GetParameter(ei, "sys", sys);
156         GetParameter(ei, "sNN", sNN);
157         GetParameter(ei, "field", field);
158         GetParameter(ei, "runNo", runNo);
159         if (!GetParameter(ei, "mc", mc, false)) mc = false;
160         
161         TString sysString;    SysString(sys, sysString);
162         TString sNNString;    SNNString(sNN, sNNString);
163         
164         DrawParameter(y, "System", sysString);
165         DrawParameter(y, "#sqrt{s_{NN}}", sNNString);
166         DrawParameter(y, "L3 B field", Form("%+2dkG", field));
167         DrawParameter(y, "Run #", Form("%6lu", runNo));
168         DrawParameter(y, "Simulation", (mc ? "yes" : "no"));    
169       }
170     }
171     PrintCanvas("Title page");
172     fParName->SetTextSize(save);
173     fParVal->SetTextSize(save);
174   }
175   TGraph* CreateCutGraph(Int_t method, Int_t iy, TH2* cuts, TH1* eloss,
176                          Int_t color)
177   {
178     TGraph*  ret = new TGraph(4);
179     Double_t y0  = TMath::Max(eloss->GetMinimum(),1.);
180     Double_t y1  = eloss->GetMaximum();
181     Double_t min = 1000;
182     Double_t max = 0;
183     if (method == 0) { // Fixed value
184       max = cuts->GetBinContent(1, iy);
185       min = eloss->GetXaxis()->GetXmin();
186     }
187     else {
188       for (Int_t ix=1; ix <= cuts->GetNbinsX(); ix++) {
189         Double_t c = cuts->GetBinContent(ix, iy);
190         if (c <= 0.0001) continue;
191         min = TMath::Min(c, min);
192         max = TMath::Max(c, max);
193       }
194     }
195     // Printf("Cuts between %f,%f @%f, %f", min, max, y0,y1);
196     ret->SetPoint(0, min, y0); 
197     ret->SetPoint(1, min, y1); 
198     ret->SetPoint(2, max, y1);
199     ret->SetPoint(3, max, y0);
200     ret->SetFillColor(color);
201     ret->SetFillStyle(3002);
202     ret->SetLineColor(kBlack);
203     ret->SetLineStyle(2);
204     ret->SetName(Form("g%s", cuts->GetName()));
205     ret->SetTitle(cuts->GetTitle());
206     
207     return ret;
208   }
209   //____________________________________________________________________
210   const Char_t* CutMethodName(Int_t lm) const
211   {
212     switch (lm) {
213     case 0: return "fixed";
214     case 1: return "fraction of MPV";
215     case 2: return "fit range";
216     case 3: return "Landau width";
217     case 4: return "Probability";
218     }
219     return "unknown";
220   }
221   //____________________________________________________________________
222   Int_t PrintCut(const TCollection* c, Double_t& y, const Char_t* name,
223                  Double_t size=0)
224   {
225     if (!c) return -1;
226
227     Int_t method = 0;
228     if (!GetParameter(c, "method", method)) return -1;
229
230     Double_t val = 0;
231     Bool_t   sig = false;
232     switch (method) {
233     case 0: // Fixed 
234       DrawParameter(y, name, "fixed", size); 
235       break;
236     case 1: // MPV
237       GetParameter(c, "frac", val);
238       DrawParameter(y, name, Form("Fraction of #Delta_{p} (%3d%%)",
239                                   Int_t(val*100)), size);
240       break;
241     case 2: // Fit range
242       DrawParameter(y, name, "Fit range"); 
243       break;
244     case 3: // Landau width
245       GetParameter(c, "nXi", val);
246       GetParameter(c, "sigma", sig);
247       DrawParameter(y, name, Form("N#times%s#xi%s (N=%4.1f)",
248                                   (sig ? "(" : ""),
249                                   (sig ? "+#sigma)" : ""), 
250                                   val), size);
251       break;
252     case 4: // Probability;
253       GetParameter(c, "probability", val);
254       DrawParameter(y, name, Form("P(#Delta)<%f", val), size);
255       break;
256     default:
257       DrawParameter(y, name, "Unknown", size);
258       break;
259     }
260     return method;
261   }
262   //____________________________________________________________________
263   void DrawSharingFilter()
264   {
265     Info("DrawSharingFilter", "Drawing sharing filter");
266     TCollection* c = GetCollection(fSums, "fmdSharingFilter");
267     if (!c) return;
268     TCollection* rc = GetCollection(fResults, "fmdSharingFilter");
269     if (!rc) rc = c;
270
271     // --- Draw summary information ----------------------------------
272     fBody->Divide(1, 3, 0, 0);
273     fBody->cd(1);
274   
275     Double_t y = .8;
276     Bool_t   angle=false, lowSignal=false, disabled=false;
277
278     if (GetParameter(c, "angle", angle))
279       DrawParameter(y, "Angle correct", (angle ? "yes" : "no")); 
280     if (GetParameter(c, "lowSignal", lowSignal))
281       DrawParameter(y, "Lower signal",  (lowSignal ? "yes" : "no"));
282     TParameter<int>* nFiles = 
283       static_cast<TParameter<int>*>(GetObject(c, "nFiles"));
284     if (nFiles)
285       DrawParameter(y, "# files merged", Form("%d", nFiles->GetVal()));    
286     if (GetParameter(c, "disabled", disabled)) 
287       DrawParameter(y, "Merging disabled", (disabled ? "yes" : "no"));
288
289     Int_t lm    = 0;
290     Int_t hm    = 0;
291     TH2*  hLow  = 0;
292     TH2*  hHigh = 0;
293     if (!disabled) {
294       Bool_t simple=false, three=false;
295       if (GetParameter(c, "simple", simple))
296         DrawParameter(y, "Simple method", (simple ? "yes" : "no"));
297       if (GetParameter(c, "sumThree", three)) 
298         DrawParameter(y, "3-strip merging", (three ? "yes" : "no"));
299     
300       TCollection* lc = GetCollection(c, "lCuts");
301       TCollection* hc = GetCollection(c, "hCuts");
302       lm              = PrintCut(lc, y, "Low cut");
303       hm              = PrintCut(hc, y, "High cut");
304       hLow            = GetH2(c, "lowCuts");
305       hHigh           = GetH2(c, "highCuts");
306       // if (hLow  && nFiles) hLow->Scale(1. / nFiles->GetVal());
307       // if (hHigh && nFiles) hHigh->Scale(1. / nFiles->GetVal());
308       DrawInPad(fBody, 2, hLow,  "colz");
309       DrawInPad(fBody, 3, hHigh, "colz");
310     }
311     PrintCanvas("Sharing filter");
312
313     if (!disabled) {
314       // --- Draw rings individually -----------------------------------
315       Double_t savX = fParVal->GetX();
316       Double_t savY = fParVal->GetY();
317       fParVal->SetX(0.6);
318       fParVal->SetY(0.6);
319       const char** ptr   = GetRingNames(false);
320       UShort_t     iq    = 1;
321       while (*ptr) { 
322         TCollection* sc = GetCollection(c, *ptr);
323         if (!sc) { ptr++; iq++; continue; }
324         
325         if (fLandscape) fBody->Divide(3, 2);
326         else            fBody->Divide(2,3);
327         
328         TH1*    esdELoss = GetH1(sc, "esdEloss");
329         esdELoss->GetXaxis()->SetRangeUser(-.1, 2);
330         TGraph* lowCut   = CreateCutGraph(lm, iq,  hLow,  esdELoss, kYellow+1);
331         TGraph* highCut  = CreateCutGraph(hm, iq,  hHigh, esdELoss, kCyan+1);
332         
333         DrawInPad(fBody, 1, esdELoss, "", kLogy,
334                   "#Delta/#Delta_{mip} reconstructed and merged");
335         DrawInPad(fBody, 1, GetH1(sc, "anaEloss"), "same");
336         DrawInPad(fBody, 1, lowCut,  "lf same"); 
337         DrawInPad(fBody, 1, highCut, "lf same", kLogy|kLegend); 
338         
339         DrawInPad(fBody, 2, GetH1(sc, "singleEloss"),    "",    kLogy,
340                   "#Delta/#Delta_{mip} for single, double, and tripple hits");
341         DrawInPad(fBody, 2, GetH1(sc, "doubleEloss"),    "same",kLogy);
342         DrawInPad(fBody, 2, GetH1(sc, "tripleEloss"),    "same",kLogy|kLegend);
343         
344         DrawInPad(fBody, 3, GetH2(sc, "singlePerStrip"), "colz",kLogz);
345         // DrawInPad(fBody, 4, GetH1(sc, "distanceBefore"), "",     0x2);
346         // DrawInPad(fBody, 4, GetH1(sc, "distanceAfter"),  "same", 0x12);
347         DrawInPad(fBody, 4, GetH2(sc, "summed"),         "colz",0x0);
348         
349         TH2* nB = GetH2(sc, "neighborsBefore");
350         if (nB) { 
351           nB->GetXaxis()->SetRangeUser(0,8); 
352           nB->GetYaxis()->SetRangeUser(0,8); 
353         }
354         DrawInPad(fBody, 5, nB, "colz", kLogz);
355         DrawInPad(fBody, 5, GetH2(sc, "neighborsAfter"), "p same", kLogz,
356                   "Correlation of neighbors before and after merging");
357         DrawInPad(fBody, 6, GetH2(sc, "beforeAfter"),    "colz",   kLogz);
358         
359         PrintCanvas(Form("Sharing filter - %s", *ptr));
360         ptr++;
361         iq++;
362       }
363       fParVal->SetX(savX);
364       fParVal->SetY(savY);
365     }
366
367     // --- MC --------------------------------------------------------
368     TCollection* cc = GetCollection(c, "esd_mc_comparion", false); // Spelling!
369     if (!cc) return; // Not MC 
370
371     DivideForRings(false, false);
372     const char** ptr = GetRingNames(false);
373     while (*ptr) { 
374       DrawInRingPad(GetH2(cc, Form("%s_corr", *ptr)), "colz", kLogz);
375       ptr++;
376     }
377
378     PrintCanvas("Sharing filter - MC vs Reco");
379
380     // --- MC --------------------------------------------------------
381     DrawTrackDensity(c);
382   }
383
384   void ShowSliceFit(Bool_t inY, TH2* h, Double_t nVar, 
385                     TVirtualPad* p, Int_t sub, UShort_t flags=0,
386                     Double_t cut=-1)
387   {
388     if (!h) return;
389
390     TObjArray* fits = new TObjArray;
391     fits->SetOwner();
392     if (inY) h->FitSlicesY(0, 1, -1, 10, "QN", fits);
393     else     h->FitSlicesX(0, 1, -1, 10, "QN", fits);
394     if (!fits) { 
395       Warning("ShowSliceFit", "No fits returned");
396       return;
397     }
398     TH1* mean = static_cast<TH1*>(fits->At(1));
399     TH1* var  = static_cast<TH1*>(fits->At(2));
400     if (!mean || !var) {
401       Warning("ShowSliceFit", "Didn't get histograms");
402       fits->Delete();
403       return;
404     }
405     TF1* fmean = new TF1("mean", "pol1");
406     TF1* fvar  = new TF1("var",  "pol1");
407     mean->Fit(fmean, "Q0+");
408     var->Fit(fvar, "Q0+");
409     if (!fmean || !fvar) {
410       Warning("ShowSliceFit", "No functions returned");
411       fits->Delete();
412       return;
413     }
414
415     TGraphErrors* g = new TGraphErrors(h->GetNbinsX());
416     g->SetName(Form("g%s", h->GetName()));
417     TString xTit = h->GetXaxis()->GetTitle();
418     TString yTit = h->GetYaxis()->GetTitle();
419     g->SetTitle(Form("Correlation of %s and %s",
420                      inY  ? xTit.Data() : yTit.Data(), 
421                      !inY ? xTit.Data() : yTit.Data()));
422     g->SetFillColor(kBlue-10);
423     g->SetFillStyle(3001);
424     TGraph* up  = (cut > 0 ? new TGraph(h->GetNbinsX()) : 0);
425     TGraph* low = (cut > 0 ? new TGraph(h->GetNbinsX()) : 0);
426     if (up)  { 
427       up ->SetLineColor(kBlack); 
428       up ->SetLineWidth(2); 
429       up ->SetLineStyle(2); 
430     }
431     if (low) { 
432       low->SetLineColor(kBlack); 
433       low->SetLineWidth(2); 
434       low->SetLineStyle(2); 
435     }
436     for (Int_t i = 1; i <= h->GetNbinsX(); i++) { 
437       Double_t x  = h->GetXaxis()->GetBinCenter(i);
438       Double_t y  = fmean->Eval(x);
439       Double_t e  = fvar->Eval(x);
440       Double_t ee = nVar * e;
441       if (flags & 0x8000) ee *= e > 0 ? TMath::Log10(e) : 1;
442       g->SetPoint(i-1, x, y);
443       g->SetPointError(i-1, 0, ee);
444
445       if (up)  up ->SetPoint(i-1,x,x+cut*x);
446       if (low) low->SetPoint(i-1,x,x-cut*x);
447     }
448     DrawInPad(p, sub, g, "3", flags);
449     if (up)  DrawInPad(p, sub, up, "l", flags);
450     if (low) DrawInPad(p, sub, low, "l", flags);
451     fmean->SetRange(h->GetXaxis()->GetXmin(), h->GetXaxis()->GetXmax());
452     fmean->SetLineWidth(2);
453     DrawInPad(p, sub, fmean, "same", flags);
454
455     TVirtualPad* pp = p->GetPad(sub);
456     Double_t y = 1-pp->GetTopMargin()-.01;
457     TLatex* l = new TLatex(.15, y, 
458                            Form("#LT%s#GT(%s) = "
459                                 "%f + %f %s", 
460                                 yTit.Data(), xTit.Data(), 
461                                 fmean->GetParameter(0), 
462                                 fmean->GetParameter(1), xTit.Data()));
463     l->SetNDC();
464     l->SetTextAlign(13);
465     l->SetTextSize(0.04);
466     l->SetTextFont(42);
467     l->Draw();
468     l->DrawLatex(0.15, y-0.07, 
469                  Form("#sigma_{%s}(%s) = "
470                       "%f + %f %s", 
471                       yTit.Data(), xTit.Data(),
472                       fvar->GetParameter(0), 
473                       fvar->GetParameter(1),  xTit.Data()));
474     l->DrawLatex(0.15, y-0.14, Form("#delta = %3.1f %s #sigma",
475                                     nVar, 
476                                     flags & 0x8000 ? "log_{10}(#sigma)" : ""));
477     fits->Delete();
478   }
479
480   //____________________________________________________________________
481   void DrawDensityCalculator()
482   {
483     Info("DrawDensityCalculator", "Drawing density calculator");
484     TCollection* c = GetCollection(fSums, "fmdDensityCalculator");
485     if (!c) return;
486
487     fBody->Divide(2, 2);
488     fBody->cd(1);
489   
490     Double_t y = .8;
491     Int_t maxParticles=0, phiAcceptance=0, etaLumping=0, phiLumping=0;
492     Bool_t method=false, recalcEta=false, recalcPhi=false;
493     Double_t maxOutliers=0, outlierCut=0;
494     Double_t size = fLandscape ? 0.06 : 0.04;
495   
496     GetParameter(c, "maxParticle", maxParticles);
497
498     if (GetParameter(c, "phiAcceptance", phiAcceptance))
499       DrawParameter(y, "#phi acceptance method", 
500                     (phiAcceptance == 1 ? "N_{ch}" : 
501                      phiAcceptance == 2 ? "#DeltaE" : "none"),       size);
502     if (GetParameter(c, "etaLumping", etaLumping) &&
503         GetParameter(c, "phiLumping", phiLumping))
504       DrawParameter(y, "Region size (sector#timesstrip)", 
505                     Form("%2d #times %2d", phiLumping, etaLumping),  size);
506     if (GetParameter(c, "method", method))
507       DrawParameter(y, "Method", (method ? "Poisson" : "#DeltaE"),   size); 
508     if (GetParameter(c, "recalcEta", recalcEta))
509       DrawParameter(y, "Recalculate #eta",(recalcEta ? "yes" : "no"),size); 
510     if (GetParameter(c, "recalcPhi", recalcPhi))
511       DrawParameter(y, "Recalculate #phi",(recalcPhi ? "yes" : "no"),size); 
512     if (GetParameter(c, "maxOutliers", maxOutliers))
513       DrawParameter(y, "Max relative N_{outlier}",
514                     Form("%5.3f",maxOutliers),size);
515     if (GetParameter(c, "outlierCut", outlierCut))
516       DrawParameter(y, "Max relative deviation",Form("%5.3f",outlierCut),size);
517
518
519     TParameter<int>* nFiles = 
520       static_cast<TParameter<int>*>(GetObject(c, "nFiles"));
521     if (nFiles)
522       DrawParameter(y, "# files merged", Form("%d", nFiles->GetVal()), size);
523
524     TCollection* lc = GetCollection(c, "lCuts");
525     PrintCut(lc, y, "Threshold", size);
526
527     TVirtualPad* p = fBody; // fBody->cd(2);
528     // p->Divide(3,1);
529
530     TH1* accI = GetH1(c, "accI");
531     TH1* accO = GetH1(c, "accO");
532     if (accI) { 
533       Double_t scale = 1./accI->GetMaximum();
534       accI->Scale(scale); 
535       accO->Scale(scale);
536       accI->SetMinimum(0); 
537     }
538     TH2* lCuts = GetH2(c, "lowCuts");
539     TH2* maxW  = GetH2(c, "maxWeights");
540     if (lCuts)           lCuts->SetTitle("Thresholds");
541     if (nFiles && lCuts) lCuts->Scale(1. / nFiles->GetVal());
542     if (nFiles && maxW)  maxW->Scale(1. / nFiles->GetVal());
543     DrawInPad(p, 2, accI); 
544     DrawInPad(p, 2, accO,  "same", kLegend); 
545     DrawInPad(p, 3, lCuts, "colz");
546     DrawInPad(p, 4, maxW,  "colz");
547   
548     PrintCanvas("Density calculator");
549
550     const char** ptr   = GetRingNames(false);
551     while (*ptr) { 
552       TCollection* sc = GetCollection(c, *ptr);
553       if (!sc) { ptr++; continue; }
554     
555       if (fLandscape) fBody->Divide(3,2);
556       else            fBody->Divide(2,3);
557     
558       TH2* corr      = GetH2(sc, "elossVsPoisson");
559       TH2* corrOut   = GetH2(sc, "elossVsPoissonOutlier");
560       TH1* diff      = GetH1(sc, "diffElossPoisson");
561       TH1* diffOut   = GetH1(sc, "diffElossPoissonOutlier");
562       TH1* eloss     = GetH1(sc, "eloss");
563       TH1* elossUsed = GetH1(sc, "elossUsed");
564       TH1* occ       = GetH1(sc, "occupancy");
565       if (eloss)     eloss    ->SetLineWidth(1);
566       if (elossUsed) elossUsed->SetLineWidth(1);
567       
568       DrawInPad(fBody, 1, corr,    "colz",        kLogz);
569       DrawInPad(fBody, 1, corrOut, "same",        kLogz);
570       DrawInPad(fBody, 2, diff,    "HIST E",      kLogy);
571       DrawInPad(fBody, 2, diffOut, "HIST E SAME", kLogy|kLegend);
572       DrawInPad(fBody, 3, occ,      "",           kLogy);
573       DrawInPad(fBody, 4, eloss,    "",           kLogy, 
574                 "#Delta/#Delta_{mip} before and after cuts");
575       DrawInPad(fBody, 4, elossUsed, "same",      kLogy|kLegend);
576       TH1* phiB = GetH1(sc, "phiBefore");
577       TH1* phiA = GetH1(sc, "phiAfter");
578       TH1* outliers = GetH1(sc, "outliers");
579       if (outliers) 
580         DrawInPad(fBody, 5, outliers, "hist", kLogy);
581       else if (phiB && phiA) { 
582         phiA->Add(phiB, -1);
583         phiA->Divide(phiB);
584         phiA->SetTitle("#Delta#phi from Ip (x,y) correction");
585         phiA->SetYTitle("(#phi_{after}-#phi_{before})/#phi_{before}");
586         DrawInPad(fBody, 5, phiA);
587       }
588       else {
589         fBody->cd(5);
590         TLatex* ltx = new TLatex(0.5, 0.5, "No outliers or #phi corrections");
591         ltx->SetTextAlign(22);
592         ltx->SetTextSize(0.07);
593         ltx->SetNDC();
594         ltx->Draw();
595       }
596       DrawInPad(fBody, 6, GetH2(sc, "phiAcc"), "colz",   kLogz);
597     
598       ShowSliceFit(true, corr, 10, fBody, 1, kLogz, outlierCut);
599
600       if (diff && diffOut) { 
601         fBody->cd(2);
602         Double_t in  = diff->GetEntries();
603         Double_t out = diffOut->GetEntries();
604         if ((in+out) > 0) {
605           TLatex*  ltx = new TLatex(0.11, 0.89, 
606                                     Form("Fraction: %7.3f%%", 
607                                          100*out/(in+out)));
608           ltx->SetNDC();
609           ltx->SetTextAlign(13);
610           ltx->SetTextSize(0.06);
611           ltx->Draw();
612         }
613       }
614       PrintCanvas(Form("Density calculator - %s", *ptr));
615       ptr++;    
616     }
617
618     TCollection* cc = GetCollection(c, "esd_mc_comparison", false); 
619     if (!cc) return; // Not MC 
620
621     fBody->Divide(2,5);
622     ptr   = GetRingNames(false);
623     Int_t cnt = 0;
624     while (*ptr) { 
625       DrawInPad(fBody, 2*cnt+1, GetH2(cc, Form("%s_corr_mc_esd", *ptr)),
626                 "colz", kLogz);
627       DrawInPad(fBody, 2*(cnt+1), GetH2(cc, Form("%s_diff_mc_esd", *ptr)),
628                 "", kLogz);
629       ptr++;
630       cnt++;
631     }
632
633     PrintCanvas("Density calculator - MC vs Reco");
634   }
635
636   //____________________________________________________________________
637   void DrawCorrector()
638   {
639     Info("DrawCorrector", "Drawing corrector"); 
640     TCollection* c = GetCollection(fSums, "fmdCorrector"); 
641     if (!c) return;
642   
643     fBody->cd();
644   
645     Double_t y = .8;  
646     Bool_t secondary=false, vertexBias=false, acceptance=false, merging=false;  
647     if (GetParameter(c, "secondary", secondary))
648       DrawParameter(y, "Secondary corr.", secondary ? "yes" : "no");
649     if (GetParameter(c, "acceptance", acceptance))
650       DrawParameter(y, "Acceptance corr.", acceptance ? "yes" : "no");
651     if (GetParameter(c, "vertexBias", vertexBias))
652       DrawParameter(y, "Vertex bias corr.", vertexBias ? "yes" : "no");
653     if (GetParameter(c, "merging", merging))  
654       DrawParameter(y, "Merging eff.", merging ? "yes" : "no");
655     
656     PrintCanvas("Corrector");
657
658     TCollection* cc = GetCollection(c, "esd_mc_comparison", false); 
659     if (!cc) return; // Not MC 
660     
661     DivideForRings(false, false);
662     const char** ptr = GetRingNames(false);
663     while (*ptr) { 
664       DrawInRingPad(GetH2(cc, Form("%s_esd_vs_mc", *ptr)), "colz", 0x0);
665       ptr++;
666     }
667
668     PrintCanvas("Corrector - MC vs Reco");
669   }
670
671   //____________________________________________________________________
672   void DrawHistCollector()
673   {
674     Info("DrawHistCollector", "Drawing histogram collector");  
675     TCollection* c = GetCollection(fSums, "fmdHistCollector");
676     if (!c) return;
677
678     fBody->Divide(2, 1);
679     TVirtualPad* p = fBody->cd(1);
680     p->Divide(1,2);
681     p->cd(1);
682
683     Double_t y = .8;
684     Int_t nCutBins=0, fiducial=0, merge=0, skipRings=0;
685     Double_t fiducialCut=0.;
686     Bool_t  bgAndHits=false;
687     Double_t size = fLandscape ? 0.06 : 0.04;
688     if (GetParameter(c, "nCutBins", nCutBins))
689       DrawParameter(y, "# of bins to cut", Form("%d", nCutBins),size);
690
691     if (GetParameter(c, "skipRings", skipRings)) {
692       TString skipped;
693       if (skipRings & 0x05) skipped.Append("FMD1i ");
694       if (skipRings & 0x09) skipped.Append("FMD2i ");
695       if (skipRings & 0x0a) skipped.Append("FMD2o ");
696       if (skipRings & 0x11) skipped.Append("FMD3i ");
697       if (skipRings & 0x12) skipped.Append("FMD3o ");
698       if (skipped.IsNull()) skipped = "none";
699       DrawParameter(y, "Skipped rings", skipped, size);
700     }
701     if (GetParameter(c, "bgAndHits", bgAndHits))
702       DrawParameter(y, "Bg & hit maps stored.", bgAndHits?"yes":"no",size);
703     if (GetParameter(c, "merge", merge))
704       DrawParameter(y, "Merge method", 
705                     (merge == 0 ? "straight mean" :
706                      merge == 1 ? "straight mean, no zeroes" : 
707                      merge == 2 ? "weighted mean" : 
708                      merge == 3 ? "least error" : 
709                      merge == 4 ? "sum" : "unknown"),size);
710     if (GetParameter(c, "fiducial", fiducial))
711       DrawParameter(y, "Fiducial method.", 
712                     fiducial == 0 ? "cut" : "distance", size);
713     if (GetParameter(c, "fiducialCut", fiducialCut))
714       DrawParameter(y, "Fiducial cut.", Form("%f", fiducialCut), size);
715
716     // p->cd(2);
717     // Printf("Drawing skipped");
718     TH1* skipped = GetH1(c, "skipped");
719     if (skipped) { 
720       skipped->SetFillColor(kRed+1);
721       skipped->SetFillStyle(3001);
722     }
723     DrawInPad(p, 2, skipped, "hist");
724                  
725     p = fBody->cd(2);
726     p->Divide(1,2,0,0);
727
728     // Printf("Drawing sumRings");
729     DrawInPad(p, 1, GetH2(c, "sumRings"), "colz"); 
730     // Printf("Drawing coverage");
731     DrawInPad(p, 2, GetH2(c, "coverage"), "colz");
732     // Printf("Done drawing for now");
733     PrintCanvas("Histogram collector");
734                 
735     
736     TIter next(c);
737     TObject* o = 0;
738     TRegexp regexp("[pm][0-9]+_[pm][0-9]+");
739     while ((o = next())) { 
740       TString name(o->GetName());
741       if (name.Index(regexp) == kNPOS) continue;
742       
743       TList* vl = static_cast<TList*>(o);
744       if (!vl) continue;
745
746       DivideForRings(false, false);
747       const char** ptr = GetRingNames(false);
748       while (*ptr) { 
749         DrawInRingPad(GetH2(vl, Form("secMap%s", *ptr)), "colz", 0x0);
750         DrawInRingPad(GetH2(vl, Form("hitMap%s", *ptr)), "box same", 0x0);
751         ptr++;
752       }
753       PrintCanvas(Form("Histogram Collector - Vertex bin %s", vl->GetName()));
754     }
755
756     o = c->FindObject("byCentrality");
757     if (!o) return;
758     TList* bc = static_cast<TList*>(o);
759
760     DrawInPad(fBody, GetH3(bc, "FMD1I"), "box", 0);
761     DrawInPad(fBody, GetH3(bc, "FMD2I"), "box same", 0);
762     DrawInPad(fBody, GetH3(bc, "FMD2O"), "box same", 0);
763     DrawInPad(fBody, GetH3(bc, "FMD3O"), "box same", 0);
764     DrawInPad(fBody, GetH3(bc, "FMD3I"), "box same", kLegend);
765   }
766
767   //____________________________________________________________________
768   void DrawCentral()
769   {
770     Info("DrawCentral", "Drawing central (SPD)");  
771     TCollection* c = fSums; 
772     if (!c) return;
773
774     fBody->Divide(2, 2);
775     fBody->cd(1);
776     Double_t y = .7;  
777     Bool_t secondary=false, acceptance=false;  
778     if (GetParameter(c, "secondary", secondary))
779       DrawParameter(y, "Secondary corr.", secondary ? "yes" : "no");
780     if (GetParameter(c, "acceptance", acceptance))
781       DrawParameter(y, "Acceptance corr.", acceptance ? "yes" : "no");
782
783                  
784     DrawInPad(fBody, 2, GetH2(c, "coverage"), "col", 0,
785               "#eta coverage per v_{z}");
786     TH2* cvst = GetH2(c, "nClusterVsnTracklet");
787     if (cvst) {
788       // cvst->Scale(1, "width");
789       cvst->GetXaxis()->SetTitle("N_{free cluster}");
790       cvst->GetYaxis()->SetTitle("N_{tracklet}");
791       cvst->GetXaxis()->SetRangeUser(1,10000);
792       cvst->GetYaxis()->SetRangeUser(1,10000);
793     }
794     DrawInPad(fBody, 3, cvst, "colz", kLogx|kLogy|kLogz,
795               "Correlation of # of tracklets and clusters"); 
796     DrawInPad(fBody, 4, GetH2(c, "clusterPerTracklet"), "colz", 0x0,
797               "# clusters per tracklet vs #eta"); 
798     ShowSliceFit(true, cvst, 3, fBody, 3, 0x8000|kLogz);
799
800     fBody->cd(1)->Modified();
801     fBody->cd(2)->Modified();
802     fBody->cd(3)->Modified();
803     fBody->cd(4)->Modified();
804     fBody->cd(1)->Update();
805     fBody->cd(2)->Update();
806     fBody->cd(3)->Update();
807     fBody->cd(4)->Update();
808     PrintCanvas("Central - overview");
809                 
810     
811     TIter next(c);
812     TObject* o = 0;
813     TRegexp regexp("[pm][0-9]+_[pm][0-9]+");
814     while ((o = next())) { 
815       TString name(o->GetName());
816       if (name.Index(regexp) == kNPOS) continue;
817       
818       TList* vl = static_cast<TList*>(o);
819
820       fBody->Divide(1, 3);
821     
822       DrawInPad(fBody, 1, GetH1(vl, "acceptance"), "", 0);
823
824       TH1* sec = GetH1(vl, "secondary");
825       sec->SetMarkerStyle(21);
826       sec->SetMarkerSize(1.2);
827       DrawInPad(fBody, 2, sec, "", 0);
828       DrawInPad(fBody, 2, GetH1(vl, "secondaryFiducial"),    "same", 0x0);
829       DrawInPad(fBody, 3, GetH2(vl, "secondaryMapFiducial"), "colz", 0);
830       DrawInPad(fBody, 3, GetH2(vl, "hitMap"),               "box same", 0x0);
831
832       fBody->cd(1)->Modified();
833       fBody->cd(2)->Modified();
834       fBody->cd(3)->Modified();
835       fBody->cd(1)->Update();
836       fBody->cd(2)->Update();
837       fBody->cd(3)->Update();
838       PrintCanvas(Form("Central - Vertex bin %s", vl->GetName()));
839     }
840   }
841
842   
843   //____________________________________________________________________
844   void AddToAll(THStack* all, const THStack* stack, Int_t curr, Int_t step)
845   {
846     if (!stack) return;
847
848     TIter   next(stack->GetHists());
849     TH1*    h = 0;
850     while ((h = static_cast<TH1*>(next()))) {
851       TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName())));
852       copy->SetDirectory(0);
853       if (curr != step) {
854         copy->SetMarkerColor(kGray);
855         copy->SetLineColor(kGray);
856       }
857       all->Add(copy);
858     }
859   }
860   //____________________________________________________________________
861   void AddToAll(THStack* all, const THStack* stack)
862   {
863     if (!stack) return;
864
865     TIter   next(stack->GetHists());
866     TH1*    h = 0;
867     while ((h = static_cast<TH1*>(next()))) {
868       TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName())));
869       copy->SetDirectory(0);
870       copy->SetMarkerColor(kGray);
871       copy->SetLineColor(kGray);
872       all->Add(copy);
873     }
874   }
875
876   //____________________________________________________________________
877   void DrawStep(Int_t        step,
878                 THStack*     all,
879                 TObject*     cur,
880                 TLegend*     leg,
881                 const char*  title,
882                 TVirtualPad* can,
883                 Int_t        sub,
884                 Int_t        nCol)
885   {
886     if (all->GetHists()->GetEntries() <= 0 || !cur) return;
887
888     // Info("", "Drawing step # %d", step);
889     Bool_t       left = sub % nCol == 1; 
890     Bool_t       right= sub % nCol == 0;
891     Bool_t       top  = (sub-1) / nCol == 0;
892     TVirtualPad* p    = can->cd(sub);
893     gStyle->SetOptTitle(0);
894     p->SetTitle(Form("Step # %d", step));
895     p->SetFillColor(kWhite);
896     p->SetRightMargin(right ? 0.02 : 0);
897     p->SetTopMargin(top ? 0.02 : 0); // 0.02);
898     // Info("", "Drawing step %d in sub-pad %d (%s)", 
899     //      step, sub, (left?"left":"right"));
900
901     p->cd();
902     all->Draw("nostack");
903     all->GetHistogram()->SetXTitle("#eta");
904     all->GetHistogram()->SetYTitle("signal");
905
906     TLegendEntry* e = 
907       static_cast<TLegendEntry*>(leg->GetListOfPrimitives()->At(step-1));
908     if (e) {
909       e->SetMarkerColor(kBlack);
910       e->SetLineColor(kBlack);
911       e->SetTextColor(kBlack);
912     }
913
914     // p->cd();
915     gROOT->SetSelectedPad(p);
916     cur->DrawClone("same nostack");
917     leg->DrawClone("");
918
919     TLatex* ltx = new TLatex(.97, .97, title);
920     ltx->SetNDC();
921     ltx->SetTextSize(.06);
922     ltx->SetTextAlign(33);
923     ltx->Draw();
924
925     ltx = new TLatex((left ? .12 : .02), .97, p->GetTitle());
926     ltx->SetNDC();
927     ltx->SetTextSize(.06);
928     ltx->SetTextAlign(13);
929     ltx->Draw();
930
931     if (step > 1) { 
932       Double_t x1 = 0.5*(p->GetUxmax()+p->GetUxmin());
933       Double_t x2 = x1;
934       Double_t y1 = p->GetUymax();
935       Double_t y2 = 0.92*y1;
936       Double_t sz = 0.05;
937       if (fLandscape) { 
938         x1 = 0.99*p->GetUxmin();
939         x2 = 0.80*x1;
940         y1 = .5*(p->GetUymax()+p->GetUymin());
941         y2 = y1;
942         sz = 0.034;
943       }
944       // Info("", "Arrow at (x1,y1)=%f,%f (x2,y2)=%f,%f", x1, y1, x2, y2);
945       TArrow* a = new TArrow(x1, y1, x2, y2, sz, "|>");
946       // (fLandscape ? "<|" : "|>"));
947       a->SetFillColor(kGray+1);
948       a->SetLineColor(kGray+1);
949       a->Draw();
950     }
951     p->Modified();
952     p->Update();
953     p->cd();
954
955     if (e) {
956       e->SetMarkerColor(kGray);
957       e->SetLineColor(kGray);
958       e->SetTextColor(kGray);
959     }
960     gStyle->SetOptTitle(1);
961   }
962
963   //____________________________________________________________________
964   void FixStack(THStack* stack, const TString& title, 
965                 const TString& extra, Int_t marker)
966   {
967     if (!stack) return;
968     stack->SetTitle(title);
969     TIter next(stack->GetHists());
970     TH1*  h = 0;
971     while ((h = static_cast<TH1*>(next())))  {
972       h->SetMarkerStyle(marker);
973       TString tit(h->GetTitle());
974       tit.ReplaceAll("cache", "");
975       tit.Append(extra);
976       h->SetTitle(tit);
977     }
978   }
979   void AddLegendEntry(TLegend* l, 
980                       const TH1* h, 
981                       const TString& title)
982   {
983     if (!h) return;
984
985     TLegendEntry* e = l->AddEntry("dummy", title.Data(), "pl");
986     e->SetMarkerStyle(h->GetMarkerStyle());
987     e->SetMarkerColor(kGray);
988     e->SetLineColor(kGray);
989     e->SetTextColor(kGray);
990   }
991                       
992
993   //____________________________________________________________________
994   void DrawSteps()
995   {
996     // MakeChapter(can, "Steps");
997
998     THStack* esds    = GetStack(GetCollection(fResults, "fmdSharingFilter"), 
999                                 "sumsESD", "summedESD");
1000     THStack* deltas  = GetStack(GetCollection(fResults, "fmdSharingFilter"), 
1001                                 "sums", "summed");
1002     THStack* nchs    = GetStack(GetCollection(fResults, 
1003                                               "fmdDensityCalculator"), 
1004                                 "sums", "inclDensity");
1005     THStack* prims   = GetStack(GetCollection(fResults, "fmdCorrector"), 
1006                                 "sums", "primaryDensity");
1007     THStack* rings   = GetStack(GetCollection(fResults, "ringResults"), "all");
1008     THStack* mcRings = GetStack(GetCollection(fResults, "mcRingResults", false),
1009                                 "all","dndeta_eta", false);
1010     TH1*     dndeta  = GetH1(fResults, "dNdeta");
1011     if (dndeta) dndeta->SetMarkerColor(kBlack);
1012
1013     FixStack(esds,   "#sum_{s} #Delta/#Delta_{mip}", "",     20);
1014     FixStack(deltas, "#sum_{c} #Delta/#Delta_{mip}", "",     21);
1015     FixStack(nchs,   "#sum_{b} N_{ch,incl}",         "",     22);
1016     FixStack(prims,  "#sum_{b} N_{ch,primary}",      "",     23);
1017     FixStack(rings,  "dN/d#eta per ring",            "",     33);
1018     FixStack(mcRings,"dN/d#eta per ring (MC)",       "(MC)", 34);
1019
1020     THStack* all = new THStack;
1021     AddToAll(all, mcRings);
1022     AddToAll(all, esds);
1023     AddToAll(all, deltas);
1024     AddToAll(all, nchs);
1025     AddToAll(all, prims);
1026     AddToAll(all, rings);
1027
1028     TH1* res = 0;
1029     if (dndeta) {
1030       res = static_cast<TH1*>(dndeta->Clone("dNdeta"));
1031       res->SetTitle("dN/d#eta");
1032       res->SetMarkerColor(kGray);
1033       res->SetLineColor(kGray);
1034       res->SetDirectory(0);
1035       all->Add(res);
1036     }
1037
1038     TLegend* l = new TLegend(.35, .2, .55, .9);
1039     l->SetFillColor(kWhite);
1040     l->SetFillStyle(0);
1041     l->SetBorderSize(0);
1042     TLegendEntry* e = 0;
1043
1044     TH1* h = 0;
1045     if (mcRings) {
1046       h = static_cast<TH1*>(mcRings->GetHists()->At(0));
1047       AddLegendEntry(l, h, mcRings->GetTitle());
1048     }
1049
1050     if (esds) {
1051       h = static_cast<TH1*>(esds->GetHists()->At(0));
1052       AddLegendEntry(l, h, esds->GetTitle());
1053     }
1054
1055     if (deltas) {
1056       h = static_cast<TH1*>(deltas->GetHists()->At(0));
1057       AddLegendEntry(l, h, deltas->GetTitle());    
1058     }
1059
1060     if (nchs) {
1061       h = static_cast<TH1*>(nchs->GetHists()->At(0));
1062       AddLegendEntry(l, h, nchs->GetTitle());    
1063     }
1064
1065     if (prims) {
1066       h = static_cast<TH1*>(prims->GetHists()->At(0));
1067       AddLegendEntry(l, h, prims->GetTitle());    
1068     }
1069
1070     if (rings) {
1071       h = static_cast<TH1*>(rings->GetHists()->At(0));
1072       AddLegendEntry(l, h, rings->GetTitle());    
1073     }
1074
1075     if (res) {
1076       h = res;
1077       AddLegendEntry(l, h, h->GetTitle());
1078     }
1079     
1080     TObject* objs[] = { mcRings, 
1081                         esds, 
1082                         deltas, 
1083                         nchs, 
1084                         prims, 
1085                         rings, 
1086                         dndeta };
1087     const char* titles[] = { /* 1 */ "MC",  
1088                              /* 2 */ "ESD input",
1089                              /* 3 */ "After merging", 
1090                              /* 4 */ "After particle counting", 
1091                              /* 5 */ "After corrections", 
1092                              /* 6 */ "After normalization", 
1093                              /* 7 */ "After combining" };
1094     Int_t nY = mcRings ? 4 : 3;
1095     Int_t nX = 2;
1096     if (fLandscape) {
1097       Int_t tmp = nX;
1098       nX        = nY;
1099       nY        = tmp;
1100     }
1101     fBody->Divide(nX, nY, 0, 0);
1102     
1103     Int_t step = 0;
1104     for (Int_t i = 0; i < 7; i++) { 
1105       TObject* obj = objs[i];
1106       if (!obj) continue;
1107
1108       step++;
1109       Int_t padNo = step;
1110       if (!fLandscape) {
1111         switch (step) { 
1112         case 1: padNo = 1; break; 
1113         case 2: padNo = 3; break; 
1114         case 3: padNo = 5; break; 
1115         case 4: padNo = (mcRings ? 7 : 2); break; 
1116         case 5: padNo = (mcRings ? 2 : 4); break; 
1117         case 6: padNo = (mcRings ? 4 : 6); break; 
1118         case 7: padNo = (mcRings ? 6 : 8); break; 
1119     }
1120       }
1121       //Printf("Drawing step %d in sub-pad %d (%s)",step,padNo,obj->GetTitle());
1122       DrawStep(step, all, obj, l, titles[i], fBody, padNo, nX);
1123     }
1124
1125     if (!esds && !mcRings && deltas) { 
1126       fBody->cd(6);
1127       TLegend* ll = new TLegend(0.01, 0.11, 0.99, 0.99);
1128       // ll->SetNDC();
1129       ll->SetFillColor(kWhite);
1130       ll->SetFillStyle(0);
1131       ll->SetBorderSize(0);
1132
1133       TIter next(deltas->GetHists());
1134       TH1*  hh = 0;
1135       while ((hh = static_cast<TH1*>(next()))) {
1136         e = ll->AddEntry("dummy", hh->GetTitle(), "pl");
1137         e->SetMarkerColor(hh->GetMarkerColor());
1138         e->SetMarkerStyle(hh->GetMarkerStyle());
1139         e->SetLineColor(kBlack);
1140       }
1141       ll->Draw();
1142     }
1143     // Printf("Done drawing steps");
1144     PrintCanvas("Steps");
1145   }
1146
1147
1148   //____________________________________________________________________
1149   void DrawResults()
1150   {
1151     // MakeChapter(can, "Results");
1152
1153     fBody->Divide(2,1);
1154
1155     TCollection* c = GetCollection(fResults, "ringResults");
1156     if (!c) return;
1157   
1158     THStack* mcRings = GetStack(GetCollection(fResults, "mcRingResults", false),
1159                                 "all", "dndeta_eta", false);
1160
1161     TH1* dndeta_phi = GetH1(fResults, "dNdeta");
1162     TH1* dndeta_eta = GetH1(fResults, "dNdeta_");
1163     dndeta_phi->SetTitle("1/N_{ev}dN_{ch}/d#eta (#varphi norm)");
1164     dndeta_eta->SetTitle("1/N_{ev}dN_{ch}/d#eta (#eta norm)");
1165     dndeta_eta->SetMarkerSize(0.7);
1166
1167     THStack* allPhi = new THStack("phiAcc", "#varphi Acceptance");
1168     THStack* allEta = new THStack("etaCov", "#eta Coverage");
1169     const char** pring   = GetRingNames(false);
1170     
1171     while ((*pring)) { 
1172       TCollection* cc     = GetCollection(c, *pring);
1173       TH1*         etaCov = GetH1(cc, "etaCov");
1174       TH1*         phiAcc = GetH1(cc, "phiAcc");
1175       TH1*         dndeta = GetH1(cc, "dndeta_phi");
1176       Int_t        color  = kBlack;
1177       if (dndeta)  color  = dndeta->GetMarkerColor();
1178       if (etaCov) { 
1179         etaCov->SetTitle(*pring);
1180         etaCov->SetFillColor(color);
1181         etaCov->SetLineColor(color);
1182         allEta->Add(etaCov);
1183       }
1184       if (phiAcc) { 
1185         phiAcc->SetFillColor(color);
1186         phiAcc->SetLineColor(color);
1187         allPhi->Add(phiAcc);
1188       }
1189       pring++;
1190     }
1191     Double_t savX = fParVal->GetX();
1192     Double_t savY = fParVal->GetY();
1193     fParVal->SetX(.3);
1194     fParVal->SetY(.2);
1195     TVirtualPad* p = fBody->cd(1);
1196     p->Divide(1,2,0,0);
1197     DrawInPad(p, 1, GetStack(c, "all"), "nostack", mcRings ? 0 : kLegend,
1198               "Individual ring results");
1199     DrawInPad(p, 1, mcRings, "nostack same", kLegend|kSilent);
1200     DrawInPad(p, 2, allEta, "nostack hist", kLegend,
1201               "#phi acceptance and #eta coverage per ring");
1202     DrawInPad(p, 2, allPhi, "nostack hist same", 0x0);
1203
1204     p = fBody->cd(2);
1205     p->Divide(1,2,0,0);
1206     DrawInPad(p, 1, dndeta_phi, "", 0x0, 
1207               "1/#it{N}_{ev} d#it{N}_{ch}/d#it{#eta}");
1208     DrawInPad(p, 1, dndeta_eta, "Same", kLegend);
1209     DrawInPad(p, 2, GetH1(fResults, "norm"), "", 0x0, 
1210               "Total #phi acceptance and #eta coverage");
1211     DrawInPad(p, 2, GetH1(fResults, "phi"), "same", kLegend);
1212     // DrawInPad(fBody, 4, GetH1(fSums,    "d2Ndetadphi"), "colz");
1213
1214     // fBody->cd(1);
1215     // TLatex* l = new TLatex(.5, .2, "Ring results");
1216     // l->SetNDC();
1217     // l->SetTextAlign(21);
1218     // l->Draw();
1219
1220     // fBody->cd(2);
1221     // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta");
1222
1223     // fBody->cd(3);
1224     // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta (#vta norm.)");
1225     
1226     fParVal->SetX(savX);
1227     fParVal->SetY(savY);
1228     PrintCanvas("Results");
1229   }
1230
1231   //____________________________________________________________________
1232   void DrawCentralResults()
1233   {
1234     // MakeChapter(can, "Results");
1235     Info("DrawCentralResults", "Drawing central results");
1236
1237     fBody->Divide(1,2,0,0);
1238
1239     TH1* dndeta_ = GetH1(fResults, "dNdeta_");
1240     TH1* dndeta  = GetH1(fResults, "dNdeta");
1241     THStack* stack = new THStack("dndetas", 
1242                                  "d#it{N}_{ch}/d#it{#eta} - central");
1243     stack->Add(dndeta_);
1244     stack->Add(dndeta);
1245     
1246     DrawInPad(fBody, 1, stack, "nostack");
1247     TH1* h = stack->GetHistogram();
1248     if (h) {
1249       h->SetXTitle("#it{#eta}");
1250       h->SetYTitle("#frac{d#it{N}_{ch}}{d#it{#eta}}");
1251     }
1252     fBody->cd(1);
1253     TLegend* l = new TLegend(.3, .05, .7, .4);
1254     l->SetFillColor(0);
1255     l->SetFillStyle(0);
1256     l->SetBorderSize(0);
1257     l->AddEntry(dndeta_, "Normalized to coverage",        "lp");
1258     l->AddEntry(dndeta,  "Normalized to #phi acceptance", "lp");
1259     l->Draw();
1260
1261     DrawInPad(fBody, 2, GetH1(fResults, "norm"));
1262     DrawInPad(fBody, 2, GetH1(fResults, "phi"), "same", kLegend);
1263
1264     PrintCanvas("Central Results");
1265
1266   }
1267   void DrawBoth(TFile* file)
1268   {
1269     Info("DrawBoth", "Drawing central & forward results");
1270     TCollection* central = GetCollection(file, "CentralResults");
1271     TCollection* forward = GetCollection(file, "ForwardResults");
1272     
1273     if (!central || !forward) {
1274       Warning("DrawBoth", "central %p or forward %p results not found", 
1275               central, forward);
1276       return;
1277     }
1278
1279     TH1* f1 = GetH1(forward, "dNdeta_");
1280     TH1* c1 = GetH1(central, "dNdeta_");
1281     TH1* f2 = GetH1(forward, "dNdeta");
1282     TH1* c2 = GetH1(central, "dNdeta");
1283     f1->SetLineColor(kBlack);
1284     f2->SetLineColor(kBlack);
1285     c1->SetLineColor(kBlack);
1286     c2->SetLineColor(kBlack);
1287     f1->SetMarkerColor(f2->GetMarkerColor());
1288     f1->SetMarkerStyle(24);
1289     c1->SetMarkerStyle(24);
1290     c2->SetMarkerStyle(20);
1291     c2->SetMarkerColor(c1->GetMarkerColor());
1292     THStack* s = new THStack("dndetas", "d#it{N}_{ch}/d#it{#eta}");
1293     s->Add(f1);
1294     s->Add(c1);
1295     s->Add(f2);
1296     s->Add(c2);
1297
1298     fBody->Divide(1, 2, 0, 0);
1299     DrawInPad(fBody, 1, s, "nostack");
1300     s->GetHistogram()->SetXTitle("#it{#eta}");
1301     s->GetHistogram()->SetYTitle("#frac{d#it{N}_{ch}}{d#it{#eta}}");
1302     
1303     fBody->cd(1);
1304     TLegend* l = new TLegend(.4, .05, .8, .4);
1305     l->SetFillColor(0);
1306     l->SetFillStyle(0);
1307     l->SetBorderSize(0);
1308     TLegendEntry* entry = l->AddEntry("dummy", "Forward", "f");
1309     entry->SetFillColor(f1->GetMarkerColor());
1310     entry->SetLineColor(f1->GetMarkerColor());
1311     entry->SetFillStyle(1001);
1312     entry->SetLineWidth(0);
1313     entry = l->AddEntry("dummy", "Central", "f");
1314     entry->SetFillColor(c1->GetMarkerColor());
1315     entry->SetLineColor(c1->GetMarkerColor());
1316     entry->SetLineWidth(0);
1317     entry->SetFillStyle(1001);
1318     entry = l->AddEntry("dummy", "Normalized to coverage", "lp");
1319     entry->SetMarkerStyle(f1->GetMarkerStyle());
1320     entry = l->AddEntry("dummy", "Normalized to #phi acceptance", "lp");
1321     entry->SetMarkerStyle(f2->GetMarkerStyle());
1322     l->Draw();
1323
1324     TH1* f3 = GetH1(forward, "norm");
1325     TH1* c3 = GetH1(central, "norm");
1326     TH1* f4 = GetH1(forward, "phi");
1327     TH1* c4 = GetH1(central, "phi");
1328     f3->SetFillColor(f1->GetMarkerColor());
1329     f4->SetFillColor(f1->GetMarkerColor());
1330     c3->SetFillColor(c1->GetMarkerColor());
1331     c4->SetFillColor(c1->GetMarkerColor());
1332     f3->SetLineColor(f1->GetMarkerColor());
1333     f4->SetLineColor(f1->GetMarkerColor());
1334     c3->SetLineColor(c1->GetMarkerColor());
1335     c4->SetLineColor(c1->GetMarkerColor());
1336     
1337     THStack* a = new THStack("norms", "Normalizations");
1338     a->Add(f3);
1339     a->Add(c3);
1340     a->Add(f4);
1341     a->Add(c4);
1342     
1343     a->SetMaximum(a->GetMaximum("nostack")*1.2);
1344     DrawInPad(fBody, 2, a, "nostack");
1345     a->GetHistogram()->SetXTitle("#it{#eta}");
1346     a->GetHistogram()->SetYTitle("Normalization (coverage or acceptance)");
1347     
1348     fBody->cd(2);
1349     l = new TLegend(.2, .94, .9, .99);
1350     l->SetFillColor(0);
1351     l->SetFillStyle(0);
1352     l->SetBorderSize(0);
1353     l->SetNColumns(2);
1354     // entry = l->AddEntry("dummy", "Forward", "f");
1355     // entry->SetFillColor(f1->GetMarkerColor());
1356     // entry->SetLineColor(f1->GetMarkerColor());
1357     // entry->SetFillStyle(1001);
1358     // entry->SetLineWidth(0);
1359     // entry = l->AddEntry("dummy", "Central", "f");
1360     // entry->SetFillColor(c1->GetMarkerColor());
1361     // entry->SetLineColor(c1->GetMarkerColor());
1362     // entry->SetLineWidth(0);
1363     // entry->SetFillStyle(1001);
1364     entry = l->AddEntry("dummy", "#eta Coverage", "f");
1365     entry->SetFillStyle(f3->GetFillStyle());
1366     entry->SetFillColor(kBlack);
1367     entry = l->AddEntry("dummy", "#phi Acceptance", "f");
1368     entry->SetFillStyle(f4->GetFillStyle());
1369     entry->SetFillColor(kBlack);
1370     l->Draw();
1371
1372     PrintCanvas("Both results");
1373   }
1374   TCollection* fSums;
1375   TCollection* fResults;
1376 };
1377
1378 // #endif