Index: /trunk/MagicSoft/Mars/datacenter/macros/plotstat.C
===================================================================
--- /trunk/MagicSoft/Mars/datacenter/macros/plotstat.C	(revision 9154)
+++ /trunk/MagicSoft/Mars/datacenter/macros/plotstat.C	(revision 9155)
@@ -1,4 +1,4 @@
 /* ======================================================================== *\
-! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.9 2008-08-15 12:14:52 dorner Exp $
+! $Name: not supported by cvs2svn $:$Id: plotstat.C,v 1.10 2008-11-12 13:38:17 tbretz Exp $
 ! --------------------------------------------------------------------------
 !
@@ -190,5 +190,5 @@
 void DrawCake(TH1F *h, Int_t p0=-1, Int_t p1=9999)
 {
-    gPad->Range(-1, -0.9, 1, 1.1);
+    gPad->Range(-1, -0.84, 1, 1.16);
 
     gPad->SetFillColor(kWhite);
@@ -208,12 +208,22 @@
     const Double_t tot7 = h[7].Integral(p0, p1);
 
+
+    TPaveText *pave = new TPaveText(-0.99, 0.87, 0.99, 1.15);
+    pave->SetBorderSize(1);
+
     TString title = Form("Total = %.1fh (excl=%.1fh)", tot1, tot1-tot2);
-
     if (p0>0 && p1<9000 && p0==p1)
         title.Prepend(Form("P%d: ", TMath::Nint(h[0].GetBinCenter(p0))));
 
-    TPaveText *pave = new TPaveText(-0.99, 0.92, 0.99, 1.09);
-    pave->SetBorderSize(1);
     pave->AddText(title)->SetTextAlign(22);
+
+    if (p0>0 && p1<9000)
+    {
+        MTime t0, t1;
+        t0.SetMagicPeriodStart(p0);
+        t1.SetMagicPeriodStart(p1+1);
+
+        pave->AddText(Form("%s 12h  -  %s 12h", t0.GetStringFmt("%Y/%m/%d").Data(), t1.GetStringFmt("%Y/%m/%d").Data()));
+    }
     pave->SetBit(kCanDelete);
     pave->Draw();
@@ -286,5 +296,5 @@
 }
 
-void DrawLegend(TH1F *h)
+TObject *DrawLegend(TH1F *h)
 {
     TLegend leg(0.01, 0.12, 0.99, 0.98, "Data Statistics");
@@ -311,5 +321,7 @@
 
     gROOT->SetSelectedPad(0);
-    leg.DrawClone()->SetBit(kCanDelete);;
+    TObject *obj = leg.DrawClone();
+    obj->SetBit(kCanDelete);;
+    return obj;
 }
 
@@ -440,5 +452,5 @@
     // --------------------------------------------
 
-    TCanvas &c0 = d.AddTab("ObsDist");
+    TCanvas &c0 = d.AddTab("ObsDist", h8.GetTitle());
     c0.SetFillColor(kWhite);
 
@@ -463,5 +475,5 @@
     // --------------------------------------------
 
-    TCanvas &c1 = d.AddTab("Hist");
+    TCanvas &c1 = d.AddTab("Hist", "Bar chart of the processing status of all data");
     c1.SetFillColor(kWhite);
     c1.Divide(2,2);
@@ -536,17 +548,17 @@
     // --------------------------------------------
 
-    TCanvas &cx = d.AddTab("All");
+    TCanvas &cx = d.AddTab("All", "Pie charts for all periods");
     cx.SetBorderMode(0);
     cx.SetFrameBorderMode(0);
     cx.SetFillColor(kWhite);
-    cx.Divide(9,5);
+    cx.Divide(12,7);
     cx.cd(1);
-    DrawLegend(h);
-
-    for (int i=0; i<h[0].GetNbinsX(); i++)
+    TObject *leg=DrawLegend(h);
+
+    for (int i=h[0].GetNbinsX()-1; i>=40; i--)
     {
         const Int_t num = TMath::Nint(h[0].GetBinCenter(i+1));
 
-        TCanvas &c = d.AddTab(Form("P%d", num));
+        TCanvas &c = d.AddTab(Form("P%d", num), Form("Pie char for period %d", num));
         c.SetBorderMode(0);
         c.SetFrameBorderMode(0);
@@ -555,5 +567,17 @@
         c.cd();
 
-        TPad *pad1 = new TPad(Form("Pad%da", num), "", 0.05, 0, 0.55, 1);
+        TPad *pad0 = new TPad(Form("Pad%dl", num), "", 0.59, 0.5, 1, 1);
+        pad0->SetBorderMode(0);
+        pad0->SetFrameBorderMode(0);
+        pad0->SetFillColor(kWhite);
+        pad0->SetBit(kCanDelete);
+        pad0->Draw();
+        pad0->cd();
+
+        leg->Draw();
+
+        c.cd();
+
+        TPad *pad1 = new TPad(Form("Pad%da", num), "", 0.03, 0, 0.50, 1);
         pad1->SetBorderMode(0);
         pad1->SetFrameBorderMode(0);
@@ -565,13 +589,10 @@
         DrawCake(h, i+1, i+1);
 
-        if (i<4*8)
-        {
-            cx.cd(i+2);
-            DrawCake(h, i+1, i+1);
-        }
+        cx.cd(i+2);
+        DrawCake(h, i+1, i+1);
 
         c.cd();
 
-        TPad *pad2 = new TPad(Form("Pad%db", num), "", 0.6, 0.02, 1, 0.48);
+        TPad *pad2 = new TPad(Form("Pad%db", num), "", 0.55, 0.02, 1, 0.48);
         pad2->SetBorderMode(0);
         pad2->SetFrameBorderMode(0);
@@ -719,5 +740,5 @@
 
     d->SaveAsRoot(path+"plotstat.root");
-    //d->SaveAsPS("plotstat.ps");
+    //d->SaveAsPS(path+"plotstat.ps");
 
     return 1;
