Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 4890)
+++ trunk/MagicSoft/Mars/Changelog	(revision 4891)
@@ -19,4 +19,13 @@
 
                                                  -*-*- END OF LINE -*-*-
+
+ 2004/09/09: Thomas Bretz
+
+  * mhvstime/MHPixVsTime.[h,cc], mhvstime/MHVsTime.[h,cc],
+    mhvstime/MHSectorVsTime.[h,cc], mhbase/MH3.[h,cc]:
+    - changed such that the axis titles can be set via the 
+      title
+
+
 
  2004/09/08: Thomas Bretz
Index: trunk/MagicSoft/Mars/mhbase/MBinning.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MBinning.cc	(revision 4890)
+++ trunk/MagicSoft/Mars/mhbase/MBinning.cc	(revision 4891)
@@ -44,6 +44,6 @@
 using namespace std;
 
-static const TString gsDefName  = "MBinning";
-static const TString gsDefTitle = "Container describing the binning of an axis";
+const TString MBinning::gsDefName  = "MBinning";
+const TString MBinning::gsDefTitle = "Container describing the binning of an axis";
 
 // --------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mhbase/MBinning.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MBinning.h	(revision 4890)
+++ trunk/MagicSoft/Mars/mhbase/MBinning.h	(revision 4891)
@@ -15,5 +15,10 @@
 class MBinning : public MParContainer
 {
+public:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
 private:
+
     TArrayD fEdges;
 
@@ -80,4 +85,6 @@
     Bool_t IsUserArray() const { return fType==kIsUserArray; }
 
+    Bool_t HasTitle() const { return gsDefTitle!=fTitle; }
+
     void Apply(TH1 &) const;
 
Index: trunk/MagicSoft/Mars/mhbase/MH3.cc
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 4890)
+++ trunk/MagicSoft/Mars/mhbase/MH3.cc	(revision 4891)
@@ -48,4 +48,16 @@
 // SetScaleY and SetScaleZ.
 //
+//
+// Axis titles
+// ===========
+//
+// 1) If no other title is given the rule for this axis is used.
+// 2) If the MBinning used for this axis has a non-default Title
+//    (MBinning::HasTitle) this title is used for the corresponding axis
+// 3) If the MH3 has a non-default title (MH3::SetTitle called)
+//    this title is set as the histogram title. It can be used to overwrite
+//    the axis titles. For more information see TH1::SetTitle, eg.
+//       SetTitle("MyHist;x[mm];y[cm];Counts");
+//
 // For example:
 //   MH3 myhist("MHillas.fLength");
@@ -83,6 +95,6 @@
 using namespace std;
 
-static const TString gsDefName  = "MH3";
-static const TString gsDefTitle = "Container for a %dD Mars Histogram";
+const TString MH3::gsDefName  = "MH3";
+const TString MH3::gsDefTitle = "Container for a n-D Mars Histogram";
 
 // --------------------------------------------------------------------------
@@ -113,5 +125,5 @@
 
     fName  = gsDefName;
-    fTitle = Form(gsDefTitle.Data(), fDimension);
+    fTitle = gsDefTitle;
 
     if (fHist)
@@ -141,5 +153,5 @@
 
     fName  = gsDefName;
-    fTitle = Form(gsDefTitle.Data(), 1);
+    fTitle = gsDefTitle;
 
     fHist->UseCurrentStyle();
@@ -168,5 +180,5 @@
 
     fName  = gsDefName;
-    fTitle = Form(gsDefTitle.Data(), 2);
+    fTitle = gsDefTitle;
 
     fHist->UseCurrentStyle();
@@ -195,5 +207,5 @@
 
     fName  = gsDefName;
-    fTitle = Form(gsDefTitle.Data(), 3);
+    fTitle = gsDefTitle;
 
     fHist->UseCurrentStyle();
@@ -266,9 +278,12 @@
             return kFALSE;
         }
+        if (fData[2] && !fData[2]->PreProcess(plist))
+            return kFALSE;
+        if (fData[2])
+            fHist->SetZTitle(fData[2]->GetTitle());
+        if (binsz->HasTitle())
+            fHist->SetZTitle(binsz->GetTitle());
         if (binsz->IsLogarithmic())
             fHist->SetBit(kIsLogz);
-        if (fData[2]) fHist->SetZTitle(fData[2]->GetTitle());
-        if (fData[2] && !fData[2]->PreProcess(plist))
-            return kFALSE;
     case 2:
         binsy = (MBinning*)plist->FindObject(bname+"Y", "MBinning");
@@ -278,9 +293,12 @@
             return kFALSE;
         }
+        if (fData[1] && !fData[1]->PreProcess(plist))
+            return kFALSE;
+        if (fData[1])
+            fHist->SetYTitle(fData[1]->GetTitle());
+        if (binsy->HasTitle())
+            fHist->SetYTitle(binsy->GetTitle());
         if (binsy->IsLogarithmic())
             fHist->SetBit(kIsLogy);
-        if (fData[1]) fHist->SetYTitle(fData[1]->GetTitle());
-        if (fData[1] && !fData[1]->PreProcess(plist))
-            return kFALSE;
     case 1:
         binsx = (MBinning*)plist->FindObject(bname+"X", "MBinning");
@@ -297,13 +315,22 @@
 
         }
+        if (fData[0] && !fData[0]->PreProcess(plist))
+            return kFALSE;
+        if (fData[0]!=NULL)
+            fHist->SetXTitle(fData[0]->GetTitle());
+        if (binsx->HasTitle())
+            fHist->SetXTitle(binsx->GetTitle());
         if (binsx->IsLogarithmic())
             fHist->SetBit(kIsLogx);
-
-      if (fData[0]!=NULL)  fHist->SetXTitle(fData[0]->GetTitle());
-        if (fData[0] && !fData[0]->PreProcess(plist))
-            return kFALSE;
     }
 
     fHist->SetName(fName);
+    fHist->SetDirectory(0);
+
+    if (fTitle!=gsDefTitle)
+    {
+        fHist->SetTitle(fTitle);
+        return kTRUE;
+    }
 
     TString title("Histogram for ");
@@ -325,6 +352,7 @@
         return kTRUE;
     }
-    cout << "Still alive...?" << endl;
-    return kTRUE;
+
+    *fLog << err << "ERROR - MH3 has " << fDimension << " dimensions!" << endl;
+    return kFALSE;
 }
 
@@ -335,5 +363,9 @@
 void MH3::SetName(const char *name)
 {
-    fHist->SetName(name);
+    if (fHist)
+    {
+        fHist->SetName(name);
+        fHist->SetDirectory(0);
+    }
     MParContainer::SetName(name);
 }
@@ -345,5 +377,6 @@
 void MH3::SetTitle(const char *title)
 {
-    fHist->SetTitle(title);
+    if (fHist)
+        fHist->SetTitle(title);
     MParContainer::SetTitle(title);
 }
@@ -644,5 +677,5 @@
         out << "   " << name << ".SetName(\"" << fName << "\");" << endl;
 
-    if (fTitle!=Form(gsDefTitle.Data(), fDimension))
+    if (fTitle!=gsDefTitle)
         out << "   " << name << ".SetTitle(\"" << fTitle << "\");" << endl;
 
Index: trunk/MagicSoft/Mars/mhbase/MH3.h
===================================================================
--- trunk/MagicSoft/Mars/mhbase/MH3.h	(revision 4890)
+++ trunk/MagicSoft/Mars/mhbase/MH3.h	(revision 4891)
@@ -15,4 +15,8 @@
 class MH3 : public MH
 {
+private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
 protected:
     // Could be const but root < 3.02/06 doesn't like this...
Index: trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.cc	(revision 4890)
+++ trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.cc	(revision 4891)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 12/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2003
+!   Copyright: MAGIC Software Development, 2000-2004
 !
 !
@@ -28,4 +28,15 @@
 //
 // Display the pixel content versus time or event number
+//
+// Axis titles
+// ===========
+//
+// 1) If no other title is given the rule for the y-axis is used.
+// 2) If the MH3 has a non-default title (MH3::SetTitle called)
+//    this title is set as the histogram title. It can be used to overwrite
+//    the axis titles. For more information see TH1::SetTitle, eg.
+//       SetTitle("MyGraph;;Counts");
+//    The title for the x-axis is ignored and set automatically (MAKE SURE
+//    YOU HAVE TWO SEMICOLON!)
 //
 /////////////////////////////////////////////////////////////////////////////
@@ -48,4 +59,7 @@
 
 using namespace std;
+
+const TString MHPixVsTime::gsDefName  = "MHPixVsTime";
+const TString MHPixVsTime::gsDefTitle = "Graph of pixel content vs. time";
 
 // --------------------------------------------------------------------------
@@ -59,6 +73,6 @@
     //   set the name and title of this object
     //
-    fName  = name  ? name  : "MHPixVsTime";
-    fTitle = title ? title : "Average of MPixVsTimes";
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
 
     TString t("Pixel Index #");
@@ -77,6 +91,26 @@
 MHPixVsTime::~MHPixVsTime()
 {
-  if(fGraph)
-    delete fGraph;
+    if (fGraph)
+        delete fGraph;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the name of the TGraph and the MHPixVsTime container
+//
+void MHPixVsTime::SetName(const char *name)
+{
+    fGraph->SetName(name);
+    MParContainer::SetName(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the title of the TGraph and the MHPixVsTime container
+//
+void MHPixVsTime::SetTitle(const char *title)
+{
+    fGraph->SetTitle(title);
+    MParContainer::SetTitle(title);
 }
 
@@ -124,4 +158,7 @@
     }
 
+    if (fTitle!=gsDefTitle)
+        fGraph->SetTitle(fTitle);
+
     return kTRUE;
 }
@@ -190,5 +227,4 @@
 
     h->SetXTitle("Time");
-    h->SetYTitle("");
     if (!fNameTime.IsNull())
     {
Index: trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.h
===================================================================
--- trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.h	(revision 4890)
+++ trunk/MagicSoft/Mars/mhvstime/MHPixVsTime.h	(revision 4891)
@@ -20,4 +20,7 @@
 {
 private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
     TGraphErrors *fGraph;
     Int_t fIndex;
@@ -46,4 +49,7 @@
     void SetType(Int_t type, Int_t e=-1) { fType = type; fTypeErr=e; }
 
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
     TH1 *GetHistByName(const TString name="");
     TGraph *GetGraph() { return fGraph; }
Index: trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc	(revision 4890)
+++ trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.cc	(revision 4891)
@@ -30,4 +30,12 @@
 // single sector
 //
+// 1) If no other title is given the rule for the y-axis is used.
+// 2) If the MH3 has a non-default title (MH3::SetTitle called)
+//    this title is set as the histogram title. It can be used to overwrite
+//    the axis titles. For more information see TH1::SetTitle, eg.
+//       SetTitle("MyGraph;;Counts");
+//    The title for the x-axis is ignored and set automatically (MAKE SURE
+//    YOU HAVE TWO SEMICOLON!)
+//
 /////////////////////////////////////////////////////////////////////////////
 #include "MHSectorVsTime.h"
@@ -50,4 +58,7 @@
 
 using namespace std;
+
+const TString MHSectorVsTime::gsDefName  = "MSectorHVsTime";
+const TString MHSectorVsTime::gsDefTitle = "Graph of sector mean vs. time";
 
 // --------------------------------------------------------------------------
@@ -62,6 +73,6 @@
     //   set the name and title of this object
     //
-    fName  = name  ? name  : "MHSectorVsTime";
-    fTitle = title ? title : "Sector mean vs time";
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
 }
 
@@ -75,4 +86,25 @@
         delete fGraph;
 }
+
+// --------------------------------------------------------------------------
+//
+// Set the name of the TGraph and the MHVsTime container
+//
+void MHSectorVsTime::SetName(const char *name)
+{
+    fGraph->SetName(name);
+    MParContainer::SetName(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the title of the TGraph and the MHVsTime container
+//
+void MHSectorVsTime::SetTitle(const char *title)
+{
+    fGraph->SetTitle(title);
+    MParContainer::SetTitle(title);
+}
+
 
 // --------------------------------------------------------------------------
@@ -127,5 +159,5 @@
     fGraph = fTypeErr<0 ? new TGraph : new TGraphErrors;
     fGraph->SetName(fEvt ? dynamic_cast<TObject*>(fEvt)->GetName() : "MCamEvent");
-    fGraph->SetTitle("Camera");
+    fGraph->SetTitle(fTitle==gsDefTitle?"Camera":fTitle);
 
     fMin =  FLT_MAX;
@@ -206,11 +238,9 @@
 void MHSectorVsTime::Draw(Option_t *opt)
 {
-    /*
+    if (!fGraph)
+        return;
+
     if (fGraph->GetN()==0)
         return;
-        */
-
-    if (fGraph->GetN()==0)
-        return;
 
     TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
@@ -220,12 +250,5 @@
 
     TString str(opt);
-    /*
-    fGraph->GetHistogram()->SetXTitle("Time");
-    fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");
-    fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1);
-    fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033);
-
-    fGraph->GetHistogram()->SetYTitle("");
-     */
+
     if (!str.Contains("A"))
         str += "A";
@@ -242,5 +265,4 @@
 
     h->SetXTitle("Time");
-    h->SetYTitle("");
 
     if (!fNameTime.IsNull())
@@ -252,29 +274,4 @@
     }
 
-    *fLog << dbg << "Draw: " << str << endl;
     fGraph->Draw(str);
-/*
-    str.ReplaceAll("same", "");
-    str.ReplaceAll("A", "");
-
-    Int_t i=-1;
-    Int_t col=kRed;
-    while ((g=(TGraphErrors*)Next()))
-    {
-        i++;
-        *fLog << dbg << "Check" << i << ": " << str << endl;
-
-        while ((fMinSector>=0 && i<fMinSector) || (fMaxSector>=0 && i>fMaxSector))
-            i++;
-
-        h = g->GetHistogram();
-        g->SetLineColor(col++);
-
-        *fLog << dbg << "Draw" << i << ": " << g->GetTitle() << endl;
-        g->Draw(str);
-
-    }
-
-    pad->Modified();
-    pad->Update();*/
-}
+}
Index: trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.h
===================================================================
--- trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.h	(revision 4890)
+++ trunk/MagicSoft/Mars/mhvstime/MHSectorVsTime.h	(revision 4891)
@@ -20,4 +20,8 @@
 class MHSectorVsTime : public MH
 {
+private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
 private:
     TGraph *fGraph;
@@ -51,4 +55,7 @@
     ~MHSectorVsTime();
 
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
     void SetNameEvt(const TString name)  { fNameEvt = name; }
     void SetNameTime(const TString name) { fNameTime = name; }
Index: trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc
===================================================================
--- trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc	(revision 4890)
+++ trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc	(revision 4891)
@@ -29,4 +29,15 @@
 // Use this class if you want to display any rule vs time (or event number)
 //
+// Axis titles
+// ===========
+//
+// 1) If no other title is given the rule for the y-axis is used.
+// 2) If the MH3 has a non-default title (MH3::SetTitle called)
+//    this title is set as the histogram title. It can be used to overwrite
+//    the axis titles. For more information see TH1::SetTitle, eg.
+//       SetTitle("MyGraph;;Counts");
+//    The title for the x-axis is ignored and set automatically (MAKE SURE
+//    YOU HAVE TWO SEMICOLON!)
+//
 // eg.
 //       MHVsTime hist("MHillas.fAlpha");
@@ -63,6 +74,6 @@
 using namespace std;
 
-static const TString gsDefName  = "MHVsTime";
-static const TString gsDefTitle = "Container for a graph vs time/evtnumber";
+const TString MHVsTime::gsDefName  = "MHVsTime";
+const TString MHVsTime::gsDefTitle = "Container for a graph vs time/evtnumber";
 
 // --------------------------------------------------------------------------
@@ -89,4 +100,5 @@
     fGraph->SetPoint(0, 0, 0); // Dummy point!
     fGraph->SetEditable();     // Used as flag: First point? yes/no
+    fGraph->SetMarkerStyle(kFullDotMedium);
 }
 
@@ -137,9 +149,10 @@
     fGraph->SetEditable();     // Used as flag: First point? yes/no
 
-    TString title(fData ? GetRule() : (TString)"Histogram");
+
+    TString title(fData ? GetRule() : (TString)"Graph");
     title += " vs ";
     title += fUseEventNumber ? "Event Number" : "Time";
 
-    fGraph->SetNameTitle(fName, title);
+    fGraph->SetNameTitle(fName, fTitle==gsDefTitle?title:fTitle);
 
     fMean = 0;
@@ -245,9 +258,4 @@
     }
 
-    fGraph->GetHistogram()->SetMarkerStyle(kFullDotMedium);
-    fGraph->GetHistogram()->SetYTitle(fAxisTitle.IsNull() ? GetRule() : fAxisTitle);
-    if (fTitle!=gsDefTitle)
-        fGraph->GetHistogram()->SetTitle(fTitle);
-
     if (TestBit(kIsLogy))
         gPad->SetLogy();
Index: trunk/MagicSoft/Mars/mhvstime/MHVsTime.h
===================================================================
--- trunk/MagicSoft/Mars/mhvstime/MHVsTime.h	(revision 4890)
+++ trunk/MagicSoft/Mars/mhvstime/MHVsTime.h	(revision 4891)
@@ -15,4 +15,8 @@
 class MHVsTime : public MH
 {
+private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
 protected:
     // Could be const but root < 3.02/06 doesn't like this...
@@ -29,6 +33,4 @@
     Int_t       fN;         //! Number of entries in fMean
     MTime       fLast;      //! For checks
-
-    TString     fAxisTitle;
 
     enum {
@@ -50,5 +52,4 @@
 
     void SetLogy(Bool_t b=kTRUE) { b ? SetBit(kIsLogy) : ResetBit(kIsLogy); }
-    void SetAxisTitle(const char *y) { fAxisTitle=y; }
 
     Bool_t SetupFill(const MParList *pList);
