Index: trunk/MagicSoft/Mars/mhist/MHHadronness.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHadronness.cc	(revision 1967)
+++ trunk/MagicSoft/Mars/mhist/MHHadronness.cc	(revision 1968)
@@ -92,11 +92,15 @@
     fGraph->SetTitle("Acceptance Gammas vs. Hadrons");
     fGraph->SetMaximum(1);
-
-    fGhness = new TH1D("Ghness", "Hadronness", nbins, 0, 1);
-    fPhness = new TH1D("Phness", "Hadronness", nbins, 0, 1);
+    fGraph->SetMarkerStyle(kFullDotSmall);
+
+    fGhness = new TH1D("Ghness", "H. Gammas",  nbins, 0, 1);
+    fPhness = new TH1D("Phness", "H. Hadrons", nbins, 0, 1);
     fGhness->SetXTitle("Hadronness");
     fPhness->SetXTitle("Hadronness");
     fGhness->SetYTitle("Counts");
     fPhness->SetYTitle("Counts");
+    fPhness->SetLineColor(kRed);
+    fGhness->SetDirectory(NULL);
+    fPhness->SetDirectory(NULL);
     
     fIntGhness = new TH1D("AccGammas",  "Acceptance", nbins, 0, 1);
@@ -108,12 +112,13 @@
     fIntGhness->SetMaximum(1.1);
     fIntPhness->SetMaximum(1.1);
+    fIntGhness->SetDirectory(NULL);
+    fIntPhness->SetDirectory(NULL);
+    fIntPhness->SetLineColor(kRed);
+    fIntGhness->SetBit(TH1::kNoStats);
+    fIntPhness->SetBit(TH1::kNoStats);
 
     fQfac = new TGraph;
     fQfac->SetTitle(" Naive Quality factor ");
-
-    fGhness->SetDirectory(NULL);
-    fPhness->SetDirectory(NULL);
-    fIntGhness->SetDirectory(NULL);
-    fIntPhness->SetDirectory(NULL);
+    fQfac->SetMarkerStyle(kFullDotSmall);
 }
 
@@ -241,5 +246,5 @@
 //  - fill the Quality histogram (formular see class description)
 //
-Bool_t MHHadronness::Finalize()
+void MHHadronness::CalcGraph(Double_t sumg, Double_t sump)
 {
     Int_t n = fGhness->GetNbinsX();
@@ -248,48 +253,68 @@
     fQfac->Set(n);
 
+    // Calculate acceptances
+    Float_t max=0;
+
+    for (Int_t i=1; i<=n; i++)
+    {
+        const Stat_t ip = fPhness->Integral(1, i)/sump;
+        const Stat_t ig = fGhness->Integral(1, i)/sumg;
+
+        fIntPhness->SetBinContent(i, ip);
+        fIntGhness->SetBinContent(i, ig);
+
+        fGraph->SetPoint(i, ip, ig);
+
+        if (ip<=0)
+            continue;
+
+        const Double_t val = ig/sqrt(ip);
+        fQfac->SetPoint(i, ig, val);
+
+        if (val>max)
+            max = val;
+    }
+
+    fQfac->SetMaximum(max*1.05);
+}
+
+Bool_t MHHadronness::Finalize()
+{
     const Stat_t sumg = fGhness->Integral();
     const Stat_t sump = fPhness->Integral();
 
     *fLog << inf << "Sum Hadronness: gammas=" << sumg << " hadrons=" << sump << endl;
-
-    if (sumg==0 )
-        *fLog << warn << "Cannot calculate hadronness for 'gammas'." << endl;
-    if (sump==0)
-        *fLog << warn << "Cannot calculate hadronness for 'hadrons'." << endl;
 
     // Normalize photon distribution
     if (sumg>0)
         fGhness->Scale(1./sumg);
+    else
+        *fLog << warn << "Cannot calculate hadronness for 'gammas'." << endl;
 
     // Normalize hadron distribution
     if (sump>0)
         fPhness->Scale(1./sump);
-
-    // Calculate acceptances
-    Float_t max=0;
-
-    for (Int_t i=1; i<=n; i++)
-    {
-        const Stat_t ip = fPhness->Integral(1, i);
-        const Stat_t ig = fGhness->Integral(1, i);
-
-        fIntPhness->SetBinContent(i, ip);
-        fIntGhness->SetBinContent(i, ig);
-
-        fGraph->SetPoint(i, ip, ig);
-
-        if (ip<=0)
-            continue;
-
-        const Double_t val = ig/sqrt(ip);
-        fQfac->SetPoint(i, ig, val);
-
-        if (val>max)
-            max = val;
-    }
-
-    fQfac->SetMaximum(max*1.05);
+    else
+        *fLog << warn << "Cannot calculate hadronness for 'hadrons'." << endl;
+
+    CalcGraph(1, 1);
 
     return kTRUE;
+}
+
+void MHHadronness::Paint(Option_t *opt="")
+{
+    Stat_t sumg = fGhness->Integral();
+    Stat_t sump = fPhness->Integral();
+
+    // Normalize photon distribution
+    if (sumg<=0)
+        sumg=1;
+
+    // Normalize hadron distribution
+    if (sump<=0)
+        sump=1;
+
+    CalcGraph(sumg, sump);
 }
 
@@ -399,130 +424,52 @@
 // --------------------------------------------------------------------------
 //
-// Draw clone of all histograms. (For the Meaning see class description)
-//
-TObject *MHHadronness::DrawClone(Option_t *opt) const
-{
-    if (fGraph->GetN()==0)
-        return NULL;
-
-    TCanvas &c = *MakeDefCanvas("Hadronness", fTitle);
-    c.Divide(2, 2);
-
-    gROOT->SetSelectedPad(NULL);
-
-    c.cd(1);
+// Draw all histograms. (For the Meaning see class description)
+//
+void MHHadronness::Draw(Option_t *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas("Hadronness", fTitle);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2, 2);
+
+    TH1 *h;
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
     //gStyle->SetOptStat(10);
-    Getghness()->DrawCopy();
-    Getphness()->SetLineColor(kRed);
-    Getphness()->DrawCopy("same");
-
-    c.cd(2);
-    //gStyle->SetOptStat(0);
-    Getighness()->DrawCopy();
-    Getiphness()->SetLineColor(kRed);
-    Getiphness()->DrawCopy("same");
-
-    c.cd(3);
-    TGraph &g2 = (TGraph&)*fQfac->DrawClone("A*");
-    g2.SetBit(kCanDelete);
-    gPad->Modified();
-    gPad->Update();
-    if (g2.GetHistogram())
-    {
-        g2.GetXaxis()->SetRangeUser(0, 1);
-        g2.GetXaxis()->SetTitle("Acceptance Gammas");
-        g2.GetYaxis()->SetTitle("Quality");
-        g2.SetMarkerStyle(kFullDotSmall);
-        g2.Draw("P");
-
-        gPad->Modified();
-        gPad->Update();
-    }
-
-    c.cd(4);
-    gPad->Modified();
-    gPad->Update();
-    TGraph &g = (TGraph&)*fGraph->DrawClone("AC");
-    g.SetBit(kCanDelete);
-    gPad->Modified();
-    gPad->Update();
-    if (g.GetHistogram())
-    {
-        g.GetXaxis()->SetRangeUser(0, 1);
-        g.GetXaxis()->SetTitle("Acceptance Hadrons");
-        g.GetYaxis()->SetTitle("Acceptance Gammas");
-        g.SetMarkerStyle(kFullDotSmall);
-        g.Draw("P");
-
-        gPad->Modified();
-        gPad->Update();
-    }
-    /*
-    const Int_t h = fMinDist->GetMaximumBin();
-    TMarker *m = new TMarker(fIntPhness->GetBinContent(h),
-                             fIntGhness->GetBinContent(h), kStar);
-    m->SetMarkerColor(kBlue);
-    m->SetBit(kCanDelete);
-    m->Draw();
-    */
-
-    gStyle->SetOptStat(1111);
-
-    return &c;
-}
-
-// --------------------------------------------------------------------------
-//
-// Draw all histograms. (For the Meaning see class description)
-//
-void MHHadronness::Draw(Option_t *)
-{
-   if (fGraph->GetN()==0)
-        return;
-
-   if (!gPad)
-        MakeDefCanvas("Hadronness", fTitle);
-
-    gPad->Divide(2, 2);
-
-    gPad->cd(1);
-    //gStyle->SetOptStat(10);
-    Getghness()->Draw();
-    Getphness()->SetLineColor(kRed);
-    Getphness()->Draw("same");
-
-    gPad->cd(2);
-    //gStyle->SetOptStat(0);
-    Getighness()->Draw();
-    Getiphness()->SetLineColor(kRed);
-    Getiphness()->Draw("same");
-
-    gPad->cd(3);
+    MH::Draw(*fGhness, *fPhness, "Hadronness"); // Displ both stat boxes
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fIntGhness->Draw();
+    fIntPhness->Draw("same");
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
     fQfac->Draw("A*");
     gPad->Modified();
     gPad->Update();
-    if (fQfac->GetHistogram())
-    {
-        fQfac->GetXaxis()->SetRangeUser(0, 1);
-        fQfac->GetXaxis()->SetTitle("Acceptance Gammas");
-        fQfac->GetYaxis()->SetTitle("Quality");
-        fQfac->SetMarkerStyle(kFullDotSmall);
+    if ((h=fQfac->GetHistogram()))
+    {
+        h->GetXaxis()->SetRangeUser(0, 1);
+        h->SetXTitle("Acceptance Gammas");
+        h->SetYTitle("Quality");
         fQfac->Draw("P");
-
         gPad->Modified();
         gPad->Update();
     }
-    gPad->cd(4);
-    gPad->Modified();
-    gPad->Update();
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
     fGraph->Draw("AC");
     gPad->Modified();
     gPad->Update();
-    if (fGraph->GetHistogram())
-    {
-        fGraph->GetXaxis()->SetRangeUser(0, 1);
-        fGraph->GetXaxis()->SetTitle("Acceptance Hadrons");
-        fGraph->GetYaxis()->SetTitle("Acceptance Gammas");
-        fGraph->SetMarkerStyle(kFullDotSmall);
+    if ((h=fGraph->GetHistogram()))
+    {
+        h->GetXaxis()->SetRangeUser(0, 1);
+        h->SetXTitle("Acceptance Hadrons");
+        h->SetYTitle("Acceptance Gammas");
         fGraph->Draw("P");
         gPad->Modified();
Index: trunk/MagicSoft/Mars/mhist/MHHadronness.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHHadronness.h	(revision 1967)
+++ trunk/MagicSoft/Mars/mhist/MHHadronness.h	(revision 1968)
@@ -26,4 +26,7 @@
     TGraph *fGraph;   //-> gamma acceptance vs. hadron acceptance
 
+    void Paint(Option_t *opt="");
+    void CalcGraph(Double_t sumg, Double_t sump);
+
 public:
     MHHadronness(Int_t nbins=100, const char *name=NULL, const char *title=NULL);
@@ -48,5 +51,4 @@
 
     void Draw(Option_t *opt="");
-    TObject *DrawClone(Option_t *opt="") const;
 
     ClassDef(MHHadronness, 1) // Gamma/Hadron Separation Quality Histograms
