Index: /trunk/MagicSoft/Mars/mhist/HistLinkDef.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 7197)
+++ /trunk/MagicSoft/Mars/mhist/HistLinkDef.h	(revision 7198)
@@ -22,5 +22,4 @@
 #pragma link C++ class MHRate+;
 #pragma link C++ class MHWeather+;
-#pragma link C++ class MHPointing+;
 
 #endif
Index: /trunk/MagicSoft/Mars/mhist/MHRate.cc
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHRate.cc	(revision 7198)
+++ /trunk/MagicSoft/Mars/mhist/MHRate.cc	(revision 7198)
@@ -0,0 +1,301 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 07/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHRate
+//
+// Display information about software trigger rate
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHRate.h"
+
+#include <TPad.h>
+#include <TCanvas.h>
+#include <TGaxis.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MTime.h"
+#include "MEventRate.h"
+#include "MPointingPos.h"
+#include "MBinning.h"
+
+ClassImp(MHRate);
+
+using namespace std;
+
+void MHRate::ResetGraph(TGraph &g) const
+{
+    g.Set(1);
+    g.SetPoint(0, 0, 0); // Dummy Point
+    g.SetEditable();     // Used as flag: First point? yes/no
+}
+
+void MHRate::InitGraph(TGraph &g) const
+{
+    ResetGraph(g);
+    g.SetMarkerStyle(kFullDotMedium);
+}
+
+void MHRate::AddPoint(TGraph &g, Double_t x, Double_t y) const
+{
+    if (g.IsEditable())
+    {
+        g.RemovePoint(0);
+        g.SetEditable(kFALSE);
+    }
+
+    g.SetPoint(g.GetN(), x, y);
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms 
+//
+MHRate::MHRate(const char *name, const char *title)
+: /*fTime(0),*/ fPointPos(0), fEvtRate(0)
+{
+    fName  = name  ? name  : "MHRate";
+    fTitle = title ? title : "Graphs for rate data";
+
+    // Init Graphs
+    fRateTime.SetNameTitle("RateTime", "Rate vs Time");
+    fRateZd.SetNameTitle("RateZd", "Rate vs Zenith distance");
+    fRate.SetNameTitle("Rate", "Distribution of Rate");
+
+    InitGraph(fRateTime);
+
+    fRateZd.SetXTitle("Zd [\\circ]");
+    fRateZd.SetYTitle("Rate [Hz]");
+
+    fRate.SetXTitle("Rate [Hz]");
+    fRate.SetYTitle("Counts");
+
+    fRateTime.SetMinimum(0);
+
+    fRate.SetDirectory(0);
+    fRateZd.SetDirectory(0);
+
+    fRateZd.SetMarkerStyle(kFullDotMedium);
+    fRateZd.SetBit(TH1::kNoStats);
+
+    MBinning b;
+    b.SetEdges(120, 0, 1200);
+    b.Apply(fRate);
+
+    b.SetEdgesASin(67, -0.005, 0.665);
+    b.Apply(fRateZd);
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning
+//
+Bool_t MHRate::SetupFill(const MParList *plist)
+{
+    fEvtRate = (MEventRate*)plist->FindObject("MEventRate");
+    if (!fEvtRate)
+    {
+        *fLog << warn << "MEventRate not found... abort." << endl;
+        return kFALSE;
+    }
+    fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
+    if (!fPointPos)
+    {
+        *fLog << warn << "MPointingPos not found... abort." << endl;
+        return kFALSE;
+    }
+
+    // Reset Graphs
+    ResetGraph(fRateTime);
+
+    fCounter = 0;
+    fMean    = 0;
+    fLast    = MTime();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MMuonCalibPar and
+// MMuonSearchPar container.
+//
+Bool_t MHRate::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MTime *t = dynamic_cast<const MTime*>(par);
+    if (!t)
+    {
+        *fLog << err <<"MHRate::Fill - ERROR: MTime not given as argument... abort." << endl;
+        return kERROR;
+    }
+
+    const Double_t rate = fEvtRate->GetRate();
+    if (rate<0)
+        return kTRUE;
+
+    const Double_t tm   = t->GetAxisTime();
+
+    if (fLast==MTime())
+        fLast = MTime();
+
+    fMean += rate;
+    fCounter++;
+
+    if ((double)*t > (double)fLast+5 && fCounter>0)
+    {
+        AddPoint(fRateTime, tm, fMean/fCounter);
+        fMean     = 0;
+        fCounter = 0;
+        fLast = *t;
+    }
+
+    fRateZd.Fill(fPointPos->GetZd(), rate);
+    fRate.Fill(rate);
+
+    return kTRUE;
+}
+
+void MHRate::DrawGraph(TGraph &g, const char *y) const
+{
+    TH1 *h = g.GetHistogram();
+    if (h)
+    {
+        TAxis *axe = h->GetXaxis();
+        axe->SetLabelSize(0.033);
+        axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT");
+        axe->SetTimeDisplay(1);
+        axe->SetTitle("Time");
+        if (y)
+            h->SetYTitle(y);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Update position of an axis on the right side of the histogram
+/*
+void MHRate::UpdateRightAxis(TGraph &g) const
+{
+    TH1 &h = *g.GetHistogram();
+
+    const Double_t max = h.GetMaximum();
+    if (max==0)
+        return;
+
+    TGaxis *axis = (TGaxis*)gPad->FindObject("RightAxis");
+    if (!axis)
+        return;
+
+    axis->SetX1(g.GetXaxis()->GetXmax());
+    axis->SetX2(g.GetXaxis()->GetXmax());
+    axis->SetY1(gPad->GetUymin());
+    axis->SetY2(gPad->GetUymax());
+    axis->SetWmax(max);
+}
+*/
+// --------------------------------------------------------------------------
+//
+// Draw an axis on the right side of the histogram
+//
+/*
+void MHRate::DrawRightAxis(const char *title) const
+{
+    TGaxis *axis = new TGaxis(gPad->GetUxmax(), gPad->GetUymin(),
+                              gPad->GetUxmax(), gPad->GetUymax(),
+                              0, 1, 510, "+L");
+    axis->SetName("RightAxis");
+    axis->SetTitle(title);
+    axis->SetTitleOffset(0.9);
+    axis->SetTextColor(kRed);
+    axis->SetBit(kCanDelete);
+    axis->Draw();
+}
+*/
+// --------------------------------------------------------------------------
+//
+// This displays the TGraph like you expect it to be (eg. time on the axis)
+// It should also make sure, that the displayed time always is UTC and
+// not local time...
+//
+void MHRate::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad();
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    gPad->SetLogy();
+    fRate.Draw();
+    //fHumidity.Draw("AP");
+    //fTemperature.Draw("P");
+    //DrawRightAxis("T [\\circ C]");
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fRateTime.Draw("AP");
+    //fSolarRadiation.Draw("AP");
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fRateZd.Draw();
+
+    if (pad->GetPad(4))
+        delete pad->GetPad(4);
+
+    /*
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fWindSpeed.Draw("AP");*/
+}
+
+void MHRate::Paint(Option_t *o)
+{
+    DrawGraph(fRateTime, "f [Hz]");
+    /*
+    gPad->cd(1);
+
+    if (gPad)
+    {
+        fHumidity.GetHistogram()->GetYaxis()->SetTitleColor(kBlue);
+        UpdateRightAxis(fTemperature);
+    }*/
+}
Index: /trunk/MagicSoft/Mars/mhist/MHRate.h
===================================================================
--- /trunk/MagicSoft/Mars/mhist/MHRate.h	(revision 7198)
+++ /trunk/MagicSoft/Mars/mhist/MHRate.h	(revision 7198)
@@ -0,0 +1,58 @@
+#ifndef MARS_MHRate
+#define MARS_MHRate
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TGraph
+#include <TGraph.h>
+#endif
+#ifndef ROOT_TProfile
+#include <TProfile.h>
+#endif
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
+//class MTime;
+class MEventRate;
+class MPointingPos;
+
+class MHRate : public MH
+{
+private:
+    TGraph   fRateTime;      // Graph of rate versus time
+    TProfile fRateZd;        // Profile of rate vs Zd
+    TH1D     fRate;          // Rate histogram
+
+    //MTime        *fTime;   //!
+    MPointingPos *fPointPos; //!
+    MEventRate   *fEvtRate;  //!
+
+    MTime fLast;             //!
+
+    Double_t fMean;          //!
+    Int_t    fCounter;       //!
+
+    void ResetGraph(TGraph &g) const;
+    void InitGraph(TGraph &g) const;
+    void AddPoint(TGraph &g, Double_t x, Double_t y) const;
+    void DrawGraph(TGraph &g, const char *y=0) const;
+    //void UpdateRightAxis(TGraph &g) const;
+    //void DrawRightAxis(const char *title) const;
+
+public:
+    MHRate(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    void Draw(Option_t *opt="");
+    void Paint(Option_t *opt="");
+
+    ClassDef(MHRate, 1) // Histogram to display information about rate
+};
+
+#endif
+
+
Index: /trunk/MagicSoft/Mars/mhist/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mhist/Makefile	(revision 7197)
+++ /trunk/MagicSoft/Mars/mhist/Makefile	(revision 7198)
@@ -35,6 +35,5 @@
            MHCamera.cc \
            MHRate.cc \
-           MHWeather.cc \
-           MHPointing.cc
+           MHWeather.cc
 
 ############################################################
Index: /trunk/MagicSoft/Mars/mpointing/MHPointing.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpointing/MHPointing.cc	(revision 7198)
+++ /trunk/MagicSoft/Mars/mpointing/MHPointing.cc	(revision 7198)
@@ -0,0 +1,292 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 05/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2005
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHPointing
+//
+// Display drive information
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHPointing.h"
+
+#include <TPad.h>
+#include <TCanvas.h>
+#include <TGaxis.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MTime.h"
+
+#include "MReportDrive.h"
+#include "MReportStarguider.h"
+
+ClassImp(MHPointing);
+
+using namespace std;
+
+void MHPointing::ResetGraph(TGraph &g) const
+{
+    g.Set(1);
+    g.SetPoint(0, 0, 0); // Dummy Point
+    g.SetEditable();     // Used as flag: First point? yes/no
+}
+
+void MHPointing::InitGraph(TGraph &g) const
+{
+    ResetGraph(g);
+    g.SetMarkerStyle(kFullDotMedium);
+}
+
+void MHPointing::AddPoint(TGraph &g, Double_t x, Double_t y) const
+{
+    if (g.IsEditable())
+    {
+        g.RemovePoint(0);
+        g.SetEditable(kFALSE);
+    }
+
+    g.SetPoint(g.GetN(), x, y);
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms 
+//
+MHPointing::MHPointing(const char *name, const char *title)
+: /*fTime(0),*/ fReportCosy(0), fReportSG(0)
+{
+    fName  = name  ? name  : "MHPointing";
+    fTitle = title ? title : "Graphs for rate data";
+
+    // Init Graphs
+    fDevTimeSG.SetNameTitle("DevSG",      "Drive (black) and starguider (blue) deviation");
+    fDevTimeCosy.SetNameTitle("DevCosy",  "Cosy deviation");
+    fBrightness.SetNameTitle("Brigtness", "Arbitrary Sky Brightness");
+    fNumStars.SetNameTitle("NumStars",    "Number of stars identified by starguider");
+    fDevZd.SetNameTitle("DevZd",          "Starguider Deviation Zd (blue), Az(black)");
+    fDevAz.SetNameTitle("DevAz",          "Starguider Deviation Az");
+
+    InitGraph(fDevTimeSG);
+    InitGraph(fDevTimeCosy);
+    InitGraph(fBrightness);
+    InitGraph(fNumStars);
+    InitGraph(fDevZd);
+    InitGraph(fDevAz);
+
+    fDevTimeSG.SetMinimum(0);
+    fDevTimeCosy.SetMinimum(0);
+    fBrightness.SetMinimum(0);
+    fNumStars.SetMinimum(0);
+
+    fDevTimeSG.SetMarkerColor(kBlue);
+    fDevZd.SetMarkerColor(kBlue);
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning
+//
+Bool_t MHPointing::SetupFill(const MParList *plist)
+{
+    //fTime = (MTime*)plist->FindObject("MTime");
+    //if (!fTime)
+    //{
+    //    *fLog << warn << "MTime not found... abort." << endl;
+    //    return kFALSE;
+    //}
+    fReportSG = (MReportStarguider*)plist->FindObject("MReportStarguider");
+    if (!fReportSG)
+    {
+        *fLog << warn << "MReportStarguider not found... abort." << endl;
+        return kFALSE;
+    }
+    fReportCosy = (MReportDrive*)plist->FindObject("MReportDrive");
+    if (!fReportCosy)
+    {
+        *fLog << warn << "MReportDrive not found... abort." << endl;
+        return kFALSE;
+    }
+
+    // Reset Graphs
+    ResetGraph(fDevTimeSG);
+    ResetGraph(fDevTimeCosy);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MMuonCalibPar and
+// MMuonSearchPar container.
+//
+Bool_t MHPointing::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MTime *t = dynamic_cast<const MTime*>(par);
+    if (!t)
+    {
+        *fLog << err <<"MHPointing::Fill - ERROR: MTime not given as argument... abort." << endl;
+        return kERROR;
+    }
+
+    const Double_t tm = t->GetAxisTime();
+
+    if (t->GetName()==(TString)"MTimeStarguider")
+    {
+        AddPoint(fDevTimeSG,  tm, fReportSG->GetDevAbs());
+        AddPoint(fBrightness, tm, fReportSG->GetSkyBrightness());
+        AddPoint(fNumStars,   tm, fReportSG->GetNumIdentifiedStars());
+        AddPoint(fDevZd,      tm, fReportSG->GetDevZd());
+        AddPoint(fDevAz,      tm, fReportSG->GetDevAz());
+        return kTRUE;
+    }
+
+    if (t->GetName()==(TString)"MTimeDrive")
+    {
+        AddPoint(fDevTimeCosy, tm, fReportCosy->GetAbsError()*60);
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
+
+void MHPointing::DrawGraph(TGraph &g, const char *y) const
+{
+    TH1 *h = g.GetHistogram();
+    if (h)
+    {
+        TAxis *axe = h->GetXaxis();
+        axe->SetLabelSize(0.033);
+        axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00 GMT");
+        axe->SetTimeDisplay(1);
+        axe->SetTitle("Time");
+        if (y)
+            h->SetYTitle(y);
+    }
+}
+/*
+// --------------------------------------------------------------------------
+//
+// Update position of an axis on the right side of the histogram
+//
+void MHPointing::UpdateRightAxis(TGraph &g) const
+{
+    TH1 &h = *g.GetHistogram();
+
+    const Double_t max = h.GetMaximum();
+    if (max==0)
+        return;
+
+    TGaxis *axis = (TGaxis*)gPad->FindObject("RightAxis");
+    if (!axis)
+        return;
+
+    axis->SetX1(g.GetXaxis()->GetXmax());
+    axis->SetX2(g.GetXaxis()->GetXmax());
+    axis->SetY1(gPad->GetUymin());
+    axis->SetY2(gPad->GetUymax());
+    axis->SetWmax(max);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw an axis on the right side of the histogram
+//
+
+void MHPointing::DrawRightAxis(const char *title) const
+{
+    TGaxis *axis = new TGaxis(gPad->GetUxmax(), gPad->GetUymin(),
+                              gPad->GetUxmax(), gPad->GetUymax(),
+                              0, 1, 510, "+L");
+    axis->SetName("RightAxis");
+    axis->SetTitle(title);
+    axis->SetTitleOffset(0.9);
+    axis->SetTextColor(kRed);
+    axis->SetBit(kCanDelete);
+    axis->Draw();
+}
+*/
+// --------------------------------------------------------------------------
+//
+// This displays the TGraph like you expect it to be (eg. time on the axis)
+// It should also make sure, that the displayed time always is UTC and
+// not local time...
+//
+void MHPointing::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad();
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fDevTimeSG.Draw("AP");
+    fDevTimeCosy.Draw("P");
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fBrightness.Draw("AP");
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fDevZd.Draw("AP");
+    fDevAz.Draw("P");
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fNumStars.Draw("AP");
+}
+
+void MHPointing::Paint(Option_t *o)
+{
+    DrawGraph(fDevTimeSG,   "\\Delta [arcmin]");
+    DrawGraph(fDevTimeCosy, "\\Delta [arcmin]");
+    DrawGraph(fBrightness,  "Brightness [au]");
+    DrawGraph(fNumStars,    "N");
+    DrawGraph(fDevZd,       "\\Delta [arcmin]");
+    DrawGraph(fDevAz,       "\\Delta [arcmin]");
+    /*
+    gPad->cd(1);
+
+    if (gPad)
+    {
+        fHumidity.GetHistogram()->GetYaxis()->SetTitleColor(kBlue);
+        UpdateRightAxis(fTemperature);
+    }*/
+}
Index: /trunk/MagicSoft/Mars/mpointing/MHPointing.h
===================================================================
--- /trunk/MagicSoft/Mars/mpointing/MHPointing.h	(revision 7198)
+++ /trunk/MagicSoft/Mars/mpointing/MHPointing.h	(revision 7198)
@@ -0,0 +1,52 @@
+#ifndef MARS_MHPointing
+#define MARS_MHPointing
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TGraph
+#include <TGraph.h>
+#endif
+
+class MTime;
+class MReportDrive;
+class MReportStarguider;
+
+class MHPointing : public MH
+{
+private:
+    MReportDrive      *fReportCosy;  //!
+    MReportStarguider *fReportSG;    //!
+
+    TGraph             fDevTimeSG;   // Starguider deviation versus time
+    TGraph             fDevTimeCosy; // Drive deviation versus time
+
+    TGraph             fBrightness;  // Arbitrary sky brightness
+
+    TGraph             fNumStars;    // Number of stars identified by starguider
+
+    TGraph             fDevZd;       // Starguider deviation Zd
+    TGraph             fDevAz;       // Starguider deviation Az
+
+    void ResetGraph(TGraph &g) const;
+    void InitGraph(TGraph &g) const;
+    void AddPoint(TGraph &g, Double_t x, Double_t y) const;
+    void DrawGraph(TGraph &g, const char *y=0) const;
+    //void UpdateRightAxis(TGraph &g) const;
+    //void DrawRightAxis(const char *title) const;
+
+public:
+    MHPointing(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    void Draw(Option_t *opt="");
+    void Paint(Option_t *opt="");
+
+    ClassDef(MHPointing, 1) // Histogram to display tracking/pointing information
+};
+
+#endif
+
+
Index: /trunk/MagicSoft/Mars/mpointing/Makefile
===================================================================
--- /trunk/MagicSoft/Mars/mpointing/Makefile	(revision 7197)
+++ /trunk/MagicSoft/Mars/mpointing/Makefile	(revision 7198)
@@ -26,4 +26,5 @@
 	   MPointingPosCalc.cc \
 	   MPointingPosInterpolate.cc \
+           MHPointing.cc \
            MSrcPosCam.cc \
            MSrcPosCalc.cc \
