Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 7195)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 7196)
@@ -20,4 +20,33 @@
 
                                                  -*-*- END OF LINE -*-*-
+ 2005/07/19 Thomas Bretz
+
+   * mjobs/MJCut.cc:
+     - write MSrcPosCam to output
+     - write MSrcPosAnti to output
+     - removed MEnergyEst from output
+     - added MSrcPosCorrect to tasklist
+
+   * mjobs/MJSpectrum.cc:
+     - removed MSrcPosCalc from tasklist for refilling
+     - removed hillas calculation from tasklist for refilling 
+       (both need a better concept in MJCut: not writing to
+        results file, but to summary file)
+
+   * mjobs/MJStar.cc:
+     - removed MSrcPosCalc from tasklist (better this is always done
+       correctly in MJCut)
+     - added Starguider information to output
+     - replaced Rate historams by new histogram MHRate
+     - added new histogram MHPointing
+
+   * mpointing/MSrcPosCorrect.cc:
+     - write new optical axis to parameter list
+
+   * mreport/MReportStarguider.[h,cc]:
+     - added GetDevAbs
+
+
+
  2005/07/16 Thomas Bretz
 
Index: /trunk/MagicSoft/Mars/NEWS
===================================================================
--- /trunk/MagicSoft/Mars/NEWS	(revision 7195)
+++ /trunk/MagicSoft/Mars/NEWS	(revision 7196)
@@ -88,4 +88,8 @@
      was assigned just with an event which was skipped later by another
      task
+   
+   - star: new histograms MHPointing and MHRate
+   
+   - star: corrects now (correctly?) for the misspointing in May/April 05
 
    - mars: show muon parameters graphically
Index: /trunk/MagicSoft/Mars/mjobs/MJCut.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7195)
+++ /trunk/MagicSoft/Mars/mjobs/MJCut.cc	(revision 7196)
@@ -51,4 +51,5 @@
 #include "MTaskEnv.h"
 #include "MSrcPosCalc.h"
+#include "MSrcPosCorrect.h"
 #include "MHillasCalc.h"
 #include "MFillH.h"
@@ -335,6 +336,8 @@
     write->AddContainer("MNewImagePar2",  "Events", kFALSE);
     write->AddContainer("MHadronness",    "Events", kFALSE);
-    write->AddContainer("MEnergyEst",     "Events", kFALSE);
+    write->AddContainer("MSrcPosCam",     "Events", kFALSE);
+    write->AddContainer("MSrcPosAnti",    "Events", kFALSE);
     write->AddContainer("ThetaSquared",   "Events", kFALSE);
+    write->AddContainer("OpticalAxis",    "Events", kFALSE);
     write->AddContainer("Disp",           "Events", kFALSE);
     write->AddContainer("MTime",          "Events", kFALSE);
@@ -549,4 +552,6 @@
     scalc.SetMode(fIsWobble?MSrcPosCalc::kWobble:MSrcPosCalc::kOffData); /********************/
 
+    MSrcPosCorrect scor;
+
     MHillasCalc hcalc;
     MHillasCalc hcalc2("MHillasCalcAnti");
@@ -558,4 +563,5 @@
     MTaskList tlist2;
     tlist2.AddToList(&scalc);
+    tlist2.AddToList(&scor);
     tlist2.AddToList(&hcalc);
     if (fIsWobble)
Index: /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 7195)
+++ /trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc	(revision 7196)
@@ -77,5 +77,5 @@
 #include "MFillH.h"
 #include "MHillasCalc.h"
-#include "MSrcPosCalc.h"
+//#include "MSrcPosCalc.h"
 #include "MContinue.h"
 
@@ -968,13 +968,15 @@
 
     // Get correct source position
-    MSrcPosCalc calc;
+    //MSrcPosCalc calc;
 
     // Calculate corresponding Hillas parameters
-    MHillasCalc hcalc1;
-    MHillasCalc hcalc2("MHillasCalcAnti");
-    hcalc1.SetFlags(MHillasCalc::kCalcHillasSrc);
-    hcalc2.SetFlags(MHillasCalc::kCalcHillasSrc);
-    hcalc2.SetNameHillasSrc("MHillasSrcAnti");
-    hcalc2.SetNameSrcPosCam("MSrcPosAnti");
+    /*
+     MHillasCalc hcalc1;
+     MHillasCalc hcalc2("MHillasCalcAnti");
+     hcalc1.SetFlags(MHillasCalc::kCalcHillasSrc);
+     hcalc2.SetFlags(MHillasCalc::kCalcHillasSrc);
+     hcalc2.SetNameHillasSrc("MHillasSrcAnti");
+     hcalc2.SetNameSrcPosCam("MSrcPosAnti");
+     */
 
     // Fill collection area and energy estimator (unfolding)
@@ -1034,7 +1036,7 @@
     if (!fRawMc && fNoThetaWeights)
         tlist2.AddToList(&contsel);
-    tlist2.AddToList(&calc);
-    tlist2.AddToList(&hcalc1);
-    tlist2.AddToList(&hcalc2);
+    //tlist2.AddToList(&calc);
+    //tlist2.AddToList(&hcalc1);
+    //tlist2.AddToList(&hcalc2);
     tlist2.AddToList(&weight);
     tlist2.AddToList(&fill1a);
Index: /trunk/MagicSoft/Mars/mjobs/MJStar.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 7195)
+++ /trunk/MagicSoft/Mars/mjobs/MJStar.cc	(revision 7196)
@@ -62,4 +62,5 @@
 #include "MImgCleanStd.h"
 #include "MSrcPosCalc.h"
+#include "MSrcPosCorrect.h"
 #include "MHillasCalc.h"
 #include "MMuonSearchParCalc.h"
@@ -192,9 +193,7 @@
     MReadReports readreal;
     readreal.AddTree("Events", "MTime.", MReadReports::kMaster);
-    readreal.AddTree("Drive", MReadReports::kRequired);
+    readreal.AddTree("Drive",            MReadReports::kRequired);
+    readreal.AddTree("Starguider",       MReadReports::kRequired);
     readreal.AddTree("CC");
-    //read.AddTree("Trigger");
-    //read.AddTree("Camera");
-    //read.AddTree("Currents");
     readreal.AddFiles(iter);
 
@@ -211,16 +210,5 @@
     MGeomApply             apply; // Only necessary to craete geometry
     MEventRateCalc         rate;
-    //MEventRateCalc         rate1; // 5min
     rate.SetNumEvents(1200);
-    //rate1.SetNumEvents(60000);
-    //rate1.SetNameEventRate("MEventRate2");
-    //rate1.SetNameTimeRate("MTimeRate2");
-
-    /*
-    MEventRateCalc         rate10000;
-    rate10000.SetNameEventRate("MEventRate10000");
-    rate10000.SetNumEvents(10000);
- */
-    //MBadPixelsMerge        merge(&badpix);
 
     MFSoftwareTrigger swtrig;
@@ -228,9 +216,9 @@
     contsw.SetInverted();
 
-
     MImgCleanStd           clean;
     clean.SetNamePedPhotCam("MPedPhotFromExtractorRndm");
 
-    MSrcPosCalc            poscalc;
+    //MSrcPosCalc            poscalc;
+    //MSrcPosCorrect         poscorrect;
     MHillasCalc            hcalc;
     hcalc.Disable(MHillasCalc::kCalcConc);
@@ -241,47 +229,20 @@
     evt0b.SetThreshold(0);
 
-    //MHCamEventRot evt0r("UsedRot", "Pixels marked Used (derotated)");
-    //evt0r.SetThreshold(0);
-
-    MH3 h1("MEventRate.fRate");
-    h1.SetName("MHEventRate");
-    h1.SetTitle("Event Rate distribution;R [Hz];Counts");
-    h1.SetLogy();
-/*
-    MH3 h12("MEventRate10000.fRate");
-    h12.SetName("MHEventRate");
-    h12.SetLogy();
- */
-    MBinning b1("BinningMHEventRate");
-    b1.SetEdges(150, 0, 1500);
-    plist.AddToList(&b1);
-
-    MHVsTime hvs("MEventRate.fRate");
-    hvs.SetTitle("Rate per 500 events;;R [Hz]");
-    hvs.SetNumEvents(500);
-    hvs.SetMinimum(0);
-
-    //MContinue cont1("MEventRate2.fRate/MEventRate.fRate>1.1");
-    //MContinue cont2("MEventRate.fRate/MEventRate2.fRate>1.1");
-
-    MFillH fillvs(&hvs,           "MTime",        "FillEventRate10s");
-
-    MFillH fill0a(&evt0a,         "MSignalCam",   "FillSignalCam");
-    MFillH fill0b(&evt0b,         "MSignalCam",   "FillCntUsedPixels");
-    //MFillH fill0r(&evt0r,         "MCerPhotEvt",  "FillCntUsedRotated");
-    MFillH fill1("MHHillas",      "MHillas",      "FillHillas");
-    MFillH fill2("MHHillasExt",   "",             "FillHillasExt");
-    MFillH fill3("MHHillasSrc",   "MHillasSrc",   "FillHillasSrc");
-    MFillH fill4("MHImagePar",    "MImagePar",    "FillImagePar");
-    MFillH fill5("MHNewImagePar", "MNewImagePar", "FillNewImagePar");
-    //MFillH fill6("MHImageParTime","MImageParTime","FillImageParTime");
-    //MFillH fill7("MHNewImagePar2","MNewImagePar2","FillNewImagePar2");
-    MFillH fill8(&h1,             "",             "FillEventRate");
-    MFillH fill9("MHEffectiveOnTime", "MTime",    "FillEffOnTime");
-    //MFillH fillb(&h12, "", "FillEvtRate2");
-    //MFillH fill9("MHCerPhot");
-
-    //fill0r.SetDrawOption("colz");
-    fill8.SetNameTab("EvtRate");
+    MFillH fillvs("MHRate",           "MTime",           "FillEventRate");
+    MFillH fillp1("MHPointing",       "MTimeDrive",      "FillDrive");
+    MFillH fillp2("MHPointing",       "MTimeStarguider", "FillStarguider");
+    fillp1.SetBit(MFillH::kDoNotDisplay);
+    //fillp2.SetNameTab("Drive");
+
+    MFillH fill0a(&evt0a,             "MSignalCam",      "FillSignalCam");
+    MFillH fill0b(&evt0b,             "MSignalCam",      "FillCntUsedPixels");
+    MFillH fill1("MHHillas",          "MHillas",         "FillHillas");
+    MFillH fill2("MHHillasExt",       "",                "FillHillasExt");
+    MFillH fill3("MHHillasSrc",       "MHillasSrc",      "FillHillasSrc");
+    MFillH fill4("MHImagePar",        "MImagePar",       "FillImagePar");
+    MFillH fill5("MHNewImagePar",     "MNewImagePar",    "FillNewImagePar");
+    MFillH fill9("MHEffectiveOnTime", "MTime",           "FillEffOnTime");
+
+    //fillvs.SetNameTab("Rate");
     fill9.SetNameTab("EffOnTime");
 
@@ -301,6 +262,4 @@
     write.AddContainer("MImagePar",     "Events");
     write.AddContainer("MNewImagePar",  "Events");
-    //write.AddContainer("MNewImagePar2", "Events");
-    //write.AddContainer("MImageParTime", "Events");
     write.AddContainer("MRawEvtHeader", "Events");
     write.AddContainer("MPointingPos",  "Events");
@@ -333,8 +292,11 @@
     else
     {
-        write.AddContainer("MTime",                "Events");
+        write.AddContainer("MTime",                 "Events");
         // Drive
-        write.AddContainer("MReportDrive",         "Drive");
-        write.AddContainer("MTimeDrive",           "Drive");
+        write.AddContainer("MReportDrive",          "Drive");
+        write.AddContainer("MTimeDrive",            "Drive");
+        // Starguider
+        write.AddContainer("MReportStarguider",     "Starguider");
+        write.AddContainer("MTimeStarguider",       "Starguider");
         // Effective On Time
         writet.AddContainer("MEffectiveOnTime",     "EffectiveOnTime");
@@ -375,14 +337,12 @@
         tlist2.AddToList(&rate);
         tlist2.AddToList(&fillvs);
-        tlist2.AddToList(&fill8);
         tlist2.AddToList(&fill9);
         tlist2.AddToList(&writet);
     }
-    //tlist2.AddToList(&fillb);
     tlist2.AddToList(&clean);
     tlist2.AddToList(&fill0a);
     tlist2.AddToList(&fill0b);
-    //tlist2.AddToList(&fill0r);
-    tlist2.AddToList(&poscalc);
+    //tlist2.AddToList(&poscalc);
+    //tlist2.AddToList(&poscorrect);
     tlist2.AddToList(&hcalc);
     tlist2.AddToList(&fill1);
@@ -439,5 +399,9 @@
     tlist.AddToList(&tlist2, "Events");
     if (!ismc)
+    {
         tlist.AddToList(&fillw,  "CC");
+        tlist.AddToList(&fillp1, "Drive");
+        tlist.AddToList(&fillp2, "Starguider");
+    }
     tlist.AddToList(&write);
 
Index: /trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc
===================================================================
--- /trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc	(revision 7195)
+++ /trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc	(revision 7196)
@@ -49,5 +49,5 @@
 //
 MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title)
-    : fSrcPosCam(NULL), fSrcPosAnti(NULL)
+    : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL)
 {
     fName  = name  ? name  : "MSrcPosCorrect";
@@ -75,4 +75,8 @@
 
     fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam");
+
+    fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis");
+    if (!fAxis)
+        return kFALSE;
 
     return kTRUE;
@@ -103,28 +107,29 @@
 // Performs source position correction in the camera.
 // Due to missfocussing a shift of
-//    dx=0.048deg and dy=0.032deg
+//    dx=0.048deg and dy=0.034deg
 //  or
 //    dx=14.24mm and dy=9.495mm
 // is added between run 53832 (excl) and 56161 (excl)
+//
 // See also: Runbook
 //
-// 2005-05-23 03:33:51:
-// We start again to make tests on AMC with Roque lamp and PinDiode Tests.
-// At park position, we do a Laser initial isation and a Laser adjustment.
-// We discovered that the procedure we used yester day for Roque Lamp
-// light source was producing a very non-uniform light
-// We did some studies to produce an uniformly illuminated li ght from the
-// Roque Lamp Then we moved the telescope to the Roque Lamp position a nd
-// did a Laser adjust for  the Roque position.  We put the telescope to
-// the same shaftencoder values as were used in August to adjust the
-// mirrors
-// ( 29691 for SE-Az and SE-Zd1 1301 and SE-Zd2 9912 ( someti mes
-// oscillating to 9913 ) ) When we looked at the image of the spot on the
-// camer a, we saw a clear offset from the centre. Then we calculated this
-// offset and put the correct numbers in the AMC code. Then we redid the
-// laser adjustment and fou nd the spot to be nicely centred.  Our
-// calculations showed that the offset was 0 .048 deg in X direction and
-// 0.032 deg in Y direction.
-// Good night
+//    2005-05-23 03:33:51:
+//    We start again to make tests on AMC with Roque lamp and PinDiode Tests.
+//    At park position, we do a Laser initial isation and a Laser adjustment.
+//    We discovered that the procedure we used yester day for Roque Lamp
+//    light source was producing a very non-uniform light
+//    We did some studies to produce an uniformly illuminated li ght from
+//    the Roque Lamp Then we moved the telescope to the Roque Lamp position
+//    and did a Laser adjust for the Roque position. We put the telescope to
+//    the same shaftencoder values as were used in August to adjust the
+//    mirrors
+//    ( 29691 for SE-Az and SE-Zd1 1301 and SE-Zd2 9912 ( sometimes
+//    oscillating to 9913 ) ) When we looked at the image of the spot on the
+//    camer a, we saw a clear offset from the centre. Then we calculated this
+//    offset and put the correct numbers in the AMC code. Then we redid the
+//    laser adjustment and fou nd the spot to be nicely centred.  Our
+//    calculations showed that the offset was 0.048 deg in X direction and
+//    0.032 deg in Y direction.
+//    Good night
 //
 Int_t MSrcPosCorrect::Process()
@@ -133,8 +138,11 @@
         return kTRUE;
 
+    // FIXME: Implement Culmination correction
+
     if (fRunNumber<56161 && fRunNumber>53832)
     {
-        // dx=-0.05deg, dy=0.03deg, d=0.06deg
+        // 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)
Index: /trunk/MagicSoft/Mars/mreport/MReportStarguider.cc
===================================================================
--- /trunk/MagicSoft/Mars/mreport/MReportStarguider.cc	(revision 7195)
+++ /trunk/MagicSoft/Mars/mreport/MReportStarguider.cc	(revision 7196)
@@ -127,4 +127,19 @@
 }
 
+Double_t MReportStarguider::GetDevAbs() const
+{
+    const Double_t pzd = fNominalZd * TMath::DegToRad();
+    const Double_t azd = fDevZd/60  * TMath::DegToRad();
+    const Double_t aaz = fDevAz/60  * TMath::DegToRad();
+
+    const double el = TMath::Pi()/2-pzd;
+
+    const double dphi2 = aaz/2.;
+    const double cos2  = cos(dphi2)*cos(dphi2);
+    const double sin2  = sin(dphi2)*sin(dphi2);
+    const double d     = cos(azd)*cos2 - cos(2*el)*sin2;
+
+    return acos(d)*TMath::RadToDeg()*60;
+}
 
 void MReportStarguider::Print(Option_t *o) const
