Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 7213)
+++ trunk/MagicSoft/Mars/Changelog	(revision 7214)
@@ -86,4 +86,17 @@
        starguider reports
      - removed displaying nominal Az
+
+   * mjobs/MJCut.cc:
+     - implemented pointing correction by starguider
+
+   * mpointing/MPointingDevCalc.cc:
+     - some minor updates
+
+   * mpointing/MSrcPosCalc.[h,cc]:
+     - implemented usage of pointing deviation -- still in progress!
+
+   * mpointing/MSrcPosCorrect.[h,cc]:
+     - inverted sign of pointing correction for anti-source
+     - write telescope axis to parlist
 
 
Index: trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7213)
+++ trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7214)
@@ -32,22 +32,27 @@
 #include "MJCut.h"
 
+// Root
 #include <TEnv.h>
 #include <TFile.h>
 
+// Environment
 #include "MLog.h"
 #include "MLogManip.h"
 
+// Eventloop
 #include "MParList.h"
 #include "MTaskList.h"
 #include "MEvtLoop.h"
 
+// Display
 #include "MStatusDisplay.h"
 
+// Tasks
 #include "MReadReports.h"
 #include "MReadMarsFile.h"
 #include "MPrint.h"
 #include "MContinue.h"
-//#include "MEnergyEstimate.h"
 #include "MTaskEnv.h"
+#include "MPointingDevCalc.h"
 #include "MSrcPosCalc.h"
 #include "MSrcPosCorrect.h"
@@ -56,7 +61,9 @@
 #include "MWriteRootFile.h"
 
+// Fit signal environment
 #include "../mhflux/MAlphaFitter.h"
 #include "../mhflux/MHAlpha.h"
 
+// Containers
 #include "MH3.h"
 #include "MBinning.h"
@@ -498,5 +505,6 @@
     MReadReports readoffdata;
     readoffdata.AddTree("Events", "MTime.", MReadReports::kMaster);
-    readoffdata.AddTree("Drive", MReadReports::kRequired);
+    readoffdata.AddTree("Drive",            MReadReports::kRequired);
+    readoffdata.AddTree("Starguider",       MReadReports::kRequired);
     readoffdata.AddTree("EffectiveOnTime");
 
@@ -596,8 +604,11 @@
         tlist2.AddToList(write1);
 
+    MPointingDevCalc devcalc;
+
     tlist.AddToList(&readoff);
     if (gLog.GetDebugLevel()>4)
         tlist.AddToList(&print2, "EffectiveOnTime");
-    tlist.AddToList(&tlist2, "Events");
+    tlist.AddToList(&devcalc, "Starguider");
+    tlist.AddToList(&tlist2,  "Events");
  
     par.SetVal(0);
@@ -645,5 +656,6 @@
     MReadReports readondata;
     readondata.AddTree("Events", "MTime.", MReadReports::kMaster);
-    readondata.AddTree("Drive", MReadReports::kRequired);
+    readondata.AddTree("Drive",            MReadReports::kRequired);
+    readondata.AddTree("Starguider",       MReadReports::kRequired);
     readondata.AddTree("EffectiveOnTime");
 
Index: trunk/MagicSoft/Mars/mpointing/MPointing.h
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MPointing.h	(revision 7213)
+++ trunk/MagicSoft/Mars/mpointing/MPointing.h	(revision 7214)
@@ -16,7 +16,7 @@
 // ---------------------------------------------------
 // FIXME: Replace coord.h completely with this!
-#ifndef __MARS__
-#include "coord.h"
-#else
+//#ifndef __MARS__
+//#include "coord.h"
+//#else
 #include <TVector2.h>
 class AltAz : public TVector2
@@ -26,4 +26,5 @@
     {
     }
+    AltAz(const AltAz &aa) : TVector2(aa) { }
     Double_t Alt() const { return fX; }
     Double_t Az() const  { return fY; }
@@ -37,9 +38,10 @@
     {
     }
+    ZdAz(const ZdAz &aa) : TVector2(aa) { }
     Double_t Zd() const { return fX; }
     Double_t Az() const { return fY; }
     ClassDef(ZdAz, 1)
 };
-#endif
+//#endif
 // ---------------------------------------------------
 
Index: trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc	(revision 7213)
+++ trunk/MagicSoft/Mars/mpointing/MPointingDevCalc.cc	(revision 7214)
@@ -92,12 +92,8 @@
     switch (fRunType)
     {
-/***/    case MRawRunHeader::kRTData:
-        /*
+    case MRawRunHeader::kRTData:
         if (!fReport)
-        {
-            *fLog << err << "MReportStarguider not found... aborting." << endl;
-            return kFALSE;
-        }*/
-/***/        return kTRUE;
+            *fLog << warn << "MReportStarguider not found... skipped." << endl;
+        return kTRUE;
 
     case MRawRunHeader::kRTMonteCarlo:
@@ -182,5 +178,5 @@
     // Linear starguider calibration taken from April/May data
     // For calibration add MDriveReport::GetErrorZd/Az !
-    devzd -= 2.686/60;
+    devzd -= 2.686/60;   // 1arcmin ~ 5mm
     devaz -= 2.840/60;
 
@@ -195,9 +191,6 @@
     }
 
+    fDeviation->SetDevZdAz(devzd, devaz);
     fSkip[0]++;
-    //fDeviation->SetDevZdAz(devzd, devaz);
-    fDeviation->SetDevZdAz(0, 0);
-
-    cout << "SETTING: " << devzd << " " << devaz << endl;
 
     return kTRUE;
@@ -214,5 +207,5 @@
     case MRawRunHeader::kRTNone:
     case MRawRunHeader::kRTData:
-/***/        return fReport ? ProcessStarguiderReport() : kTRUE;
+        return fReport ? ProcessStarguiderReport() : kTRUE;
 
     case MRawRunHeader::kRTMonteCarlo:
Index: trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc	(revision 7213)
+++ trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc	(revision 7214)
@@ -75,4 +75,5 @@
 #include "MObservatory.h"
 #include "MPointingPos.h"
+#include "MPointingDev.h"
 #include "MSrcPosCam.h"
 #include "MRawRunHeader.h"
@@ -92,6 +93,6 @@
 //
 MSrcPosCalc::MSrcPosCalc(const char *name, const char *title)
-    : fObservatory(NULL), fPointPos(NULL), fSourcePos(NULL), fSrcPosCam(NULL),
-    fSrcPosAnti(NULL), fGeom(NULL), fTime(NULL), fMode(kDefault)
+    : fObservatory(NULL), fPointPos(NULL), fSourcePos(NULL), fDeviation(NULL),
+    fSrcPosCam(NULL), fSrcPosAnti(NULL), fGeom(NULL), fTime(NULL), fMode(kDefault)
 {
     fName  = name  ? name  : "MSrcPosCalc";
@@ -189,4 +190,6 @@
         return kFALSE;
     }
+
+    fDeviation = (MPointingDev*)pList->FindObject("MPointingDev");
 
     *fLog << inf;
@@ -313,5 +316,5 @@
      */
 
-    /* --- NEW --- */
+    /* --- NEW ---  Same as MSrcPosCorrect::CalcXYinCamera */
     const Double_t XC0 = TMath::Sin(theta)*TMath::Sin(phi-phi0);
     const Double_t XC1 = TMath::Cos(theta0)*TMath::Cos(theta);
@@ -365,7 +368,18 @@
     pos0 *= conv;
 
+    TVector2 vx;
+    if (fDeviation)
+    {
+        vx = CalcXYinCamera(pos0, pos)*fGeom->GetCameraDist()*1000;
+        pos0.SetZdAz(pos0.Theta()-fDeviation->GetDevZdRad(),
+                     pos0.Phi()  -fDeviation->GetDevAzRad());
+    }
+
     // Calculate source position in camera, and convert to mm:
     TVector2 v = CalcXYinCamera(pos0, pos)*fGeom->GetCameraDist()*1000;
     SetSrcPos(v);
+
+    if (fDeviation)
+        cout << fPointPos->GetZd() << ":  " << vx.X() << "/" <<v.X() << "  " << vx.Y() << "/" <<v.Y() << endl;
 
     return kTRUE;
@@ -391,5 +405,5 @@
     if (str.First(':')<0)
     {
-        ret = atof(str);
+        ret = str.Atof();
         return kTRUE;
     }
Index: trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h	(revision 7213)
+++ trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h	(revision 7214)
@@ -12,4 +12,5 @@
 class MObservatory;
 class MPointingPos;
+class MPointingDev;
 class MSrcPosCam;
 class MGeomCam;
@@ -33,4 +34,5 @@
     MPointingPos *fPointPos;
     MPointingPos *fSourcePos;
+    MPointingDev *fDeviation;
     MSrcPosCam   *fSrcPosCam;
     MSrcPosCam   *fSrcPosAnti;
Index: trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc	(revision 7213)
+++ trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc	(revision 7214)
@@ -39,6 +39,8 @@
 #include "MLogManip.h"
 
+#include "MGeomCam.h"
 #include "MSrcPosCam.h"
 #include "MRawRunHeader.h"
+#include "MReportStarguider.h"
 
 ClassImp(MSrcPosCorrect);
@@ -49,5 +51,5 @@
 //
 MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title)
-    : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL)
+    : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL), fGeom(NULL)
 {
     fName  = name  ? name  : "MSrcPosCorrect";
@@ -139,4 +141,14 @@
 //    Good night
 //
+// Believing the Database the following data is affected:
+//   1ES1426+428           Off1ES1426-1
+//   1ES1959+650           Off1ES1959-1
+//   2E-1415+2557          Off2E1415-1
+//   Arp-220               OffArp-220-1
+//   GC-W1                 OffHB1553-1
+//   HB89-1553+11          OffM87-1
+//   M87                   OffW-Comae-1
+//   W-Comae
+//
 Int_t MSrcPosCorrect::Process()
 {
@@ -144,14 +156,19 @@
         return kTRUE;
 
-    // FIXME: Implement Culmination correction
-
+    TVector2 d;
     if (fRunNumber<56161 && fRunNumber>53832)
     {
         // dx=-0.048deg, dy=0.034deg, d=0.059deg
         static const TVector2 dxy(-14.24, -9.495);
-        fAxis->SetXY(dxy);
-        fSrcPosCam->Add(dxy);
-        if (fSrcPosAnti)
-            fSrcPosAnti->Add(dxy);
+
+        d -= dxy;
+    }
+
+    fAxis->SetXY(d);
+    fSrcPosCam->Add(d);
+    if (fSrcPosAnti)
+    {
+        d *= -1; // Anti-Source position should always be symetric
+        fSrcPosAnti->Add(d);
     }
 
Index: trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.h
===================================================================
--- trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.h	(revision 7213)
+++ trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.h	(revision 7214)
@@ -6,14 +6,19 @@
 #endif
 
+class MGeomCam;
+class TVector2;
 class MSrcPosCam;
+class MReportStarguider;
 
 class MSrcPosCorrect : public MTask
 {
 private:
-    MSrcPosCam   *fSrcPosCam;
-    MSrcPosCam   *fSrcPosAnti;
-    MSrcPosCam   *fAxis;
+    MSrcPosCam *fSrcPosCam;   //!
+    MSrcPosCam *fSrcPosAnti;  //!
+    MSrcPosCam *fAxis;        //!
 
-    UShort_t fRunType;            //! Run Type to decide where to get pointing position from
+    MGeomCam   *fGeom;        //!
+
+    UShort_t fRunType;        //! Run Type to decide where to get pointing position from
     UInt_t   fRunNumber;
 
