Index: trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 4915)
+++ trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 4920)
@@ -15,4 +15,5 @@
 #pragma link C++ class MHEnergyTime+;
 #pragma link C++ class MHEnergyTheta+;
+#pragma link C++ class MHEffectiveOnTime+;
 #pragma link C++ class MHAlphaEnergyTime+;
 #pragma link C++ class MHAlphaEnergyTheta+;
Index: trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.cc	(revision 4915)
+++ trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.cc	(revision 4920)
@@ -63,6 +63,7 @@
 //
 MHEffectiveOnTime::MHEffectiveOnTime(const char *name, const char *title)
-    : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE), fInterval(60),
-    fNameProjDeltaT(Form("DeltaT_%p", this)), fNameProjTheta(Form("Theta_%p", this))
+    : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE), 
+    fNumEvents(200*60), fNameProjDeltaT(Form("DeltaT_%p", this)),
+    fNameProjTheta(Form("Theta_%p", this))
 {
     //
@@ -73,12 +74,20 @@
 
     // Main histogram
-    fHDeltaT.SetName("DeltaT");
-    fHDeltaT.SetXTitle("\\Delta t [s]");
-    fHDeltaT.SetYTitle("\\Theta [\\circ]");
-    fHDeltaT.UseCurrentStyle();
-    fHDeltaT.SetDirectory(NULL);
+    fH2DeltaT.SetName("DeltaT");
+    fH2DeltaT.SetXTitle("\\Delta t [s]");
+    fH2DeltaT.SetYTitle("\\Theta [\\circ]");
+    fH2DeltaT.SetZTitle("Count");
+    fH2DeltaT.UseCurrentStyle();
+    fH2DeltaT.SetDirectory(NULL);
+
+    // Main histogram
+    fH1DeltaT.SetName("DeltaT");
+    fH1DeltaT.SetXTitle("\\Delta t [s]");
+    fH1DeltaT.SetYTitle("Counts");
+    fH1DeltaT.UseCurrentStyle();
+    fH1DeltaT.SetDirectory(NULL);
 
     // effective on time versus theta
-    fHEffOnTheta.SetName("EffOnTime");
+    fHEffOnTheta.SetName("EffOnTheta");
     fHEffOnTheta.SetTitle("Effective On Time T_{eff}");
     fHEffOnTheta.SetXTitle("\\Theta [\\circ]");
@@ -102,24 +111,26 @@
     fHEffOnTime.Sumw2();
 
-    // chi2/NDF versus theta
-    fHChi2.SetName("Chi2/NDF");
-    fHChi2.SetTitle("\\chi^{2}/NDF of Effective On Time Fit");
-    fHChi2.SetXTitle("\\Theta [\\circ]");
-    fHChi2.SetYTitle("\\chi^{2}/NDF");
-    fHChi2.UseCurrentStyle();
-    fHChi2.SetDirectory(NULL);
-    fHChi2.GetYaxis()->SetTitleOffset(1.2);
-    //fHChi2.Sumw2();
-
     // chi2 probability
-    fHProb.SetName("Prob");
-    fHProb.SetTitle("\\chi^{2} Probability of Fit");
-    fHProb.SetXTitle("\\Theta [\\circ]");
-    fHProb.SetYTitle("p [%]");
-    fHProb.UseCurrentStyle();
-    fHProb.SetDirectory(NULL);
-    fHProb.GetYaxis()->SetTitleOffset(1.2);
-    fHProb.SetMaximum(101);
-    //fHChi2.Sumw2();
+    fHProbTheta.SetName("ProbTheta");
+    fHProbTheta.SetTitle("\\chi^{2} Probability of Fit");
+    fHProbTheta.SetXTitle("\\Theta [\\circ]");
+    fHProbTheta.SetYTitle("p [%]");
+    fHProbTheta.UseCurrentStyle();
+    fHProbTheta.SetDirectory(NULL);
+    fHProbTheta.GetYaxis()->SetTitleOffset(1.2);
+    fHProbTheta.SetMaximum(101);
+
+    // chi2 probability
+    fHProbTime.SetName("ProbTime");
+    fHProbTime.SetTitle("\\chi^{2} Probability of Fit");
+    fHProbTime.SetXTitle("Time");
+    fHProbTime.SetYTitle("p [%]");
+    fHProbTime.UseCurrentStyle();
+    fHProbTime.SetDirectory(NULL);
+    fHProbTime.GetYaxis()->SetTitleOffset(1.2);
+    fHProbTime.GetXaxis()->SetLabelSize(0.033);
+    fHProbTime.GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT");
+    fHProbTime.GetXaxis()->SetTimeDisplay(1);
+    fHProbTime.SetMaximum(101);
 
     // lambda versus theta
@@ -141,4 +152,16 @@
     //fHN0del.Sumw2();
 
+    // chi2/NDF versus theta
+    /*
+     fHChi2.SetName("Chi2/NDF");
+     fHChi2.SetTitle("\\chi^{2}/NDF of Effective On Time Fit");
+     fHChi2.SetXTitle("\\Theta [\\circ]");
+     fHChi2.SetYTitle("\\chi^{2}/NDF");
+     fHChi2.UseCurrentStyle();
+     fHChi2.SetDirectory(NULL);
+     fHChi2.GetYaxis()->SetTitleOffset(1.2);
+     //fHChi2.Sumw2();
+     */
+
     // setup binning
     MBinning btheta("BinningTheta");
@@ -148,11 +171,13 @@
     btime.SetEdges(50, 0, 0.1);
 
-    MH::SetBinning(&fHDeltaT, &btime, &btheta);
+    MH::SetBinning(&fH2DeltaT, &btime, &btheta);
+
+    btime.Apply(fH1DeltaT);
 
     btheta.Apply(fHEffOnTheta);
-    btheta.Apply(fHChi2);
     btheta.Apply(fHLambda);
     btheta.Apply(fHN0);
-    btheta.Apply(fHProb);
+    btheta.Apply(fHProbTheta);
+    //btheta.Apply(fHChi2);
 }
 
@@ -180,76 +205,21 @@
    const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningDeltaT");
    const MBinning* binstheta = (MBinning*)plist->FindObject("BinningTheta");
-   if (!binstheta || !binsdtime)
-       *fLog << warn << dbginf << "At least one MBinning not found... ignored." << endl;
-   else
+   if (binsdtime)
+       binsdtime->Apply(fH1DeltaT);
+   if (binstheta)
    {
-       SetBinning(&fHDeltaT, binsdtime, binstheta);
-
        binstheta->Apply(fHEffOnTheta);
-       binstheta->Apply(fHChi2);
        binstheta->Apply(fHLambda);
        binstheta->Apply(fHN0);
-       binstheta->Apply(fHProb);
+       binstheta->Apply(fHProbTheta);
+       //binstheta->Apply(fHChi2);
    }
+   if (binstheta && binsdtime)
+       SetBinning(&fH2DeltaT, binsdtime, binstheta);
 
    return kTRUE;
 }
 
-Bool_t MHEffectiveOnTime::Finalize()
-{
-    FitThetaBins();
-    Calc();
-
-    fIsFinalized = kTRUE;
-
-    return kTRUE;
-}
-
-void MHEffectiveOnTime::FitThetaBins()
-{
-    const TString name = Form("CalcTheta%d", (UInt_t)gRandom->Uniform(999999999));
-
-    // nbins = number of Theta bins
-    const Int_t nbins = fHDeltaT.GetNbinsY();
-
-    TH1D *h=0;
-    for (int i=1; i<=nbins; i++)
-    {
-        //        TH1D &h = *hist->ProjectionX("Calc-theta", i, i);
-        h = fHDeltaT.ProjectionX(name, i, i, "E");
-
-        Double_t res[7];
-        if (!FitH(h, res))
-            continue;
-
-        // the effective on time is Nm/lambda
-        fHEffOnTheta.SetBinContent(i, res[0]);
-        fHEffOnTheta.SetBinError  (i, res[1]);
-
-        // plot chi2-probability of fit
-        fHProb.SetBinContent(i, res[2]);
-
-        // plot chi2/NDF of fit
-        fHChi2.SetBinContent(i, res[3]);
-
-        // lambda of fit
-        fHLambda.SetBinContent(i, res[4]);
-        fHLambda.SetBinError  (i, res[5]);
-
-        // N0 of fit
-        fHN0.SetBinContent(i, res[6]);
-
-        // Rdead (from fit) is the fraction from real time lost by the dead time
-        //fHRdead.SetBinContent(i, Rdead);
-        //fHRdead.SetBinError  (i,dRdead);
-    }
-
-    // Histogram is reused via gROOT->FindObject()
-    // Need to be deleted only once
-    if (h)
-        delete h;
-}
-
-Bool_t MHEffectiveOnTime::FitH(TH1D *h, Double_t *res) const
+Bool_t MHEffectiveOnTime::FitH(TH1D *h, Double_t *res, Bool_t paint) const
 {
     const Double_t Nm = h->Integral();
@@ -296,5 +266,14 @@
 
     // was fit successful ?
-    if (NDF<=0 || chi2>=2.5*NDF)
+    const Bool_t ok = NDF>0 && chi2<2.5*NDF;
+
+    if (paint)
+    {
+        func.SetLineWidth(2);
+        func.SetLineColor(ok ? kGreen : kRed);
+        func.Paint("same");
+    }
+
+    if (!ok)
         return kFALSE;
 
@@ -332,12 +311,12 @@
 
     // plot chi2/NDF of fit
-    res[3] = NDF ? chi2/NDF : 0.0;
+    //res[3] = NDF ? chi2/NDF : 0.0;
 
     // lambda of fit
-    res[4] = lambda;
-    res[5] = dl;
+    res[3] = lambda;
+    res[4] = dl;
 
     // N0 of fit
-    res[6] = N0;
+    res[5] = N0;
 
     // Rdead (from fit) is the fraction from real time lost by the dead time
@@ -348,30 +327,197 @@
 }
 
+void MHEffectiveOnTime::FitThetaBins()
+{
+    const TString name = Form("CalcTheta%d", (UInt_t)gRandom->Uniform(999999999));
+
+    // nbins = number of Theta bins
+    const Int_t nbins = fH2DeltaT.GetNbinsY();
+
+    TH1D *h=0;
+    for (int i=1; i<=nbins; i++)
+    {
+        //        TH1D &h = *hist->ProjectionX("Calc-theta", i, i);
+        h = fH2DeltaT.ProjectionX(name, i, i, "E");
+
+        Double_t res[6];
+        if (!FitH(h, res))
+            continue;
+
+        // the effective on time is Nm/lambda
+        fHEffOnTheta.SetBinContent(i, res[0]);
+        fHEffOnTheta.SetBinError  (i, res[1]);
+
+        // plot chi2-probability of fit
+        fHProbTheta.SetBinContent(i, res[2]);
+
+        // plot chi2/NDF of fit
+        //fHChi2.SetBinContent(i, res[3]);
+
+        // lambda of fit
+        fHLambda.SetBinContent(i, res[3]);
+        fHLambda.SetBinError  (i, res[4]);
+
+        // N0 of fit
+        fHN0.SetBinContent(i, res[5]);
+
+        // Rdead (from fit) is the fraction from real time lost by the dead time
+        //fHRdead.SetBinContent(i, Rdead);
+        //fHRdead.SetBinError  (i,dRdead);
+    }
+
+    // Histogram is reused via gROOT->FindObject()
+    // Need to be deleted only once
+    if (h)
+        delete h;
+}
+
+void MHEffectiveOnTime::FitTimeBin()
+{
+    //
+    // Fit histogram
+    //
+    Double_t res[6];
+    if (!FitH(&fH1DeltaT, res))
+        return;
+
+    // Reset Histogram
+    fH1DeltaT.Reset();
+
+    //
+    // Prepare Histogram
+    //
+
+    // Get x-axis
+    TAxis &x = *fHEffOnTime.GetXaxis();
+
+    // Get number of bins
+    const Int_t n = x.GetNbins();
+
+    // Enhance binning
+    MBinning bins;
+    bins.SetEdges(x);
+    bins.AddEdge(fLastTime.GetAxisTime());
+    bins.Apply(fHEffOnTime);
+    bins.Apply(fHProbTime);
+
+    //
+    // Fill histogram
+    //
+    fHEffOnTime.SetBinContent(n, res[0]);
+    fHEffOnTime.SetBinError(n, res[1]);
+
+    fHProbTime.SetBinContent(n, res[2]);
+
+    //
+    // Now prepare output
+    //
+    fParam->SetVal(res[0], res[1]);
+    fParam->SetReadyToSave();
+
+    *fTime = fLastTime;
+
+    // Include the current event
+    fTime->Plus1ns();
+
+    *fLog << fLastTime << ":  Val=" << res[0] << "  Err=" << res[1] << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the histogram
+//
+Bool_t MHEffectiveOnTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MTime *time = dynamic_cast<const MTime*>(par);
+    if (!time)
+    {
+        *fLog << err << "ERROR - MHEffectiveOnTime::Fill without argument or container doesn't inherit from MTime... abort." << endl;
+        return kFALSE;
+    }
+
+    if (fLastTime==MTime())
+    {
+        MBinning bins;
+        bins.SetEdges(2, time->GetAxisTime()-fNumEvents/200, time->GetAxisTime());
+        bins.Apply(fHEffOnTime);
+        bins.Apply(fHProbTime);
+
+        fParam->SetVal(0, 0);
+        fParam->SetReadyToSave();
+
+        *fTime = *time;
+
+        // Make this 1ns before the first event!
+        fTime->Minus1ns();
+    }
+
+    const Double_t dt = *time-fLastTime;
+
+    fH2DeltaT.Fill(dt, fPointPos->GetZd(), w);
+    fH1DeltaT.Fill(dt, w);
+
+    fLastTime = *time;
+
+    if (fH1DeltaT.GetEntries()>=fNumEvents)
+        FitTimeBin();
+
+    return kTRUE;
+}
+
+Bool_t MHEffectiveOnTime::Finalize()
+{
+    FitThetaBins();
+    FitTimeBin();
+
+    fIsFinalized = kTRUE;
+
+    return kTRUE;
+}
+
+void MHEffectiveOnTime::PaintText(Double_t val, Double_t error) const
+{
+    TLatex text(0.45, 0.94, Form("T_{eff} = %.1fs \\pm %.1fs", val, error));
+    text.SetBit(TLatex::kTextNDC);
+    text.SetTextSize(0.04);
+    text.Paint();
+}
+
 void MHEffectiveOnTime::Paint(Option_t *opt)
 {
-    TVirtualPad *padsave = gPad;
+    TH1D *h=0;
 
     TString o(opt);
     if (o==(TString)"fit")
     {
-        TH1D *h0=0;
-
-        padsave->GetPad(1)->cd(1);
-        if ((h0 = (TH1D*)gPad->FindObject(fNameProjDeltaT)))
+        TVirtualPad *pad = gPad;
+
+        pad->GetPad(1)->cd(1);
+        if ((h = (TH1D*)gPad->FindObject(fNameProjDeltaT)))
         {
-            h0 = fHDeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E");
-            if (h0->GetEntries()>0)
+            h = fH2DeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E");
+            if (h->GetEntries()>0)
                 gPad->SetLogy();
         }
 
-        padsave->GetPad(2)->cd(1);
-        if ((h0 = (TH1D*)gPad->FindObject(fNameProjTheta)))
-            fHDeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E");
+        pad->GetPad(2)->cd(1);
+        if ((h = (TH1D*)gPad->FindObject(fNameProjTheta)))
+            fH2DeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E");
 
         if (!fIsFinalized)
             FitThetaBins();
+        return;
     }
-
-    TH1D *h=0;
+    if (o==(TString)"paint")
+    {
+        if ((h = (TH1D*)gPad->FindObject(fNameProjDeltaT)))
+        {
+            Double_t res[6];
+            if (FitH(h, res, kTRUE))
+                PaintText(res[0], res[1]);
+        }
+        return;
+    }
+
+    h=0;
     if (o==(TString)"theta")
         h = &fHEffOnTheta;
@@ -379,16 +525,12 @@
         h = &fHEffOnTime;
 
-    if (h)
-    {
-        Double_t error = 0;
-        for (int i=0; i<h->GetXaxis()->GetNbins(); i++)
-            error += h->GetBinError(i);
-
-        TLatex text(0.45, 0.94, Form("T_{eff} = %.1fs \\pm %.1fs", h->Integral(), error));
-        text.SetBit(TLatex::kTextNDC);
-        text.SetTextSize(0.04);
-        text.Paint();
-    }
-    gPad = padsave;
+    if (!h)
+        return;
+
+    Double_t error = 0;
+    for (int i=0; i<h->GetXaxis()->GetNbins(); i++)
+        error += h->GetBinError(i);
+
+    PaintText(h->Integral(), error);
 }
 
@@ -410,8 +552,8 @@
     pad->cd(1);
     gPad->SetBorderMode(0);
-    gPad->Divide(1, 2, 0, 0);
+    gPad->Divide(1, 3, 0, 0);
     pad->GetPad(1)->cd(1);
     gPad->SetBorderMode(0);
-    h = fHDeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E");
+    h = fH2DeltaT.ProjectionX(fNameProjDeltaT, -1, 9999, "E");
     h->SetTitle("Distribution of \\Delta t [s]");
     h->SetXTitle("\\Delta t [s]");
@@ -421,6 +563,11 @@
     h->SetBit(kCanDelete);
     h->Draw();
+    AppendPad("paint");
 
     pad->GetPad(1)->cd(2);
+    gPad->SetBorderMode(0);
+    fHProbTime.Draw();
+
+    pad->GetPad(1)->cd(3);
     gPad->SetBorderMode(0);
     fHEffOnTime.Draw();
@@ -433,5 +580,5 @@
     pad->GetPad(2)->cd(1);
     gPad->SetBorderMode(0);
-    h = fHDeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E");
+    h = fH2DeltaT.ProjectionY(fNameProjTheta, -1, 9999, "E");
     h->SetTitle("Distribution of  \\Theta [\\circ]");
     h->SetXTitle("\\Theta [\\circ]");
@@ -445,5 +592,5 @@
     pad->GetPad(2)->cd(2);
     gPad->SetBorderMode(0);
-    fHProb.Draw();
+    fHProbTheta.Draw();
 
     pad->GetPad(2)->cd(3);
@@ -452,109 +599,2 @@
     AppendPad("theta");
 }
-
-void MHEffectiveOnTime::FillTimeBin(Double_t val, Double_t err)
-{
-    // Get x-axis
-    TAxis &x = *fHEffOnTime.GetXaxis();
-
-    // Get number of bins
-    const Int_t n = x.GetNbins();
-
-    // Fill last bin with new values
-    fHEffOnTime.SetBinContent(n, fParam->GetVal());
-    fHEffOnTime.SetBinError(n, fParam->GetErr());
-
-    // Get time range of histogram, get bin width
-    const Double_t lo = fHEffOnTime.GetXaxis()->GetXmin();
-    const Double_t up = fHEffOnTime.GetXaxis()->GetXmax();
-    const Double_t w  = fHEffOnTime.GetXaxis()->GetBinWidth(1);
-
-    // Enhance histogram by one bin
-    MBinning bins;
-    bins.SetEdges(n+2, lo, up+w);
-    bins.Apply(fHEffOnTime);
-
-    // Transform overflow bin
-    // fHEffOnTime.SetBinContent(n+2, fHEffOnTime.GetBinContent(n+1));
-    // fHEffOnTime.SetBinError(n+2, fHEffOnTime.GetBinError(n+1));
-}
-
-void MHEffectiveOnTime::Calc()
-{
-    TH1D *h = fHDeltaT.ProjectionX("", -1, 99999, "E");
-    h->SetDirectory(0);
-
-    Double_t res[7];
-    Bool_t rc = FitH(h, res);
-    delete h;
-
-    if (!rc)
-        return;
-
-    const Double_t val   = res[0];
-    const Double_t error = res[1];
-
-    fParam->SetVal(val>fEffOnTime0?val-fEffOnTime0:0, error-fEffOnErr0);
-    fParam->SetReadyToSave();
-
-    FillTimeBin(fParam->GetVal(), fParam->GetErr());
-
-    fEffOnTime0 = val;
-    fEffOnErr0  = error;
-
-    MTime now(*fTime);
-    now.AddMilliSeconds(fInterval*1000);
-
-    *fLog <<all << now << " - ";// << fLastTime-fTime;
-    *fLog << Form("T_{eff} = %.1fs \\pm %.1fs",
-                  fParam->GetVal(), fParam->GetErr());
-    *fLog << Form("   %.1f   %.1f",
-                  val, error) << endl;
-
-    fTime->AddMilliSeconds(fInterval*1000);
-}
-
-// --------------------------------------------------------------------------
-//
-//  Fill the histogram
-//
-Bool_t MHEffectiveOnTime::Fill(const MParContainer *par, const Stat_t w)
-{
-    const MTime *time = dynamic_cast<const MTime*>(par);
-    if (!time)
-    {
-        *fLog << err << "ERROR - MHEffectiveOnTime::Fill without argument or container doesn't inherit from MTime... abort." << endl;
-        return kFALSE;
-    }
-
-    if (*fTime==MTime())
-    {
-        *fLog << all << *time << " - " << *fTime << " " << TMath::Floor(*time) << endl;
-        fEffOnTime0 = 0;
-        fEffOnErr0  = 0;
-
-        fParam->SetVal(0, 0);
-        fParam->SetReadyToSave();
-
-        *fTime = *time;
-
-        MBinning bins;
-        bins.SetEdges(2, fTime->GetAxisTime(), fTime->GetAxisTime()+fInterval);
-        bins.Apply(fHEffOnTime);
-
-        // Make this just a ns before the first event
-        fTime->Minus1ns();
-    }
-
-    if (*fTime+fInterval<*time)
-    {
-        FitThetaBins();
-        Calc();
-    }
-
-    fHDeltaT.Fill(*time-fLastTime, fPointPos->GetZd(), w);
-    fLastTime = *time;
-
-    return kTRUE;
-}
-
Index: trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.h
===================================================================
--- trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.h	(revision 4915)
+++ trunk/MagicSoft/Mars/mhist/MHEffectiveOnTime.h	(revision 4920)
@@ -27,15 +27,16 @@
     MTime           fLastTime;   //!
 
-    Double_t        fEffOnTime0; //!
-    Double_t        fEffOnErr0;  //!
-
     MTime          *fTime;       //!
     MParameterDerr *fParam;      //!
 
-    TH2D fHDeltaT;
-    TH1D fHEffOnTheta;
-    TH1D fHEffOnTime;
-    TH1D fHChi2;
-    TH1D fHProb;
+    TH2D fH2DeltaT;              // Counts vs Delta T and Theta
+    TH1D fH1DeltaT;              //! Counts vs Delta T (for a time interval)
+
+    TH1D fHEffOnTheta;           // Effective On time versus Theta
+    TH1D fHEffOnTime;            // Effective On time versus Time
+
+    TH1D fHProbTheta;            // Chisq prob fit of Effective On time versus Theta
+    TH1D fHProbTime;             // Chisq prob fit of Effective On time versus Time
+
     TH1D fHN0;
     TH1D fHLambda;
@@ -43,25 +44,22 @@
     Bool_t fIsFinalized;
 
-    Int_t fInterval;
+    Int_t fNumEvents;
 
     const TString fNameProjDeltaT;  //! This should make sure, that gROOT doen't confuse the projection with something else
     const TString fNameProjTheta;   //! This should make sure, that gROOT doen't confuse the projection with something else
 
-    Bool_t FitH(TH1D *h, Double_t *res) const;
+    Bool_t FitH(TH1D *h, Double_t *res, Bool_t paint=kFALSE) const;
     void FitThetaBins();
-    void FillTimeBin(Double_t val, Double_t err);
-    void Calc();
+    void FitTimeBin();
+    void PaintText(Double_t val, Double_t error) const;
 
 public:
     MHEffectiveOnTime(const char *name=NULL, const char *title=NULL);
 
-    void SetInterval(Int_t i) { fInterval=i; }
+    void SetNumEvents(Int_t i) { fNumEvents=i; }
 
     Bool_t SetupFill(const MParList *pList);
     Bool_t Fill(const MParContainer *par, const Stat_t w=1);
     Bool_t Finalize();
-
-    const TH2D *GetHist() { return &fHDeltaT; }
-    const TH2D *GetHist() const { return &fHDeltaT; }
 
     void Draw(Option_t *option="");
Index: trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- trunk/MagicSoft/Mars/mhist/Makefile	(revision 4915)
+++ trunk/MagicSoft/Mars/mhist/Makefile	(revision 4920)
@@ -22,5 +22,5 @@
 	   -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage \
            -I../mmain -I../mmc -I../mreflector -I../mpointing       \
-           -I../mastro -I../mpedestal -I../mbadpixels
+           -I../mastro -I../mpedestal -I../msignal -I../mbadpixels
 
 SRCFILES = MHEvent.cc \
@@ -28,4 +28,5 @@
            MHCamEvent.cc \
            MHCamEventRot.cc \
+           MHEffectiveOnTime.cc \
            MHFadcPix.cc \
            MHFadcCam.cc \
