]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/scripts/SummaryAODDrawer.C
Addd script to generate summary documents
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / scripts / SummaryAODDrawer.C
1 #include "SummaryDrawer.C"
2
3
4 class SummaryAODDrawer : public SummaryDrawer
5 {
6 public:
7   SummaryAODDrawer() 
8     : SummaryDrawer(),
9       fSums(0),
10       fResults(0)
11   {}
12   
13   //__________________________________________________________________
14   /** 
15    * 
16    * 
17    * @param fname 
18    * @param what 
19    */
20   void Run(const char* fname, UShort_t what=0x7F)
21   {
22     // --- Open the file ---------------------------------------------
23     TString filename(fname);
24     TFile*  file = TFile::Open(filename, "READ");
25     if (!file) { 
26       Error("Run", "Failed to open \"%s\"", filename.Data());
27       return;
28     }
29     
30     // --- Get top-level collection ----------------------------------
31     fSums = GetCollection(file, "Forward");
32     if (!fSums) return;
33
34     // --- Make our canvas -------------------------------------------
35     TString pdfName(filename);
36     pdfName.ReplaceAll(".root", ".pdf");
37     CreateCanvas(pdfName, what & 0x100);
38     
39     // --- Set pause flag --------------------------------------------
40     fPause = what & 0x80;
41
42     // --- Do each sub-algorithm -------------------------------------
43     if (what & 0x01) DrawEventInspector();
44     if (what & 0x02) DrawSharingFilter();
45     if (what & 0x04) DrawDensityCalculator();
46     if (what & 0x08) DrawCorrector();
47     if (what & 0x10) DrawHistCollector();
48   
49     // --- Do the results ----------------------------------------------
50     fResults = GetCollection(file, "ForwardResults");
51     if (!fResults) fResults = fSums; // Old-style
52     
53     if (what & 0x20) DrawSteps();
54     if (what & 0x40) DrawResults();
55   
56     CloseCanvas();
57   }
58 protected:
59   //____________________________________________________________________
60   void DrawEventInspector()
61   {
62     Info("DrawEventInspector", "Drawing event inspector");
63     TCollection* c = GetCollection(fSums, "fmdEventInspector");
64     if (!c) return;
65
66     Int_t sys=0, sNN=0, field=0, runNo=0, lowFlux=0, nPileUp=0;
67     Int_t aliRev=0, aliBra=0;
68     Bool_t fpVtx=false, v0and=false;
69     Double_t dPileUp=0.;
70     Double_t y = .8;
71
72     GetParameter(c, "sys",           sys);
73     GetParameter(c, "sNN",           sNN);
74     GetParameter(c, "field",         field);
75     GetParameter(c, "runNo",         runNo);
76     GetParameter(c, "lowFlux",       lowFlux);
77     GetParameter(c, "fpVtx",         fpVtx);
78     GetParameter(c, "v0and",         v0and);
79     GetParameter(c, "nPileUp",       nPileUp);
80     GetParameter(c, "dPileup",       dPileUp);
81     GetParameter(c, "alirootRev",    aliRev);
82     GetParameter(c, "alirootBranch", aliBra);
83
84     fBody->cd();
85
86     Double_t save = fParName->GetTextSize();
87     fParName->SetTextSize(0.03);
88     fParVal->SetTextSize(0.03);
89     DrawParameter(y, "System", (sys == 1 ? "pp" : sys == 2 ? "PbPb" : 
90                                 sys == 3 ? "pPb" : "unknown"));
91     DrawParameter(y, "#sqrt{s_{NN}}",                   Form("%5dGeV", sNN));
92     DrawParameter(y, "L3 B field",                      Form("%+2dkG", field));
93     DrawParameter(y, "Run #",                           Form("%6d", runNo));
94     DrawParameter(y, "Low flux cut",                    Form("%6d", lowFlux));
95     DrawParameter(y, "Use PWG-UD vertex",               (fpVtx ? "yes" : "no"));
96     DrawParameter(y, "Use V0AND for NSD",               (v0and ? "yes" : "no"));
97     DrawParameter(y, "Least # of pile-up vertex",       Form("%d", nPileUp));
98     DrawParameter(y, "Least distance of pile-up vertex",Form("%fcm", dPileUp));
99     DrawParameter(y, "AliROOT", Form("%7lu/0x%8lx", ULong_t(aliRev), 
100                                      ULong_t(aliBra)));
101
102     PrintCanvas("Event Inspector");
103     fParName->SetTextSize(save);
104     fParVal->SetTextSize(save);
105
106     fBody->Divide(2,4);
107     
108     TH1*    nEventsTr    = GetH1(c, "nEventsTr");
109     TH1*    nEventsTrVtx = GetH1(c, "nEventsTrVtx");
110     TH1*    vertex       = GetH1(c, "vertex", false);
111     Bool_t  mc           = (vertex != 0);
112     if (nEventsTr)    nEventsTr->Rebin(2);
113     if (nEventsTrVtx) nEventsTrVtx->Rebin(2);
114     if (vertex) {
115       // vertex->Rebin(2);
116       vertex->SetFillColor(kMagenta+2);
117     }
118     DrawInPad(fBody, 1, nEventsTr);
119     DrawInPad(fBody, 1, vertex, "same");
120     DrawInPad(fBody, 1, nEventsTrVtx, "same"); 
121     DrawInPad(fBody, 1, GetH1(c, "nEventsAccepted"), "same", 0x10);
122
123
124     DrawInPad(fBody, 2, GetH2(c, "nEventsAcceptedXY"), "colz", 0x4);
125     DrawInPad(fBody, 3, GetH1(c, "triggers"),          "hist text");
126     DrawInPad(fBody, 4, GetH2(c, "triggerCorr"),       "colz", 0x4);
127     DrawInPad(fBody, 5, GetH1(c, "status"),            "hist text");
128     DrawInPad(fBody, 6, GetH1(c, "type"),              "hist text");
129     DrawInPad(fBody, 7, GetH1(c, "cent"));
130     DrawInPad(fBody, 8, GetH2(c, "centVsQuality"), "colz", 0x4);
131
132     PrintCanvas("EventInspector - Histograms");  
133
134     if (!mc) return; // not MC 
135   
136     TH1* phiR         = GetH1(c, "phiR");
137     TH1* b            = GetH1(c, "b");
138     TH2* bVsNpart     = GetH2(c, "bVsParticipants");
139     TH2* bVsNbin      = GetH2(c, "bVsBinary");
140     TH2* bVsCent      = GetH2(c, "bVsCentrality");
141     TH2* vzComparison = GetH2(c, "vzComparison");
142     TH2* centVsNpart  = GetH2(c, "centralityVsParticipans");// Spelling!
143     TH2* centVsNbin   = GetH2(c, "centralityVsBinary");
144   
145     fBody->Divide(2,3);
146
147     DrawInPad(fBody, 1, phiR);
148     DrawInPad(fBody, 2, vzComparison, "colz", 0x4);
149     DrawInPad(fBody, 3, b);
150
151     TProfile* nPartB = bVsNpart->ProfileX("nPartB",1,-1,"s");
152     TProfile* nBinB  = bVsNbin->ProfileX("nBinB",1,-1,"s");
153     nPartB->SetMarkerColor(kBlue+2);
154     nPartB->SetMarkerStyle(20);
155     nPartB->SetLineColor(kBlue+2);
156     nPartB->SetFillColor(kBlue-10);
157     nPartB->SetFillStyle(1001);
158     nPartB->SetMarkerSize(0.7);
159     nBinB->SetMarkerColor(kRed+2);
160     nBinB->SetMarkerStyle(21);
161     nBinB->SetLineColor(kRed+2);
162     nBinB->SetFillColor(kRed-10);
163     nBinB->SetMarkerSize(0.7);
164     nBinB->SetFillStyle(1001);
165
166     DrawTwoInPad(fBody, 4, nPartB, nBinB, "e3 p", 0x10);
167
168     DrawInPad(fBody, 5, bVsCent, "colz", 0x4);
169
170     TProfile* nPartC = centVsNpart->ProfileY("nPartC",1,-1,"s");
171     TProfile* nBinC  = centVsNbin->ProfileY("nBinC",1,-1,"s");
172     nPartC->SetMarkerColor(kBlue+2);
173     nPartC->SetMarkerStyle(20);
174     nPartC->SetLineColor(kBlue+2);
175     nPartC->SetFillColor(kBlue-10);
176     nPartC->SetFillStyle(1001);
177     nPartC->SetMarkerSize(0.7);
178     nBinC->SetMarkerColor(kRed+2);
179     nBinC->SetMarkerStyle(21);
180     nBinC->SetLineColor(kRed+2);
181     nBinC->SetFillColor(kRed-10);
182     nBinC->SetMarkerSize(0.7);
183     nBinC->SetFillStyle(1001);
184
185     DrawTwoInPad(fBody, 6, nPartC, nBinC, "e3 p", 0x10);
186
187     PrintCanvas("EventInspector - Monte-Carlo");  
188   }
189   //____________________________________________________________________
190   void DrawSharingFilter()
191   {
192     Info("DrawEventInspector", "Drawing sharing filter");
193     TCollection* c = GetCollection(fSums, "fmdSharingFilter");
194     if (!c) return;
195
196     fBody->Divide(1, 3);
197     fBody->cd(1);
198   
199     Double_t y = .8;
200     Bool_t   angle=false, lowSignal=false, simple=false;
201   
202     GetParameter(c, "angle",     angle);
203     GetParameter(c, "lowSignal", lowSignal);
204     GetParameter(c, "simple",    simple);
205
206     DrawParameter(y, "Angle correct", (angle ? "yes" : "no")); 
207     DrawParameter(y, "Lower signal",  (lowSignal ? "yes" : "no"));
208     DrawParameter(y, "Simple method", (simple ? "yes" : "no"));
209
210     DrawInPad(fBody, 2, GetH2(c, "lowCuts"), "colz");
211     DrawInPad(fBody, 3, GetH2(c, "highCuts"), "colz");
212   
213     PrintCanvas("Sharing filter");
214
215     const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 };
216     const char** ptr   = subs;
217     while (*ptr) { 
218       TCollection* sc = GetCollection(c, *ptr);
219       if (!sc) { ptr++; continue; }
220     
221       fBody->Divide(2,3);
222       DrawInPad(fBody, 1, GetH1(sc, "esdEloss"),       "",     0x2);
223       DrawInPad(fBody, 1, GetH1(sc, "anaEloss"),       "same", 0x12);
224       DrawInPad(fBody, 2, GetH1(sc, "singleEloss"),    "",     0x2);
225       DrawInPad(fBody, 2, GetH1(sc, "doubleEloss"),    "same", 0x2);
226       DrawInPad(fBody, 2, GetH1(sc, "tripleEloss"),    "same", 0x12);  
227       DrawInPad(fBody, 3, GetH2(sc, "singlePerStrip"), "colz", 0x4);
228       DrawInPad(fBody, 4, GetH1(sc, "distanceBefore"), "",     0x2);
229       DrawInPad(fBody, 4, GetH1(sc, "distanceAfter"),  "same", 0x12);
230
231       TH2* nB = GetH2(sc, "neighborsBefore");
232       if (nB) { 
233         nB->GetXaxis()->SetRangeUser(0,8); 
234         nB->GetYaxis()->SetRangeUser(0,8); 
235       }
236       DrawInPad(fBody, 5, nB, "colz", 0x4);
237       DrawInPad(fBody, 5, GetH2(sc, "neighborsAfter"), "p same", 0x4);
238       DrawInPad(fBody, 6, GetH2(sc, "beforeAfter"),    "colz",   0x4);
239
240       PrintCanvas(Form("Sharing filter - %s", *ptr));
241       ptr++;
242     }
243
244     // --- MC --------------------------------------------------------
245     TCollection* cc = GetCollection(c, "esd_mc_comparion", false); // Spelling!
246     if (!cc) return; // Not MC 
247
248     DivideForRings(false, false);
249     DrawInRingPad(1, 'I', GetH2(cc, "FMD1i_corr"), "colz", 0x4);
250     DrawInRingPad(2, 'I', GetH2(cc, "FMD2i_corr"), "colz", 0x4);
251     DrawInRingPad(2, 'O', GetH2(cc, "FMD2o_corr"), "colz", 0x4);
252     DrawInRingPad(3, 'I', GetH2(cc, "FMD3i_corr"), "colz", 0x4);
253     DrawInRingPad(3, 'O', GetH2(cc, "FMD3o_corr"), "colz", 0x4);
254
255     PrintCanvas("Sharing filter - MC vs Reco");
256
257     // --- MC --------------------------------------------------------
258     TCollection* mc = GetCollection(c, "mcTrackDensity", false);
259     if (!mc) return; // Not MC 
260
261     fBody->Divide(2,3);
262     DrawInPad(fBody, 1, GetH2(mc, "binFlow"),    "colz", 0x4);
263     DrawInPad(fBody, 2, GetH2(mc, "binFlowEta"), "colz", 0x4);
264     DrawInPad(fBody, 3, GetH2(mc, "binFlowPhi"), "colz", 0x4);
265     DrawInPad(fBody, 4, GetH1(mc, "nRefs"),       "",    0x2);
266     DrawInPad(fBody, 4, GetH1(mc, "clusterRefs"), "same");
267     DrawInPad(fBody, 4, GetH1(mc, "clusterSize"), "same");
268     DrawInPad(fBody, 4, GetH1(mc, "nClusters"),    "same", 0x10);
269     DrawInPad(fBody, 5, GetH2(mc, "clusterVsRefs"),"colz", 0x4);
270
271     PrintCanvas("Sharing filter - MC");  
272   }
273
274   //____________________________________________________________________
275   void DrawDensityCalculator()
276   {
277     Info("DrawDensityCalculator", "Drawing density calculator");
278     TCollection* c = GetCollection(fSums, "fmdDensityCalculator");
279     if (!c) return;
280
281     fBody->Divide(2, 2);
282     fBody->cd(1);
283   
284     Double_t y = .8;
285     Int_t maxParticles=0, phiAcceptance=0, etaLumping=0, phiLumping=0;
286     Bool_t method=false, recalcEta=false, recalcPhi=false;
287   
288     GetParameter(c, "maxParticle",     maxParticles);
289     GetParameter(c, "phiAcceptance",   phiAcceptance);
290     GetParameter(c, "etaLumping",      etaLumping);
291     GetParameter(c, "phiLumping",      phiLumping);
292     GetParameter(c, "method",          method);
293     GetParameter(c, "recalcEta",       recalcEta);
294     GetParameter(c, "recalcPhi",       recalcPhi);
295
296     Double_t size = fLandscape ? 0.06 : 0.04;
297     DrawParameter(y, "Method", (method ? "Poisson" : "#DeltaE"),   size); 
298     DrawParameter(y, "Recalculate #eta",(recalcEta ? "yes" : "no"),size); 
299     DrawParameter(y, "Recalculate #phi",(recalcPhi ? "yes" : "no"),size); 
300     DrawParameter(y, "#phi acceptance method", 
301                   (phiAcceptance == 1 ? "N_{ch}" : 
302                    phiAcceptance == 2 ? "#DeltaE" : "none"),       size);
303     DrawParameter(y, "Region size (sector#timesstrip)", 
304                   Form("%2d #times %2d", phiLumping, etaLumping),  size);
305
306     TVirtualPad* p = fBody; // fBody->cd(2);
307     // p->Divide(3,1);
308
309     TH1* accI = GetH1(c, "accI");
310     TH1* accO = GetH1(c, "accO");
311     if (accI) { 
312       Double_t scale = 1./accI->GetMaximum();
313       accI->Scale(scale); 
314       accO->Scale(scale);
315       accI->SetMinimum(0); 
316     }
317     DrawInPad(p, 2, accI); 
318     DrawInPad(p, 2, accO, "same", 0x10); 
319     DrawInPad(p, 3, GetH2(c, "lowCuts"), "colz");
320     DrawInPad(p, 4, GetH2(c, "maxWeights"), "colz");
321   
322     PrintCanvas("Density calculator");
323
324     const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 };
325     const char** ptr   = subs;
326     while (*ptr) { 
327       TCollection* sc = GetCollection(c, *ptr);
328       if (!sc) { ptr++; continue; }
329     
330       fBody->Divide(2,3);
331     
332       DrawInPad(fBody, 1, GetH2(sc, "elossVsPoisson"), "colz",   0x4);
333       DrawInPad(fBody, 2, GetH1(sc, "diffElossPoisson"), "",     0x2);
334       DrawInPad(fBody, 3, GetH1(sc, "occupancy"),        "",     0x2);
335       DrawInPad(fBody, 4, GetH1(sc, "eloss"),            "",     0x2);
336       DrawInPad(fBody, 4, GetH1(sc, "elossUsed"),        "same", 0x12);
337       TH1* phiB = GetH1(sc, "phiBefore");
338       TH1* phiA = GetH1(sc, "phiAfter");
339       if (phiB && phiA) { 
340         phiA->Add(phiB, -1);
341         phiA->Divide(phiB);
342         phiA->SetTitle("#Delta#phi from Ip (x,y) correction");
343         phiA->SetYTitle("(#phi_{after}-#phi_{before})/#phi_{before}");
344       }
345       DrawInPad(fBody, 5, phiA);
346       DrawInPad(fBody, 6, GetH2(sc, "phiAcc"), "colz",   0x4);
347     
348       PrintCanvas(Form("Density calculator - %s", *ptr));
349       ptr++;    
350     }
351
352     TCollection* cc = GetCollection(c, "esd_mc_comparison", false); 
353     if (!cc) return; // Not MC 
354
355     fBody->Divide(2,5);
356     DrawInPad(fBody, 1, GetH2(cc, "FMD1I_corr_mc_esd"), "colz", 0x4);
357     DrawInPad(fBody, 3, GetH2(cc, "FMD2I_corr_mc_esd"), "colz", 0x4);
358     DrawInPad(fBody, 5, GetH2(cc, "FMD2O_corr_mc_esd"), "colz", 0x4);
359     DrawInPad(fBody, 7, GetH2(cc, "FMD3O_corr_mc_esd"), "colz", 0x4);
360     DrawInPad(fBody, 9, GetH2(cc, "FMD3I_corr_mc_esd"), "colz", 0x4);
361     DrawInPad(fBody, 2,  GetH1(cc, "FMD1I_diff_mc_esd"), "", 0x2);
362     DrawInPad(fBody, 4,  GetH1(cc, "FMD2I_diff_mc_esd"), "", 0x2);
363     DrawInPad(fBody, 6,  GetH1(cc, "FMD2O_diff_mc_esd"), "", 0x2);
364     DrawInPad(fBody, 8,  GetH1(cc, "FMD3O_diff_mc_esd"), "", 0x2);
365     DrawInPad(fBody, 10, GetH1(cc, "FMD3I_diff_mc_esd"), "", 0x2);
366
367     PrintCanvas("Density calculator - MC vs Reco");
368   }
369
370   //____________________________________________________________________
371   void DrawCorrector()
372   {
373     Info("DrawCorrector", "Drawing corrector"); 
374     TCollection* c = GetCollection(fSums, "fmdCorrector"); 
375     if (!c) return;
376   
377     fBody->cd();
378   
379     Double_t y = .8;  
380     Bool_t secondary=false, vertexBias=false, acceptance=false, merging=false;  
381     GetParameter(c, "secondary",    secondary);
382     GetParameter(c, "acceptance",   acceptance);
383     GetParameter(c, "vertexBias",   vertexBias);
384     GetParameter(c, "merging",      merging);
385   
386     DrawParameter(y, "Secondary corr.", secondary ? "yes" : "no");
387     DrawParameter(y, "Acceptance corr.", acceptance ? "yes" : "no");
388     DrawParameter(y, "Vertex bias corr.", vertexBias ? "yes" : "no");
389     DrawParameter(y, "Merging eff.", merging ? "yes" : "no");
390     
391     PrintCanvas("Corrector");
392
393     TCollection* cc = GetCollection(c, "esd_mc_comparison", false); 
394     if (!cc) return; // Not MC 
395     
396     DivideForRings(false, false);
397
398     DrawInRingPad(1, 'I', GetH2(cc, "FMD1I_esd_vs_mc"), "colz", 0x0);
399     DrawInRingPad(2, 'I', GetH2(cc, "FMD2I_esd_vs_mc"), "colz", 0x0);
400     DrawInRingPad(2, 'O', GetH2(cc, "FMD2O_esd_vs_mc"), "colz", 0x0);
401     DrawInRingPad(3, 'O', GetH2(cc, "FMD3O_esd_vs_mc"), "colz", 0x0);
402     DrawInRingPad(3, 'I', GetH2(cc, "FMD3I_esd_vs_mc"), "colz", 0x0);
403
404     PrintCanvas("Corrector - MC vs Reco");
405   }
406
407   //____________________________________________________________________
408   void DrawHistCollector()
409   {
410     Info("DrawHistCollector", "Drawing histogram collector");  
411     TCollection* c = GetCollection(fSums, "fmdHistCollector");
412     if (!c) return;
413
414     fBody->Divide(1, 3);
415     fBody->cd(1);
416
417     Double_t y = .8;
418     Int_t nCutBins=0, fiducial=0, merge=0, skipRings=0;
419     Double_t fiducialCut=0.;
420     Bool_t  bgAndHits=false;
421
422     GetParameter(c, "nCutBins",       nCutBins);
423     GetParameter(c, "skipRings",      skipRings);
424     GetParameter(c, "bgAndHits",      bgAndHits);
425     GetParameter(c, "merge",          merge);
426     GetParameter(c, "fiducial",       fiducial);
427     // GetParameter(c, "correctionCut",  fiducialCut);
428     GetParameter(c, "fiducialCut",  fiducialCut);
429
430     DrawParameter(y, "# of bins to cut",      Form("%d", nCutBins));
431     DrawParameter(y, "Bg & hit maps stored.", bgAndHits?"yes":"no");
432     DrawParameter(y, "Fiducial method.", 
433                   fiducial == 0 ? "cut" : "distance");
434     DrawParameter(y, "Fiducial cut.", Form("%f", fiducialCut));
435     DrawParameter(y, "Merge method", 
436                   (merge == 0 ? "straight mean" :
437                    merge == 1 ? "straight mean, no zeroes" : 
438                    merge == 2 ? "weighted mean" : 
439                    merge == 3 ? "least error" : 
440                    merge == 4 ? "sum" : "unknown"));
441     TString skipped;
442     if (skipRings & 0x11) skipped.Append("FMD1i ");
443     if (skipRings & 0x21) skipped.Append("FMD2i ");
444     if (skipRings & 0x22) skipped.Append("FMD2o ");
445     if (skipRings & 0x31) skipped.Append("FMD3i ");
446     if (skipRings & 0x32) skipped.Append("FMD3o ");
447     DrawParameter(y, "Skipped rings", skipped);
448                  
449     DrawInPad(fBody, 2, GetH2(c, "sumRings"), "colz"); 
450     DrawInPad(fBody, 3, GetH2(c, "coverage"), "colz");
451
452     fBody->cd(1)->Modified();
453     fBody->cd(2)->Modified();
454     fBody->cd(3)->Modified();
455     fBody->cd(1)->Update();
456     fBody->cd(2)->Update();
457     fBody->cd(3)->Update();
458     PrintCanvas("Histogram collector");
459   }
460   
461   //____________________________________________________________________
462   void AddToAll(THStack* all, const THStack* stack, Int_t curr, Int_t step)
463   {
464     if (!stack) return;
465
466     TIter   next(stack->GetHists());
467     TH1*    h = 0;
468     while ((h = static_cast<TH1*>(next()))) {
469       TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName())));
470       copy->SetDirectory(0);
471       if (curr != step) {
472         copy->SetMarkerColor(kGray);
473         copy->SetLineColor(kGray);
474       }
475       all->Add(copy);
476     }
477   }
478   //____________________________________________________________________
479   void AddToAll(THStack* all, const THStack* stack)
480   {
481     if (!stack) return;
482
483     TIter   next(stack->GetHists());
484     TH1*    h = 0;
485     while ((h = static_cast<TH1*>(next()))) {
486       TH1* copy = static_cast<TH1*>(h->Clone(Form("%s_copy", h->GetName())));
487       copy->SetDirectory(0);
488       copy->SetMarkerColor(kGray);
489       copy->SetLineColor(kGray);
490       all->Add(copy);
491     }
492   }
493
494   //____________________________________________________________________
495   void DrawStep(Int_t        step,
496                 THStack*     all,
497                 TObject*     cur,
498                 TLegend*     leg,
499                 const char*  title,
500                 TVirtualPad* can)
501   {
502     // Info("", "Drawing step # %d", step);
503     Bool_t left = (step % 2) == 1; 
504     TVirtualPad* p = can->cd(step);
505     gStyle->SetOptTitle(0);
506     p->SetTitle(Form("Step # %d", step));
507     p->SetFillColor(kWhite);
508     p->SetRightMargin(left ? 0 : 0.02);
509     p->SetTopMargin(0); // 0.02);
510
511     p->cd();
512     all->Draw("nostack");
513     all->GetHistogram()->SetXTitle("#eta");
514     all->GetHistogram()->SetYTitle("signal");
515
516     // p->cd();
517     gROOT->SetSelectedPad(p);
518     cur->DrawClone("same nostack");
519     leg->DrawClone("");
520
521     TLatex* ltx = new TLatex(.97, .97, title);
522     ltx->SetNDC();
523     ltx->SetTextSize(.06);
524     ltx->SetTextAlign(33);
525     ltx->Draw();
526
527     ltx = new TLatex((left ? .12 : .02), .97, p->GetTitle());
528     ltx->SetNDC();
529     ltx->SetTextSize(.06);
530     ltx->SetTextAlign(13);
531     ltx->Draw();
532
533     p->Modified();
534     p->Update();
535     p->cd();
536   }
537
538   //____________________________________________________________________
539   void FixStack(THStack* stack, const TString& title, 
540                 const TString& extra, Int_t marker)
541   {
542     if (!stack) return;
543     stack->SetTitle(title);
544     TIter next(stack->GetHists());
545     TH1*  h = 0;
546     while ((h = static_cast<TH1*>(next())))  {
547       h->SetMarkerStyle(marker);
548       TString tit(h->GetTitle());
549       tit.ReplaceAll("cache", "");
550       tit.Append(extra);
551       h->SetTitle(tit);
552     }
553   }
554   //____________________________________________________________________
555   void DrawSteps()
556   {
557     // MakeChapter(can, "Steps");
558
559     THStack* deltas  = GetStack(GetCollection(fResults, "fmdSharingFilter"), 
560                                 "sums", "summed");
561     THStack* nchs    = GetStack(GetCollection(fResults, 
562                                               "fmdDensityCalculator"), 
563                                 "sums", "inclDensity");
564     THStack* prims   = GetStack(GetCollection(fResults, "fmdCorrector"), 
565                                 "sums", "primaryDensity");
566     THStack* rings   = GetStack(GetCollection(fResults, "ringResults"), "all");
567     THStack* mcRings = GetStack(GetCollection(fResults, "mcRingResults", false),
568                                 "all","dndeta_eta", false);
569     TH1*     dndeta  = GetH1(fResults, "dNdeta");
570     dndeta->SetMarkerColor(kBlack);
571
572     FixStack(deltas, "#sum_{} #Delta/#Delta_{mip}",  "",     20);
573     FixStack(nchs,   "#sum_{} N_{ch,incl}",          "",     21);
574     FixStack(prims,  "#sum_{} N_{ch,primary}",       "",     22);
575     FixStack(rings,  "dN/d#eta per ring",            "",     23);
576     FixStack(mcRings,"dN/d#eta per ring (MC)",       "(MC)", 34);
577
578     THStack* all = new THStack;
579     AddToAll(all, mcRings);
580     AddToAll(all, deltas);
581     AddToAll(all, nchs);
582     AddToAll(all, prims);
583     AddToAll(all, rings);
584
585     TH1* res = static_cast<TH1*>(dndeta->Clone("dNdeta"));
586     res->SetTitle("dN/d#eta");
587     res->SetMarkerColor(kGray);
588     res->SetLineColor(kGray);
589     res->SetDirectory(0);
590     all->Add(res);
591
592     TLegend* l = new TLegend(.35, .2, .55, .9);
593     l->SetFillColor(kWhite);
594     l->SetFillStyle(0);
595     l->SetBorderSize(0);
596     TLegendEntry* e = 0;
597
598     TH1* h = 0;
599     if (mcRings) {
600       h = static_cast<TH1*>(mcRings->GetHists()->At(0));
601       e = l->AddEntry("dummy", mcRings->GetTitle(), "pl");
602       e->SetMarkerStyle(h->GetMarkerStyle());
603       e->SetMarkerColor(kGray);
604       e->SetLineColor(kGray);
605       e->SetTextColor(kGray);
606     }
607
608     h = static_cast<TH1*>(deltas->GetHists()->At(0));
609     e = l->AddEntry("dummy", deltas->GetTitle(), "pl");
610     e->SetMarkerStyle(h->GetMarkerStyle());
611     e->SetMarkerColor(kGray);
612     e->SetLineColor(kGray);
613     e->SetTextColor(kGray);
614     
615     h = static_cast<TH1*>(nchs->GetHists()->At(0));
616     e = l->AddEntry("dummy", nchs->GetTitle(), "pl");
617     e->SetMarkerStyle(h->GetMarkerStyle());
618     e->SetMarkerColor(kGray);
619     e->SetLineColor(kGray);
620     e->SetTextColor(kGray);
621     
622     h = static_cast<TH1*>(prims->GetHists()->At(0));
623     e = l->AddEntry("dummy", prims->GetTitle(), "pl");
624     e->SetMarkerStyle(h->GetMarkerStyle());
625     e->SetMarkerColor(kGray);
626     e->SetLineColor(kGray);
627     e->SetTextColor(kGray);
628     
629     h = static_cast<TH1*>(rings->GetHists()->At(0));
630     e = l->AddEntry("dummy", rings->GetTitle(), "pl");
631     e->SetMarkerStyle(h->GetMarkerStyle());
632     e->SetMarkerColor(kGray);
633     e->SetLineColor(kGray);
634     e->SetTextColor(kGray);
635     
636     h = res;
637     e = l->AddEntry("dummy", h->GetTitle(), "pl");
638     e->SetMarkerStyle(h->GetMarkerStyle());
639     e->SetMarkerColor(kGray);
640     e->SetLineColor(kGray);
641     e->SetTextColor(kGray);
642     
643     TObject* objs[] = { mcRings, 
644                         deltas, 
645                         nchs, 
646                         prims, 
647                         rings, 
648                         dndeta };
649     const char* titles[] = { "MC", 
650                              "After merging", 
651                              "After particle counting", 
652                              "After corrections", 
653                              "After normalization", 
654                              "After combining" };
655     
656     fBody->Divide(2, 3, 0, 0); // mcRings ? 4 : 3, 0, 0);
657     Int_t step = 0;
658     for (Int_t i = 0; i < 6; i++) { 
659       TObject* obj = objs[i];
660       if (!obj) continue;
661       e = static_cast<TLegendEntry*>(l->GetListOfPrimitives()->At(step));
662       e->SetMarkerColor(kBlack);
663       e->SetLineColor(kBlack);
664       e->SetTextColor(kBlack);
665       step++;
666       
667       DrawStep(step, all, obj, l, titles[i], fBody);
668       e->SetMarkerColor(kGray);
669       e->SetLineColor(kGray);
670       e->SetTextColor(kGray);
671     }
672
673     if (!mcRings) { 
674       fBody->cd(6);
675       TLegend* ll = new TLegend(0.01, 0.11, 0.99, 0.99);
676       // ll->SetNDC();
677       ll->SetFillColor(kWhite);
678       ll->SetFillStyle(0);
679       ll->SetBorderSize(0);
680
681       TIter next(deltas->GetHists());
682       TH1*  hh = 0;
683       while ((hh = static_cast<TH1*>(next()))) {
684         e = ll->AddEntry("dummy", hh->GetTitle(), "pl");
685         e->SetMarkerColor(hh->GetMarkerColor());
686         e->SetMarkerStyle(hh->GetMarkerStyle());
687         e->SetLineColor(kBlack);
688       }
689       ll->Draw();
690     }
691     PrintCanvas("Steps");
692   }
693
694
695   //____________________________________________________________________
696   void DrawResults()
697   {
698     // MakeChapter(can, "Results");
699
700     fBody->Divide(2,2);
701
702     TCollection* c = GetCollection(fResults, "ringResults");
703     if (!c) return;
704   
705     THStack* mcRings = GetStack(GetCollection(fResults, "mcRingResults", false),
706                                 "all", "dndeta_eta", false);
707
708     TH1* dndeta_phi = GetH1(fResults, "dNdeta");
709     TH1* dndeta_eta = GetH1(fResults, "dNdeta_");
710     dndeta_phi->SetTitle("1/N_{ev}dN_{ch}/d#eta (#varphi norm)");
711     dndeta_eta->SetTitle("1/N_{ev}dN_{ch}/d#eta (#eta norm)");
712     dndeta_eta->SetMarkerSize(0.7);
713
714     DrawInPad(fBody, 1, GetStack(c, "all"), "nostack", mcRings ? 0 : 0x10);
715     DrawInPad(fBody, 2, dndeta_phi);
716     DrawInPad(fBody, 2, dndeta_eta, "Same", 0x10);
717     DrawInPad(fBody, 3, GetH1(fResults, "norm"));
718     DrawInPad(fBody, 3, GetH1(fResults, "phi"), "same", 0x10);
719     DrawInPad(fBody, 4, GetH1(fSums,    "d2Ndetadphi"), "colz");
720     DrawInPad(fBody, 1, mcRings, "nostack same", 0x10);
721
722     fBody->cd(1);
723     TLatex* l = new TLatex(.5, .2, "Ring results");
724     l->SetNDC();
725     l->SetTextAlign(21);
726     l->Draw();
727
728     fBody->cd(2);
729     l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta");
730
731     // fBody->cd(3);
732     // l->DrawLatex(.5, .2, "1/N_{ev}dN_{ch}/d#eta (#vta norm.)");
733     
734     PrintCanvas("Results");
735   }
736
737   TCollection* fSums;
738   TCollection* fResults;
739 };
740
741 // #endif