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