Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 1294)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 1295)
@@ -275,4 +275,52 @@
      - changed pointers in Calc functions to references
 
+
+
+ 2002/04/24: Wolfgang Wittek
+
+   * Work was done on the calculation of photon fluxes as a function of
+     Theta and as a function of time. The work is still in progress.
+
+   * macros/wowflux.C
+     - the macr was added (extended and improved version of flux.C)
+     - the macro steers the calculation of photon fluxes as a function
+       of Theta and time
+     - the macro is not yet complete; testing and developing is going on
+
+   * mhist/MHAlphaEnergyTheta
+           MHAlphaEnergyTime
+           MHEffOnTimeTheta
+           MHEffOnTimeTime
+           MHTimeDiffTheta
+           MHTimeDiffTime
+
+     - documentation was added 
+     - histogram axes were labeled
+     - in addition :
+          in MHEffOnTimeTheta
+             - range in which the fit of the distribution of time differences
+               is to be performed has been calculated
+             - new histograms were added (chi2/NDF, lambda, N0del)
+            
+
+   * mhist/MHThetabarTheta          calculation of <Theta> as a function of 
+                                    Theta 
+           MHThetabarTime           calculation of <Theta> as a function of
+                                    time
+
+     - these classes were added; 
+       they are needed in the flux calculation in 
+       order to select for a given bin in Theta (or time) the appropriate 
+       effective collection area, which is assumed to be given as a function 
+       of Theta and the true energy
+
+
+   * mhist/MHMcEnergyMigration      calculation of the migration matrix in
+                                    the energy
+     - this class was added;
+       the migration matrix describes the migration from the true (E_true)
+       to the estimated energy (E_est); it is needed to determine the
+       distribution of E_true from the measured distribution of E_est 
+       by unfolding
 
 
@@ -713,8 +761,4 @@
      - fix bug of Pedestal and Pedestal fluctuaions correspondence.
 
-<<<<<<< Changelog
-
-=======
->>>>>>> 1.148
 
  2001/12/18: Thomas Bretz
Index: /trunk/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc	(revision 1294)
+++ /trunk/MagicSoft/Mars/mhist/MHEffOnTimeTime.cc	(revision 1295)
@@ -28,8 +28,11 @@
 //  MHEffOnTimeTime                                                         //
 //                                                                          //
+//  calculates the effective on time for each bin in time                   //
 //                                                                          //
 //////////////////////////////////////////////////////////////////////////////
 
 #include "MHEffOnTimeTime.h"
+
+#include <TStyle.h>
 
 #include <TF1.h>
@@ -50,9 +53,8 @@
 // --------------------------------------------------------------------------
 //
-// Default Constructor. It sets name and title only. Typically you won't
-// need to change this.
+// Default Constructor. It sets name and title of the histograms.
 //
 MHEffOnTimeTime::MHEffOnTimeTime(const char *name, const char *title)
-    : fHist()
+    : fHEffOn()
 {
     //
@@ -62,83 +64,171 @@
     fTitle = title ? title : "1-D histogram of Eff On Time";
 
-    fHist.SetName("EffOn");
-    fHist.SetTitle("Effective On Time Vs. Time");
-
-
-    fHist.SetDirectory(NULL);
-
-    fHist.SetXTitle("t_{eff} [s]");
-    fHist.SetYTitle("t [s]");
-}
-
-TObject *MHEffOnTimeTime::DrawClone(Option_t *opt) const
-{
-    TCanvas *c = MakeDefCanvas("EffOnTimeTime", "t_eff vs. t");
-
-    gROOT->SetSelectedPad(NULL);
-
-    ((TH2&)fHist).DrawCopy(opt);
-
-    c->Modified();
-    c->Update();
-
-    return c;
-}
-
-void MHEffOnTimeTime::Draw(Option_t *opt)
-{
-    if (!gPad)
-        MakeDefCanvas("EffOnTimeTime", "t_eff vs. t");
-
-    fHist.Draw(opt);
-
-    gPad->Modified();
-    gPad->Update();
-}
-
-
+    // effective on time versus time
+    fHEffOn.SetName("EffOn");
+    fHEffOn.SetTitle("Effective On Time vs. Time");
+
+    fHEffOn.SetDirectory(NULL);
+
+    fHEffOn.SetXTitle("time [s]");
+    fHEffOn.SetYTitle("t-eff [s]");
+
+    // chi2/NDF versus time
+    fHChi2.SetName("Chi2/NDF");
+    fHChi2.SetTitle("Chi2/NDF of OnTimeFit vs. Time");
+
+    fHChi2.SetDirectory(NULL);
+
+    fHChi2.SetXTitle("time [s]");
+    fHChi2.SetYTitle("chi2/NDF");
+
+    // lambda versus time
+    fHLambda.SetName("lambda");
+    fHLambda.SetTitle("lambda of OnTimeFit vs. Time");
+
+    fHLambda.SetDirectory(NULL);
+
+    fHLambda.SetXTitle("time [s]");
+    fHLambda.SetYTitle("\\lambda [Hz]");
+
+    // N0del versus time
+    fHN0del.SetName("N0del");
+    fHN0del.SetTitle("N0del of OnTimeFit vs. Time");
+
+    fHN0del.SetDirectory(NULL);
+
+    fHN0del.SetXTitle("time [s]");
+    fHN0del.SetYTitle("N0del");
+}
+
+// -----------------------------------------------------------------------
+//
+// Calculate the effective on time by fitting the distribution of
+// time differences
+//
 void MHEffOnTimeTime::Calc(TH2D *hist)
 {
+    // nbins = number of time bins
     const Int_t nbins = hist->GetNbinsY();
 
-    for (int i=1; i<nbins; i++)
+    for (int i=1; i<=nbins; i++)
     {
-        //char txt[100];
-        //sprintf(txt, "Name%d", 100*i);
-        //new TCanvas(txt, "Title");
-
-        TH1D &h = *hist->ProjectionX("dTime-Distribution for fixed Theta", i, i);
-
-        //hist->Draw();
-        //gPad->SetLogy();
-
-        Double_t Nmdel = h.Integral("width");
-        Double_t mean  = h.GetMean();
-
-        TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)",
-                 mean, hist->GetXaxis()->GetXmax());
-
-        func.SetParameter(0, 100); // [Hz]
-        func.SetParameter(1, Nmdel);
-
-        func.SetParLimits(0, 0, 1000);    // [Hz]
-        func.SetParLimits(1, 0, 2*Nmdel);
-
-        func.SetParName(0, "lambda");
-        func.SetParName(1, "Nmdel");
-
-        h.Fit("Poisson", "RN");
-
-        //func.SetRange(0, 0.1); // Range of Drawing
-        //func.DrawCopy("same");
-
-        //cout << func.GetParameter(0) << " " << func.GetParameter(1) << endl;
-
-        Double_t lambda = func.GetParameter(0);
-        //Double_t a      = func.GetParameter(1);
-
-        //cout << "t_eff = " << h->Integral()/lambda << "  T(last)=" << time.GetTimeLo()*0.0001 << endl;
-
-        fHist.SetBinContent(i, h.Integral()/lambda);
+
+        //        TH1D &h = *hist->ProjectionX("Calc-time", i, i, "E");
+        TH1D &h = *hist->ProjectionX("Calc-time", i, i, "E");
+
+
+        // Nmdel = Nm * binwidth,  with Nm = number of observed events
+        const Double_t Nmdel = h.Integral("width");
+        const Double_t Nm    = h.Integral();
+	//        Double_t mean  = h->GetMean();
+
+        //...................................................
+        // determine range (yq[0], yq[1]) of time differences 
+        // where fit should be performed;
+        // require a fraction >=xq[0] of all entries to lie below yq[0]
+        //     and a fraction <=xq[1] of all entries to lie below yq[1];  
+        // within the range (yq[0], yq[1]) there must be no empty bin;
+        // choose pedestrian approach as long as GetQuantiles is not available
+
+        Double_t xq[2] = { 0.15, 0.95 };
+        Double_t yq[2];
+
+        // GetQuantiles doesn't seem to be available in root 3.01/06
+	// h->GetQuantiles(2,yq,xq);
+
+        const Double_t sumtot = h.Integral();
+        const Int_t    jbins  = h.GetNbinsX();
+       
+        if (sumtot > 0.0)
+        {
+            // char txt[100];
+            // sprintf(txt, "time_bin:%d", i);
+            // new TCanvas(txt, txt);
+
+            Double_t sum1 = 0.0;
+            yq[0]  = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                if (sum1 >= xq[0]*sumtot)
+                {
+                    yq[0] = h.GetBinLowEdge(j);
+                    break;
+                }
+                sum1 += h.GetBinContent(j);
+            }
+        
+            Double_t sum2 = 0.0;
+            yq[1] = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                const Double_t content = h.GetBinContent(j);
+                sum2 += content;
+                if (sum2 >= xq[1]*sumtot || content == 0.0)
+                {
+                    yq[1] = h.GetBinLowEdge(j);
+                    break;
+                }
+            }
+
+            //...................................................
+
+            // parameter 0 = lambda
+            // parameter 1 = N0*del        with N0 = ideal number of events
+            //                             and del = bin width of time difference
+            TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)", yq[0], yq[1]);
+
+            func.SetParameter(0, 100); // [Hz]
+            func.SetParameter(1, Nmdel);
+
+            func.SetParLimits(0, 0, 1000);    // [Hz]
+            func.SetParLimits(1, 0, 10*Nmdel);
+
+            func.SetParName(0, "lambda");
+            func.SetParName(1, "Nmdel");
+
+            // options : 0  (=zero) do not plot the function
+            //           I  use integral of function in bin rather than value at bin center
+            //           R  use the range specified in the function range
+            //           Q  quiet mode
+            h.Fit("Poisson", "0IRQ");
+
+            // gPad->SetLogy();
+            // gStyle->SetOptFit(1011);
+            // h->GetXaxis()->SetTitle("time difference [s]");
+            // h->GetYaxis()->SetTitle("Counts");
+            // h->DrawCopy();
+
+            // func.SetRange(yq[0], yq[1]); // Range of Drawing
+            // func.DrawCopy("same");
+
+            const Double_t lambda = func.GetParameter(0);
+            const Double_t N0del  = func.GetParameter(1);
+            const Double_t chi2   = func.GetChisquare();
+            const Int_t    NDF    = func.GetNDF();
+
+            // was fit successful ?
+            if (NDF>0  &&  chi2<2.5*NDF)
+            {
+                // the effective on time is Nm/lambda
+                fHEffOn.SetBinContent(i, Nm/lambda);
+
+                // plot chi2/NDF of fit
+                fHChi2.SetBinContent(i, NDF ? chi2/NDF : 0.0);
+
+                // lambda of fit
+                fHLambda.SetBinContent(i, lambda);
+
+                // N0del of fit
+                fHN0del.SetBinContent(i, N0del);
+
+                delete &h;
+                continue;
+            }
+        }
+
+        fHEffOn.SetBinContent (i, 1.e-20);
+        fHChi2.SetBinContent  (i, 1.e-20);
+        fHLambda.SetBinContent(i, 1.e-20);
+        fHN0del.SetBinContent (i, 1.e-20);
 
         delete &h;
@@ -146,4 +236,8 @@
 }
 
+// -------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
 Bool_t MHEffOnTimeTime::SetupFill(const MParList *plist)
 {
@@ -155,12 +249,86 @@
     }
 
-    SetBinning(&fHist, binstime);
+    SetBinning(&fHEffOn,  binstime);
+    SetBinning(&fHChi2,   binstime);
+    SetBinning(&fHLambda, binstime);
+    SetBinning(&fHN0del,  binstime);
+
+    fHEffOn.Sumw2();
+    fHChi2.Sumw2();
+    fHLambda.Sumw2();
+    fHN0del.Sumw2();
 
     return kTRUE;
 }
 
+// -------------------------------------------------------------------------
+//
+// Dummy Fill
+// without it get error message :
+// Error: MHEffOnTimeTime() no default constructor FILE:macros/wowflux.C LINE:359
+//*** Interpreter error recovered ***
 Bool_t MHEffOnTimeTime::Fill(const MParContainer *par)
 {
-    return kTRUE;
-}
-
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHEffOnTimeTime::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MakeDefCanvas("EffOnTimeTime", "Results from on time fit vs. time");
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    ((TH2*)&fHEffOn)->DrawCopy(opt);
+
+    c.cd(2);
+    ((TH2*)&fHChi2)->DrawCopy(opt);
+
+    c.cd(3);
+    ((TH2*)&fHLambda)->DrawCopy(opt);
+
+    c.cd(4);
+    ((TH2*)&fHN0del)->DrawCopy(opt);
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHEffOnTimeTime::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MakeDefCanvas("EffOnTimeTime", "Results from on time fit vs. time");
+
+    gPad->Divide(2,2);
+
+    gPad->cd(1);
+    fHEffOn.Draw(opt);
+
+    gPad->cd(2);
+    fHChi2.Draw(opt);
+
+    gPad->cd(3);
+    fHLambda.Draw(opt);
+
+    gPad->cd(4);
+    fHN0del.Draw(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+
+
+
+
Index: /trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc	(revision 1294)
+++ /trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.cc	(revision 1295)
@@ -28,4 +28,5 @@
 //  MHTimeDiffTheta                                                         //
 //                                                                          //
+//  calculates the 2D-histogram   time-difference vs. Theta                 //
 //                                                                          //
 //////////////////////////////////////////////////////////////////////////////
@@ -49,6 +50,5 @@
 // --------------------------------------------------------------------------
 //
-// Default Constructor. It sets name and title only. Typically you won't
-// need to change this.
+// Default Constructor. It sets name and title of the histogram.
 //
 MHTimeDiffTheta::MHTimeDiffTheta(const char *name, const char *title)
@@ -59,12 +59,16 @@
     //
     fName  = name  ? name  : "MHTimeDiffTheta";
-    fTitle = title ? title : "2-D histogram in time and time difference";
+    fTitle = title ? title : "2-D histogram in Theta and time difference";
 
     fHist.SetDirectory(NULL);
 
-    fHist.GetXaxis()->SetTitle("\\Delta t [s]");
-    fHist.GetYaxis()->SetTitle("\\Theta [\\circ]");
-}
-
+    fHist.SetXTitle("\\Delta t [s]");
+    fHist.SetYTitle("\\Theta [\\circ]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histogram
+//
 Bool_t MHTimeDiffTheta::SetupFill(const MParList *plist)
 {
@@ -96,8 +100,13 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
 TObject *MHTimeDiffTheta::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("DiffTimeTheta", "Distrib of Delta t, Theta");
-    c->Divide(2, 2);
+    TCanvas &c = *MakeDefCanvas("DiffTimeTheta", "Distrib of \\Delta t, Theta");
+
+    c.Divide(2, 2);
 
     gROOT->SetSelectedPad(NULL);
@@ -106,26 +115,41 @@
     // FIXME: ProjectionX,Y is not const within root
     //
+
     TH1D *h;
 
-    c->cd(1);
-    h = ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E");
-    h->DrawCopy(opt);
-    delete h;
+    c.cd(1);
+    h = ((TH2*)&fHist)->ProjectionX("ProjX-Theta", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Delta t [s]");
+    h->SetXTitle("\\Delta t [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);;
     gPad->SetLogy();
 
-    c->cd(2);
-    h = ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E");
-    h->DrawCopy(opt);
-    delete h;
-
-    c->cd(3);
+    c.cd(2);
+    h = ((TH2*)&fHist)->ProjectionY("ProjY-timediff", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Theta [\\circ]");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);;
+
+    c.cd(3);
     ((TH2*)&fHist)->DrawCopy(opt);
 
-    c->Modified();
-    c->Update();
-
-    return c;
-}
-
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
 void MHTimeDiffTheta::Draw(Option_t *opt)
 {
@@ -138,21 +162,36 @@
 
     gPad->cd(1);
-    h = fHist.ProjectionX("ProX", -1, 9999, "E");
-    h->DrawCopy(opt);
-    delete h;
+    h = fHist.ProjectionX("ProjX_Theta", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Delta t [s]");
+    h->SetXTitle("\\Delta t [s]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);;
     gPad->SetLogy();
 
     gPad->cd(2);
-    h = fHist.ProjectionY("ProY", -1, 9999, "E");
-    h->DrawCopy(opt);
-    delete h;
+    h = fHist.ProjectionY("ProjY_timediff", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Theta [\\circ]");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("Counts");
+
+    h->Draw(opt);
+    h->SetBit(kCanDelete);;
 
     gPad->cd(3);
-    fHist.Draw(opt);
+    fHist.DrawCopy(opt);
 
     gPad->Modified();
     gPad->Update();
-}
-
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the histogram
+//
 Bool_t MHTimeDiffTheta::Fill(const MParContainer *par)
 {
Index: /trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.h	(revision 1294)
+++ /trunk/MagicSoft/Mars/mhist/MHTimeDiffTheta.h	(revision 1295)
@@ -35,5 +35,5 @@
     TObject *DrawClone(Option_t *option="") const;
 
-    ClassDef(MHTimeDiffTheta, 1) //Histogram to store a 3-Dim histogram in alpha, Energy and time
+    ClassDef(MHTimeDiffTheta, 1) //2D-histogram  time-diff vs. Theta
 };
 
Index: /trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.cc	(revision 1294)
+++ /trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.cc	(revision 1295)
@@ -28,4 +28,6 @@
 //  MHTimeDiffTime                                                          //
 //                                                                          //
+//  calculates the 2D-histogram   time-difference vs. time                  //
+//                                                                          //
 //                                                                          //
 //////////////////////////////////////////////////////////////////////////////
@@ -48,6 +50,5 @@
 // --------------------------------------------------------------------------
 //
-// Default Constructor. It sets name and title only. Typically you won't
-// need to change this.
+// Default Constructor. It sets name and title of the histogram
 //
 MHTimeDiffTime::MHTimeDiffTime(const char *name, const char *title)
@@ -62,66 +63,87 @@
     fHist.SetDirectory(NULL);
 
-    fHist.GetXaxis()->SetTitle("\\Delta t [s]");
-    fHist.GetYaxis()->SetTitle("t [s]");
+    fHist.SetXTitle("\\Delta t [s]");
+    fHist.SetYTitle("t [s]");
 }
 
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histogram
+//
 Bool_t MHTimeDiffTime::SetupFill(const MParList *plist)
 {
-   fTime = (MTime*)plist->FindObject("MTime");
-   if (!fTime)
-   {
-       *fLog << err << dbginf << "MTime not found... aborting." << endl;
-       return kFALSE;
-   }
+    fTime = (MTime*)plist->FindObject("MTime");
+    if (!fTime)
+    {
+        *fLog << err << dbginf << "MTime not found... aborting." << endl;
+        return kFALSE;
+    }
 
-   const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningTimeDiff");
-   const MBinning* binstime  = (MBinning*)plist->FindObject("BinningTime");
-   if (!binstime || !binsdtime)
-   {
-       *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
-       return kFALSE;      
-   }
+    const MBinning* binsdtime = (MBinning*)plist->FindObject("BinningTimeDiff");
+    const MBinning* binstime  = (MBinning*)plist->FindObject("BinningTime");
+    if (!binstime || !binsdtime)
+    {
+        *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+        return kFALSE;
+    }
 
-   SetBinning(&fHist, binsdtime, binstime);
+    SetBinning(&fHist, binsdtime, binstime);
 
-   return kTRUE;
+    return kTRUE;
 }
 
+// --------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
 TObject *MHTimeDiffTime::DrawClone(Option_t *opt) const
 {
-    TCanvas *c = MakeDefCanvas("DiffTimeTime", "Distrib of dt, t");
-    c->Divide(2, 2);
+
+    TCanvas &c = *MakeDefCanvas("DiffTimeTime", "Distrib of \\Delta t, time");
+
+    c.Divide(2, 2);
 
     gROOT->SetSelectedPad(NULL);
 
-    //
-    // FIXME: ProjectionX,Y is not const within root
-    //
     TH1D *h;
 
-    c->cd(1);
-    h = ((TH2*)&fHist)->ProjectionX("ProX", -1, 9999, "E");
+    c.cd(1);
+    h = ((TH2*)&fHist)->ProjectionX("ProjX-sumtime", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Delta t [s]");
+    h->SetXTitle("\\Delta t [s]");
+    h->SetYTitle("Counts");
+
     h->Draw(opt);
     h->SetBit(kCanDelete);
     gPad->SetLogy();
 
-    c->cd(2);
-    h = ((TH2*)&fHist)->ProjectionY("ProY", -1, 9999, "E");
+    c.cd(2);
+    h = ((TH2*)&fHist)->ProjectionY("ProjY-sumtimediff", -1, 9999, "E");
+
+    h->SetTitle("Distribution of time [s]");
+    h->SetXTitle("time [s]");
+    h->SetYTitle("Counts");
+
     h->Draw(opt);
     h->SetBit(kCanDelete);
 
-    c->cd(3);
+    c.cd(3);
     ((TH2*)&fHist)->DrawCopy(opt);
 
-    c->Modified();
-    c->Update();
+    c.Modified();
+    c.Update();
 
-    return c;
+    return &c;
 }
 
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
 void MHTimeDiffTime::Draw(Option_t *opt)
 {
     if (!gPad)
-        MakeDefCanvas("DiffTimeTime", "Distrib of dt, t");
+        MakeDefCanvas("DiffTimeTime", "Distrib of \\Delta t, time");
 
     gPad->Divide(2,2);
@@ -130,5 +152,10 @@
 
     gPad->cd(1);
-    h = fHist.ProjectionX("ProX", -1, 9999, "E");
+    h = fHist.ProjectionX("ProjX_sumtime", -1, 9999, "E");
+
+    h->SetTitle("Distribution of \\Delta t [s]");
+    h->SetXTitle("\\Delta t [s]");
+    h->SetYTitle("Counts");
+
     h->Draw(opt);
     h->SetBit(kCanDelete);
@@ -136,5 +163,10 @@
 
     gPad->cd(2);
-    h = fHist.ProjectionY("ProY", -1, 9999, "E");
+    h = fHist.ProjectionY("ProjY_sumtimediff", -1, 9999, "E");
+
+    h->SetTitle("Distribution of time [s]");
+    h->SetXTitle("time [s]");
+    h->SetYTitle("Counts");
+
     h->Draw(opt);
     h->SetBit(kCanDelete);
@@ -145,6 +177,11 @@
     gPad->Modified();
     gPad->Update();
+
 }
 
+// --------------------------------------------------------------------------
+//
+//  Fill the histogram
+//
 Bool_t MHTimeDiffTime::Fill(const MParContainer *par)
 {
@@ -158,2 +195,5 @@
 }
 
+
+
+
Index: /trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.h	(revision 1294)
+++ /trunk/MagicSoft/Mars/mhist/MHTimeDiffTime.h	(revision 1295)
@@ -33,5 +33,5 @@
     TObject *DrawClone(Option_t *option="") const;
 
-    ClassDef(MHTimeDiffTime, 1) //Histogram to store a 3-Dim histogram in alpha, Energy and time
+    ClassDef(MHTimeDiffTime, 1) //2D-histogram  time-diff vs. time
 };
 
